wpseek.com
WordPress开发者和主题制作者的搜索引擎
wp_admin_page_exists › WordPress Function
Since7.2.0
已弃用n/a
› wp_admin_page_exists ( 没有参数 )
| 返回: |
|
| 定义在: |
|
| 文档: |
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
源码
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 ] )
);
}