-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmenu_dropdown_custom_control.php
33 lines (32 loc) · 1.07 KB
/
menu_dropdown_custom_control.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
if (class_exists('WP_Customize_Control'))
{
/**
* Class to create a custom menu control
*/
class Menu_Dropdown_Custom_control extends WP_Customize_Control
{
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
?>
<label>
<span class="customize-menu-dropdown"><?php echo esc_html( $this->label ); ?></span>
<select name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>">
<?php
$menus = wp_get_nav_menus($args);
if($menus){
foreach ( $menus as $menu ) {
echo '<option value="'.$menu->term_id.'"'.selected($this->value, $menu->term_id).'>'.$menu->name.'</option>';
}
}
?>
</select>
</label>
<?php
}
}
}
?>