mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
6485e5e3cf
While "Menu/Theme locations" was descriptive of what the choices listed were, in the context of editing an individual nav menu it is more descriptive to use a setting label that tells you what it is you are affecting for that nav menu, which is where it will be displayed. Technically multiple locations can be chosen, but in practice that appears to be rare enough that we can avoid an awkward "location(s)" type string. props Fencer04 for the initial patch. fixes #38525. Built from https://develop.svn.wordpress.org/trunk@39098 git-svn-id: http://core.svn.wordpress.org/trunk@39040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
103 lines
2.9 KiB
PHP
103 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Customize API: WP_Customize_Nav_Menu_Control class
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Customize
|
|
* @since 4.4.0
|
|
*/
|
|
|
|
/**
|
|
* Customize Nav Menu Control Class.
|
|
*
|
|
* @since 4.3.0
|
|
*/
|
|
class WP_Customize_Nav_Menu_Control extends WP_Customize_Control {
|
|
|
|
/**
|
|
* Control type.
|
|
*
|
|
* @since 4.3.0
|
|
* @access public
|
|
* @var string
|
|
*/
|
|
public $type = 'nav_menu';
|
|
|
|
/**
|
|
* The nav menu setting.
|
|
*
|
|
* @since 4.3.0
|
|
* @access public
|
|
* @var WP_Customize_Nav_Menu_Setting
|
|
*/
|
|
public $setting;
|
|
|
|
/**
|
|
* Don't render the control's content - it uses a JS template instead.
|
|
*
|
|
* @since 4.3.0
|
|
* @access public
|
|
*/
|
|
public function render_content() {}
|
|
|
|
/**
|
|
* JS/Underscore template for the control UI.
|
|
*
|
|
* @since 4.3.0
|
|
* @access public
|
|
*/
|
|
public function content_template() {
|
|
?>
|
|
<button type="button" class="button add-new-menu-item" aria-label="<?php esc_attr_e( 'Add or remove menu items' ); ?>" aria-expanded="false" aria-controls="available-menu-items">
|
|
<?php _e( 'Add Items' ); ?>
|
|
</button>
|
|
<button type="button" class="button-link reorder-toggle" aria-label="<?php esc_attr_e( 'Reorder menu items' ); ?>" aria-describedby="reorder-items-desc-{{ data.menu_id }}">
|
|
<span class="reorder"><?php _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span>
|
|
<span class="reorder-done"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span>
|
|
</button>
|
|
<p class="screen-reader-text" id="reorder-items-desc-{{ data.menu_id }}"><?php _e( 'When in reorder mode, additional controls to reorder menu items will be available in the items list above.' ); ?></p>
|
|
<span class="menu-delete-item">
|
|
<button type="button" class="button-link menu-delete">
|
|
<?php _e( 'Delete Menu' ); ?>
|
|
</button>
|
|
</span>
|
|
<?php if ( current_theme_supports( 'menus' ) ) : ?>
|
|
<ul class="menu-settings">
|
|
<li class="customize-control">
|
|
<span class="customize-control-title"><?php _e( 'Display Location' ); ?></span>
|
|
</li>
|
|
|
|
<?php foreach ( get_registered_nav_menus() as $location => $description ) : ?>
|
|
<li class="customize-control customize-control-checkbox assigned-menu-location">
|
|
<label>
|
|
<input type="checkbox" data-menu-id="{{ data.menu_id }}" data-location-id="<?php echo esc_attr( $location ); ?>" class="menu-location" /> <?php echo $description; ?>
|
|
<span class="theme-location-set"><?php
|
|
/* translators: %s: menu name */
|
|
printf( _x( '(Current: %s)', 'menu location' ),
|
|
'<span class="current-menu-location-name-' . esc_attr( $location ) . '"></span>'
|
|
);
|
|
?></span>
|
|
</label>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
<?php endif;
|
|
}
|
|
|
|
/**
|
|
* Return parameters for this control.
|
|
*
|
|
* @since 4.3.0
|
|
* @access public
|
|
*
|
|
* @return array Exported parameters.
|
|
*/
|
|
public function json() {
|
|
$exported = parent::json();
|
|
$exported['menu_id'] = $this->setting->term_id;
|
|
|
|
return $exported;
|
|
}
|
|
}
|