WordPress.org

Make WordPress Core

Changeset 20572


Ignore:
Timestamp:
04/23/2012 11:03:09 PM (8 years ago)
Author:
koopersmith
Message:

Theme Customizer: Simplify logic when preparing menu controls. Include instructions to edit menu content in section description. Add string for default state. see #19910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize.php

    r20545 r20572  
    633633            'theme_supports' => 'menus',
    634634            'priority'       => 40,
    635             '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 ) ),
    636         ) );
    637 
    638         foreach ( $locations as $location => $description ) {
    639             $choices = array( 0 => '' );
     635            '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.'),
     636        ) );
     637
     638        if ( $menus ) {
     639            $choices = array( 0 => __( '— Select —' ) );
    640640            foreach ( $menus as $menu ) {
    641641                $truncated_name = wp_html_excerpt( $menu->name, 40 );
    642                 $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…';
     642                $truncated_name = ( $truncated_name == $menu->name ) ? $menu->name : trim( $truncated_name ) . '…';
    643643                $choices[ $menu->term_id ] = $truncated_name;
    644644            }
    645645
    646             $menu_setting_id = "nav_menu_locations[{$location}]";
    647 
    648             $this->add_setting( $menu_setting_id, array(
    649                 'sanitize_callback' => 'absint',
    650                 'theme_supports'    => 'menus',
    651             ) );
    652 
    653             $this->add_control( $menu_setting_id, array(
    654                 'label'   => $description,
    655                 'section' => 'nav',
    656                 'type'    => 'select',
    657                 'choices' => $choices,
    658             ) );
     646            foreach ( $locations as $location => $description ) {
     647                $menu_setting_id = "nav_menu_locations[{$location}]";
     648
     649                $this->add_setting( $menu_setting_id, array(
     650                    'sanitize_callback' => 'absint',
     651                    'theme_supports'    => 'menus',
     652                ) );
     653
     654                $this->add_control( $menu_setting_id, array(
     655                    'label'   => $description,
     656                    'section' => 'nav',
     657                    'type'    => 'select',
     658                    'choices' => $choices,
     659                ) );
     660            }
    659661        }
    660662
Note: See TracChangeset for help on using the changeset viewer.