Get the current screen object
Return
WP_Screen|null Current screen object or null when screen not defined.Source
function get_current_screen() {
global $current_screen;
if ( ! isset( $current_screen ) ) {
return null;
}
return $current_screen;
}
Related
Used by | Description |
---|---|
WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies()wp-includes/class-wp-plugin-dependencies.php | Displays an admin notice if dependencies are not installed. |
wp_global_styles_render_svg_filters()wp-includes/deprecated.php | Renders the SVG filters supplied by theme.json. |
WP_Site_Health::admin_body_class()wp-admin/includes/class-wp-site-health.php | Adds a class to the body HTML tag. |
WP_Site_Health::enqueue_scripts()wp-admin/includes/class-wp-site-health.php | Enqueues the site health scripts. |
WP_Privacy_Policy_Content::notice()wp-admin/includes/class-wp-privacy-policy-content.php | Adds a notice with a link to the guide when editing the privacy policy page. |
WP_Privacy_Policy_Content::policy_text_changed_notice()wp-admin/includes/class-wp-privacy-policy-content.php | Outputs a warning when some privacy info has changed. |
_wp_privacy_settings_filter_draft_page_titles()wp-admin/includes/misc.php | Appends ‘(Draft)’ to draft page titles in the privacy page dropdown so that unpublished content is obvious. |
WP_Widget_Custom_HTML::add_help_text()wp-includes/widgets/class-wp-widget-custom-html.php | Add help text to widgets admin screen. |
wp_ajax_search_install_plugins()wp-admin/includes/ajax-actions.php | Handles searching plugins to install via AJAX. |
wp_ajax_search_plugins()wp-admin/includes/ajax-actions.php | Handles searching plugins via AJAX. |
WP_Screen::render_view_mode()wp-admin/includes/class-wp-screen.php | Renders the list table view mode preferences. |
WP_Screen::get()wp-admin/includes/class-wp-screen.php | Fetches a screen object. |
add_screen_option()wp-admin/includes/screen.php | Register and configure an admin screen option |
screen_layout()wp-admin/includes/deprecated.php | Returns the screen layout options. |
screen_options()wp-admin/includes/deprecated.php | Returns the screen’s per-page options. |
screen_meta()wp-admin/includes/deprecated.php | Renders the screen’s help. |
wp_plugin_update_row()wp-admin/includes/update.php | Displays update information for a plugin. |
wp_add_dashboard_widget()wp-admin/includes/dashboard.php | Adds a new dashboard widget. |
wp_dashboard()wp-admin/includes/dashboard.php | Displays the dashboard. |
wp_dashboard_setup()wp-admin/includes/dashboard.php | Registers dashboard widgets. |
_get_list_table()wp-admin/includes/list-table.php | Fetches an instance of a WP_List_Table class. |
iframe_header()wp-admin/includes/template.php | Generic Iframe header for use with Thickbox. |
add_meta_box()wp-admin/includes/template.php | Adds a meta box to one or more screens. |
do_meta_boxes()wp-admin/includes/template.php | Meta-Box template function. |
remove_meta_box()wp-admin/includes/template.php | Removes a meta box from one or more screens. |
do_accordion_sections()wp-admin/includes/template.php | Meta Box Accordion Template Function. |
post_comment_meta_box()wp-admin/includes/meta-boxes.php | Displays comments for post. |
page_attributes_meta_box()wp-admin/includes/meta-boxes.php | Displays page attributes form fields. |
Custom_Image_Header::help()wp-admin/includes/class-custom-image-header.php | Adds contextual help. |
Custom_Background::admin_load()wp-admin/includes/class-custom-background.php | Sets up the enqueue for the CSS & JavaScript files. |
wp_auth_check_load()wp-includes/functions.php | Loads the auth check for monitoring whether the user is still logged in. |
wp_admin_bar_edit_menu()wp-includes/admin-bar.php | Provides an edit link for posts and terms. |
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |
This could be useful in unit tests
Be aware the this function doesn’t always exist, something that @ravanh had sort of eluded to. It isn’t loaded and available until after
admin_init
has fired. It is advisable to check whether the function exists when using it within any hooks in the even those hooks fire before that function is actually loaded and available to use.Another Example: