diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
index c898fc5169..e5e9d07d65 100644
|
|
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func |
1208 | 1208 | * and only include lowercase alphanumeric, dashes, and underscores characters |
1209 | 1209 | * to be compatible with sanitize_key(). |
1210 | 1210 | * @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. |
| 1212 | * |
1211 | 1213 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1212 | 1214 | */ |
1213 | | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 1215 | function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1214 | 1216 | global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
1215 | 1217 | $_registered_pages, $_parent_pages; |
1216 | 1218 | |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1240 | 1242 | } |
1241 | 1243 | } |
1242 | 1244 | |
1243 | | $submenu[ $parent_slug ][] = array( $menu_title, $capability, $menu_slug, $page_title ); |
| 1245 | $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); |
| 1246 | if ( null === $position ) { |
| 1247 | $submenu[ $parent_slug ][] = $new_sub_menu; |
| 1248 | } else { |
| 1249 | //Set the position to a multiple of 5 |
| 1250 | $position = ( $position > 1 ) ? $position * 5 : $position; |
| 1251 | if ( isset( $submenu[ $parent_slug ][ $position ] ) ) { |
| 1252 | $existing_keys = array_keys( $submenu[ $parent_slug ] ); |
| 1253 | while ( in_array( $position, $existing_keys, true ) ) { |
| 1254 | $position += 0.1; |
| 1255 | } |
| 1256 | } |
| 1257 | $submenu[ $parent_slug ][ $position ] = $new_sub_menu; |
| 1258 | } |
| 1259 | // Sort the parent array |
| 1260 | ksort( $submenu[ $parent_slug ] ); |
1244 | 1261 | |
1245 | 1262 | $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); |
1246 | 1263 | if ( ! empty( $function ) && ! empty( $hookname ) ) { |
… |
… |
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, |
1279 | 1296 | * @param string $capability The capability required for this menu to be displayed to the user. |
1280 | 1297 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1281 | 1298 | * @param callable $function The function to be called to output the content for this page. |
| 1299 | * @param int $position The position in the menu order this one should appear. |
1282 | 1300 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1283 | 1301 | */ |
1284 | | function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1285 | | return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1302 | function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1303 | return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1286 | 1304 | } |
1287 | 1305 | |
1288 | 1306 | /** |
… |
… |
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, |
1301 | 1319 | * @param string $capability The capability required for this menu to be displayed to the user. |
1302 | 1320 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1303 | 1321 | * @param callable $function The function to be called to output the content for this page. |
| 1322 | * @param int $position The position in the menu order this one should appear. |
1304 | 1323 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1305 | 1324 | */ |
1306 | | function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1307 | | return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1325 | function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1326 | return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1308 | 1327 | } |
1309 | 1328 | |
1310 | 1329 | /** |
… |
… |
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1323 | 1342 | * @param string $capability The capability required for this menu to be displayed to the user. |
1324 | 1343 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1325 | 1344 | * @param callable $function The function to be called to output the content for this page. |
| 1345 | * @param int $position The position in the menu order this one should appear. |
1326 | 1346 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1327 | 1347 | */ |
1328 | | function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1329 | | return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1348 | function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1349 | return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1330 | 1350 | } |
1331 | 1351 | |
1332 | 1352 | /** |
… |
… |
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1345 | 1365 | * @param string $capability The capability required for this menu to be displayed to the user. |
1346 | 1366 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1347 | 1367 | * @param callable $function The function to be called to output the content for this page. |
| 1368 | * @param int $position The position in the menu order this one should appear. |
1348 | 1369 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1349 | 1370 | */ |
1350 | | function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1351 | | return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1371 | function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1372 | return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1352 | 1373 | } |
1353 | 1374 | |
1354 | 1375 | /** |
… |
… |
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f |
1367 | 1388 | * @param string $capability The capability required for this menu to be displayed to the user. |
1368 | 1389 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1369 | 1390 | * @param callable $function The function to be called to output the content for this page. |
| 1391 | * @param int $position The position in the menu order this one should appear. |
1370 | 1392 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1371 | 1393 | */ |
1372 | | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1373 | | if ( current_user_can( 'edit_users' ) ) { |
| 1394 | |
| 1395 | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1396 | if ( current_user_can('edit_users') ) { |
1374 | 1397 | $parent = 'users.php'; |
1375 | 1398 | } else { |
1376 | 1399 | $parent = 'profile.php'; |
1377 | 1400 | } |
1378 | | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1401 | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1379 | 1402 | } |
1380 | 1403 | /** |
1381 | 1404 | * Add submenu page to the Dashboard main menu. |
… |
… |
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1393 | 1416 | * @param string $capability The capability required for this menu to be displayed to the user. |
1394 | 1417 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1395 | 1418 | * @param callable $function The function to be called to output the content for this page. |
| 1419 | * @param int $position The position in the menu order this one should appear. |
1396 | 1420 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1397 | 1421 | */ |
1398 | | function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1399 | | return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1422 | function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1423 | return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1400 | 1424 | } |
1401 | 1425 | |
1402 | 1426 | /** |
… |
… |
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, |
1415 | 1439 | * @param string $capability The capability required for this menu to be displayed to the user. |
1416 | 1440 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1417 | 1441 | * @param callable $function The function to be called to output the content for this page. |
| 1442 | * @param int $position The position in the menu order this one should appear. |
1418 | 1443 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1419 | 1444 | */ |
1420 | | function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1421 | | return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1445 | function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1446 | return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1422 | 1447 | } |
1423 | 1448 | |
1424 | 1449 | /** |
… |
… |
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1437 | 1462 | * @param string $capability The capability required for this menu to be displayed to the user. |
1438 | 1463 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1439 | 1464 | * @param callable $function The function to be called to output the content for this page. |
| 1465 | * @param int $position The position in the menu order this one should appear. |
1440 | 1466 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1441 | 1467 | */ |
1442 | | function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1443 | | return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1468 | function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1469 | return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1444 | 1470 | } |
1445 | 1471 | |
1446 | 1472 | /** |
… |
… |
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1459 | 1485 | * @param string $capability The capability required for this menu to be displayed to the user. |
1460 | 1486 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1461 | 1487 | * @param callable $function The function to be called to output the content for this page. |
| 1488 | * @param int $position The position in the menu order this one should appear. |
1462 | 1489 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1463 | 1490 | */ |
1464 | | function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1465 | | return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1491 | function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1492 | return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1466 | 1493 | } |
1467 | 1494 | |
1468 | 1495 | /** |
… |
… |
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1481 | 1508 | * @param string $capability The capability required for this menu to be displayed to the user. |
1482 | 1509 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1483 | 1510 | * @param callable $function The function to be called to output the content for this page. |
| 1511 | * @param int $position The position in the menu order this one should appear. |
1484 | 1512 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1485 | 1513 | */ |
1486 | | function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1487 | | return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1514 | function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1515 | return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position); |
1488 | 1516 | } |
1489 | 1517 | |
1490 | 1518 | /** |
… |
… |
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun |
1503 | 1531 | * @param string $capability The capability required for this menu to be displayed to the user. |
1504 | 1532 | * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1505 | 1533 | * @param callable $function The function to be called to output the content for this page. |
| 1534 | * @param int $position The position in the menu order this one should appear. |
1506 | 1535 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
1507 | 1536 | */ |
1508 | | function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
1509 | | return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1537 | function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
| 1538 | return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1510 | 1539 | } |
1511 | 1540 | |
1512 | 1541 | /** |