From 99dd4f8c38b062a85ad4fee5df377f30137dba8c Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 14 Dec 2018 01:07:11 +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. Merges [43777] from the 5.0 branch to trunk. See #45037. git-svn-id: https://develop.svn.wordpress.org/trunk@44130 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-screen.php | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index f8e63554ca..f96430984d 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -178,6 +178,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. * @@ -412,6 +420,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. *