Skip to content

Block Library: Add filter for inner blocks in the Navigation block#37998

Merged
gziolo merged 4 commits intoWordPress:trunkfrom
afragen:add-core-nav-filter
Sep 13, 2022
Merged

Block Library: Add filter for inner blocks in the Navigation block#37998
gziolo merged 4 commits intoWordPress:trunkfrom
afragen:add-core-nav-filter

Conversation

@afragen
Copy link
Copy Markdown
Member

@afragen afragen commented Jan 15, 2022

Description

Add filter to navigation.php to add ability to modify navigation block menu items.

Fixes #37717

Types of changes

New feature: filter menu items of navigation block.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
  • I've updated related schemas if appropriate.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jan 15, 2022
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @afragen! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Soean Soean added the [Block] Navigation Affects the Navigation Block label Jan 15, 2022
*
* @param \WP_Block_List $inner_blocks
*/
$inner_blocks = apply_filters( 'render_block_core_navigation_inner_blocks', $inner_blocks );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is one filter that uses a different naming pattern. Let's align it with:

/**
* Filters the fallback experience for the Navigation block.
*
* Returning a falsey value will opt out of the fallback and cause the block not to render.
* To customise the blocks provided return an array of blocks - these should be valid
* children of the `core/navigation` block.
*
* @since 5.9.0
*
* @param array[] default fallback blocks provided by the default block mechanic.
*/
return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks );

@gziolo gziolo changed the title add filter to $inner_blocks Block Library: Add filter for inner blocks in the Navigation block Sep 13, 2022
@gziolo gziolo added [Package] Block library /packages/block-library [Feature] Extensibility The ability to extend blocks or the editing experience [Type] New API New API to be used by plugin developers or package users. Needs Dev Note Requires a developer note for a major WordPress release cycle labels Sep 13, 2022
Copy link
Copy Markdown
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

@afragen, thank you for your contribution.

@gziolo gziolo merged commit 5ce0149 into WordPress:trunk Sep 13, 2022
@github-actions github-actions bot added this to the Gutenberg 14.1 milestone Sep 13, 2022
@gziolo gziolo mentioned this pull request Sep 13, 2022
6 tasks
@bph bph mentioned this pull request Sep 14, 2022
89 tasks
@afragen afragen deleted the add-core-nav-filter branch September 22, 2022 21:21
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] Extensibility The ability to extend blocks or the editing experience First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Needs Dev Note Requires a developer note for a major WordPress release cycle [Package] Block library /packages/block-library [Type] New API New API to be used by plugin developers or package users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filter allow modification of navigation block menu items

3 participants