Javascript 自定义WordPress管理菜单:如何使其可供编辑?
我在WordPress的管理面板的侧栏中添加了一个自定义菜单:Javascript 自定义WordPress管理菜单:如何使其可供编辑?,javascript,wordpress,Javascript,Wordpress,我在WordPress的管理面板的侧栏中添加了一个自定义菜单: function custom_settings_add_menu() { add_menu_page( 'custom_settings', 'Custom Settings', 'read', 'custom_settings', 'custom_settings_page', null, 20); } add_action( 'admin_menu', 'custom_settings_add_menu' ); 使用re
function custom_settings_add_menu() {
add_menu_page( 'custom_settings', 'Custom Settings', 'read', 'custom_settings', 'custom_settings_page', null, 20);
}
add_action( 'admin_menu', 'custom_settings_add_menu' );
使用read
,我可以让编辑看到菜单,但是当他们试图更改设置时,WordPress告诉他们没有必要的权限
有人知道如何让编辑器编辑设置吗?我认为更改设置的正确权限是编辑主题选项,因此请尝试将其添加到函数中。php:
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
然后,编辑器将看到“外观”下的所有选项。您可以像这样隐藏其他选项:
function hide_menu() {
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
//etc...
add_action('admin_head', 'hide_menu');
如果您想让这些调整更容易进行,请使用。我认为修改它的正确权限是编辑主题选项,因此请尝试将其添加到函数中。php:
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
然后,编辑器将看到“外观”下的所有选项。您可以像这样隐藏其他选项:
function hide_menu() {
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
//etc...
add_action('admin_head', 'hide_menu');
如果您想让这些调整更容易进行,请使用