WordPress.org

Ready to get started?Download WordPress

Codex

Class Reference/WP Screen

Contents

Role of WP_Screen

This is a concrete class that is instantiated in the WordPress $screen global. It is primarily used to create and customize WordPress admin screens (as of WordPress 3.3).

Is is located in wp-admin/includes/screen.php with other admin screen-related functions.

Public Properties

The following properties are built into the WP_Screen class.

$action
Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
$base
The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped. For example, for an $id of 'edit-post' the base is 'edit'.
$id
The unique ID of the screen.
$is_network
Whether the screen is in the network admin.
$is_user
Whether the screen is in the user admin.
$parent_base
The base menu parent. This is derived from $parent_file by removing the query string and any .php extension. $parent_file values of 'edit.php?post_type=page' and 'edit.php?post_type=post' have a $parent_base of 'edit'.
$parent_file
The $parent_file for the screen per the admin menu system. Some $parent_file values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
$post_type
The post type associated with the screen, if any. The 'edit.php?post_type=page' screen has a post type of 'page'. The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
$taxonomy
The taxonomy associated with the screen, if any. The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.

Private Properties

The following properties are built into the WP_Screen class.

$_help_tabs
Private. The help tab data associated with the screen, if any.
$_help_sidebar
Private. The help sidebar data associated with screen, if any.
$_old_compat_help
Private. Stores old string-based help.
$_options
Private. The screen options associated with screen, if any.
$_registry
Private. The screen object registry.
$_show_screen_options
Private. Stores the result of the public show_screen_options() function.
$_screen_settings
Private. Stores the 'screen_settings' section of screen options.

Static Methods

The following methods are available statically.

get( $hook_name="" )
Fetches a screen object. If $hook_name is omitted, the current $hook_suffix global is used automatically.

The following methods are available statically.

add_old_compat_help( $screen, $help )
Provided for backwards compatibility, this sets the old, string-based contextual help for the specified screen.

Object Methods

The following methods are available from a WP_Screen() instance.

set_current_screen()
Makes the screen object the current screen.
in_admin()
Indicates whether the screen is in a particular admin (network, user, site or any of the three).
set_parentage( $parent_file )
Sets the parent information for the screen. This is called in admin-header.php after the menu parent for the screen has been determined.
add_option( $option, $args = array() )
Adds an option for the screen. Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options.
get_option( $option, $key = false )
Gets the arguments for an option for the screen.
add_help_tab( $args )
Add a help tab to the contextual help for the screen. Call this on the load-$pagenow hook for the relevant screen. The $args array takes the following values: (string) title, (string) id, (string) content, and a callback (callback).
remove_help_tab( $id )
Removes a help tab from the contextual help for the screen.
remove_help_tabs()
Removes ALL help tabs from the contextual help for the screen.
set_help_sidebar( $content )
Add a sidebar to the contextual help for the screen. Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help.
render_screen_meta()
Render the screen's help section. This will trigger the deprecated filters for backwards compatibility.
show_screen_options()
Automatically sets the $_screen_settings property and returns the $_show_screen_options property.
render_screen_options()
Renders the screen options tab.
render_screen_layout()
Render the option for number of columns on the page
render_per_page_options()
Render the "items per page" option

Change Log

Since: 3.3.0

Source File

WP_Screen() is located in /wp-admin/includes/screen.php.

Related

PHPDocs for WP_Screen

Resources

See also index of Class Reference and index of Function Reference.