[wp-trac] [WordPress Trac] #54806: Site Editor: Remote block patterns are not loaded
WordPress Trac
noreply at wordpress.org
Thu Jan 13 02:30:38 UTC 2022
#54806: Site Editor: Remote block patterns are not loaded
--------------------------+--------------------
Reporter: noisysocks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.9
Component: Editor | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+--------------------
Originally reported in
https://github.com/WordPress/gutenberg/issues/37814.
1. Activate an "empty" theme, e.g. the one that's in the Gutenberg repo.
https://github.com/WordPress/gutenberg/tree/trunk/test/emptytheme
2. Open the Site Editor.
3. Open the inserter.
4. Select "Patterns".
5. Note that many block pattern categories are missing. (They appear in
the post editor.)
The problem is that remote patterns are loaded when the `current_screen`
hook is called.
https://github.com/WordPress/wordpress-
develop/blob/7f2ddd0ae6f128d4292d7cbd20d9e359bb176609/src/wp-includes
/default-filters.php#L335
Before proceeding, this hook checks that `$current_screen→is_block_editor`
is true.
https://github.com/WordPress/wordpress-
develop/blob/7f2ddd0ae6f128d4292d7cbd20d9e359bb176609/src/wp-includes
/block-patterns.php#L55-L57
But `is_block_editor` is not set to true until after the `current_screen`
hook is called.
https://github.com/WordPress/wordpress-
develop/blob/7f2ddd0ae6f128d4292d7cbd20d9e359bb176609/src/wp-
admin/admin.php#L212
https://github.com/WordPress/wordpress-
develop/blob/7f2ddd0ae6f128d4292d7cbd20d9e359bb176609/src/wp-admin/site-
editor.php#L32
The inserter hides the categories as they are empty.
Unfortunately there is no suitable hook that fires in between the call to
`$current_screen→is_block_editor( true )` and the call to
`WP_Block_Patterns_Registry::get_instance()->get_all_registered()`.
Perhaps we should call `_load_remote_block_patterns` and
`_load_remote_featured_patterns` directly instead of using a hook? What do
you think @hellofromtonya?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54806>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list