Make WordPress Core

Ticket #32672: 32672.2.diff

File 32672.2.diff, 3.3 KB (added by valendesigns, 8 years ago)
  • src/wp-admin/js/customize-nav-menus.js

    diff --git src/wp-admin/js/customize-nav-menus.js src/wp-admin/js/customize-nav-menus.js
    index e9ee86f..ff6b1a2 100644
     
    893893                        // Add/remove menus from the available options when they are added and removed.
    894894                        api.bind( 'add', function( setting ) {
    895895                                var option, menuId, matches = setting.id.match( navMenuIdRegex );
    896                                 if ( ! matches || false === setting() ) {
     896                                if ( ! matches || 'undefined' === typeof setting().name ) {
    897897                                        return;
    898898                                }
    899899                                menuId = matches[1];
  • src/wp-includes/class-wp-customize-nav-menus.php

    diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
    index 7fbbda8..28cf4a1 100644
    final class WP_Customize_Nav_Menus { 
    420420                        'description' => $description,
    421421                ) );
    422422
    423                 // @todo if ( ! $menus ) : make a "default" menu
    424                 if ( $menus ) {
    425                         $choices = array( '0' => __( '— Select —' ) );
    426                         foreach ( $menus as $menu ) {
    427                                 $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
    428                         }
    429 
    430                         foreach ( $locations as $location => $description ) {
    431                                 $setting_id = "nav_menu_locations[{$location}]";
    432 
    433                                 $setting = $this->manager->get_setting( $setting_id );
    434                                 if ( $setting ) {
    435                                         $setting->transport = 'postMessage';
    436                                         remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
    437                                         add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
    438                                 } else {
    439                                         $this->manager->add_setting( $setting_id, array(
    440                                                 'sanitize_callback' => array( $this, 'intval_base10' ),
    441                                                 'theme_supports'    => 'menus',
    442                                                 'type'              => 'theme_mod',
    443                                                 'transport'         => 'postMessage',
    444                                         ) );
    445                                 }
     423                $choices = array( '0' => __( '— Select —' ) );
     424                foreach ( $menus as $menu ) {
     425                        $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
     426                }
    446427
    447                                 $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
    448                                         'label'       => $description,
    449                                         'location_id' => $location,
    450                                         'section'     => 'menu_locations',
    451                                         'choices'     => $choices,
    452                                 ) ) );
     428                foreach ( $locations as $location => $description ) {
     429                        $setting_id = "nav_menu_locations[{$location}]";
     430
     431                        $setting = $this->manager->get_setting( $setting_id );
     432                        if ( $setting ) {
     433                                $setting->transport = 'postMessage';
     434                                remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
     435                                add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
     436                        } else {
     437                                $this->manager->add_setting( $setting_id, array(
     438                                        'sanitize_callback' => array( $this, 'intval_base10' ),
     439                                        'theme_supports'    => 'menus',
     440                                        'type'              => 'theme_mod',
     441                                        'transport'         => 'postMessage',
     442                                ) );
    453443                        }
     444
     445                        $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
     446                                'label'       => $description,
     447                                'location_id' => $location,
     448                                'section'     => 'menu_locations',
     449                                'choices'     => $choices,
     450                        ) ) );
    454451                }
    455452
    456453                // Register each menu as a Customizer section, and add each menu item to each menu.