Make WordPress Core

Ticket #39776: 39776.4.diff

File 39776.4.diff, 13.7 KB (added by welcher, 5 years ago)

Patch refresh for 5.3

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

    diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
    index 683cb7c215..a1be9ec57a 100644
    function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func 
    13381338 *                              and only include lowercase alphanumeric, dashes, and underscores characters
    13391339 *                              to be compatible with sanitize_key().
    13401340 * @param callable $function    The function to be called to output the content for this page.
     1341 * @param int      $position    The position order in the menu where this item should appear.
     1342 *
    13411343 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    13421344 */
    1343 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
     1345function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
    13441346        global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
    13451347                $_registered_pages, $_parent_pages;
    13461348
    function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, 
    13701372                }
    13711373        }
    13721374
    1373         $submenu[ $parent_slug ][] = array( $menu_title, $capability, $menu_slug, $page_title );
     1375        $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
     1376        if ( null === $position ) {
     1377                $submenu[ $parent_slug ][] = $new_sub_menu;
     1378        } else {
     1379                // If there is a position.
     1380                // Grab all of the items before the insertion point.
     1381                $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
     1382                // Grab all of the items after the insertion point
     1383                $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true );
     1384                // Add the new item
     1385                $before_items[] = $new_sub_menu;
     1386                // Merge the items.
     1387                $submenu[ $parent_slug ] = array_merge( $before_items, $after_items );
     1388        }
     1389        // Sort the parent array
     1390        ksort( $submenu[ $parent_slug ] );
    13741391
    13751392        $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
    13761393        if ( ! empty( $function ) && ! empty( $hookname ) ) {
    function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, 
    14091426 * @param string   $capability The capability required for this menu to be displayed to the user.
    14101427 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14111428 * @param callable $function   The function to be called to output the content for this page.
     1429 * @param int      $position   The position in the menu order this one should appear.
    14121430 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    14131431 */
    1414 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1415         return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1432function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1433        return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    14161434}
    14171435
    14181436/**
    function add_management_page( $page_title, $menu_title, $capability, $menu_slug, 
    14311449 * @param string   $capability The capability required for this menu to be displayed to the user.
    14321450 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14331451 * @param callable $function   The function to be called to output the content for this page.
     1452 * @param int      $position   The position in the menu order this one should appear.
    14341453 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    14351454 */
    1436 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1437         return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1455function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1456        return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    14381457}
    14391458
    14401459/**
    function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f 
    14531472 * @param string   $capability The capability required for this menu to be displayed to the user.
    14541473 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14551474 * @param callable $function   The function to be called to output the content for this page.
     1475 * @param int      $position   The position in the menu order this one should appear.
    14561476 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    14571477 */
    1458 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1459         return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1478function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1479        return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    14601480}
    14611481
    14621482/**
    function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    14751495 * @param string   $capability The capability required for this menu to be displayed to the user.
    14761496 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14771497 * @param callable $function   The function to be called to output the content for this page.
     1498 * @param int      $position   The position in the menu order this one should appear.
    14781499 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    14791500 */
    1480 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1481         return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1501function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1502        return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    14821503}
    14831504
    14841505/**
    function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f 
    14971518 * @param string   $capability The capability required for this menu to be displayed to the user.
    14981519 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    14991520 * @param callable $function   The function to be called to output the content for this page.
     1521 * @param int      $position   The position in the menu order this one should appear.
    15001522 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    15011523 */
    1502 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1503         if ( current_user_can( 'edit_users' ) ) {
     1524
     1525function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1526        if ( current_user_can('edit_users') ) {
    15041527                $parent = 'users.php';
    15051528        } else {
    15061529                $parent = 'profile.php';
    15071530        }
    1508         return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
     1531        return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    15091532}
    15101533/**
    15111534 * Add submenu page to the Dashboard main menu.
    function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    15231546 * @param string   $capability The capability required for this menu to be displayed to the user.
    15241547 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    15251548 * @param callable $function   The function to be called to output the content for this page.
     1549 * @param int      $position   The position in the menu order this one should appear.
    15261550 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    15271551 */
    1528 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1529         return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1552function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1553        return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    15301554}
    15311555
    15321556/**
    function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, 
    15451569 * @param string   $capability The capability required for this menu to be displayed to the user.
    15461570 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    15471571 * @param callable $function   The function to be called to output the content for this page.
     1572 * @param int      $position   The position in the menu order this one should appear.
    15481573 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    15491574 */
    1550 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1551         return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1575function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1576        return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    15521577}
    15531578
    15541579/**
    function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    15671592 * @param string   $capability The capability required for this menu to be displayed to the user.
    15681593 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    15691594 * @param callable $function   The function to be called to output the content for this page.
     1595 * @param int      $position   The position in the menu order this one should appear.
    15701596 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    15711597 */
    1572 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1573         return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1598function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1599        return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    15741600}
    15751601
    15761602/**
    function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    15891615 * @param string   $capability The capability required for this menu to be displayed to the user.
    15901616 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    15911617 * @param callable $function   The function to be called to output the content for this page.
     1618 * @param int      $position   The position in the menu order this one should appear.
    15921619 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    15931620 */
    1594 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1595         return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1621function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1622        return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    15961623}
    15971624
    15981625/**
    function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    16111638 * @param string   $capability The capability required for this menu to be displayed to the user.
    16121639 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    16131640 * @param callable $function   The function to be called to output the content for this page.
     1641 * @param int      $position   The position in the menu order this one should appear.
    16141642 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    16151643 */
    1616 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1617         return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
     1644function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1645        return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position);
    16181646}
    16191647
    16201648/**
    function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun 
    16331661 * @param string   $capability The capability required for this menu to be displayed to the user.
    16341662 * @param string   $menu_slug  The slug name to refer to this menu by (should be unique for this menu).
    16351663 * @param callable $function   The function to be called to output the content for this page.
     1664 * @param int      $position   The position in the menu order this one should appear.
    16361665 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
    16371666 */
    1638 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
    1639         return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
     1667function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
     1668        return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
    16401669}
    16411670
    16421671/**