is_admin(): bool
Determines whether the current request is for an administrative interface page.
Description
Does not check if the user is an administrator; use current_user_can() for checking roles and capabilities.
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Return
bool True if inside WordPress administration interface, false otherwise.
Source
File: wp-includes/load.php
.
View all references
function is_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin();
} elseif ( defined( 'WP_ADMIN' ) ) {
return WP_ADMIN;
}
return false;
}
Related
Used By
Used By | Description |
---|---|
wp_enqueue_emoji_styles() wp-includes/formatting.php |
Enqueues the important emoji-related styles. |
wp_enqueue_admin_bar_header_styles() wp-includes/admin-bar.php |
Enqueues inline style to hide the admin bar when printing. |
WP_Font_Face::__construct() wp-includes/fonts/class-wp-font-face.php |
Creates and initializes an instance of WP_Font_Face. |
wp_get_loading_optimization_attributes() wp-includes/media.php |
Gets loading optimization attributes. |
_wp_theme_json_webfonts_handler() wp-includes/deprecated.php |
Runs the theme.json webfonts handler. |
wp_global_styles_render_svg_filters() wp-includes/deprecated.php |
Renders the SVG filters supplied by theme.json. |
wp_get_loading_attr_default() wp-includes/deprecated.php |
Gets the default value to use for a |
wp_admin_bar_edit_site_menu() wp-includes/admin-bar.php |
Adds the “Edit site” link to the Toolbar. |
wp_should_load_separate_core_block_assets() wp-includes/script-loader.php |
Checks whether separate styles should be loaded for core blocks on-render. |
wp_get_inline_script_tag() wp-includes/script-loader.php |
Wraps inline JavaScript in |
wp_sanitize_script_attributes() wp-includes/script-loader.php |
Sanitizes an attributes array into an attributes string to be placed inside a |
wp_get_script_tag() wp-includes/script-loader.php |
Formats |
wp_is_site_protected_by_basic_auth() wp-includes/load.php |
Checks if this site is protected by HTTP Basic Auth. |
WP_REST_Site_Health_Controller::load_admin_textdomain() wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php |
Loads the admin textdomain for Site Health tests. |
is_protected_endpoint() wp-includes/load.php |
Determines whether we are currently on an endpoint that should be protected against WSODs. |
WP_Fatal_Error_Handler::handle() wp-includes/class-wp-fatal-error-handler.php |
Runs the shutdown handler. |
WP_Site_Health::check_wp_version_check_exists() wp-admin/includes/class-wp-site-health.php |
Tests whether |
determine_locale() wp-includes/l10n.php |
Determines the current locale desired for the request. |
wp_common_block_scripts_and_styles() wp-includes/script-loader.php |
Handles the enqueueing of block scripts and styles that are common to both the editor and the front-end. |
wp_enqueue_registered_block_scripts_and_styles() wp-includes/script-loader.php |
Enqueues registered block scripts and styles, depending on current rendered context (only enqueuing editor scripts while in context of the editor). |
use_block_editor_for_post() wp-includes/post.php |
Returns whether the post can be edited in the block editor. |
wp_add_privacy_policy_content() wp-admin/includes/plugin.php |
Declares a helper function for adding content to the Privacy Policy Guide. |
WP_Customize_Manager::establish_loaded_changeset() wp-includes/class-wp-customize-manager.php |
Establishes the loaded changeset. |
_WP_Editors::enqueue_default_editor() wp-includes/class-wp-editor.php |
Enqueue all editor scripts. |
WP_Taxonomy::set_props() wp-includes/class-wp-taxonomy.php |
Sets taxonomy properties. |
WP_Taxonomy::add_rewrite_rules() wp-includes/class-wp-taxonomy.php |
Adds the necessary rewrite rules for the taxonomy. |
WP_Post_Type::add_rewrite_rules() wp-includes/class-wp-post-type.php |
Adds the necessary rewrite rules for the post type. |
WP_Post_Type::set_props() wp-includes/class-wp-post-type.php |
Sets post type properties. |
get_rest_url() wp-includes/rest-api.php |
Retrieves the URL to a REST endpoint on a site. |
wp_admin_bar_customize_menu() wp-includes/admin-bar.php |
Adds the “Customize” link to the Toolbar. |
WP_Customize_Nav_Menu_Item_Setting::sort_wp_get_nav_menu_items() wp-includes/customize/class-wp-customize-nav-menu-item-setting.php |
Re-apply the tail logic also applied on $items by wp_get_nav_menu_items() . |
WP_Customize_Manager::wp_loaded() wp-includes/class-wp-customize-manager.php |
Registers styles/scripts and initialize the preview of each setting |
WP_Customize_Manager::wp_redirect_status() wp-includes/class-wp-customize-manager.php |
Prevents Ajax requests from following redirects when previewing a theme by issuing a 200 response instead of a 30x. |
WP_Styles::__construct() wp-includes/class-wp-styles.php |
Constructor. |
remove_editor_styles() wp-includes/theme.php |
Removes all visual editor stylesheets. |
_custom_header_background_just_in_time() wp-includes/theme.php |
Registers the internal custom header and background routines. |
_wp_customize_include() wp-includes/theme.php |
Includes and instantiates the WP_Customize_Manager class. |
switch_theme() wp-includes/theme.php |
Switches the theme. |
get_theme_mods() wp-includes/theme.php |
Retrieves all theme modifications. |
load_default_textdomain() wp-includes/l10n.php |
Loads default translated strings based on locale. |
wp_heartbeat_settings() wp-includes/general-template.php |
Default settings for heartbeat. |
wp_admin_bar_dashboard_view_site_menu() wp-includes/deprecated.php |
Add the “Dashboard”/”Visit Site” menu. |
WP_Theme::get_allowed_on_site() wp-includes/class-wp-theme.php |
Returns array of stylesheet names of themes allowed on the site. |
WP::handle_404() wp-includes/class-wp.php |
Set the Headers for 404, if nothing is found for requested URL. |
WP::parse_request() wp-includes/class-wp.php |
Parses the request to find the correct WordPress query. |
WP_Query::parse_query() wp-includes/class-wp-query.php |
Parses a query string and sets query type booleans. |
wp_deregister_script() wp-includes/functions.wp-scripts.php |
Removes a registered script. |
wp_auth_check_load() wp-includes/functions.php |
Loads the auth check for monitoring whether the user is still logged in. |
wp_widget_rss_output() wp-includes/widgets.php |
Display the RSS entries in a list. |
get_pagenum_link() wp-includes/link-template.php |
Retrieves the link for a page number. |
WP_Admin_Bar::_render() wp-includes/class-wp-admin-bar.php | |
wp_admin_bar_sidebar_toggle() wp-includes/admin-bar.php |
Adds the sidebar toggle button. |
wp_admin_bar_site_menu() wp-includes/admin-bar.php |
Adds the “Site Name” menu. |
wp_admin_bar_edit_menu() wp-includes/admin-bar.php |
Provides an edit link for posts and terms. |
wp_admin_bar_search_menu() wp-includes/admin-bar.php |
Adds search form. |
is_admin_bar_showing() wp-includes/admin-bar.php |
Determines whether the admin bar should be showing. |
wp_user_settings() wp-includes/option.php |
Saves and restores user interface settings stored in a cookie. |
get_post_class() wp-includes/post-template.php |
Retrieves an array of the class names for the post container element. |
get_the_title() wp-includes/post-template.php |
Retrieves the post title. |
wp_enqueue_media() wp-includes/media.php |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
wp_video_shortcode() wp-includes/media.php |
Builds the Video shortcode output. |
image_constrain_size_for_editor() wp-includes/media.php |
Scales down the default size of an image. |
wp_get_attachment_url() wp-includes/post.php |
Retrieves the URL for an attachment. |
redirect_canonical() wp-includes/canonical.php |
Redirects incoming links to the proper URL based on the site url. |
ms_not_installed() wp-includes/ms-load.php |
Displays a failure message. |
_post_format_request() wp-includes/post-formats.php |
Filters the request to allow for the format prefix. |
wp_get_nav_menu_items() wp-includes/nav-menu.php |
Retrieves all menu items of a navigation menu. |
dynamic_sidebar() wp-includes/widgets.php |
Display dynamic sidebar. |
wp_get_sidebars_widgets() wp-includes/widgets.php |
Retrieve full list of sidebars and their widget instance IDs. |
wp_convert_widget_settings() wp-includes/widgets.php |
Converts the widget settings from single to multi-widget format. |
WP_Customize_Widgets::schedule_customize_register() wp-includes/class-wp-customize-widgets.php |
Ensures widgets are available for all types of previews. |
script_concat_settings() wp-includes/script-loader.php |
Determines the concatenation and compression settings for scripts and styles. |
wp_default_scripts() wp-includes/script-loader.php |
Registers all WordPress scripts. |
_WP_Editors::editor_settings() wp-includes/class-wp-editor.php | |
_WP_Editors::editor_js() wp-includes/class-wp-editor.php |
Print (output) the TinyMCE configuration and initialization scripts. |
Changelog
Version | Description |
---|---|
1.5.1 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Be aware that ‘is_admin()’ will return ‘false’ while in the theme customizer view, despite essentially being in the admin dashboard. To test for the customizer, use ‘is_customize_preview()’.
Example:
Note that
is_admin()
will returnfalse
when using the block editor. See https://core.trac.wordpress.org/ticket/47394Migrate from Codex:
is_admin()
returns true for Ajax requests, sincewp-admin/admin-ajax.php
defines theWP_ADMIN
constant as true.Top ↑
Feedback
That’s valuable information but not “absolute”. There are plugins that define their own Ajax endpoints and don’t come in through admin-ajax. An example I’ve seen is with JWT auth requests. So unless those specific plugins are hooked by a local function on auth success, so that WP_ADMIN can be defined outside of that code, is_admin() may still return false for these kinds of Ajax requests. — By Tony G —