wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_admin_page_exists › WordPress Function
Since7.2.0
Deprecatedn/a
› wp_admin_page_exists ( No parameters )
| Returns: |
|
| Defined at: |
|
| Codex: |
Determines whether the requested admin page is registered.
This does not check whether the current user has the capability to access the page, only whether the page itself exists. Pages registered for a capability the current user lacks are recorded in the no-privilege registries rather than in $_registered_pages, and are still considered to exist so that the caller can report a permission error instead of a "page not found" error.Related Functions: wp_admin_css, _wp_admin_bar_init, get_admin_page_parent, domain_exists, wp_admin_bar_edit_menu
Source
function wp_admin_page_exists(): bool {
global $plugin_page, $_registered_pages, $_wp_menu_nopriv, $_wp_submenu_nopriv,
$_wp_nopriv_pages;
if ( ! isset( $plugin_page ) ) {
return true;
}
$hookname = get_plugin_page_hookname( $plugin_page, get_admin_page_parent() );
if ( isset( $_registered_pages[ $hookname ] ) ) {
return true;
}
// The page may be registered for a capability the current user lacks.
if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) || isset( $_wp_nopriv_pages[ $plugin_page ] ) ) {
return true;
}
foreach ( (array) $_wp_submenu_nopriv as $nopriv_submenus ) {
if ( isset( $nopriv_submenus[ $plugin_page ] ) ) {
return true;
}
}
return false;
}