Make WordPress Core

Ticket #39776: 39776.diff

File 39776.diff, 13.5 KB (added by welcher, 7 years ago)

Initial Patch

  • src/wp-admin/includes/plugin.php

    diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
    index e4018d7..84944e9 100644
    function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func 
    11321132 * @param string   $capability  The capability required for this menu to be displayed to the user.
    11331133 * @param string   $menu_slug   The slug name to refer to this menu by (should be unique for this menu).
    11341134 * @param callable $function    The function to be called to output the content for this page.
     1135 * @param int      $position   The position in the menu order this one should appear.
     1136 *
    11351137 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    11361138 */
    1137 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1139function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
    11381140        global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
    11391141                $_registered_pages, $_parent_pages;
    11401142
    function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, 
    11621164                }
    11631165        }
    11641166
    1165         $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title );
     1167        $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
     1168        if ( null === $position ) {
     1169                $submenu[ $parent_slug ][] = $new_sub_menu;
     1170        } elseif ( isset( $submenu[ $parent_slug ][ "$position" ] ) ) {
     1171                $position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ) , -5 ) * 0.00001;
     1172                $submenu[ $parent_slug ][ "$position" ] = $new_sub_menu;
     1173        } else {
     1174                $submenu[ $parent_slug ][ $position ] = $new_sub_menu;
     1175        }
     1176        ksort( $submenu[ $parent_slug ] );
    11661177
    11671178        $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug);
    11681179        if (!empty ( $function ) && !empty ( $hookname ))
    function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, 
    11971208 * @param string   $capability The capability required for this menu to be displayed to the user.
    11981209 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    11991210 * @param callable $function   The function to be called to output the content for this page.
     1211 * @param int      $position   The position in the menu order this one should appear.
    12001212 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    12011213 */
    1202 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1203         return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1214function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1215        return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    12041216}
    12051217
    12061218/**
    function add_management_page( $page_title, $menu_title, $capability, $menu_slug, 
    12171229 * @param string   $capability The capability required for this menu to be displayed to the user.
    12181230 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    12191231 * @param callable $function   The function to be called to output the content for this page.
     1232 * @param int      $position   The position in the menu order this one should appear.
    12201233 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    12211234 */
    1222 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1223         return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1235function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1236        return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    12241237}
    12251238
    12261239/**
    function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f 
    12371250 * @param string   $capability The capability required for this menu to be displayed to the user.
    12381251 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    12391252 * @param callable $function   The function to be called to output the content for this page.
     1253 * @param int      $position   The position in the menu order this one should appear.
    12401254 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    12411255 */
    1242 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1243         return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1256function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1257        return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    12441258}
    12451259
    12461260/**
    function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    12571271 * @param string   $capability The capability required for this menu to be displayed to the user.
    12581272 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    12591273 * @param callable $function   The function to be called to output the content for this page.
     1274 * @param int      $position   The position in the menu order this one should appear.
    12601275 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    12611276 */
    1262 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1263         return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1277function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1278        return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    12641279}
    12651280
    12661281/**
    function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f 
    12771292 * @param string   $capability The capability required for this menu to be displayed to the user.
    12781293 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    12791294 * @param callable $function   The function to be called to output the content for this page.
     1295 * @param int      $position   The position in the menu order this one should appear.
    12801296 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    12811297 */
    1282 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1298function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
    12831299        if ( current_user_can('edit_users') )
    12841300                $parent = 'users.php';
    12851301        else
    12861302                $parent = 'profile.php';
    1287         return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
     1303        return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    12881304}
    12891305/**
    12901306 * Add submenu page to the Dashboard main menu.
    function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    13001316 * @param string   $capability The capability required for this menu to be displayed to the user.
    13011317 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    13021318 * @param callable $function   The function to be called to output the content for this page.
     1319 * @param int      $position   The position in the menu order this one should appear.
    13031320 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13041321 */
    1305 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1306         return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1322function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1323        return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    13071324}
    13081325
    13091326/**
    function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, 
    13201337 * @param string   $capability The capability required for this menu to be displayed to the user.
    13211338 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    13221339 * @param callable $function   The function to be called to output the content for this page.
     1340 * @param int      $position   The position in the menu order this one should appear.
    13231341 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13241342 */
    1325 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1326         return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1343function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1344        return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    13271345}
    13281346
    13291347/**
    function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    13401358 * @param string   $capability The capability required for this menu to be displayed to the user.
    13411359 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    13421360 * @param callable $function   The function to be called to output the content for this page.
     1361 * @param int      $position   The position in the menu order this one should appear.
    13431362 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13441363 */
    1345 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1346         return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1364function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1365        return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    13471366}
    13481367
    13491368/**
    function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    13601379 * @param string   $capability The capability required for this menu to be displayed to the user.
    13611380 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    13621381 * @param callable $function   The function to be called to output the content for this page.
     1382 * @param int      $position   The position in the menu order this one should appear.
    13631383 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13641384 */
    1365 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1366         return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1385function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1386        return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    13671387}
    13681388
    13691389/**
    function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    13801400 * @param string   $capability The capability required for this menu to be displayed to the user.
    13811401 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    13821402 * @param callable $function   The function to be called to output the content for this page.
     1403 * @param int      $position   The position in the menu order this one should appear.
    13831404 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13841405 */
    1385 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1386         return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
     1406function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1407        return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position);
    13871408}
    13881409
    13891410/**
    function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    14001421 * @param string   $capability The capability required for this menu to be displayed to the user.
    14011422 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14021423 * @param callable $function   The function to be called to output the content for this page.
     1424 * @param int      $position   The position in the menu order this one should appear.
    14031425 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    14041426 */
    1405 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1406         return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1427function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1428        return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    14071429}
    14081430
    14091431/**