-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Allow filtering of Nav block fallback #36850
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getdave
added
[Block] Navigation
Affects the Navigation Block
Backport to WP 6.7 Beta/RC
Pull request that needs to be backported to the WordPress major release that's currently in beta
labels
Nov 25, 2021
cc @fklein-lu also for review |
adamziel
approved these changes
Nov 25, 2021
getdave
commented
Nov 25, 2021
@@ -187,6 +187,7 @@ function( $block ) { | |||
* @return array the array of blocks to be used as a fallback. | |||
*/ | |||
function block_core_navigation_get_fallback_blocks() { | |||
|
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.
Suggested change
Let's leave this open overnight (UTC) to see if there's further feedback. If I don't receive any then I'll merge this based on @adamziel's 👍 |
Cheers for the quick follow up 👍 |
getdave
force-pushed
the
fix/make-nav-block-fallback-filterable
branch
from
November 25, 2021 16:18
b93b623
to
4750be3
Compare
38 tasks
Ok as there was no further feedback I will merge this. |
noisysocks
removed
the
Backport to WP 6.7 Beta/RC
Pull request that needs to be backported to the WordPress major release that's currently in beta
label
Nov 29, 2021
noisysocks
pushed a commit
that referenced
this pull request
Nov 29, 2021
* Create filter and improve output validity test * Document the filter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In #36740 (comment) we introduced a specific fallback mechanic for the Nav block front-of-site rendering for the case where a Menu was not specifically assigned to the block.
This aimed to follow the existing code patterns set by
wp_nav_menu
.That PR didn't handle allowing developers to filter the fallback output of the block. This PR enables that via the introduction of a block-specific filter
block_core_navigation_render_fallback
.This is important because traditionally Theme developers have had the option to opt-out of the
wp_nav_menu
's fallback mechanic via thefallback_cb
argument that you can pass to that function.This PR replicates that. Developers can now do this to opt out of rendering a fallback:
Alternatively they can return their own list of blocks to act as a fallback with the caveat that these blocks must be valid as children of the
core/navigation
block.If folks are in favour of merging this PR then I'll document the filter.
Note this overlaps with #36849. If/when that is merged then we'll consolidate the "empty" checking mechanics.
How has this been tested?
core/page-list
block used to render the default fallback experience.mu-plugin
, but you could simply add to your Theme'sfunctions.php
:Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).