current_screen WordPress Action Hook

The current_screen hook is one of the most important hooks in WordPress. It is used to determine the current screen and is used by many core functions.

do_action( 'current_screen', WP_Screen $current_screen ) #

Fires after the current screen has been set.


Parameters

$current_screen

(WP_Screen)Current WP_Screen object.


Top ↑

More Information

current_screen is an admin hook triggered after the necessary elements to identify a screen are set up. This hook provides a WP_Screen object as a parameter.

Top ↑

Parameter for hooked function

The following is a sample of the WP_Screen object passed as parameter to a function hooked to current_screen and called in a custom post type editing screen.

WP_Screen Object {
	["action"] => string(0) ""
	["base"] => string(4) "post"
	["columns":"WP_Screen":private] => int(0)
	["id"] => string(12) "someposttype"
	["in_admin":protected] => string(4) "site"
	["is_network"] => bool(false)
	["is_user"] => bool(false)
	["parent_base"] => NULL
	["parent_file"] => NULL
	["post_type"] => string(12) "someposttype"
	["taxonomy"] => string(0) ""
	["_help_tabs":"WP_Screen":private] => array(0) { }
	["_help_sidebar":"WP_Screen":private] => string(0) ""
	["_options":"WP_Screen":private] => array(0) { }
	["_show_screen_options":"WP_Screen":private] => NULL
	["_screen_settings":"WP_Screen":private] => NULL
}

and a sample of the object returned in a taxonomy list screen

WP_Screen Object {
	["action"] => string(0) ""
	["base"] => string(9) "edit-tags"
	["columns":"WP_Screen":private] => int(0)
	["id"] => string(10) "edit-mytax"
	["in_admin":protected] => string(4) "site"
	["is_network"] => bool(false)
	["is_user"] => bool(false)
	["parent_base"] => NULL
	["parent_file"] => NULL
	["post_type"] => string(12) "someposttype"
	["taxonomy"] => string(5) "mytax"
	["_help_tabs":"WP_Screen":private] => array(0) { }
	["_help_sidebar":"WP_Screen":private] =>	string(0) ""
	["_options":"WP_Screen":private] => array(0) { }
	["_show_screen_options":"WP_Screen":private] => NULL
	["_screen_settings":"WP_Screen":private] => NULL
}




Top ↑

Source

File: wp-admin/includes/class-wp-screen.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.