-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Ability to add custom Navigation area types #36373
Comments
@anton-vlasenko Might you be able to help out with this one? |
@getdave I think there's already a I don't know that a filter is needed given the function already exists. Could you add a use case for such a filter to the issue description? |
Hi Dan. If
|
Lets move the conversation over here.
I think it's fine to let users change the public facing names of a navigation area (e.g. from 'Primary' to 'Header'). But we should do our best to promote keeping the 'keys' ( Perhaps something like this would make it clearer and more declarative for users: register_navigation_area( array(
// These three areas will migrate menus on theme switch
array(
'name' => 'Header',
'type' => WP_NAVIGATION_AREA_PRIMARY
),
array(
'name' => 'Footer',
'type' => WP_NAVIGATION_AREA_SECONDARY
),
array(
'name' => 'Sidebar',
'type' => WP_NAVIGATION_AREA_TERTIARY
),
) ); I think it might be a problem that we only support three 'types' or 'keys' at the moment. Should we add more names (like you mentioned with quaternary, quinary, senary, septenary, octonary, nonary, denary?).
Filters usually also allow overwriting, they can return completely different data. That's why I'd prefer a A filter is also something to consider in the future, but there should be a clear use case for it.
There are lots of 'register' functions across the WordPress codebase: https://wordpress.org/search/register_ |
Sorry for the delay. |
For reference, here's an example of how it works currently: Perhaps it's ok. We should definitely test that it works for themes. Maybe we can try it out in Twenty Twenty Two or one of the theme experiments. I think it could be an idea to improve the docs to recommend not changing the default (primary, secondary, tertiary) keys in the array, and also include examples that show registering more than just the default areas as well as using different names. e.g.: register_navigation_areas(
array(
'primary' => _x( 'Header', 'navigation area' ),
'secondary' => _x( 'Footer', 'navigation area' ),
'tertiary' => _x( 'Sidebar', 'navigation area' ),
'shop'. => _x( 'Shop sub-navigation', 'navigation area' ),
)
); |
Nothing stops us from disallowing developers to change the default keys via the filter programmatically while allowing them to change titles. |
What problem does this address?
Currently, out of the box the Navigation Area block supports
Developers should be able to extend this list.
What is your proposed solution?
Add a filter or provide some other means of extending the list of areas.
The text was updated successfully, but these errors were encountered: