[wp-trac] [WordPress Trac] #19272: Add Filter to Nav Menu Support Themes Text

WordPress Trac noreply at wordpress.org
Wed Jun 8 19:54:33 UTC 2022


#19272: Add Filter to Nav Menu Support Themes Text
-------------------------------------------------+-------------------------
 Reporter:  wpsmith                              |       Owner:
                                                 |  bhargavbhandari90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Menus                                |     Version:
 Severity:  trivial                              |  Resolution:
 Keywords:  good-first-bug has-patch needs-docs  |     Focuses:
  dev-feedback needs-refresh                     |
-------------------------------------------------+-------------------------
Description changed by SergeyBiryukov:

Old description:

> Frameworks could use a filter here to customize the message: _n('Your
> theme supports %s menu. Select which menu you would like to use.', 'Your
> theme supports %s menus. Select which menu appears in each location.',
> $num_locations ). For example, it may be the child theme that doesn't
> support the menus. Also, if none are supported (say via
> add_theme_support), then when it's zero, it says: "Your theme supports 0
> menus. Select which menu appears in each location." (which doesn't make
> much sense). So adding a filter can enable theme developers to further
> customize.
>
> An example use case:
> add_filter( 'nav_menu_theme_support_text' ,
> 'wps_nav_menu_theme_support_text' );
> function wps_nav_menu_theme_support_text ( $num_locations ) {
>         if ( $num_locations == 0 )
>                 $text = 'Your child theme does not support custom
> menus.';
>         else
>                 $text = _n('Your theme supports %s menu. Select which
> menu you would like to use.', 'Your theme supports %s menus. Select which
> menu appears in each location.', $num_locations );
>         return $text;
> }

New description:

 Frameworks could use a filter here to customize the message: `_n('Your
 theme supports %s menu. Select which menu you would like to use.', 'Your
 theme supports %s menus. Select which menu appears in each location.',
 $num_locations )`. For example, it may be the child theme that doesn't
 support the menus. Also, if none are supported (say via
 add_theme_support), then when it's zero, it says: "Your theme supports 0
 menus. Select which menu appears in each location." (which doesn't make
 much sense). So adding a filter can enable theme developers to further
 customize.

 An example use case:
 {{{
 add_filter( 'nav_menu_theme_support_text' ,
 'wps_nav_menu_theme_support_text' );
 function wps_nav_menu_theme_support_text ( $num_locations ) {
         if ( $num_locations == 0 )
                 $text = 'Your child theme does not support custom menus.';
         else
                 $text = _n('Your theme supports %s menu. Select which menu
 you would like to use.', 'Your theme supports %s menus. Select which menu
 appears in each location.', $num_locations );
         return $text;
 }
 }}}

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/19272#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list