diff --git src/wp-admin/includes/menu.php src/wp-admin/includes/menu.php
index 1c6f545f48..cafd99d780 100644
|
|
if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) |
330 | 330 | unset( $menu[ $last_menu_key ] ); |
331 | 331 | unset( $last_menu_key ); |
332 | 332 | |
333 | | if ( !user_can_access_admin_page() ) { |
| 333 | if ( ! admin_page_exists() ) { |
| 334 | |
| 335 | /** |
| 336 | * Fires when access to an admin page does not exist. |
| 337 | * |
| 338 | * @since 4.9.0 |
| 339 | */ |
| 340 | do_action( 'admin_page_not_found' ); |
| 341 | |
| 342 | wp_die( __( 'The requested page does not exist.' ), 403 ); |
| 343 | } elseif ( ! user_can_access_admin_page() ) { |
334 | 344 | |
335 | 345 | /** |
336 | 346 | * Fires when access to an admin page is denied. |
diff --git src/wp-admin/includes/plugin.php src/wp-admin/includes/plugin.php
index 0bc928d742..3566d29e41 100644
|
|
function get_plugin_page_hookname( $plugin_page, $parent_page ) { |
1688 | 1688 | return $page_type . '_page_' . $plugin_name; |
1689 | 1689 | } |
1690 | 1690 | |
| 1691 | /** |
| 1692 | * @since 4.9.0 |
| 1693 | * |
| 1694 | * @global $admin_page_parent |
| 1695 | * @global string $plugin_page |
| 1696 | * @global array $_registered_pages |
| 1697 | */ |
| 1698 | function admin_page_exists() { |
| 1699 | global $admin_page_parent, $plugin_page, $_registered_pages; |
| 1700 | |
| 1701 | if ( ! isset( $admin_page_parent ) ) { |
| 1702 | $admin_page_parent = get_admin_page_parent(); |
| 1703 | } |
| 1704 | |
| 1705 | if ( isset( $plugin_page ) ) { |
| 1706 | $hookname = get_plugin_page_hookname( $plugin_page, $admin_page_parent ); |
| 1707 | |
| 1708 | if ( ! isset($_registered_pages[$hookname]) ) { |
| 1709 | return false; |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | return true; |
| 1714 | } |
| 1715 | |
1691 | 1716 | /** |
1692 | 1717 | * |
1693 | 1718 | * @global string $pagenow |
… |
… |
function get_plugin_page_hookname( $plugin_page, $parent_page ) { |
1700 | 1725 | */ |
1701 | 1726 | function user_can_access_admin_page() { |
1702 | 1727 | global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv, |
1703 | | $plugin_page, $_registered_pages; |
| 1728 | $plugin_page, $_registered_pages, $admin_page_parent; ; |
1704 | 1729 | |
1705 | | $parent = get_admin_page_parent(); |
| 1730 | $parent = isset( $admin_page_parent ) ? $admin_page_parent : get_admin_page_parent(); |
1706 | 1731 | |
1707 | 1732 | if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) |
1708 | 1733 | return false; |
… |
… |
function user_can_access_admin_page() { |
1713 | 1738 | |
1714 | 1739 | $hookname = get_plugin_page_hookname($plugin_page, $parent); |
1715 | 1740 | |
1716 | | if ( !isset($_registered_pages[$hookname]) ) |
| 1741 | if ( ! admin_page_exists() ) { |
1717 | 1742 | return false; |
| 1743 | } |
1718 | 1744 | } |
1719 | 1745 | |
1720 | 1746 | if ( empty( $parent) ) { |