如何隐藏WordPress后台的显示选项和帮助选项卡

0

WordPress后台屏幕右上角有两个小工具:显示选项(Screen Options)和帮助(Help),作为定制化Dashboard的一部分,某些时候需要将这两个小东西隐藏,隐藏的方法如下。

隐藏显示选项

在主题的functions.php中写如下代码

1
2
function remove_screen_options(){ return false;}
add_filter('screen_options_show_screen', 'remove_screen_options');


对Editor(编辑)以下级别的用户隐藏显示选项

1
2
3
4
5
6
function remove_screen_options(){
    if( !current_user_can('publish_pages') )
         return false;
    return true;
}
add_filter('screen_options_show_screen', 'remove_screen_options');

隐藏帮助选项卡

在主题的functions.php中添加

1
2
3
4
5
add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
    $screen->remove_help_tabs();
    return $old_help;
}

本文整理自:solagirl

发表评论

您的邮箱不会公开,当您的评论有新的回复时,会通过您填写的邮箱向您发送评论内容。 必填字段 *

为何看不到我发布的评论?

正在提交, 请稍候...