屏蔽WordPress后台无用项

WordPress 后台很多模块有时并不需要,使用下面的代码可以将它们屏蔽掉。

根据需要,将下面代码添加到当前主题functions.php模板文件中:

屏蔽左侧菜单

  1.  remove_menus() {
  2.      ;
  3.      = (
  4.         __(\’Dashboard\’),
  5.         __(\’Posts\’),
  6.         __(\’Media\’),
  7.         __(\’Links\’),
  8.         __(\’Pages\’),
  9.         __(\’Appearance\’),
  10.         __(\’Tools\’),
  11.         __(\’Users\’),
  12.         __(\’Settings\’),
  13.         __(\’Comments\’),
  14.         __(\’Plugins\’)
  15.     );
  16.      ();
  17.      (prev()){
  18.          = (\’ \’,[key()][0]);
  19.         (([0], \'<\’) === FALSE) {
  20.             (in_array([0] != NULL ? [0]: , )){
  21.                 unset([key()]);
  22.             }
  23.         } {
  24.          = (\'<\’, [0]);
  25.             (in_array([0] != NULL ? [0]: , )){
  26.                 unset([key()]);
  27.             }
  28.         }
  29.     }
  30. }
  31.  (is_admin()){
  32.     
  33.     add_action(\’admin_menu\’, \’remove_menus\’);
  34. }

删除子菜单

  1.  remove_submenu() {
  2.     
  3.     remove_submenu_page(\’options-general.php\’, \’options-privacy.php\’);
  4.     
  5.     remove_submenu_page(\’themes.php\’, \’theme-editor.php\’);
  6. }
  7.  (is_admin()){
  8.     
  9.     add_action(\’admin_init\’,\’remove_submenu\’);
  10. }

屏蔽后台更新模块

  1.  wp_hide_nag() {
  2.     remove_action( \’admin_notices\’, \’update_nag\’, 3 );
  3. }
  4. add_action(\’admin_menu\’,\’wp_hide_nag\’);

  1.  remove_screen_options(){  false;}
  2.     add_filter(\’screen_options_show_screen\’, \’remove_screen_options\’);
  3.     add_filter( \’contextual_help\’, \’wpse50723_remove_help\’, 999, 3 );
  4.      wpse50723_remove_help(, , ){
  5.     ->remove_help_tabs();
  6.      ;
  7. }

屏蔽后台仪表盘无用模块

  1.  example_remove_dashboard_widgets() {
  2.     
  3.      ;
  4.     
  5.     unset([\’dashboard\’][\’side\’][\’core\’][\’dashboard_quick_press\’]);
  6.     
  7.     unset([\’dashboard\’][\’normal\’][\’core\’][\’dashboard_incoming_links\’]);
  8.     
  9.     unset([\’dashboard\’][\’normal\’][\’core\’][\’dashboard_plugins\’]);
  10.     
  11.     unset([\’dashboard\’][\’normal\’][\’core\’][\’dashboard_recent_comments\’]);
  12.     
  13.     unset([\’dashboard\’][\’side\’][\’core\’][\’dashboard_recent_drafts\’]);
  14.     
  15.     unset([\’dashboard\’][\’side\’][\’core\’][\’dashboard_primary\’]);
  16.     
  17.     unset([\’dashboard\’][\’side\’][\’core\’][\’dashboard_secondary\’]);
  18.     
  19.     unset([\’dashboard\’][\’normal\’][\’core\’][\’dashboard_right_now\’]);
  20. }
  21. add_action(\’wp_dashboard_setup\’, \’example_remove_dashboard_widgets\’ );

屏蔽后台页脚版本信息

  1.  change_footer_admin () { ;}
  2. add_filter(\’admin_footer_text\’, \’change_footer_admin\’, 9999);
  3.  change_footer_version() { ;}
  4. add_filter( \’update_footer\’, \’change_footer_version\’, 9999);

屏蔽后台左上LOGO

  1.  annointed_admin_bar_remove() {
  2.          ;
  3.         
  4.         ->remove_menu(\’wp-logo\’);
  5. }
  6. add_action(\’wp_before_admin_bar_render\’, \’annointed_admin_bar_remove\’, 0);

补:

add_action( \'admin_menu\', function(){
remove_menu_page( \'index.php\' ); //仪表盘
remove_menu_page( \'upload.php\' ); //多媒体
remove_menu_page( \'edit.php?post_type=page\' ); //页面
remove_menu_page( \'edit-comments.php\' ); //评论
remove_menu_page( \'plugins.php\' ); //插件
remove_menu_page( \'tools.php\' ); //工具
remove_menu_page( \'options-general.php\' ); //设置
});
    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0 分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容