[wp-trac] [WordPress Trac] #46195: is_block_editor() returns false in the block editor
WordPress Trac
noreply at wordpress.org
Wed Apr 17 01:55:28 UTC 2019
#46195: is_block_editor() returns false in the block editor
-------------------------------------------------+-------------------------
Reporter: Chouby | Owner: desrosj
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.1.2
Component: Editor | Version: 5.0
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing needs-dev- | Focuses:
note has-unit-tests commit | administration
-------------------------------------------------+-------------------------
Changes (by desrosj):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"45224" 45224]:
{{{
#!CommitTicketReference repository="" revision="45224"
Administration: Improve the accuracy of `is_block_editor()`.
Currently, there are a number of scenarios where `is_block_editor()` (and
`WP_Screen::is_block_editor`) would incorrectly indicate block editor
support at different points of the loading process. Most notably, checking
`is_block_editor` when hooking into the `current_screen` action will
always result in `false`, even when the block editor is being loaded. This
is because `is_block_editor` is not set to `true` until `edit-form-
blocks.php` is included.
This change adds logic to `WP_Screen` to ensure the accuracy of
`is_block_editor` on block editor pages earlier in the load process.
While edit screens will now be accurate 100% of the time from
`current_screen` on, there are still a few edge cases where
`is_block_editor` could contain an incorrect value when creating a new
post.
Because a `WP_Post` object is a required parameter for the
`replace_editor` filter and `use_block_editor_for_post()` function,
`WP_Screen` will fall back to the value returned by
`use_block_editor_for_post_type()` for the post being created. To
eliminate these edge cases, the `use_block_editor_for_post_type` filter
can be used to return the appropriate boolean value to indicate support.
Props Chouby, desrosj, aduth, johnbillion.
Fixes #46195.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46195#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list