convert_to_screen

Convert a screen string to a screen object.

Description

(WP_Screen) convert_to_screen( (string) $hook_name ); 

Returns (WP_Screen)

Screen object.

Parameters (1)

0. $hook_name (string)
The hook name (also known as the hook suffix) used to determine the screen.

Usage

  1. if ( !function_exists( 'convert_to_screen' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // The hook name (also known as the hook suffix) used to determine the screen. 
  5. $hook_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = convert_to_screen($hook_name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/template.php  
  1. function convert_to_screen( $hook_name ) { 
  2. if ( ! class_exists( 'WP_Screen' ) ) { 
  3. _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3.0' ); 
  4. return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' ); 
  5.  
  6. return WP_Screen::get( $hook_name );