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 |
1338 | 1338 | * and only include lowercase alphanumeric, dashes, and underscores characters |
1339 | 1339 | * to be compatible with sanitize_key(). |
1340 | 1340 | * @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 | * |
1341 | 1343 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1342 | 1344 | */ |
1343 | | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 1345 | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1344 | 1346 | global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
1345 | 1347 | $_registered_pages, $_parent_pages; |
1346 | 1348 | |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1370 | 1372 | } |
1371 | 1373 | } |
1372 | 1374 | |
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 ] ); |
1374 | 1391 | |
1375 | 1392 | $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); |
1376 | 1393 | if ( ! empty( $function ) && ! empty( $hookname ) ) { |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1409 | 1426 | * @param string $capability The capability required for this menu to be displayed to the user. |
1410 | 1427 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1411 | 1428 | * @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. |
1412 | 1430 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1413 | 1431 | */ |
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 ); |
| 1432 | function 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 ); |
1416 | 1434 | } |
1417 | 1435 | |
1418 | 1436 | /** |
… |
… |
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, |
1431 | 1449 | * @param string $capability The capability required for this menu to be displayed to the user. |
1432 | 1450 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1433 | 1451 | * @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. |
1434 | 1453 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1435 | 1454 | */ |
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 ); |
| 1455 | function 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 ); |
1438 | 1457 | } |
1439 | 1458 | |
1440 | 1459 | /** |
… |
… |
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1453 | 1472 | * @param string $capability The capability required for this menu to be displayed to the user. |
1454 | 1473 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1455 | 1474 | * @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. |
1456 | 1476 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1457 | 1477 | */ |
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 ); |
| 1478 | function 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 ); |
1460 | 1480 | } |
1461 | 1481 | |
1462 | 1482 | /** |
… |
… |
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1475 | 1495 | * @param string $capability The capability required for this menu to be displayed to the user. |
1476 | 1496 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1477 | 1497 | * @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. |
1478 | 1499 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1479 | 1500 | */ |
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 ); |
| 1501 | function 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 ); |
1482 | 1503 | } |
1483 | 1504 | |
1484 | 1505 | /** |
… |
… |
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1497 | 1518 | * @param string $capability The capability required for this menu to be displayed to the user. |
1498 | 1519 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1499 | 1520 | * @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. |
1500 | 1522 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1501 | 1523 | */ |
1502 | | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1503 | | if ( current_user_can( 'edit_users' ) ) { |
| 1524 | |
| 1525 | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1526 | if ( current_user_can('edit_users') ) { |
1504 | 1527 | $parent = 'users.php'; |
1505 | 1528 | } else { |
1506 | 1529 | $parent = 'profile.php'; |
1507 | 1530 | } |
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 ); |
1509 | 1532 | } |
1510 | 1533 | /** |
1511 | 1534 | * Add submenu page to the Dashboard main menu. |
… |
… |
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1523 | 1546 | * @param string $capability The capability required for this menu to be displayed to the user. |
1524 | 1547 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1525 | 1548 | * @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. |
1526 | 1550 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1527 | 1551 | */ |
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 ); |
| 1552 | function 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 ); |
1530 | 1554 | } |
1531 | 1555 | |
1532 | 1556 | /** |
… |
… |
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, |
1545 | 1569 | * @param string $capability The capability required for this menu to be displayed to the user. |
1546 | 1570 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1547 | 1571 | * @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. |
1548 | 1573 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1549 | 1574 | */ |
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 ); |
| 1575 | function 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 ); |
1552 | 1577 | } |
1553 | 1578 | |
1554 | 1579 | /** |
… |
… |
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1567 | 1592 | * @param string $capability The capability required for this menu to be displayed to the user. |
1568 | 1593 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1569 | 1594 | * @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. |
1570 | 1596 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1571 | 1597 | */ |
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 ); |
| 1598 | function 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 ); |
1574 | 1600 | } |
1575 | 1601 | |
1576 | 1602 | /** |
… |
… |
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1589 | 1615 | * @param string $capability The capability required for this menu to be displayed to the user. |
1590 | 1616 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1591 | 1617 | * @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. |
1592 | 1619 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1593 | 1620 | */ |
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 ); |
| 1621 | function 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 ); |
1596 | 1623 | } |
1597 | 1624 | |
1598 | 1625 | /** |
… |
… |
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1611 | 1638 | * @param string $capability The capability required for this menu to be displayed to the user. |
1612 | 1639 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1613 | 1640 | * @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. |
1614 | 1642 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1615 | 1643 | */ |
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 ); |
| 1644 | function 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); |
1618 | 1646 | } |
1619 | 1647 | |
1620 | 1648 | /** |
… |
… |
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1633 | 1661 | * @param string $capability The capability required for this menu to be displayed to the user. |
1634 | 1662 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1635 | 1663 | * @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. |
1636 | 1665 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1637 | 1666 | */ |
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 ); |
| 1667 | function 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 ); |
1640 | 1669 | } |
1641 | 1670 | |
1642 | 1671 | /** |