#35203 closed enhancement (fixed)
Capacity to change the type label in set nav menu items in Customize
Reported by: | joe_bopper | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | Customize | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Currently the Customize interface outputs all non-default item type labels as "Custom Link" on first load, even though they may have been added by a different item type (using the hooks customize_nav_menu_available_items and customize_nav_menu_available_item_types). The only thing needed to fix this is to add a filter hook into the function wp_customize_nav_menu_item_setting::value_as_wp_post_nav_menu_item, I believe. It'd be best to behave similarly to the wp_setup_nav_menu_item hook.
Cheers.
Attachments (2)
Change History (9)
#1
@
8 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 4.6
- Version set to 4.3
Good idea @joe_bopper! 35203.diff introduces a customize_setup_nav_menu_item
filter, which behaves the same way as wp_setup_nav_menu_item
, but is named differently in case in needs to be used differently for items in the customizer. It makes the two filters for more specific properties redundant, but we probably can't remove those at this point.
For the issue mentioned in the ticket description, this can now be used as:
add_filter( 'customize_setup_nav_men_item', function( $menu_item ) { if ( conditional ) { $menu_item->type_label = __( 'Something Else' ); } return $menu_item; }
@westonruter, are you okay with the naming of this? It's derived from this function's derivation from wp_setup_nav_menu_item()
.
#2
@
8 years ago
@celloexpressions there is already a wp_setup_nav_menu_item
filter that applies in wp_setup_nav_menu_item()
. This actually will be getting called in WP_Customize_Nav_Menu_Item_Setting::value()
if the initial value
is not passed in up front (to save on performance). So I think what is needed is just to apply wp_setup_nav_menu_item
filters at the end of WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()
. This should result in the proper type_label
appearing on the nav menus admin page as well.
#3
@
8 years ago
We could use the same filter, but I think there may be some instances where you'd need different handling here. Can't think of a specific example right now though, so I'd be fine with reusing wp_setup_nav_menu_item
directly.
Would just switch wp
for customize
in the patch.
Introduce
customize_setup_nav_menu_item
filter to allow modifications to nav-menu-item as wp_post objects in the Customizer.