WP_Screen::is_block_editor( bool $set = null ): bool

Sets or returns whether the block editor is loading on the current screen.

Parameters

$setbooloptional
Sets whether the block editor is loading on the current screen or not.

Default:null

Return

bool True if the block editor is being loaded, false otherwise.

Source

public function is_block_editor( $set = null ) {
	if ( null !== $set ) {
		$this->is_block_editor = (bool) $set;
	}

	return $this->is_block_editor;
}

Changelog

VersionDescription
5.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example usage:

    $current_screen = get_current_screen();
    if (
    	method_exists( $current_screen, 'is_block_editor' )
    	&& $current_screen->is_block_editor()
    ) {
    	// Do something if the Block Editor is being loaded...
    }

    For instance, I have a metabox marked as [ '__back_compat_meta_box' => true ] and wanted to ensure its scripts and styles aren’t being loaded unnecessarily in the Block Editor.

You must log in before being able to contribute a note or feedback.