Make WordPress Core

Ticket #32672: 32672.diff

File 32672.diff, 2.7 KB (added by markoheijnen, 8 years ago)
  • src/wp-includes/class-wp-customize-nav-menus.php

     
    403403                        'description' => $description,
    404404                ) );
    405405
    406                 // @todo if ( ! $menus ) : make a "default" menu
    407                 if ( $menus ) {
    408                         $choices = array( '0' => __( '— Select —' ) );
    409                         foreach ( $menus as $menu ) {
    410                                 $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
    411                         }
     406                $choices = array( '0' => __( '— Select —' ) );
     407                foreach ( $menus as $menu ) {
     408                        $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
     409                }
    412410
    413                         foreach ( $locations as $location => $description ) {
    414                                 $setting_id = "nav_menu_locations[{$location}]";
     411                foreach ( $locations as $location => $description ) {
     412                        $setting_id = "nav_menu_locations[{$location}]";
    415413
    416                                 $setting = $this->manager->get_setting( $setting_id );
    417                                 if ( $setting ) {
    418                                         $setting->transport = 'postMessage';
    419                                         remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
    420                                         add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
    421                                 } else {
    422                                         $this->manager->add_setting( $setting_id, array(
    423                                                 'sanitize_callback' => array( $this, 'intval_base10' ),
    424                                                 'theme_supports'    => 'menus',
    425                                                 'type'              => 'theme_mod',
    426                                                 'transport'         => 'postMessage',
    427                                         ) );
    428                                 }
     414                        $setting = $this->manager->get_setting( $setting_id );
     415                        if ( $setting ) {
     416                                $setting->transport = 'postMessage';
     417                                remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
     418                                add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
     419                        } else {
     420                                $this->manager->add_setting( $setting_id, array(
     421                                        'sanitize_callback' => array( $this, 'intval_base10' ),
     422                                        'theme_supports'    => 'menus',
     423                                        'type'              => 'theme_mod',
     424                                        'transport'         => 'postMessage',
     425                                ) );
     426                        }
    429427
    430                                 $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
    431                                         'label'       => $description,
    432                                         'location_id' => $location,
    433                                         'section'     => 'menu_locations',
    434                                         'choices'     => $choices,
    435                                 ) ) );
    436                         }
     428                        $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
     429                                'label'       => $description,
     430                                'location_id' => $location,
     431                                'section'     => 'menu_locations',
     432                                'choices'     => $choices,
     433                        ) ) );
    437434                }
    438435
    439436                // Register each menu as a Customizer section, and add each menu item to each menu.