WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 8 weeks ago

#19272 assigned enhancement

Add Filter to Nav Menu Support Themes Text

Reported by: wpsmith Owned by: bhargavbhandari90
Milestone: Awaiting Review Priority: normal
Severity: trivial Version:
Component: Menus Keywords: good-first-bug good-first-patch has-patch needs-testing
Focuses: Cc:

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;

}

Attachments (3)

nav_menu_theme_support_text.patch (939 bytes) - added by wpsmith 4 years ago.
refreshed-nav_menu_theme_support_text.diff (996 bytes) - added by horike 9 months ago.
ticket#19272.patch (1.1 KB) - added by bhargavbhandari90 5 months ago.
Check with this. As we applying filter to a string so add

Download all attachments as: .zip

Change History (8)

comment:1 @chriscct79 months ago

  • Keywords good-first-bug good-first-patch needs-refresh added; has-patch removed

Needs to be refreshed because of #24945

comment:2 @horike9 months ago

  • Keywords has-patch added; needs-refresh removed

comment:3 @Yahire Furniture8 months ago

  • Keywords needs-testing added

@bhargavbhandari905 months ago

Check with this. As we applying filter to a string so add

comment:4 in reply to: ↑ description @bhargavbhandari905 months ago

Replying to wpsmith:

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;

}

As we are applying filters to string, so add filter will contain two arguments so $num_locations should be 2nd argument..

comment:5 @obenland8 weeks ago

  • Owner set to bhargavbhandari90
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.