52 * @param bool $translate Optional. If the returned data should be translated. Default true. |
52 * @param bool $translate Optional. If the returned data should be translated. Default true. |
53 * @return array { |
53 * @return array { |
54 * Plugin data. Values will be empty if not supplied by the plugin. |
54 * Plugin data. Values will be empty if not supplied by the plugin. |
55 * |
55 * |
56 * @type string $Name Name of the plugin. Should be unique. |
56 * @type string $Name Name of the plugin. Should be unique. |
57 * @type string $Title Title of the plugin and link to the plugin's site (if set). |
57 * @type string $PluginURI Plugin URI. |
|
58 * @type string $Version Plugin version. |
58 * @type string $Description Plugin description. |
59 * @type string $Description Plugin description. |
59 * @type string $Author Author's name. |
60 * @type string $Author Plugin author's name. |
60 * @type string $AuthorURI Author's website address (if set). |
61 * @type string $AuthorURI Plugin author's website address (if set). |
61 * @type string $Version Plugin version. |
|
62 * @type string $TextDomain Plugin textdomain. |
62 * @type string $TextDomain Plugin textdomain. |
63 * @type string $DomainPath Plugins relative directory path to .mo files. |
63 * @type string $DomainPath Plugin's relative directory path to .mo files. |
64 * @type bool $Network Whether the plugin can only be activated network-wide. |
64 * @type bool $Network Whether the plugin can only be activated network-wide. |
65 * @type string $RequiresWP Minimum required version of WordPress. |
65 * @type string $RequiresWP Minimum required version of WordPress. |
66 * @type string $RequiresPHP Minimum required version of PHP. |
66 * @type string $RequiresPHP Minimum required version of PHP. |
67 * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. |
67 * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. |
|
68 * @type string $Title Title of the plugin and link to the plugin's site (if set). |
|
69 * @type string $AuthorName Plugin author's name. |
68 * } |
70 * } |
69 */ |
71 */ |
70 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { |
72 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { |
71 |
73 |
72 $default_headers = array( |
74 $default_headers = array( |
127 * @param string $plugin_file Path to the main plugin file. |
129 * @param string $plugin_file Path to the main plugin file. |
128 * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. |
130 * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. |
129 * @param bool $markup Optional. If the returned data should have HTML markup applied. |
131 * @param bool $markup Optional. If the returned data should have HTML markup applied. |
130 * Default true. |
132 * Default true. |
131 * @param bool $translate Optional. If the returned data should be translated. Default true. |
133 * @param bool $translate Optional. If the returned data should be translated. Default true. |
132 * @return array { |
134 * @return array Plugin data. Values will be empty if not supplied by the plugin. |
133 * Plugin data. Values will be empty if not supplied by the plugin. |
135 * See get_plugin_data() for the list of possible values. |
134 * |
|
135 * @type string $Name Name of the plugin. Should be unique. |
|
136 * @type string $Title Title of the plugin and link to the plugin's site (if set). |
|
137 * @type string $Description Plugin description. |
|
138 * @type string $Author Author's name. |
|
139 * @type string $AuthorURI Author's website address (if set). |
|
140 * @type string $Version Plugin version. |
|
141 * @type string $TextDomain Plugin textdomain. |
|
142 * @type string $DomainPath Plugins relative directory path to .mo files. |
|
143 * @type bool $Network Whether the plugin can only be activated network-wide. |
|
144 * } |
|
145 */ |
136 */ |
146 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { |
137 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { |
147 |
138 |
148 // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path. |
139 // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path. |
149 $plugin_file = plugin_basename( $plugin_file ); |
140 $plugin_file = plugin_basename( $plugin_file ); |
162 } elseif ( 'hello.php' === basename( $plugin_file ) ) { |
153 } elseif ( 'hello.php' === basename( $plugin_file ) ) { |
163 $textdomain = 'default'; |
154 $textdomain = 'default'; |
164 } |
155 } |
165 if ( $textdomain ) { |
156 if ( $textdomain ) { |
166 foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) { |
157 foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) { |
167 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain |
158 if ( ! empty( $plugin_data[ $field ] ) ) { |
168 $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
159 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain |
|
160 $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
|
161 } |
169 } |
162 } |
170 } |
163 } |
171 } |
164 } |
172 |
165 |
173 // Sanitize fields. |
166 // Sanitize fields. |
1291 * @global array $menu |
1284 * @global array $menu |
1292 * @global array $admin_page_hooks |
1285 * @global array $admin_page_hooks |
1293 * @global array $_registered_pages |
1286 * @global array $_registered_pages |
1294 * @global array $_parent_pages |
1287 * @global array $_parent_pages |
1295 * |
1288 * |
1296 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1289 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1297 * @param string $menu_title The text to be used for the menu. |
1290 * @param string $menu_title The text to be used for the menu. |
1298 * @param string $capability The capability required for this menu to be displayed to the user. |
1291 * @param string $capability The capability required for this menu to be displayed to the user. |
1299 * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only |
1292 * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only |
1300 * include lowercase alphanumeric, dashes, and underscores characters to be compatible |
1293 * include lowercase alphanumeric, dashes, and underscores characters to be compatible |
1301 * with sanitize_key(). |
1294 * with sanitize_key(). |
1302 * @param callable $function The function to be called to output the content for this page. |
1295 * @param callable $callback Optional. The function to be called to output the content for this page. |
1303 * @param string $icon_url The URL to the icon to be used for this menu. |
1296 * @param string $icon_url Optional. The URL to the icon to be used for this menu. |
1304 * * Pass a base64-encoded SVG using a data URI, which will be colored to match |
1297 * * Pass a base64-encoded SVG using a data URI, which will be colored to match |
1305 * the color scheme. This should begin with 'data:image/svg+xml;base64,'. |
1298 * the color scheme. This should begin with 'data:image/svg+xml;base64,'. |
1306 * * Pass the name of a Dashicons helper class to use a font icon, |
1299 * * Pass the name of a Dashicons helper class to use a font icon, |
1307 * e.g. 'dashicons-chart-pie'. |
1300 * e.g. 'dashicons-chart-pie'. |
1308 * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS. |
1301 * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS. |
1309 * @param int $position The position in the menu order this item should appear. |
1302 * @param int|float $position Optional. The position in the menu order this item should appear. |
1310 * @return string The resulting page's hook_suffix. |
1303 * @return string The resulting page's hook_suffix. |
1311 */ |
1304 */ |
1312 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { |
1305 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) { |
1313 global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; |
1306 global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; |
1314 |
1307 |
1315 $menu_slug = plugin_basename( $menu_slug ); |
1308 $menu_slug = plugin_basename( $menu_slug ); |
1316 |
1309 |
1317 $admin_page_hooks[ $menu_slug ] = sanitize_title( $menu_title ); |
1310 $admin_page_hooks[ $menu_slug ] = sanitize_title( $menu_title ); |
1318 |
1311 |
1319 $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
1312 $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
1320 |
1313 |
1321 if ( ! empty( $function ) && ! empty( $hookname ) && current_user_can( $capability ) ) { |
1314 if ( ! empty( $callback ) && ! empty( $hookname ) && current_user_can( $capability ) ) { |
1322 add_action( $hookname, $function ); |
1315 add_action( $hookname, $callback ); |
1323 } |
1316 } |
1324 |
1317 |
1325 if ( empty( $icon_url ) ) { |
1318 if ( empty( $icon_url ) ) { |
1326 $icon_url = 'dashicons-admin-generic'; |
1319 $icon_url = 'dashicons-admin-generic'; |
1327 $icon_class = 'menu-icon-generic '; |
1320 $icon_class = 'menu-icon-generic '; |
1330 $icon_class = ''; |
1323 $icon_class = ''; |
1331 } |
1324 } |
1332 |
1325 |
1333 $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
1326 $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
1334 |
1327 |
1335 if ( null === $position ) { |
1328 if ( null !== $position && ! is_numeric( $position ) ) { |
|
1329 _doing_it_wrong( |
|
1330 __FUNCTION__, |
|
1331 sprintf( |
|
1332 /* translators: %s: add_menu_page() */ |
|
1333 __( 'The seventh parameter passed to %s should be numeric representing menu position.' ), |
|
1334 '<code>add_menu_page()</code>' |
|
1335 ), |
|
1336 '6.0.0' |
|
1337 ); |
|
1338 $position = null; |
|
1339 } |
|
1340 |
|
1341 if ( null === $position || ! is_numeric( $position ) ) { |
1336 $menu[] = $new_menu; |
1342 $menu[] = $new_menu; |
1337 } elseif ( isset( $menu[ "$position" ] ) ) { |
1343 } elseif ( isset( $menu[ (string) $position ] ) ) { |
1338 $position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ), -5 ) * 0.00001; |
1344 $collision_avoider = base_convert( substr( md5( $menu_slug . $menu_title ), -4 ), 16, 10 ) * 0.00001; |
1339 $menu[ "$position" ] = $new_menu; |
1345 $position = (string) ( $position + $collision_avoider ); |
|
1346 $menu[ $position ] = $new_menu; |
1340 } else { |
1347 } else { |
|
1348 /* |
|
1349 * Cast menu position to a string. |
|
1350 * |
|
1351 * This allows for floats to be passed as the position. PHP will normally cast a float to an |
|
1352 * integer value, this ensures the float retains its mantissa (positive fractional part). |
|
1353 * |
|
1354 * A string containing an integer value, eg "10", is treated as a numeric index. |
|
1355 */ |
|
1356 $position = (string) $position; |
1341 $menu[ $position ] = $new_menu; |
1357 $menu[ $position ] = $new_menu; |
1342 } |
1358 } |
1343 |
1359 |
1344 $_registered_pages[ $hookname ] = true; |
1360 $_registered_pages[ $hookname ] = true; |
1345 |
1361 |
1366 * @global array $_wp_real_parent_file |
1382 * @global array $_wp_real_parent_file |
1367 * @global bool $_wp_submenu_nopriv |
1383 * @global bool $_wp_submenu_nopriv |
1368 * @global array $_registered_pages |
1384 * @global array $_registered_pages |
1369 * @global array $_parent_pages |
1385 * @global array $_parent_pages |
1370 * |
1386 * |
1371 * @param string $parent_slug The slug name for the parent menu (or the file name of a standard |
1387 * @param string $parent_slug The slug name for the parent menu (or the file name of a standard |
1372 * WordPress admin page). |
1388 * WordPress admin page). |
1373 * @param string $page_title The text to be displayed in the title tags of the page when the menu |
1389 * @param string $page_title The text to be displayed in the title tags of the page when the menu |
1374 * is selected. |
1390 * is selected. |
1375 * @param string $menu_title The text to be used for the menu. |
1391 * @param string $menu_title The text to be used for the menu. |
1376 * @param string $capability The capability required for this menu to be displayed to the user. |
1392 * @param string $capability The capability required for this menu to be displayed to the user. |
1377 * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu |
1393 * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu |
1378 * and only include lowercase alphanumeric, dashes, and underscores characters |
1394 * and only include lowercase alphanumeric, dashes, and underscores characters |
1379 * to be compatible with sanitize_key(). |
1395 * to be compatible with sanitize_key(). |
1380 * @param callable $function The function to be called to output the content for this page. |
1396 * @param callable $callback Optional. The function to be called to output the content for this page. |
1381 * @param int $position The position in the menu order this item should appear. |
1397 * @param int|float $position Optional. The position in the menu order this item should appear. |
1382 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1398 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1383 */ |
1399 */ |
1384 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1400 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1385 global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
1401 global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
1386 $_registered_pages, $_parent_pages; |
1402 $_registered_pages, $_parent_pages; |
1387 |
1403 |
1388 $menu_slug = plugin_basename( $menu_slug ); |
1404 $menu_slug = plugin_basename( $menu_slug ); |
1389 $parent_slug = plugin_basename( $parent_slug ); |
1405 $parent_slug = plugin_basename( $parent_slug ); |
1410 } |
1426 } |
1411 } |
1427 } |
1412 } |
1428 } |
1413 |
1429 |
1414 $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); |
1430 $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); |
1415 if ( ! is_int( $position ) ) { |
1431 |
1416 if ( null !== $position ) { |
1432 if ( null !== $position && ! is_numeric( $position ) ) { |
1417 _doing_it_wrong( |
1433 _doing_it_wrong( |
1418 __FUNCTION__, |
1434 __FUNCTION__, |
1419 sprintf( |
1435 sprintf( |
1420 /* translators: %s: add_submenu_page() */ |
1436 /* translators: %s: add_submenu_page() */ |
1421 __( 'The seventh parameter passed to %s should be an integer representing menu position.' ), |
1437 __( 'The seventh parameter passed to %s should be numeric representing menu position.' ), |
1422 '<code>add_submenu_page()</code>' |
1438 '<code>add_submenu_page()</code>' |
1423 ), |
1439 ), |
1424 '5.3.0' |
1440 '5.3.0' |
1425 ); |
1441 ); |
1426 } |
1442 $position = null; |
1427 |
1443 } |
|
1444 |
|
1445 if ( |
|
1446 null === $position || |
|
1447 ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) ) |
|
1448 ) { |
1428 $submenu[ $parent_slug ][] = $new_sub_menu; |
1449 $submenu[ $parent_slug ][] = $new_sub_menu; |
1429 } else { |
1450 } else { |
1430 // Append the submenu if the parent item is not present in the submenu, |
1451 // Test for a negative position. |
1431 // or if position is equal or higher than the number of items in the array. |
1452 $position = max( $position, 0 ); |
1432 if ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) ) { |
1453 if ( 0 === $position ) { |
1433 $submenu[ $parent_slug ][] = $new_sub_menu; |
1454 // For negative or `0` positions, prepend the submenu. |
|
1455 array_unshift( $submenu[ $parent_slug ], $new_sub_menu ); |
1434 } else { |
1456 } else { |
1435 // Test for a negative position. |
1457 // Grab all of the items before the insertion point. |
1436 $position = max( $position, 0 ); |
1458 $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true ); |
1437 if ( 0 === $position ) { |
1459 // Grab all of the items after the insertion point. |
1438 // For negative or `0` positions, prepend the submenu. |
1460 $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true ); |
1439 array_unshift( $submenu[ $parent_slug ], $new_sub_menu ); |
1461 // Add the new item. |
1440 } else { |
1462 $before_items[] = $new_sub_menu; |
1441 // Grab all of the items before the insertion point. |
1463 // Merge the items. |
1442 $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true ); |
1464 $submenu[ $parent_slug ] = array_merge( $before_items, $after_items ); |
1443 // Grab all of the items after the insertion point. |
1465 } |
1444 $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true ); |
1466 } |
1445 // Add the new item. |
1467 |
1446 $before_items[] = $new_sub_menu; |
|
1447 // Merge the items. |
|
1448 $submenu[ $parent_slug ] = array_merge( $before_items, $after_items ); |
|
1449 } |
|
1450 } |
|
1451 } |
|
1452 // Sort the parent array. |
1468 // Sort the parent array. |
1453 ksort( $submenu[ $parent_slug ] ); |
1469 ksort( $submenu[ $parent_slug ] ); |
1454 |
1470 |
1455 $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); |
1471 $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug ); |
1456 if ( ! empty( $function ) && ! empty( $hookname ) ) { |
1472 if ( ! empty( $callback ) && ! empty( $hookname ) ) { |
1457 add_action( $hookname, $function ); |
1473 add_action( $hookname, $callback ); |
1458 } |
1474 } |
1459 |
1475 |
1460 $_registered_pages[ $hookname ] = true; |
1476 $_registered_pages[ $hookname ] = true; |
1461 |
1477 |
1462 /* |
1478 /* |
1487 * |
1503 * |
1488 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1504 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1489 * @param string $menu_title The text to be used for the menu. |
1505 * @param string $menu_title The text to be used for the menu. |
1490 * @param string $capability The capability required for this menu to be displayed to the user. |
1506 * @param string $capability The capability required for this menu to be displayed to the user. |
1491 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1507 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1492 * @param callable $function The function to be called to output the content for this page. |
1508 * @param callable $callback Optional. The function to be called to output the content for this page. |
1493 * @param int $position The position in the menu order this item should appear. |
1509 * @param int $position Optional. The position in the menu order this item should appear. |
1494 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1510 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1495 */ |
1511 */ |
1496 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1512 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1497 return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1513 return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1498 } |
1514 } |
1499 |
1515 |
1500 /** |
1516 /** |
1501 * Add submenu page to the Settings main menu. |
1517 * Adds a submenu page to the Settings main menu. |
1502 * |
1518 * |
1503 * This function takes a capability which will be used to determine whether |
1519 * This function takes a capability which will be used to determine whether |
1504 * or not a page is included in the menu. |
1520 * or not a page is included in the menu. |
1505 * |
1521 * |
1506 * The function which is hooked in to handle the output of the page must check |
1522 * The function which is hooked in to handle the output of the page must check |
1511 * |
1527 * |
1512 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1528 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1513 * @param string $menu_title The text to be used for the menu. |
1529 * @param string $menu_title The text to be used for the menu. |
1514 * @param string $capability The capability required for this menu to be displayed to the user. |
1530 * @param string $capability The capability required for this menu to be displayed to the user. |
1515 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1531 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1516 * @param callable $function The function to be called to output the content for this page. |
1532 * @param callable $callback Optional. The function to be called to output the content for this page. |
1517 * @param int $position The position in the menu order this item should appear. |
1533 * @param int $position Optional. The position in the menu order this item should appear. |
1518 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1534 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1519 */ |
1535 */ |
1520 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1536 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1521 return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1537 return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1522 } |
1538 } |
1523 |
1539 |
1524 /** |
1540 /** |
1525 * Add submenu page to the Appearance main menu. |
1541 * Adds a submenu page to the Appearance main menu. |
1526 * |
1542 * |
1527 * This function takes a capability which will be used to determine whether |
1543 * This function takes a capability which will be used to determine whether |
1528 * or not a page is included in the menu. |
1544 * or not a page is included in the menu. |
1529 * |
1545 * |
1530 * The function which is hooked in to handle the output of the page must check |
1546 * The function which is hooked in to handle the output of the page must check |
1535 * |
1551 * |
1536 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1552 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1537 * @param string $menu_title The text to be used for the menu. |
1553 * @param string $menu_title The text to be used for the menu. |
1538 * @param string $capability The capability required for this menu to be displayed to the user. |
1554 * @param string $capability The capability required for this menu to be displayed to the user. |
1539 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1555 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1540 * @param callable $function The function to be called to output the content for this page. |
1556 * @param callable $callback Optional. The function to be called to output the content for this page. |
1541 * @param int $position The position in the menu order this item should appear. |
1557 * @param int $position Optional. The position in the menu order this item should appear. |
1542 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1558 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1543 */ |
1559 */ |
1544 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1560 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1545 return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1561 return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1546 } |
1562 } |
1547 |
1563 |
1548 /** |
1564 /** |
1549 * Add submenu page to the Plugins main menu. |
1565 * Adds a submenu page to the Plugins main menu. |
1550 * |
1566 * |
1551 * This function takes a capability which will be used to determine whether |
1567 * This function takes a capability which will be used to determine whether |
1552 * or not a page is included in the menu. |
1568 * or not a page is included in the menu. |
1553 * |
1569 * |
1554 * The function which is hooked in to handle the output of the page must check |
1570 * The function which is hooked in to handle the output of the page must check |
1559 * |
1575 * |
1560 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1576 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1561 * @param string $menu_title The text to be used for the menu. |
1577 * @param string $menu_title The text to be used for the menu. |
1562 * @param string $capability The capability required for this menu to be displayed to the user. |
1578 * @param string $capability The capability required for this menu to be displayed to the user. |
1563 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1579 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1564 * @param callable $function The function to be called to output the content for this page. |
1580 * @param callable $callback Optional. The function to be called to output the content for this page. |
1565 * @param int $position The position in the menu order this item should appear. |
1581 * @param int $position Optional. The position in the menu order this item should appear. |
1566 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1582 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1567 */ |
1583 */ |
1568 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1584 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1569 return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1585 return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1570 } |
1586 } |
1571 |
1587 |
1572 /** |
1588 /** |
1573 * Add submenu page to the Users/Profile main menu. |
1589 * Adds a submenu page to the Users/Profile main menu. |
1574 * |
1590 * |
1575 * This function takes a capability which will be used to determine whether |
1591 * This function takes a capability which will be used to determine whether |
1576 * or not a page is included in the menu. |
1592 * or not a page is included in the menu. |
1577 * |
1593 * |
1578 * The function which is hooked in to handle the output of the page must check |
1594 * The function which is hooked in to handle the output of the page must check |
1583 * |
1599 * |
1584 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1600 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1585 * @param string $menu_title The text to be used for the menu. |
1601 * @param string $menu_title The text to be used for the menu. |
1586 * @param string $capability The capability required for this menu to be displayed to the user. |
1602 * @param string $capability The capability required for this menu to be displayed to the user. |
1587 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1603 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1588 * @param callable $function The function to be called to output the content for this page. |
1604 * @param callable $callback Optional. The function to be called to output the content for this page. |
1589 * @param int $position The position in the menu order this item should appear. |
1605 * @param int $position Optional. The position in the menu order this item should appear. |
1590 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1606 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1591 */ |
1607 */ |
1592 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1608 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1593 if ( current_user_can( 'edit_users' ) ) { |
1609 if ( current_user_can( 'edit_users' ) ) { |
1594 $parent = 'users.php'; |
1610 $parent = 'users.php'; |
1595 } else { |
1611 } else { |
1596 $parent = 'profile.php'; |
1612 $parent = 'profile.php'; |
1597 } |
1613 } |
1598 return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1614 return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1599 } |
1615 } |
1600 |
1616 |
1601 /** |
1617 /** |
1602 * Add submenu page to the Dashboard main menu. |
1618 * Adds a submenu page to the Dashboard main menu. |
1603 * |
1619 * |
1604 * This function takes a capability which will be used to determine whether |
1620 * This function takes a capability which will be used to determine whether |
1605 * or not a page is included in the menu. |
1621 * or not a page is included in the menu. |
1606 * |
1622 * |
1607 * The function which is hooked in to handle the output of the page must check |
1623 * The function which is hooked in to handle the output of the page must check |
1612 * |
1628 * |
1613 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1629 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1614 * @param string $menu_title The text to be used for the menu. |
1630 * @param string $menu_title The text to be used for the menu. |
1615 * @param string $capability The capability required for this menu to be displayed to the user. |
1631 * @param string $capability The capability required for this menu to be displayed to the user. |
1616 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1632 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1617 * @param callable $function The function to be called to output the content for this page. |
1633 * @param callable $callback Optional. The function to be called to output the content for this page. |
1618 * @param int $position The position in the menu order this item should appear. |
1634 * @param int $position Optional. The position in the menu order this item should appear. |
1619 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1635 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1620 */ |
1636 */ |
1621 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1637 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1622 return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1638 return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1623 } |
1639 } |
1624 |
1640 |
1625 /** |
1641 /** |
1626 * Add submenu page to the Posts main menu. |
1642 * Adds a submenu page to the Posts main menu. |
1627 * |
1643 * |
1628 * This function takes a capability which will be used to determine whether |
1644 * This function takes a capability which will be used to determine whether |
1629 * or not a page is included in the menu. |
1645 * or not a page is included in the menu. |
1630 * |
1646 * |
1631 * The function which is hooked in to handle the output of the page must check |
1647 * The function which is hooked in to handle the output of the page must check |
1636 * |
1652 * |
1637 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1653 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1638 * @param string $menu_title The text to be used for the menu. |
1654 * @param string $menu_title The text to be used for the menu. |
1639 * @param string $capability The capability required for this menu to be displayed to the user. |
1655 * @param string $capability The capability required for this menu to be displayed to the user. |
1640 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1656 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1641 * @param callable $function The function to be called to output the content for this page. |
1657 * @param callable $callback Optional. The function to be called to output the content for this page. |
1642 * @param int $position The position in the menu order this item should appear. |
1658 * @param int $position Optional. The position in the menu order this item should appear. |
1643 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1659 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1644 */ |
1660 */ |
1645 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1661 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1646 return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1662 return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1647 } |
1663 } |
1648 |
1664 |
1649 /** |
1665 /** |
1650 * Add submenu page to the Media main menu. |
1666 * Adds a submenu page to the Media main menu. |
1651 * |
1667 * |
1652 * This function takes a capability which will be used to determine whether |
1668 * This function takes a capability which will be used to determine whether |
1653 * or not a page is included in the menu. |
1669 * or not a page is included in the menu. |
1654 * |
1670 * |
1655 * The function which is hooked in to handle the output of the page must check |
1671 * The function which is hooked in to handle the output of the page must check |
1660 * |
1676 * |
1661 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1677 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1662 * @param string $menu_title The text to be used for the menu. |
1678 * @param string $menu_title The text to be used for the menu. |
1663 * @param string $capability The capability required for this menu to be displayed to the user. |
1679 * @param string $capability The capability required for this menu to be displayed to the user. |
1664 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1680 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1665 * @param callable $function The function to be called to output the content for this page. |
1681 * @param callable $callback Optional. The function to be called to output the content for this page. |
1666 * @param int $position The position in the menu order this item should appear. |
1682 * @param int $position Optional. The position in the menu order this item should appear. |
1667 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1683 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1668 */ |
1684 */ |
1669 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1685 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1670 return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1686 return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1671 } |
1687 } |
1672 |
1688 |
1673 /** |
1689 /** |
1674 * Add submenu page to the Links main menu. |
1690 * Adds a submenu page to the Links main menu. |
1675 * |
1691 * |
1676 * This function takes a capability which will be used to determine whether |
1692 * This function takes a capability which will be used to determine whether |
1677 * or not a page is included in the menu. |
1693 * or not a page is included in the menu. |
1678 * |
1694 * |
1679 * The function which is hooked in to handle the output of the page must check |
1695 * The function which is hooked in to handle the output of the page must check |
1684 * |
1700 * |
1685 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1701 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1686 * @param string $menu_title The text to be used for the menu. |
1702 * @param string $menu_title The text to be used for the menu. |
1687 * @param string $capability The capability required for this menu to be displayed to the user. |
1703 * @param string $capability The capability required for this menu to be displayed to the user. |
1688 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1704 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1689 * @param callable $function The function to be called to output the content for this page. |
1705 * @param callable $callback Optional. The function to be called to output the content for this page. |
1690 * @param int $position The position in the menu order this item should appear. |
1706 * @param int $position Optional. The position in the menu order this item should appear. |
1691 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1707 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1692 */ |
1708 */ |
1693 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1709 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1694 return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1710 return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1695 } |
1711 } |
1696 |
1712 |
1697 /** |
1713 /** |
1698 * Add submenu page to the Pages main menu. |
1714 * Adds a submenu page to the Pages main menu. |
1699 * |
1715 * |
1700 * This function takes a capability which will be used to determine whether |
1716 * This function takes a capability which will be used to determine whether |
1701 * or not a page is included in the menu. |
1717 * or not a page is included in the menu. |
1702 * |
1718 * |
1703 * The function which is hooked in to handle the output of the page must check |
1719 * The function which is hooked in to handle the output of the page must check |
1708 * |
1724 * |
1709 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1725 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1710 * @param string $menu_title The text to be used for the menu. |
1726 * @param string $menu_title The text to be used for the menu. |
1711 * @param string $capability The capability required for this menu to be displayed to the user. |
1727 * @param string $capability The capability required for this menu to be displayed to the user. |
1712 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1728 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1713 * @param callable $function The function to be called to output the content for this page. |
1729 * @param callable $callback Optional. The function to be called to output the content for this page. |
1714 * @param int $position The position in the menu order this item should appear. |
1730 * @param int $position Optional. The position in the menu order this item should appear. |
1715 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1731 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1716 */ |
1732 */ |
1717 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1733 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1718 return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1734 return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1719 } |
1735 } |
1720 |
1736 |
1721 /** |
1737 /** |
1722 * Add submenu page to the Comments main menu. |
1738 * Adds a submenu page to the Comments main menu. |
1723 * |
1739 * |
1724 * This function takes a capability which will be used to determine whether |
1740 * This function takes a capability which will be used to determine whether |
1725 * or not a page is included in the menu. |
1741 * or not a page is included in the menu. |
1726 * |
1742 * |
1727 * The function which is hooked in to handle the output of the page must check |
1743 * The function which is hooked in to handle the output of the page must check |
1732 * |
1748 * |
1733 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1749 * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. |
1734 * @param string $menu_title The text to be used for the menu. |
1750 * @param string $menu_title The text to be used for the menu. |
1735 * @param string $capability The capability required for this menu to be displayed to the user. |
1751 * @param string $capability The capability required for this menu to be displayed to the user. |
1736 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1752 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1737 * @param callable $function The function to be called to output the content for this page. |
1753 * @param callable $callback Optional. The function to be called to output the content for this page. |
1738 * @param int $position The position in the menu order this item should appear. |
1754 * @param int $position Optional. The position in the menu order this item should appear. |
1739 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1755 * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required. |
1740 */ |
1756 */ |
1741 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) { |
1757 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) { |
1742 return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position ); |
1758 return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position ); |
1743 } |
1759 } |
1744 |
1760 |
1745 /** |
1761 /** |
1746 * Remove a top-level admin menu. |
1762 * Removes a top-level admin menu. |
|
1763 * |
|
1764 * Example usage: |
|
1765 * |
|
1766 * - `remove_menu_page( 'tools.php' )` |
|
1767 * - `remove_menu_page( 'plugin_menu_slug' )` |
1747 * |
1768 * |
1748 * @since 3.1.0 |
1769 * @since 3.1.0 |
1749 * |
1770 * |
1750 * @global array $menu |
1771 * @global array $menu |
1751 * |
1772 * |
1792 |
1819 |
1793 return false; |
1820 return false; |
1794 } |
1821 } |
1795 |
1822 |
1796 /** |
1823 /** |
1797 * Get the URL to access a particular menu page based on the slug it was registered with. |
1824 * Gets the URL to access a particular menu page based on the slug it was registered with. |
1798 * |
1825 * |
1799 * If the slug hasn't been registered properly, no URL will be returned. |
1826 * If the slug hasn't been registered properly, no URL will be returned. |
1800 * |
1827 * |
1801 * @since 3.0.0 |
1828 * @since 3.0.0 |
1802 * |
1829 * |
1803 * @global array $_parent_pages |
1830 * @global array $_parent_pages |
1804 * |
1831 * |
1805 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1832 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). |
1806 * @param bool $echo Whether or not to echo the URL. Default true. |
1833 * @param bool $display Optional. Whether or not to display the URL. Default true. |
1807 * @return string The menu page URL. |
1834 * @return string The menu page URL. |
1808 */ |
1835 */ |
1809 function menu_page_url( $menu_slug, $echo = true ) { |
1836 function menu_page_url( $menu_slug, $display = true ) { |
1810 global $_parent_pages; |
1837 global $_parent_pages; |
1811 |
1838 |
1812 if ( isset( $_parent_pages[ $menu_slug ] ) ) { |
1839 if ( isset( $_parent_pages[ $menu_slug ] ) ) { |
1813 $parent_slug = $_parent_pages[ $menu_slug ]; |
1840 $parent_slug = $_parent_pages[ $menu_slug ]; |
1814 |
1841 |
1839 * @since 1.5.0 |
1866 * @since 1.5.0 |
1840 * |
1867 * |
1841 * @global string $parent_file |
1868 * @global string $parent_file |
1842 * @global array $menu |
1869 * @global array $menu |
1843 * @global array $submenu |
1870 * @global array $submenu |
1844 * @global string $pagenow |
1871 * @global string $pagenow The filename of the current screen. |
1845 * @global string $typenow |
1872 * @global string $typenow The post type of the current screen. |
1846 * @global string $plugin_page |
1873 * @global string $plugin_page |
1847 * @global array $_wp_real_parent_file |
1874 * @global array $_wp_real_parent_file |
1848 * @global array $_wp_menu_nopriv |
1875 * @global array $_wp_menu_nopriv |
1849 * @global array $_wp_submenu_nopriv |
1876 * @global array $_wp_submenu_nopriv |
1850 * |
1877 * |
1851 * @param string $parent The slug name for the parent menu (or the file name of a standard |
1878 * @param string $parent_page Optional. The slug name for the parent menu (or the file name |
1852 * WordPress admin page). Default empty string. |
1879 * of a standard WordPress admin page). Default empty string. |
1853 * @return string The parent file of the current admin page. |
1880 * @return string The parent file of the current admin page. |
1854 */ |
1881 */ |
1855 function get_admin_page_parent( $parent = '' ) { |
1882 function get_admin_page_parent( $parent_page = '' ) { |
1856 global $parent_file, $menu, $submenu, $pagenow, $typenow, |
1883 global $parent_file, $menu, $submenu, $pagenow, $typenow, |
1857 $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; |
1884 $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; |
1858 |
1885 |
1859 if ( ! empty( $parent ) && 'admin.php' !== $parent ) { |
1886 if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) { |
1860 if ( isset( $_wp_real_parent_file[ $parent ] ) ) { |
1887 if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) { |
1861 $parent = $_wp_real_parent_file[ $parent ]; |
1888 $parent_page = $_wp_real_parent_file[ $parent_page ]; |
1862 } |
1889 } |
1863 |
1890 |
1864 return $parent; |
1891 return $parent_page; |
1865 } |
1892 } |
1866 |
1893 |
1867 if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) { |
1894 if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) { |
1868 foreach ( (array) $menu as $parent_menu ) { |
1895 foreach ( (array) $menu as $parent_menu ) { |
1869 if ( $parent_menu[2] === $plugin_page ) { |
1896 if ( $parent_menu[2] === $plugin_page ) { |
1895 } |
1922 } |
1896 |
1923 |
1897 return $parent_file; |
1924 return $parent_file; |
1898 } |
1925 } |
1899 |
1926 |
1900 foreach ( array_keys( (array) $submenu ) as $parent ) { |
1927 foreach ( array_keys( (array) $submenu ) as $parent_page ) { |
1901 foreach ( $submenu[ $parent ] as $submenu_array ) { |
1928 foreach ( $submenu[ $parent_page ] as $submenu_array ) { |
1902 if ( isset( $_wp_real_parent_file[ $parent ] ) ) { |
1929 if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) { |
1903 $parent = $_wp_real_parent_file[ $parent ]; |
1930 $parent_page = $_wp_real_parent_file[ $parent_page ]; |
1904 } |
1931 } |
1905 |
1932 |
1906 if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) { |
1933 if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) { |
1907 $parent_file = $parent; |
1934 $parent_file = $parent_page; |
1908 return $parent; |
1935 return $parent_page; |
1909 } elseif ( empty( $typenow ) && $pagenow === $submenu_array[2] |
1936 } elseif ( empty( $typenow ) && $pagenow === $submenu_array[2] |
1910 && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) ) |
1937 && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) ) |
1911 ) { |
1938 ) { |
1912 $parent_file = $parent; |
1939 $parent_file = $parent_page; |
1913 return $parent; |
1940 return $parent_page; |
1914 } elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) { |
1941 } elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) { |
1915 $parent_file = $parent; |
1942 $parent_file = $parent_page; |
1916 return $parent; |
1943 return $parent_page; |
1917 } |
1944 } |
1918 } |
1945 } |
1919 } |
1946 } |
1920 |
1947 |
1921 if ( empty( $parent_file ) ) { |
1948 if ( empty( $parent_file ) ) { |
1928 * Gets the title of the current admin page. |
1955 * Gets the title of the current admin page. |
1929 * |
1956 * |
1930 * @since 1.5.0 |
1957 * @since 1.5.0 |
1931 * |
1958 * |
1932 * @global string $title |
1959 * @global string $title |
1933 * @global array $menu |
1960 * @global array $menu |
1934 * @global array $submenu |
1961 * @global array $submenu |
1935 * @global string $pagenow |
1962 * @global string $pagenow The filename of the current screen. |
|
1963 * @global string $typenow The post type of the current screen. |
1936 * @global string $plugin_page |
1964 * @global string $plugin_page |
1937 * @global string $typenow |
|
1938 * |
1965 * |
1939 * @return string The title of the current admin page. |
1966 * @return string The title of the current admin page. |
1940 */ |
1967 */ |
1941 function get_admin_page_title() { |
1968 function get_admin_page_title() { |
1942 global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow; |
1969 global $title, $menu, $submenu, $pagenow, $typenow, $plugin_page; |
1943 |
1970 |
1944 if ( ! empty( $title ) ) { |
1971 if ( ! empty( $title ) ) { |
1945 return $title; |
1972 return $title; |
1946 } |
1973 } |
1947 |
1974 |
2519 $deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins ); |
2546 $deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins ); |
2520 |
2547 |
2521 foreach ( $deactivated_plugins as $plugin ) { |
2548 foreach ( $deactivated_plugins as $plugin ) { |
2522 if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) { |
2549 if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) { |
2523 $explanation = sprintf( |
2550 $explanation = sprintf( |
2524 /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version, 4: Compatible plugin version */ |
2551 /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version, 4: Compatible plugin version. */ |
2525 __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ), |
2552 __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ), |
2526 $plugin['plugin_name'], |
2553 $plugin['plugin_name'], |
2527 $plugin['version_deactivated'], |
2554 $plugin['version_deactivated'], |
2528 $GLOBALS['wp_version'], |
2555 $GLOBALS['wp_version'], |
2529 $plugin['version_compatible'] |
2556 $plugin['version_compatible'] |
2530 ); |
2557 ); |
2531 } else { |
2558 } else { |
2532 $explanation = sprintf( |
2559 $explanation = sprintf( |
2533 /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version */ |
2560 /* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version. */ |
2534 __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ), |
2561 __( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ), |
2535 $plugin['plugin_name'], |
2562 $plugin['plugin_name'], |
2536 ! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '', |
2563 ! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '', |
2537 $GLOBALS['wp_version'], |
2564 $GLOBALS['wp_version'], |
2538 $plugin['version_compatible'] |
2565 $plugin['version_compatible'] |