Skip to content
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

Navigation block: Check for insert_hooked_blocks_into_rest_response i… #62134

Merged

Conversation

ockham
Copy link
Contributor

@ockham ockham commented May 30, 2024

Related PR: WordPress/wordpress-develop#6677

What?

Adding another has_filter check before adding the Navigation block's filter to insert hooked blocks into the REST API response for a wp_navigation post type.

Why?

The logic to add hooked blocks to a wp_navigation post type REST responses is being moved into Core, see WordPress/wordpress-develop#6677.

Modeled after #61903.

@ockham ockham added [Type] Code Quality Issues or PRs that relate to code quality [Block] Navigation Affects the Navigation Block [Feature] Block hooks labels May 30, 2024
@ockham ockham self-assigned this May 30, 2024
*/
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) ) {
if (
! has_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response' ) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the main question for this PR is if we're happy with this tentative name (insert_hooked_blocks_into_rest_response).

@ockham ockham marked this pull request as ready for review May 30, 2024 09:43
@ockham ockham requested a review from ajitbohra as a code owner May 30, 2024 09:43
@ockham ockham requested a review from tjcafferkey May 30, 2024 09:43
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ockham <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ packages/block-library/src/navigation/index.php

@ockham
Copy link
Contributor Author

ockham commented May 31, 2024

I'll go ahead and land this, to unblock WordPress/wordpress-develop#6677. It's very low-risk, as it only adds another condition to determine whether or not to add the block_core_navigation_insert_hooked_blocks_into_rest_response filter.

It's very similar in nature to #61903, and will allow us to harmonize the hooked blocks injection code (moving it out of the Navigation block and into Core, see https://core.trac.wordpress.org/ticket/60759).

@ockham ockham merged commit 325c994 into trunk May 31, 2024
70 of 71 checks passed
@ockham ockham deleted the add/has-filter-insert_hooked_blocks_into_rest_response-check branch May 31, 2024 07:45
@github-actions github-actions bot added this to the Gutenberg 18.5 milestone May 31, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jun 4, 2024
…n Core (WordPress#62134)

Adding another `has_filter` check before adding the Navigation block's `block_core_navigation_insert_hooked_blocks_into_rest_response` filter to insert hooked blocks into the REST API response for a `wp_navigation` post type.
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
…n Core (WordPress#62134)

Adding another `has_filter` check before adding the Navigation block's `block_core_navigation_insert_hooked_blocks_into_rest_response` filter to insert hooked blocks into the REST API response for a `wp_navigation` post type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Feature] Block hooks [Type] Code Quality Issues or PRs that relate to code quality
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant