#46195 (is_block_editor() returns false in the block editor) – WordPress Trac (original) (raw)
#46195 closed defect (bug) (fixed)
| Reported by: | |
Owned by: | |
|---|---|---|---|
| Milestone: | 5.2 | Priority: | normal |
| Severity: | normal | Version: | 5.0 |
| Component: | Editor | Keywords: | has-patch has-unit-tests has-dev-note |
| Focuses: | administration | Cc: |
The current_screen action is supposed to be fired after the necessary elements to identify a screen are set up. So I would expect that $screen->is_block_editor() returns the right value in a function hooked to current_screen. But in fact $screen->is_block_editor() always return false even if are in the block editor.
That's because the property is_block_editor is set much later, after current_screen action is fired.
This small code snippet allows to reproduce the issue:
add_action( 'current_screen', function( $screen ) { error_log( var_export( $screen->is_block_editor(), true ) ); } );