wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
wp_admin_page_exists › WordPress Function
Depuis7.2.0
Dépréciéen/a
› wp_admin_page_exists ( Pas de paramètres )
| Retourne: |
|
| Défini(e) dans: |
|
| 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.Fonctions en relation: 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;
}
return array_any(
(array) $_wp_submenu_nopriv,
fn( $nopriv_submenus ) => isset( $nopriv_submenus[ $plugin_page ] )
);
}