WordPress.org

Make WordPress Core

Ticket #14666: 14666.diff

File 14666.diff, 9.9 KB (added by scribu, 9 years ago)
  • wp-admin/includes/plugin.php

     
    852852/**
    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
    863857 * @param string $capability The capability required for this menu to be displayed to the user.
     
    876870/**
    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
    887875 * @param string $capability The capability required for this menu to be displayed to the user.
     
    900888/**
    901889 * Add a sub menu page
    902890 *
    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.
    908  *
    909891 * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
    910892 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    911893 * @param string $menu_title The text to be used for the menu
     
    962944
    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.
    968947 *
    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.
    971  *
    972948 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    973949 * @param string $menu_title The text to be used for the menu
    974950 * @param string $capability The capability required for this menu to be displayed to the user.
     
    981957
    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.
    987960 *
    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.
    990  *
    991961 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    992962 * @param string $menu_title The text to be used for the menu
    993963 * @param string $capability The capability required for this menu to be displayed to the user.
     
    1000970
    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.
    1006973 *
    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.
    1009  *
    1010974 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    1011975 * @param string $menu_title The text to be used for the menu
    1012976 * @param string $capability The capability required for this menu to be displayed to the user.
     
    1019983
    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.
    1025986 *
    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.
    1028  *
    1029987 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    1030988 * @param string $menu_title The text to be used for the menu
    1031989 * @param string $capability The capability required for this menu to be displayed to the user.
     
    1038996
    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.
    1044999 *
    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.
    1047  *
    10481000 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    10491001 * @param string $menu_title The text to be used for the menu
    10501002 * @param string $capability The capability required for this menu to be displayed to the user.
     
    10601012}
    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.
    10661015 *
    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.
    1069  *
    10701016 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    10711017 * @param string $menu_title The text to be used for the menu
    10721018 * @param string $capability The capability required for this menu to be displayed to the user.
     
    10791025
    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.
    10851028 *
    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.
    1088  *
    10891029 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    10901030 * @param string $menu_title The text to be used for the menu
    10911031 * @param string $capability The capability required for this menu to be displayed to the user.
     
    10981038
    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.
    11041041 *
    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.
    1107  *
    11081042 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    11091043 * @param string $menu_title The text to be used for the menu
    11101044 * @param string $capability The capability required for this menu to be displayed to the user.
     
    11171051
    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.
    11231054 *
    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.
    1126  *
    11271055 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    11281056 * @param string $menu_title The text to be used for the menu
    11291057 * @param string $capability The capability required for this menu to be displayed to the user.
     
    11361064
    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.
    11421067 *
    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.
    1145  *
    11461068 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    11471069 * @param string $menu_title The text to be used for the menu
    11481070 * @param string $capability The capability required for this menu to be displayed to the user.
     
    11551077
    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.
    11611080 *
    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.
    1164  *
    11651081 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
    11661082 * @param string $menu_title The text to be used for the menu
    11671083 * @param string $capability The capability required for this menu to be displayed to the user.
     
    11721088        return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    11731089}
    11741090
     1091
    11751092/**
     1093 * Remove a top level menu page
     1094 *
     1095 * @since 3.1.0
     1096 *
     1097 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
     1098 * @return array|bool The removed menu item 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 a top level menu page
     1115 *
     1116 * @since 3.1.0
     1117 *
     1118 * @param string $menu_slug The slug name of the parent menu
     1119 * @param string $menu_slug The slug name of the submenu
     1120 * @return array|bool The removed submenu item 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;
     1136}
     1137
     1138/**
    11761139 * Get the url to access a particular menu page based on the slug it was registered with.
    11771140 *
    11781141 * If the slug hasn't been registered properly no url will be returned