Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2169,12 +2169,13 @@ function get_plugin_page_hookname( $plugin_page, $parent_page ) {
* @global array $_wp_submenu_nopriv
* @global string $plugin_page
* @global array $_registered_pages
* @global array $admin_page_hooks
*
* @return bool True if the current user can access the admin page, false otherwise.
*/
function user_can_access_admin_page() {
global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv,
$plugin_page, $_registered_pages;
$plugin_page, $_registered_pages, $admin_page_hooks;

$parent = get_admin_page_parent();

Expand All @@ -2192,6 +2193,11 @@ function user_can_access_admin_page() {
if ( ! isset( $_registered_pages[ $hookname ] ) ) {
return false;
}

// It's a toplevel page, but accessed with the wrong parent.
if ( isset( $admin_page_hooks[ $plugin_page ] ) && $parent !== $plugin_page ) {
return false;
}
}

if ( empty( $parent ) ) {
Expand Down
Loading