WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/16/2015 10:07:08 PM (6 years ago)
Author:
ocean90
Message:

Add menu management to the Customizer.

This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.

props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.

File:
1 edited

Legend:

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

    r32744 r32806  
    5050    public $widgets;
    5151
     52    /**
     53     * Methods and properties deailing with managing nav menus in the Customizer.
     54     *
     55     * @var WP_Customize_Nav_Menus
     56     */
     57    public $nav_menus;
     58
    5259    protected $settings   = array();
    5360    protected $containers = array();
     
    105112        require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' );
    106113        require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
     114        require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' );
    107115
    108116        $this->widgets = new WP_Customize_Widgets( $this );
     117        $this->nav_menus = new WP_Customize_Nav_Menus( $this );
    109118
    110119        add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
     
    14821491            foreach ( array( 'color', 'image', 'position_x', 'repeat', 'attachment' ) as $prop ) {
    14831492                $this->get_setting( 'background_' . $prop )->transport = 'postMessage';
    1484             }
    1485         }
    1486 
    1487         /* Nav Menus */
    1488 
    1489         $locations      = get_registered_nav_menus();
    1490         $menus          = wp_get_nav_menus();
    1491         $num_locations  = count( array_keys( $locations ) );
    1492 
    1493         if ( 1 == $num_locations ) {
    1494             $description = __( 'Your theme supports one menu. Select which menu you would like to use.' );
    1495         } else {
    1496             $description = sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) );
    1497         }
    1498 
    1499         $this->add_section( 'nav', array(
    1500             'title'          => __( 'Navigation' ),
    1501             'theme_supports' => 'menus',
    1502             'priority'       => 100,
    1503             'description'    => $description . "\n\n" . __( 'You can edit your menu content on the Menus screen in the Appearance section.' ),
    1504         ) );
    1505 
    1506         if ( $menus ) {
    1507             $choices = array( '' => __( '— Select —' ) );
    1508             foreach ( $menus as $menu ) {
    1509                 $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' );
    1510             }
    1511 
    1512             foreach ( $locations as $location => $description ) {
    1513                 $menu_setting_id = "nav_menu_locations[{$location}]";
    1514 
    1515                 $this->add_setting( $menu_setting_id, array(
    1516                     'sanitize_callback' => 'absint',
    1517                     'theme_supports'    => 'menus',
    1518                 ) );
    1519 
    1520                 $this->add_control( $menu_setting_id, array(
    1521                     'label'   => $description,
    1522                     'section' => 'nav',
    1523                     'type'    => 'select',
    1524                     'choices' => $choices,
    1525                 ) );
    15261493            }
    15271494        }
Note: See TracChangeset for help on using the changeset viewer.