WordPress.org

Make WordPress Core

Ticket #15067: 15067.2.diff

File 15067.2.diff, 8.6 KB (added by johnjamesjacoby, 8 years ago)

Patch applies clean. I like that it doesn't trigger deprecated notices yet. Refreshed to remove unnecessary brackets per coding standard.

  • wp-admin/includes/plugin.php

     
    853853 * The function which is hooked in to handle the output of the page must check
    854854 * that the user has the required capability as well.
    855855 *
    856  * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     856 * @param mixed $page_title_or_params The text to be displayed in the title tags of the page when the menu is selected
     857 *                                    OR, an array of this and all subsequent parameters.
    857858 * @param string $menu_title The text to be used for the menu
    858859 * @param string $capability The capability required for this menu to be displayed to the user.
    859860 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
     
    863864 *
    864865 * @return string The resulting page's hook_suffix
    865866 */
    866 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL ) {
     867function add_menu_page( $page_title_or_params, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '', $icon_url = '', $position = NULL ) {
    867868        global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
    868869
     870        if ( is_array( $page_title_or_params ) )
     871                extract( shortcode_atts( array( 'page_title' => NULL, 'menu_title' => NULL, 'capability' => NULL, 'menu_slug' => NULL, 'function' => '', 'icon_url' => '', 'position' => NULL ), $page_title_or_params ) );
     872        else
     873                $page_title = $page_title_or_params;
     874
    869875        $menu_slug = plugin_basename( $menu_slug );
    870876
    871877        $admin_page_hooks[$menu_slug] = sanitize_title( $menu_title );
     
    913919 *
    914920 * @return string The resulting page's hook_suffix
    915921 */
    916 function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
     922function add_object_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '', $icon_url = '') {
    917923        global $_wp_last_object_menu;
    918924
    919925        $_wp_last_object_menu++;
     
    939945 *
    940946 * @return string The resulting page's hook_suffix
    941947 */
    942 function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
     948function add_utility_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '', $icon_url = '') {
    943949        global $_wp_last_utility_menu;
    944950
    945951        $_wp_last_utility_menu++;
     
    956962 * The function which is hooked in to handle the output of the page must check
    957963 * that the user has the required capability as well.
    958964 *
    959  * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
    960  * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
     965 * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page),
     966 * @param mixed $page_title_or_params The text to be displayed in the title tags of the page when the menu is selected
     967 *                                    OR, an array of this and all subsequent parameters.
    961968 * @param string $menu_title The text to be used for the menu
    962969 * @param string $capability The capability required for this menu to be displayed to the user.
    963970 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
     
    965972 *
    966973 * @return string The resulting page's hook_suffix
    967974 */
    968 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     975function add_submenu_page( $parent_slug, $page_title_or_params, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    969976        global $submenu;
    970977        global $menu;
    971978        global $_wp_real_parent_file;
     
    973980        global $_registered_pages;
    974981        global $_parent_pages;
    975982
     983        if ( is_array( $page_title_or_params ) )
     984                extract( shortcode_atts( array( 'page_title' => NULL, 'menu_title' => NULL, 'capability' => NULL, 'menu_slug' => NULL, 'function' => '' ), $page_title_or_params ) );
     985        else
     986                $page_title = $page_title_or_params;
     987
    976988        $menu_slug = plugin_basename( $menu_slug );
    977989        $parent_slug = plugin_basename( $parent_slug);
    978990
     
    10291041 *
    10301042 * @return string The resulting page's hook_suffix
    10311043 */
    1032 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1044function add_management_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    10331045        return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    10341046}
    10351047
     
    10501062 *
    10511063 * @return string The resulting page's hook_suffix
    10521064 */
    1053 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1065function add_options_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    10541066        return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    10551067}
    10561068
     
    10711083 *
    10721084 * @return string The resulting page's hook_suffix
    10731085 */
    1074 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1086function add_theme_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    10751087        return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    10761088}
    10771089
     
    10921104 *
    10931105 * @return string The resulting page's hook_suffix
    10941106 */
    1095 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1107function add_plugins_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    10961108        return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    10971109}
    10981110
     
    11131125 *
    11141126 * @return string The resulting page's hook_suffix
    11151127 */
    1116 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1128function add_users_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    11171129        if ( current_user_can('edit_users') )
    11181130                $parent = 'users.php';
    11191131        else
     
    11371149 *
    11381150 * @return string The resulting page's hook_suffix
    11391151 */
    1140 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1152function add_dashboard_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    11411153        return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    11421154}
    11431155
     
    11581170 *
    11591171 * @return string The resulting page's hook_suffix
    11601172 */
    1161 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1173function add_posts_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    11621174        return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    11631175}
    11641176
     
    11791191 *
    11801192 * @return string The resulting page's hook_suffix
    11811193 */
    1182 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1194function add_media_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    11831195        return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    11841196}
    11851197
     
    12001212 *
    12011213 * @return string The resulting page's hook_suffix
    12021214 */
    1203 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1215function add_links_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    12041216        return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    12051217}
    12061218
     
    12211233 *
    12221234 * @return string The resulting page's hook_suffix
    12231235*/
    1224 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1236function add_pages_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    12251237        return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
    12261238}
    12271239
     
    12421254 *
    12431255 * @return string The resulting page's hook_suffix
    12441256*/
    1245 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1257function add_comments_page( $page_title, $menu_title = NULL, $capability = NULL, $menu_slug = NULL, $function = '' ) {
    12461258        return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
    12471259}
    12481260