Make WordPress Core

Changeset 15753


Ignore:
Timestamp:
10/07/2010 10:35:31 PM (14 years ago)
Author:
scribu
Message:

Introduce remove_menu_page() and remove_submenu_page(). Fixes #12718

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r15744 r15753  
    853853 * Add a top level menu page in the 'objects' section
    854854 *
    855  * This function takes a capability which will be used to determine whether
    856  * or not a page is included in the menu.
    857  *
    858  * The function which is hooked in to handle the output of the page must check
    859  * that the user has the required capability as well.
    860  *
    861855 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    862856 * @param string $menu_title The text to be used for the menu
     
    877871 * Add a top level menu page in the 'utility' section
    878872 *
    879  * This function takes a capability which will be used to determine whether
    880  * or not a page is included in the menu.
    881  *
    882  * The function which is hooked in to handle the output of the page must check
    883  * that the user has the required capability as well.
    884  *
    885873 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    886874 * @param string $menu_title The text to be used for the menu
     
    900888/**
    901889 * Add a sub menu page
    902  *
    903  * This function takes a capability which will be used to determine whether
    904  * or not a page is included in the menu.
    905  *
    906  * The function which is hooked in to handle the output of the page must check
    907  * that the user has the required capability as well.
    908890 *
    909891 * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
     
    963945/**
    964946 * Add sub menu page to the tools main menu.
    965 *
    966  * This function takes a capability which will be used to determine whether
    967  * or not a page is included in the menu.
    968  *
    969  * The function which is hooked in to handle the output of the page must check
    970  * that the user has the required capability as well.
    971947 *
    972948 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    982958/**
    983959 * Add sub menu page to the options main menu.
    984 *
    985  * This function takes a capability which will be used to determine whether
    986  * or not a page is included in the menu.
    987  *
    988  * The function which is hooked in to handle the output of the page must check
    989  * that the user has the required capability as well.
    990960 *
    991961 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    1001971/**
    1002972 * Add sub menu page to the themes main menu.
    1003 *
    1004  * This function takes a capability which will be used to determine whether
    1005  * or not a page is included in the menu.
    1006  *
    1007  * The function which is hooked in to handle the output of the page must check
    1008  * that the user has the required capability as well.
    1009973 *
    1010974 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    1020984/**
    1021985 * Add sub menu page to the plugins main menu.
    1022 *
    1023  * This function takes a capability which will be used to determine whether
    1024  * or not a page is included in the menu.
    1025  *
    1026  * The function which is hooked in to handle the output of the page must check
    1027  * that the user has the required capability as well.
    1028986 *
    1029987 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    1039997/**
    1040998 * Add sub menu page to the Users/Profile main menu.
    1041 *
    1042  * This function takes a capability which will be used to determine whether
    1043  * or not a page is included in the menu.
    1044  *
    1045  * The function which is hooked in to handle the output of the page must check
    1046  * that the user has the required capability as well.
    1047999 *
    10481000 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    10611013/**
    10621014 * Add sub menu page to the Dashboard main menu.
    1063 *
    1064  * This function takes a capability which will be used to determine whether
    1065  * or not a page is included in the menu.
    1066  *
    1067  * The function which is hooked in to handle the output of the page must check
    1068  * that the user has the required capability as well.
    10691015 *
    10701016 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    10801026/**
    10811027 * Add sub menu page to the posts main menu.
    1082 *
    1083  * This function takes a capability which will be used to determine whether
    1084  * or not a page is included in the menu.
    1085  *
    1086  * The function which is hooked in to handle the output of the page must check
    1087  * that the user has the required capability as well.
    10881028 *
    10891029 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    10991039/**
    11001040 * Add sub menu page to the media main menu.
    1101 *
    1102  * This function takes a capability which will be used to determine whether
    1103  * or not a page is included in the menu.
    1104  *
    1105  * The function which is hooked in to handle the output of the page must check
    1106  * that the user has the required capability as well.
    11071041 *
    11081042 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    11181052/**
    11191053 * Add sub menu page to the links main menu.
    1120 *
    1121  * This function takes a capability which will be used to determine whether
    1122  * or not a page is included in the menu.
    1123  *
    1124  * The function which is hooked in to handle the output of the page must check
    1125  * that the user has the required capability as well.
    11261054 *
    11271055 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    11371065/**
    11381066 * Add sub menu page to the pages main menu.
    1139 *
    1140  * This function takes a capability which will be used to determine whether
    1141  * or not a page is included in the menu.
    1142  *
    1143  * The function which is hooked in to handle the output of the page must check
    1144  * that the user has the required capability as well.
    11451067 *
    11461068 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    11561078/**
    11571079 * Add sub menu page to the comments main menu.
    1158 *
    1159  * This function takes a capability which will be used to determine whether
    1160  * or not a page is included in the menu.
    1161  *
    1162  * The function which is hooked in to handle the output of the page must check
    1163  * that the user has the required capability as well.
    11641080 *
    11651081 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     
    11711087function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    11721088    return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1089}
     1090
     1091
     1092/**
     1093 * Remove a top level admin menu
     1094 *
     1095 * @since 3.1.0
     1096 *
     1097 * @param string $menu_slug The slug of the menu
     1098 * @return array|bool The removed menu on success, False if not found
     1099 */
     1100function remove_menu_page( $menu_slug ) {
     1101    global $menu;
     1102
     1103    foreach ( $menu as $i => $item ) {
     1104        if ( $menu_slug == $item[2] ) {
     1105            unset( $menu[$i] );
     1106            return $item;
     1107        }
     1108    }
     1109
     1110    return false;
     1111}
     1112
     1113/**
     1114 * Remove an admin submenu
     1115 *
     1116 * @since 3.1.0
     1117 *
     1118 * @param string $menu_slug The slug for the parent menu
     1119 * @param string $submenu_slug The slug of the submenu
     1120 * @return array|bool The removed submenu on success, False if not found
     1121 */
     1122function remove_submenu_page( $menu_slug, $submenu_slug ) {
     1123    global $submenu;
     1124
     1125    if ( !isset( $submenu[$menu_slug] ) )
     1126        return false;
     1127
     1128    foreach ( $submenu[$menu_slug] as $i => $item ) {
     1129        if ( $submenu_slug == $item[2] ) {
     1130            unset( $submenu[$menu_slug][$i] );
     1131            return $item;
     1132        }
     1133    }
     1134
     1135    return false;
    11731136}
    11741137
Note: See TracChangeset for help on using the changeset viewer.