Sets or returns whether the block editor is loading on the current screen.
Parameters
$set
booloptional- Sets whether the block editor is loading on the current screen or not.
Default:
null
Source
public function is_block_editor( $set = null ) {
if ( null !== $set ) {
$this->is_block_editor = (bool) $set;
}
return $this->is_block_editor;
}
Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |
Example usage:
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.$current_screen = get_current_screen(); if ( null !== $current_screen && method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) { // Do something if the Block Editor is being loaded... }