删除子菜单


//remove submenus
function remove_submenus() {
  global $submenu;
  unset($submenu['index.php'][10]); // Removes 'Updates'.
  unset($submenu['themes.php'][5]); // Removes 'Themes'.
  unset($submenu['options-general.php'][15]); // Removes 'Writing'.
  unset($submenu['options-general.php'][25]); // Removes 'Discussion'.
  unset($submenu['edit.php'][16]); // Removes 'Tags'. 
}
add_action('admin_menu', 'remove_submenus');

根据角色设定菜单可见性


//remove role menus
function remove_menus() {
    global $menu;
    // 这里$restricted设置了评论和工具菜单
    $restricted = array(__('Comments'), __('Tools'));
    end ($menu);
    while (prev($menu)){
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    }
}
function remove_submenu() {
    remove_submenu_page( 'options-general.php', 'options-privacy.php' );
}
global $current_user;
get_currentuserinfo();
//如果当前用户的等级小于3,那么就删除对应的菜单
if ($current_user->user_level < 3 && is_admin()) {
    add_action('admin_menu', 'remove_menus');
    add_action('admin_init','remove_submenu');
}
0 级对应 订阅者 1 级对应 投稿者 2 – 4 级对应 作者 5 – 7 级对应 编辑 8 – 10 级对应 管理员

修改后台LOGO图标


//custom admin logo
function custom_logo() {
  echo '<style type="text/css">
    #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/admin_logo.png) !important; }
    </style>';
}
add_action('admin_head', 'custom_logo');

修改登录页面LOGO


//custom login logo
function custom_login_logo() {
  echo '<style type="text/css">
    h1 a { background-image:url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }
    </style>';
}
add_action('login_head', 'custom_login_logo');

隐藏版本更新


//Hide the Upgrade Notice to Recent Versions
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

修改页脚信息


//Customize the Footer
function modify_footer_admin () {
  echo 'Created by <a href="http://wiinder.com">wiinder</a>.';
  echo 'Powered by<a href="http://WordPress.org">WordPress</a>.';
}
add_filter('admin_footer_text', 'modify_footer_admin');

去除编辑页面媒体上传按钮


//remove all media buttons
add_action('admin_init', 'remove_all_media_buttons');
function remove_all_media_buttons()
{
    remove_all_actions('media_buttons');
}

完整删除WP版本号


//完整的删除WordPress的版本号
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');

隐藏帮助按钮和版本更新


//隐藏管理后台帮助按钮和版本更新提示
function hide_help() {
	echo'<style type="text/css">#contextual-help-link-wrap { display: none !important; } .update-nag{ display: none !important; } #footer-left, #footer-upgrade{ display: none !important; }#wp-admin-bar-wp-logo{display: none !important;}.default-header img{width:400px;}</style>';
}
add_action('admin_head', 'hide_help');

去除header冗余代码


//去除header冗余代码
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'wp_generator');