
內容簡介
自訂 WordPress 後臺頁面鎖定外掛
用法
在自訂頁面的函式中使用 Occupied::protect() 啟用鎖定功能。
<?php
add_action('admin_menu', 'register_my_plugin_menu');
function register_my_plugin_menu(){
add_menu_page("My Cool Plugin", "cool-plugin", "manage_options", "my_cool_plugin_page", "render_my_cool_plugin", "dashicons-heart", 7);
}
function render_my_cool_plugin(){
// Occupied::protect 啟用當前頁面鎖定並返回鎖定數組
// 可選:傳入要在鎖定模式框中顯示的消息
$lock = Occupied::protect("Cool Plugin Occupied!");
echo "<h1>My Cool Plugin!</h1>";
}
?>
在其他操作中,您可以檢查當前用戶是否佔用屏幕
<?php
function some_other_action(){
if(Occupied::is_authorized('toplevel_page_my_cool_plugin_page')){
// 商務邏輯,保存到數據庫,等等..
}else{
// 返回錯誤
}
}
?><h3>待辦事項</h3>
* 拆分樣式
* 添加鎖定鉤子
* 重新考慮使用 Vue 作為模態框和部分事件處理程序
開發人員
此外掛在 GitHub 上開發
許可證
GPLv3
外掛標籤
開發者團隊
原文外掛簡介
custom page locking for WordPress admin screens
usage
In the function for your custom page, just use Occupied::protect() to enable locking on that page.
My Cool Plugin!
";
}
?>
In another action, you can check whether a screen is occupied by the current user
todo
* break out styles
* add locking hooks
* rethink using vue for a modal and some event handlers
developers
This plugin is developed on github
license
GPLv3
