Title: WP_Screen::get
Published: April 25, 2014
Last modified: February 24, 2026

---

# WP_Screen::get( string|WP_Screen $hook_name ): 󠀁[WP_Screen](https://developer.wordpress.org/reference/classes/wp_screen/)󠁿

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#wp--skip-link--target)

Fetches a screen object.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#parameters)󠁿

 `$hook_name`string|[WP_Screen](https://developer.wordpress.org/reference/classes/wp_screen/)
optional

The hook name (also known as the hook suffix) used to determine the screen.
 Defaults
to the current $hook_suffix global.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#return)󠁿

 [WP_Screen](https://developer.wordpress.org/reference/classes/wp_screen/) Screen
object.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#source)󠁿

    ```php
    public static function get( $hook_name = '' ) {
    	if ( $hook_name instanceof WP_Screen ) {
    		return $hook_name;
    	}

    	$id              = '';
    	$post_type       = null;
    	$taxonomy        = null;
    	$in_admin        = false;
    	$action          = '';
    	$is_block_editor = false;

    	if ( $hook_name ) {
    		$id = $hook_name;
    	} elseif ( ! empty( $GLOBALS['hook_suffix'] ) ) {
    		$id = $GLOBALS['hook_suffix'];
    	}

    	// For those pesky meta boxes.
    	if ( $hook_name && post_type_exists( $hook_name ) ) {
    		$post_type = $id;
    		$id        = 'post'; // Changes later. Ends up being $base.
    	} else {
    		if ( str_ends_with( $id, '.php' ) ) {
    			$id = substr( $id, 0, -4 );
    		}

    		if ( in_array( $id, array( 'post-new', 'link-add', 'media-new', 'user-new' ), true ) ) {
    			$id     = substr( $id, 0, -4 );
    			$action = 'add';
    		}
    	}

    	if ( ! $post_type && $hook_name ) {
    		if ( str_ends_with( $id, '-network' ) ) {
    			$id       = substr( $id, 0, -8 );
    			$in_admin = 'network';
    		} elseif ( str_ends_with( $id, '-user' ) ) {
    			$id       = substr( $id, 0, -5 );
    			$in_admin = 'user';
    		}

    		$id = sanitize_key( $id );
    		if ( 'edit-comments' !== $id && 'edit-tags' !== $id && str_starts_with( $id, 'edit-' ) ) {
    			$maybe = substr( $id, 5 );
    			if ( taxonomy_exists( $maybe ) ) {
    				$id       = 'edit-tags';
    				$taxonomy = $maybe;
    			} elseif ( post_type_exists( $maybe ) ) {
    				$id        = 'edit';
    				$post_type = $maybe;
    			}
    		}

    		if ( ! $in_admin ) {
    			$in_admin = 'site';
    		}
    	} else {
    		if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
    			$in_admin = 'network';
    		} elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
    			$in_admin = 'user';
    		} else {
    			$in_admin = 'site';
    		}
    	}

    	if ( 'index' === $id ) {
    		$id = 'dashboard';
    	} elseif ( 'front' === $id ) {
    		$in_admin = false;
    	}

    	$base = $id;

    	// If this is the current screen, see if we can be more accurate for post types and taxonomies.
    	if ( ! $hook_name ) {
    		if ( isset( $_REQUEST['post_type'] ) ) {
    			$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
    		}
    		if ( isset( $_REQUEST['taxonomy'] ) ) {
    			$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
    		}

    		switch ( $base ) {
    			case 'post':
    				if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
    					wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 );
    				} elseif ( isset( $_GET['post'] ) ) {
    					$post_id = (int) $_GET['post'];
    				} elseif ( isset( $_POST['post_ID'] ) ) {
    					$post_id = (int) $_POST['post_ID'];
    				} else {
    					$post_id = 0;
    				}

    				if ( $post_id ) {
    					$post = get_post( $post_id );
    					if ( $post ) {
    						$post_type = $post->post_type;

    						/** This filter is documented in wp-admin/post.php */
    						$replace_editor = apply_filters( 'replace_editor', false, $post );

    						if ( ! $replace_editor ) {
    							$is_block_editor = use_block_editor_for_post( $post );
    						}
    					}
    				}
    				break;
    			case 'edit-tags':
    			case 'term':
    				if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
    					$post_type = 'post';
    				}
    				break;
    			case 'upload':
    				$post_type = 'attachment';
    				break;
    		}
    	}

    	switch ( $base ) {
    		case 'post':
    			if ( null === $post_type ) {
    				$post_type = 'post';
    			}

    			// When creating a new post, use the default block editor support value for the post type.
    			if ( empty( $post_id ) ) {
    				$is_block_editor = use_block_editor_for_post_type( $post_type );
    			}

    			$id = $post_type;
    			break;
    		case 'edit':
    			if ( null === $post_type ) {
    				$post_type = 'post';
    			}
    			$id .= '-' . $post_type;
    			break;
    		case 'edit-tags':
    		case 'term':
    			if ( null === $taxonomy ) {
    				$taxonomy = 'post_tag';
    			}
    			// The edit-tags ID does not contain the post type. Look for it in the request.
    			if ( null === $post_type ) {
    				$post_type = 'post';
    				if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
    					$post_type = $_REQUEST['post_type'];
    				}
    			}

    			$id = 'edit-' . $taxonomy;
    			break;
    	}

    	if ( 'network' === $in_admin ) {
    		$id   .= '-network';
    		$base .= '-network';
    	} elseif ( 'user' === $in_admin ) {
    		$id   .= '-user';
    		$base .= '-user';
    	}

    	if ( isset( self::$_registry[ $id ] ) ) {
    		$screen = self::$_registry[ $id ];
    		if ( get_current_screen() === $screen ) {
    			return $screen;
    		}
    	} else {
    		$screen     = new self();
    		$screen->id = $id;
    	}

    	$screen->base            = $base;
    	$screen->action          = $action;
    	$screen->post_type       = (string) $post_type;
    	$screen->taxonomy        = (string) $taxonomy;
    	$screen->is_user         = ( 'user' === $in_admin );
    	$screen->is_network      = ( 'network' === $in_admin );
    	$screen->in_admin        = $in_admin;
    	$screen->is_block_editor = $is_block_editor;

    	self::$_registry[ $id ] = $screen;

    	return $screen;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-screen.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-screen.php#L210)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-screen.php#L210-L398)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#hooks)󠁿

 [apply_filters( ‘replace_editor’, bool $replace, WP_Post $post )](https://developer.wordpress.org/reference/hooks/replace_editor/)

Allows replacement of the editor.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#related)󠁿

| Uses | Description | 
| [use_block_editor_for_post_type()](https://developer.wordpress.org/reference/functions/use_block_editor_for_post_type/)`wp-includes/post.php` |

Returns whether a post type is compatible with the block editor.

  | 
| [use_block_editor_for_post()](https://developer.wordpress.org/reference/functions/use_block_editor_for_post/)`wp-includes/post.php` |

Returns whether the post can be edited in the block editor.

  | 
| [get_current_screen()](https://developer.wordpress.org/reference/functions/get_current_screen/)`wp-admin/includes/screen.php` |

Get the current screen object

  | 
| [WP_Screen::__construct()](https://developer.wordpress.org/reference/classes/wp_screen/__construct/)`wp-admin/includes/class-wp-screen.php` |

Constructor

  | 
| [is_object_in_taxonomy()](https://developer.wordpress.org/reference/functions/is_object_in_taxonomy/)`wp-includes/taxonomy.php` |

Determines if the given object type is associated with the given taxonomy.

  | 
| [taxonomy_exists()](https://developer.wordpress.org/reference/functions/taxonomy_exists/)`wp-includes/taxonomy.php` |

Determines whether the taxonomy name exists.

  | 
| [post_type_exists()](https://developer.wordpress.org/reference/functions/post_type_exists/)`wp-includes/post.php` |

Determines whether a post type is registered.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [sanitize_key()](https://developer.wordpress.org/reference/functions/sanitize_key/)`wp-includes/formatting.php` |

Sanitizes a string key.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 7 more](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Nav_Menus_Panel::render_screen_options()](https://developer.wordpress.org/reference/classes/wp_customize_nav_menus_panel/render_screen_options/)`wp-includes/customize/class-wp-customize-nav-menus-panel.php` |

Render screen options for Menus.

  | 
| [set_current_screen()](https://developer.wordpress.org/reference/functions/set_current_screen/)`wp-admin/includes/screen.php` |

Set the current screen object

  | 
| [convert_to_screen()](https://developer.wordpress.org/reference/functions/convert_to_screen/)`wp-admin/includes/template.php` |

Converts a screen string to a screen object.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_screen/get/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.3.0](https://developer.wordpress.org/reference/since/3.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_screen%2Fget%2F)
before being able to contribute a note or feedback.