Make WordPress Core


Ignore:
Timestamp:
05/16/2016 07:21:22 AM (9 years ago)
Author:
westonruter
Message:

Customize: Include shortcut button in Custom Menu widget to edit the selected menu in the Customizer.

Clicking on the Edit Menu button focuses on the corresponding nav menu section. Upon collapsing the nav menu section, the focus is returned to the Custom Menu widget instead of taking the user to the menus root panel. In this way, the back button behavior is modified once to serve as breadcrumb/history navigation. The Edit Menu button with the breadcrumb back button behavior greatly reduce the number of UI interactions needed to edit a menu referenced in a Custom Menu widget.

Props celloexpressions, westonruter.
Fixes #32683.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-nav-menu-widget.php

    r37040 r37437  
    1515 * @see WP_Widget
    1616 */
    17  class WP_Nav_Menu_Widget extends WP_Widget {
     17class WP_Nav_Menu_Widget extends WP_Widget {
    1818
    1919    /**
     
    111111     *
    112112     * @param array $instance Current settings.
     113     * @global WP_Customize_Manager $wp_customize
    113114     */
    114115    public function form( $instance ) {
     116        global $wp_customize;
    115117        $title = isset( $instance['title'] ) ? $instance['title'] : '';
    116118        $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
     
    123125        <p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>>
    124126            <?php
    125             if ( isset( $GLOBALS['wp_customize'] ) && $GLOBALS['wp_customize'] instanceof WP_Customize_Manager ) {
     127            if ( $wp_customize instanceof WP_Customize_Manager ) {
    126128                $url = 'javascript: wp.customize.panel( "nav_menus" ).focus();';
    127129            } else {
     
    147149                </select>
    148150            </p>
     151            <?php if ( $wp_customize instanceof WP_Customize_Manager ) : ?>
     152                <p class="edit-selected-nav-menu" style="<?php if ( ! $nav_menu ) { echo 'display: none;'; } ?>">
     153                    <button type="button" class="button"><?php _e( 'Edit Menu' ) ?></button>
     154                </p>
     155            <?php endif; ?>
    149156        </div>
    150157        <?php
Note: See TracChangeset for help on using the changeset viewer.