WordPress shields useless modules and menus-PHP source code

Source: Internet
Author: User
WordPress shields useless modules and menus 1. code

Function remove_menus () {global $ menu; $ restricted = array (_ ('dashboard '), _ ('posts'), _ ('media '), _ ('link'), _ ('Pages '), _ ('appearance'), _ ('tools '), _ ('users '), _ ('Settings'), _ ('comments'), _ ('ins ins'); end ($ menu); while (prev ($ menu )) {$ value = explode ('', $ menu [key ($ menu)] [0]); if (strpos ($ value [0], '<') === FALSE) {if (in_array ($ value [0]! = NULL? $ Value [0]: "", $ restricted) {unset ($ menu [key ($ menu)]) ;}} else {$ value2 = explode ('<', $ value [0]); if (in_array ($ value2 [0]! = NULL? $ Value2 [0]: "", $ restricted) {unset ($ menu [key ($ menu)]) ;}}} if (is_admin ()) {// mask the left menu add_action ('admin _ menu ', 'remove _ menus ');}

2. delete a sub-menu

Function remove_submenu () {// delete the submenu "privacy" remove_submenu_page ('options-general. php', 'options-privacy. php '); // delete the sub-menu "edit" remove_submenu_page ('themes. php', 'theme-editor. php ');} if (is_admin () {// delete the sub-menu add_action ('admin _ init', 'remove _ submenu ');}

3. shielding the background update Module

function wp_hide_nag() {remove_action( 'admin_notices', 'update_nag', 3 );}add_action('admin_menu','wp_hide_nag');

4. Shield the background navigation bar LOGO

function annointed_admin_bar_remove() {   global $wp_admin_bar;   $wp_admin_bar->remove_menu('wp-logo');}add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);

5. delete useless background modules

Function example_remove_dashboard_widgets () {// Globalize the metaboxes array, this holds all the widgets for wp-admin global $ wp_meta_boxes; // the following code deletes the "quick release" module unset ($ wp_meta_boxes ['dashboard '] ['side'] ['core'] ['dashboard _ quick_press']).; // the following code deletes the unset module of the "import link" module ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard _ incoming_links ']).; // the following code deletes the "plug-in" module unset ($ wp_meta_boxes ['dashboard '] ['normal'] ['core'] ['dashboard _ ins']). // the following code deletes the unset module of the "recent comments" module ($ wp_meta_boxes ['dashboard '] ['normal'] ['core'] ['dashboard _ recent_comments']); // the following code deletes the unset module of the "recent draft" module ($ wp_meta_boxes ['dashboard '] ['side'] ['core'] ['dashboard _ recent_drafts']).; // the following code deletes the "WordPress development log" module unset ($ wp_meta_boxes ['dashboard'] ['day'] ['core'] ['dashboard _ primary'] ); // the following code deletes the "other WordPress News" module unset ($ wp_meta_boxes ['dashboard '] ['day'] ['core'] ['dashboard _ secondary'] ); // the following code deletes the "overview" module unset ($ wp_meta_boxes ['dashboard '] ['normal'] ['core'] ['dashboard _ right_now']).} add_action ('WP _ dashboard_setup ', 'example _ remove_dashboard_widgets ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.