]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/customize/class-wp-customize-nav-menu-control.php
WordPress 4.4.1
[autoinstalls/wordpress.git] / wp-includes / customize / class-wp-customize-nav-menu-control.php
1 <?php
2 /**
3  * Customize API: WP_Customize_Nav_Menu_Control class
4  *
5  * @package WordPress
6  * @subpackage Customize
7  * @since 4.4.0
8  */
9
10 /**
11  * Customize Nav Menu Control Class.
12  *
13  * @since 4.3.0
14  */
15 class WP_Customize_Nav_Menu_Control extends WP_Customize_Control {
16
17         /**
18          * Control type.
19          *
20          * @since 4.3.0
21          * @access public
22          * @var string
23          */
24         public $type = 'nav_menu';
25
26         /**
27          * The nav menu setting.
28          *
29          * @since 4.3.0
30          * @access public
31          * @var WP_Customize_Nav_Menu_Setting
32          */
33         public $setting;
34
35         /**
36          * Don't render the control's content - it uses a JS template instead.
37          *
38          * @since 4.3.0
39          * @access public
40          */
41         public function render_content() {}
42
43         /**
44          * JS/Underscore template for the control UI.
45          *
46          * @since 4.3.0
47          * @access public
48          */
49         public function content_template() {
50                 ?>
51                 <button type="button" class="button-secondary add-new-menu-item" aria-label="<?php esc_attr_e( 'Add or remove menu items' ); ?>" aria-expanded="false" aria-controls="available-menu-items">
52                         <?php _e( 'Add Items' ); ?>
53                 </button>
54                 <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 }}">
55                         <span class="reorder"><?php _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span>
56                         <span class="reorder-done"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span>
57                 </button>
58                 <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>
59                 <span class="menu-delete-item">
60                         <button type="button" class="button-link menu-delete">
61                                 <?php _e( 'Delete Menu' ); ?>
62                         </button>
63                 </span>
64                 <?php if ( current_theme_supports( 'menus' ) ) : ?>
65                 <ul class="menu-settings">
66                         <li class="customize-control">
67                                 <span class="customize-control-title"><?php _e( 'Menu locations' ); ?></span>
68                         </li>
69
70                         <?php foreach ( get_registered_nav_menus() as $location => $description ) : ?>
71                         <li class="customize-control customize-control-checkbox assigned-menu-location">
72                                 <label>
73                                         <input type="checkbox" data-menu-id="{{ data.menu_id }}" data-location-id="<?php echo esc_attr( $location ); ?>" class="menu-location" /> <?php echo $description; ?>
74                                         <span class="theme-location-set"><?php
75                                                 /* translators: %s: menu name */
76                                                 printf( _x( '(Current: %s)', 'menu location' ),
77                                                         '<span class="current-menu-location-name-' . esc_attr( $location ) . '"></span>'
78                                                 );
79                                         ?></span>
80                                 </label>
81                         </li>
82                         <?php endforeach; ?>
83
84                 </ul>
85                 <?php endif;
86         }
87
88         /**
89          * Return parameters for this control.
90          *
91          * @since 4.3.0
92          * @access public
93          *
94          * @return array Exported parameters.
95          */
96         public function json() {
97                 $exported            = parent::json();
98                 $exported['menu_id'] = $this->setting->term_id;
99
100                 return $exported;
101         }
102 }