From e0361726c2f2b23460056060ea3159b83f31de6b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 22 Oct 2018 02:06:40 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/branches/5.0@43777 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43606 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-screen.php | 24 ++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php index 84cbd9164f..6798b1c5cf 100644 --- a/wp-admin/includes/class-wp-screen.php +++ b/wp-admin/includes/class-wp-screen.php @@ -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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 609344e718..5bcde7d35e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-43776'; +$wp_version = '5.0-alpha-43777'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.