wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_admin_page_exists › WordPress Function

Seit7.2.0
Veraltetn/v
› wp_admin_page_exists ( Keine Parameter )
Gibt zurück:
  • (bool) True if the admin page exists, false otherwise.
Definiert in:
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.


Quellcode

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;
}