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-section.php

    r32658 r32806  
    502502    }
    503503}
     504
     505/**
     506 * Customize Menu Section Class
     507 *
     508 * Custom section only needed in JS.
     509 *
     510 * @since 4.3.0
     511 */
     512class WP_Customize_Nav_Menu_Section extends WP_Customize_Section {
     513
     514    /**
     515     * Control type.
     516     *
     517     * @since 4.3.0
     518     *
     519     * @access public
     520     * @var string
     521     */
     522    public $type = 'nav_menu';
     523
     524    /**
     525     * Get section params for JS.
     526     *
     527     * @since 4.3.0
     528     *
     529     * @return array
     530     */
     531    function json() {
     532        $exported = parent::json();
     533        $exported['menu_id'] = intval( preg_replace( '/^nav_menu\[(\d+)\]/', '$1', $this->id ) );
     534
     535        return $exported;
     536    }
     537}
     538
     539/**
     540 * Customize Menu Section Class
     541 *
     542 * Implements the new-menu-ui toggle button instead of a regular section.
     543 *
     544 * @since 4.3.0
     545 */
     546class WP_Customize_New_Menu_Section extends WP_Customize_Section {
     547
     548    /**
     549     * Control type.
     550     *
     551     * @since 4.3.0
     552     *
     553     * @access public
     554     * @var string
     555     */
     556    public $type = 'new_menu';
     557
     558    /**
     559     * Render the section, and the controls that have been added to it.
     560     *
     561     * @since 4.3.0
     562     */
     563    protected function render() {
     564        ?>
     565        <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section-new-menu">
     566            <button type="button" class="button-secondary add-new-menu-item add-menu-toggle">
     567                <?php echo esc_html( $this->title ); ?>
     568                <span class="screen-reader-text"><?php _e( 'Press return or enter to open' ); ?></span>
     569            </button>
     570            <ul class="new-menu-section-content"></ul>
     571        </li>
     572        <?php
     573    }
     574}
Note: See TracChangeset for help on using the changeset viewer.