diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
index 54c6db27ac..33266d67a0 100644
|
|
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func |
1312 | 1312 | * and only include lowercase alphanumeric, dashes, and underscores characters |
1313 | 1313 | * to be compatible with sanitize_key(). |
1314 | 1314 | * @param callable $function The function to be called to output the content for this page. |
| 1315 | * @param int $position The position order in the menu where this item should appear. |
| 1316 | * |
1315 | 1317 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1316 | 1318 | */ |
1317 | | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 1319 | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1318 | 1320 | global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
1319 | 1321 | $_registered_pages, $_parent_pages; |
1320 | 1322 | |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1344 | 1346 | } |
1345 | 1347 | } |
1346 | 1348 | |
1347 | | $submenu[ $parent_slug ][] = array( $menu_title, $capability, $menu_slug, $page_title ); |
| 1349 | $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); |
| 1350 | if ( null === $position ) { |
| 1351 | $submenu[ $parent_slug ][] = $new_sub_menu; |
| 1352 | } else { |
| 1353 | // If there is a position. |
| 1354 | // Grab all of the items before the insertion point. |
| 1355 | $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true ); |
| 1356 | // Grab all of the items after the insertion point |
| 1357 | $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true ); |
| 1358 | // Add the new item |
| 1359 | $before_items[] = $new_sub_menu; |
| 1360 | // Merge the items. |
| 1361 | $submenu[ $parent_slug ] = array_merge( $before_items, $after_items ); |
| 1362 | } |
| 1363 | // Sort the parent array |
| 1364 | ksort( $submenu[ $parent_slug ] ); |
1348 | 1365 | |
1349 | 1366 | $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); |
1350 | 1367 | if ( ! empty( $function ) && ! empty( $hookname ) ) { |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1383 | 1400 | * @param string $capability The capability required for this menu to be displayed to the user. |
1384 | 1401 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1385 | 1402 | * @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. |
1386 | 1404 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1387 | 1405 | */ |
1388 | | function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1389 | | return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1406 | function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1407 | return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1390 | 1408 | } |
1391 | 1409 | |
1392 | 1410 | /** |
… |
… |
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, |
1405 | 1423 | * @param string $capability The capability required for this menu to be displayed to the user. |
1406 | 1424 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1407 | 1425 | * @param callable $function The function to be called to output the content for this page. |
| 1426 | * @param int $position The position in the menu order this one should appear. |
1408 | 1427 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1409 | 1428 | */ |
1410 | | function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1411 | | return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1429 | function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1430 | return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1412 | 1431 | } |
1413 | 1432 | |
1414 | 1433 | /** |
… |
… |
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1427 | 1446 | * @param string $capability The capability required for this menu to be displayed to the user. |
1428 | 1447 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1429 | 1448 | * @param callable $function The function to be called to output the content for this page. |
| 1449 | * @param int $position The position in the menu order this one should appear. |
1430 | 1450 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1431 | 1451 | */ |
1432 | | function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1433 | | return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1452 | function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1453 | return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1434 | 1454 | } |
1435 | 1455 | |
1436 | 1456 | /** |
… |
… |
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1449 | 1469 | * @param string $capability The capability required for this menu to be displayed to the user. |
1450 | 1470 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1451 | 1471 | * @param callable $function The function to be called to output the content for this page. |
| 1472 | * @param int $position The position in the menu order this one should appear. |
1452 | 1473 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1453 | 1474 | */ |
1454 | | function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1455 | | return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1475 | function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1476 | return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1456 | 1477 | } |
1457 | 1478 | |
1458 | 1479 | /** |
… |
… |
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1471 | 1492 | * @param string $capability The capability required for this menu to be displayed to the user. |
1472 | 1493 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1473 | 1494 | * @param callable $function The function to be called to output the content for this page. |
| 1495 | * @param int $position The position in the menu order this one should appear. |
1474 | 1496 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1475 | 1497 | */ |
1476 | | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1477 | | if ( current_user_can( 'edit_users' ) ) { |
| 1498 | |
| 1499 | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1500 | if ( current_user_can('edit_users') ) { |
1478 | 1501 | $parent = 'users.php'; |
1479 | 1502 | } else { |
1480 | 1503 | $parent = 'profile.php'; |
1481 | 1504 | } |
1482 | | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1505 | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1483 | 1506 | } |
1484 | 1507 | /** |
1485 | 1508 | * Add submenu page to the Dashboard main menu. |
… |
… |
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1497 | 1520 | * @param string $capability The capability required for this menu to be displayed to the user. |
1498 | 1521 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1499 | 1522 | * @param callable $function The function to be called to output the content for this page. |
| 1523 | * @param int $position The position in the menu order this one should appear. |
1500 | 1524 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1501 | 1525 | */ |
1502 | | function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1503 | | return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1526 | function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1527 | return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1504 | 1528 | } |
1505 | 1529 | |
1506 | 1530 | /** |
… |
… |
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, |
1519 | 1543 | * @param string $capability The capability required for this menu to be displayed to the user. |
1520 | 1544 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1521 | 1545 | * @param callable $function The function to be called to output the content for this page. |
| 1546 | * @param int $position The position in the menu order this one should appear. |
1522 | 1547 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1523 | 1548 | */ |
1524 | | function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1525 | | return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1549 | function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1550 | return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1526 | 1551 | } |
1527 | 1552 | |
1528 | 1553 | /** |
… |
… |
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1541 | 1566 | * @param string $capability The capability required for this menu to be displayed to the user. |
1542 | 1567 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1543 | 1568 | * @param callable $function The function to be called to output the content for this page. |
| 1569 | * @param int $position The position in the menu order this one should appear. |
1544 | 1570 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1545 | 1571 | */ |
1546 | | function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1547 | | return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1572 | function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1573 | return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1548 | 1574 | } |
1549 | 1575 | |
1550 | 1576 | /** |
… |
… |
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1563 | 1589 | * @param string $capability The capability required for this menu to be displayed to the user. |
1564 | 1590 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1565 | 1591 | * @param callable $function The function to be called to output the content for this page. |
| 1592 | * @param int $position The position in the menu order this one should appear. |
1566 | 1593 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1567 | 1594 | */ |
1568 | | function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1569 | | return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1595 | function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1596 | return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1570 | 1597 | } |
1571 | 1598 | |
1572 | 1599 | /** |
… |
… |
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1585 | 1612 | * @param string $capability The capability required for this menu to be displayed to the user. |
1586 | 1613 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1587 | 1614 | * @param callable $function The function to be called to output the content for this page. |
| 1615 | * @param int $position The position in the menu order this one should appear. |
1588 | 1616 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1589 | 1617 | */ |
1590 | | function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1591 | | return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1618 | function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1619 | return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position); |
1592 | 1620 | } |
1593 | 1621 | |
1594 | 1622 | /** |
… |
… |
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1607 | 1635 | * @param string $capability The capability required for this menu to be displayed to the user. |
1608 | 1636 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1609 | 1637 | * @param callable $function The function to be called to output the content for this page. |
| 1638 | * @param int $position The position in the menu order this one should appear. |
1610 | 1639 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1611 | 1640 | */ |
1612 | | function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1613 | | return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1641 | function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1642 | return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1614 | 1643 | } |
1615 | 1644 | |
1616 | 1645 | /** |