Theme Customizer: Simplify logic when preparing menu controls. Include instructions to edit menu content in section description. Add string for default state. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20572 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2407473309
commit
e73e1f4e5d
@ -632,30 +632,32 @@ final class WP_Customize {
|
||||
'title' => __( 'Navigation' ),
|
||||
'theme_supports' => 'menus',
|
||||
'priority' => 40,
|
||||
'description' => sprintf( _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 ), number_format_i18n( $num_locations ) ),
|
||||
'description' => sprintf( _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 ), number_format_i18n( $num_locations ) ) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'),
|
||||
) );
|
||||
|
||||
foreach ( $locations as $location => $description ) {
|
||||
$choices = array( 0 => '' );
|
||||
if ( $menus ) {
|
||||
$choices = array( 0 => __( '— Select —' ) );
|
||||
foreach ( $menus as $menu ) {
|
||||
$truncated_name = wp_html_excerpt( $menu->name, 40 );
|
||||
$truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…';
|
||||
$truncated_name = ( $truncated_name == $menu->name ) ? $menu->name : trim( $truncated_name ) . '…';
|
||||
$choices[ $menu->term_id ] = $truncated_name;
|
||||
}
|
||||
|
||||
$menu_setting_id = "nav_menu_locations[{$location}]";
|
||||
foreach ( $locations as $location => $description ) {
|
||||
$menu_setting_id = "nav_menu_locations[{$location}]";
|
||||
|
||||
$this->add_setting( $menu_setting_id, array(
|
||||
'sanitize_callback' => 'absint',
|
||||
'theme_supports' => 'menus',
|
||||
) );
|
||||
$this->add_setting( $menu_setting_id, array(
|
||||
'sanitize_callback' => 'absint',
|
||||
'theme_supports' => 'menus',
|
||||
) );
|
||||
|
||||
$this->add_control( $menu_setting_id, array(
|
||||
'label' => $description,
|
||||
'section' => 'nav',
|
||||
'type' => 'select',
|
||||
'choices' => $choices,
|
||||
) );
|
||||
$this->add_control( $menu_setting_id, array(
|
||||
'label' => $description,
|
||||
'section' => 'nav',
|
||||
'type' => 'select',
|
||||
'choices' => $choices,
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Static Front Page */
|
||||
|
Loading…
x
Reference in New Issue
Block a user