Skip to content
Closed
Prev Previous commit
Add default-filters update
  • Loading branch information
tjcafferkey committed May 15, 2024
commit fa8cfb447bb5c3143524f5931d4da41a157bf6d9
5 changes: 5 additions & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,4 +757,9 @@
add_filter( 'rest_pre_insert_wp_template', 'inject_ignored_hooked_blocks_metadata_attributes' );
add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' );

// Note: When can we remove this conditional?
if ( ! has_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' ) && ! has_filter( 'rest_pre_insert_wp_navigation', 'gutenberg_block_core_navigation_update_ignore_hooked_blocks_meta' ) ) {
Comment on lines +760 to +761
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it when the block_core_navigation_update_ignore_hooked_blocks_meta filter is no longer attached to the rest_pre_insert_wp_navigation hook. Since this is done by GB code, we'll have to wait until it's removed there, and blocks code is sync'd to Core.

OTOH, we'll have to retain the code in GB for at least two WP releases, as it's required to support the current WordPress version and the one before. So if this PR makes it into WP 6.6, GB still needs to support 6.5, so we'll have to retain the code there.

I'd suggest doing it the other way round: Add the filter unconditionally here, and instead add (yet another 😬) has_filter check in GB. (We will need to wait for GB to release a version that includes that check before we can land the Core PR in order to prevent Core trunk + GB stable from breaking.)

add_filter( 'rest_pre_insert_wp_navigation', 'inject_ignored_hooked_blocks_metadata_attributes' );
}

unset( $filter, $action );