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.

Merges [43777] from the 5.0 branch to trunk.

See #45037.

Built from https://develop.svn.wordpress.org/trunk@44130


git-svn-id: http://core.svn.wordpress.org/trunk@43960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-12-14 01:08:38 +00:00
parent 786eb29de1
commit 74e7094bd0
2 changed files with 25 additions and 1 deletions

View File

@ -178,6 +178,14 @@ final class WP_Screen {
*/ */
private $_screen_settings; 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. * Fetches a screen object.
* *
@ -412,6 +420,22 @@ final class WP_Screen {
return ( $admin == $this->in_admin ); 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. * Sets the old string-based contextual help for the screen for backward compatibility.
* *

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44129'; $wp_version = '5.1-alpha-44130';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.