]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/customize/class-wp-customize-nav-menu-location-control.php
WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / customize / class-wp-customize-nav-menu-location-control.php
1 <?php
2 /**
3  * Customize API: WP_Customize_Nav_Menu_Location_Control class
4  *
5  * @package WordPress
6  * @subpackage Customize
7  * @since 4.4.0
8  */
9
10 /**
11  * Customize Menu Location Control Class.
12  *
13  * This custom control is only needed for JS.
14  *
15  * @since 4.3.0
16  *
17  * @see WP_Customize_Control
18  */
19 class WP_Customize_Nav_Menu_Location_Control extends WP_Customize_Control {
20
21         /**
22          * Control type.
23          *
24          * @since 4.3.0
25          * @access public
26          * @var string
27          */
28         public $type = 'nav_menu_location';
29
30         /**
31          * Location ID.
32          *
33          * @since 4.3.0
34          * @access public
35          * @var string
36          */
37         public $location_id = '';
38
39         /**
40          * Refresh the parameters passed to JavaScript via JSON.
41          *
42          * @since 4.3.0
43          * @access public
44          *
45          * @see WP_Customize_Control::to_json()
46          */
47         public function to_json() {
48                 parent::to_json();
49                 $this->json['locationId'] = $this->location_id;
50         }
51
52         /**
53          * Render content just like a normal select control.
54          *
55          * @since 4.3.0
56          * @access public
57          */
58         public function render_content() {
59                 if ( empty( $this->choices ) ) {
60                         return;
61                 }
62                 ?>
63                 <label>
64                         <?php if ( ! empty( $this->label ) ) : ?>
65                         <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
66                         <?php endif; ?>
67
68                         <?php if ( ! empty( $this->description ) ) : ?>
69                         <span class="description customize-control-description"><?php echo $this->description; ?></span>
70                         <?php endif; ?>
71
72                         <select <?php $this->link(); ?>>
73                                 <?php
74                                 foreach ( $this->choices as $value => $label ) :
75                                         echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
76                                 endforeach;
77                                 ?>
78                         </select>
79                 </label>
80                 <?php
81         }
82 }