Block Editor: Add an is_block_editor() method to WP_Screen.

This method allows checking (or setting) whether the block editor is loading on the current screen.

See #45037.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43777 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2018-10-22 02:05:23 +00:00
parent a398d9963a
commit d0eaeb3b16

View File

@ -181,6 +181,14 @@ final class WP_Screen {
*/
private $_screen_settings;
/**
* Whether the screen is using the block editor.
*
* @since 5.0.0
* @var bool
*/
public $is_block_editor = false;
/**
* Fetches a screen object.
*
@ -399,6 +407,22 @@ final class WP_Screen {
return ( $admin == $this->in_admin );
}
/**
* Sets or returns whether the block editor is loading on the current screen.
*
* @since 5.0.0
*
* @param bool $set Optional. Sets whether the block editor is loading on the current screen or not.
* @return bool True if the block editor is being loaded, false otherwise.
*/
public function is_block_editor( $set = null ) {
if ( $set !== null ) {
$this->is_block_editor = (bool) $set;
}
return $this->is_block_editor;
}
/**
* Sets the old string-based contextual help for the screen for backward compatibility.
*