Make WordPress Core

Ticket #32672: 32672.3.diff

File 32672.3.diff, 3.2 KB (added by westonruter, 8 years ago)

Additional change: https://github.com/xwp/wordpress-develop/commit/9a4fbe8570237ff9c05242d0876244026b7fc018 All patches: https://github.com/xwp/wordpress-develop/pull/97

  • 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 f94c2d0..e745561 100644
     
    25452545         * @returns {string}
    25462546         */
    25472547        function displayNavMenuName( name ) {
     2548                name = name || '';
    25482549                name = $( '<div>' ).text( name ).html(); // Emulate esc_html() which is used in wp-admin/nav-menus.php.
    25492550                name = $.trim( name );
    25502551                return name || api.Menus.data.l10n.unnamed;
  • 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 7d32cbb..e7b7e0f 100644
    final class WP_Customize_Nav_Menus { 
    433433                        'description' => $description,
    434434                ) );
    435435
    436                 // @todo if ( ! $menus ) : make a "default" menu
    437                 if ( $menus ) {
    438                         $choices = array( '0' => __( '&mdash; Select &mdash;' ) );
    439                         foreach ( $menus as $menu ) {
    440                                 $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
    441                         }
    442 
    443                         foreach ( $locations as $location => $description ) {
    444                                 $setting_id = "nav_menu_locations[{$location}]";
    445 
    446                                 $setting = $this->manager->get_setting( $setting_id );
    447                                 if ( $setting ) {
    448                                         $setting->transport = 'postMessage';
    449                                         remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
    450                                         add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
    451                                 } else {
    452                                         $this->manager->add_setting( $setting_id, array(
    453                                                 'sanitize_callback' => array( $this, 'intval_base10' ),
    454                                                 'theme_supports'    => 'menus',
    455                                                 'type'              => 'theme_mod',
    456                                                 'transport'         => 'postMessage',
    457                                         ) );
    458                                 }
     436                $choices = array( '0' => __( '&mdash; Select &mdash;' ) );
     437                foreach ( $menus as $menu ) {
     438                        $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
     439                }
    459440
    460                                 $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
    461                                         'label'       => $description,
    462                                         'location_id' => $location,
    463                                         'section'     => 'menu_locations',
    464                                         'choices'     => $choices,
    465                                 ) ) );
     441                foreach ( $locations as $location => $description ) {
     442                        $setting_id = "nav_menu_locations[{$location}]";
     443
     444                        $setting = $this->manager->get_setting( $setting_id );
     445                        if ( $setting ) {
     446                                $setting->transport = 'postMessage';
     447                                remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
     448                                add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
     449                        } else {
     450                                $this->manager->add_setting( $setting_id, array(
     451                                        'sanitize_callback' => array( $this, 'intval_base10' ),
     452                                        'theme_supports'    => 'menus',
     453                                        'type'              => 'theme_mod',
     454                                        'transport'         => 'postMessage',
     455                                ) );
    466456                        }
     457
     458                        $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
     459                                'label'       => $description,
     460                                'location_id' => $location,
     461                                'section'     => 'menu_locations',
     462                                'choices'     => $choices,
     463                        ) ) );
    467464                }
    468465
    469466                // Register each menu as a Customizer section, and add each menu item to each menu.