wordpress移除不必要的信息
1.移除不必要的头部信息
//移除不必要head信息 remove_action('wp_head', 'wp_generator' ); //去除版本信息 remove_action('wp_head', 'wlwmanifest_link' ); remove_action('wp_head', 'rsd_link' );//清除离线编辑器接口 remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );//清除前后文信息 remove_action('wp_head', 'feed_links',2 ); remove_action('wp_head', 'feed_links_extra',3 );//清除feed信息 remove_action('wp_head', 'wp_shortlink_wp_head',10,0 );
2.清除DashBoard小工具
1 //清除dashboard小插件 2 function remove_dashboard_widgets() { 3 // Globalize the metaboxes array, this holds all the widgets for wp-admin 4 global $wp_meta_boxes; 5 // 以下这一行代码将删除 "快速发布" 模块 6 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); 7 // 以下这一行代码将删除 "引入链接" 模块 8 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); 9 // 以下这一行代码将删除 "插件" 模块 10 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); 11 // 以下这一行代码将删除 "近期评论" 模块 12 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); 13 // 以下这一行代码将删除 "近期草稿" 模块 14 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); 15 // 以下这一行代码将删除 "WordPress 开发日志" 模块 16 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); 17 // 以下这一行代码将删除 "其它 WordPress 新闻" 模块 18 unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); 19 // 以下这一行代码将删除 "概况" 模块 20 unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); 21 } 22 add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
3.禁止wordpress显示更新信息
1 //禁用更新提示 2 add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); // 关闭核心提示 3 4 add_filter('pre_site_transient_update_plugins', create_function('$a', "return null;")); // 关闭插件提示 5 6 add_filter('pre_site_transient_update_themes', create_function('$a', "return null;")); // 关闭主题提示 7 8 remove_action('admin_init', '_maybe_update_core'); // 禁止 WordPress 检查更新 9 10 remove_action('admin_init', '_maybe_update_plugins'); // 禁止 WordPress 更新插件 11 12 remove_action('admin_init', '_maybe_update_themes'); // 禁止 WordPress 更新主题
4.屏蔽后台页脚信息
1 //屏蔽后台页脚信息 2 function change_footer_admin () {return '';} 3 add_filter('admin_footer_text', 'change_footer_admin', 9999); 4 function change_footer_version() {return '';} 5 add_filter( 'update_footer', 'change_footer_version', 9999);
5.屏蔽左上logo
1 //屏蔽左上logo 2 function annointed_admin_bar_remove() { 3 global $wp_admin_bar; 4 /* Remove their stuff */ 5 $wp_admin_bar->remove_menu('wp-logo'); 6 } 7 add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);