-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run template-part registration after all other blocks #3384
Run template-part registration after all other blocks #3384
Conversation
Prioity 22 was chosen because register_legacy_post_comments_block is priority 21 and this should be called afterwards
This gives more breathing room for blocks that want to register themselves in a different order
3da02d0
to
f4f1bce
Compare
Rebased. |
/* | ||
* This block relies on generated styles from previously registered blocks, so | ||
* it should be registered last. | ||
*/ | ||
add_action( 'init', 'register_block_core_template_part', 29 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we'd need to make this change to the corresponding file in Gutenberg, since Core's build process uses the files from the @wordpress/block-library
package as its source of truth for dynamic blocks' PHP code and overwrites any changes we make here 😬
(I think that's also the reason for the test failures we're seeing in CI.)
I'll change the Trac ticket linked in the PR desc to https://core.trac.wordpress.org/ticket/56736, since this PR would solve that, and the previously linked ticket (https://core.trac.wordpress.org/ticket/56644) has now been fixed. |
Closing this out. Both related trac tickets have been solved. |
This is another (partial) alternative to #3352, #3359, and #3373.
This adjusts the priorities of block registration so that the
core/template-part
block is registered last. This means that all blocks (exceptcore/template-part
) will be registered before the metadata formget_blocks_metadata
is called for the first time.It currently has the problem that the block metadata for the
core/template-part
block itself won't be included, but that may be fixed with the combination of cache invalidation from #3373 if we can guarantee thatregister_block_core_template_part
never unregisters any blocks.I upped the
WP_Block_Supports::init
priority value to make room for blocks likecore/post-comments
to be registered after the rest of the core blocks, but before thecore/template-part
registration.Trac ticket: https://core.trac.wordpress.org/ticket/56736
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.