PluginProbe
QuadMenu – Mega Menu / 1.8.9
QuadMenu – Mega Menu v1.8.9
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / includes / widget.php

widget.php in QuadMenu – Mega Menu 1.8.9, at includes/widget.php

132 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 die('-1');
4 }
5
6 function quadmenu_load_widget() {
7 register_widget('quadmenu_widget');
8 }
9
10 add_action('widgets_init', 'quadmenu_load_widget');
11
12 class QuadMenu_Widget extends WP_Widget {
13
14 function __construct() {
15 self::QuadMenu_Widget();
16 }
17
18 function QuadMenu_Widget() {
19
20 $widget_ops = array('classname' => 'widget_quadmenu_widget', 'description' => esc_html__('A widget that displays the menu in the sidebar.', 'quadmenu'));
21
22 $control_ops = array('width' => 200, 'height' => 250, 'id_base' => 'quadmenu_widget');
23
24 parent::__construct('quadmenu_widget', esc_html__('QuadMenu Widget', 'quadmenu'), $widget_ops, $control_ops);
25 }
26
27 function widget($args, $instance) {
28
29 extract($args);
30
31 extract(shortcode_atts(array('menu' => '', 'theme' => '', 'layout' => 'inherit'), $instance));
32
33 echo $before_widget;
34
35 $args = array(
36 'echo' => false,
37 'menu' => $menu,
38 'theme' => $theme,
39 'layout' => $layout,
40 'theme_location' => 'widget',
41 );
42
43 if (wp_doing_ajax()) {
44 $args['layout_classes'] = 'js';
45 }
46
47 echo quadmenu($args);
48
49 echo $after_widget;
50 }
51
52 function update($new_instance, $old_instance) {
53 $instance = $old_instance;
54 $instance['theme'] = strip_tags($new_instance['theme']);
55 $instance['menu'] = strip_tags($new_instance['menu']);
56 $instance['layout'] = strip_tags($new_instance['layout']);
57 return $instance;
58 }
59
60 function themes($current = false) {
61
62 global $quadmenu_themes;
63
64 foreach ($quadmenu_themes as $key => $theme) {
65 ?>
66 <option value="<?php echo esc_attr($key); ?>" <?php echo selected($key, $current); ?>><?php echo esc_html($theme); ?></option>
67 <?php
68 }
69 }
70
71 function menus($current = false) {
72
73 $menus = wp_get_nav_menus();
74
75 foreach ($menus as $key => $menu) {
76 ?>
77 <option value="<?php echo esc_attr($menu->term_id); ?>" <?php echo selected($menu->term_id, $current); ?>><?php echo esc_html($menu->name); ?></option>
78 <?php
79 }
80 }
81
82 function layouts($current = false) {
83
84 $layouts = array(
85 'embed' => esc_html__('Embed', 'quadmenu'),
86 'collapse' => esc_html__('Collapse', 'quadmenu'),
87 'offcanvas' => esc_html__('Offcanvas', 'quadmenu'),
88 'vertical' => esc_html__('Vertical', 'quadmenu'),
89 'inherit' => esc_html__('Inherit', 'quadmenu'),
90 );
91
92 foreach ($layouts as $key => $layout) {
93 ?>
94 <option value="<?php echo esc_attr($key); ?>" <?php echo selected($key, $current); ?>><?php echo esc_html($layout); ?></option>
95 <?php
96 }
97 }
98
99 function form($instance) {
100
101 $defaults = array(
102 'location' => '',
103 'menu' => '',
104 'layout' => '',
105 'theme' => '',
106 );
107
108 $instance = wp_parse_args((array) $instance, $defaults);
109 ?>
110 <p>
111 <label for="<?php echo $this->get_field_id('menu'); ?>"><?php esc_html_e('Menu', 'quadmenu'); ?></label>
112 <select id="<?php echo $this->get_field_id('menu'); ?>" name="<?php echo $this->get_field_name('menu'); ?>" class="widefat">
113 <?php echo $this->menus($instance['menu']); ?>
114 </select>
115 </p>
116 <p>
117 <label for="<?php echo $this->get_field_id('layout'); ?>"><?php esc_html_e('Layout', 'quadmenu'); ?></label>
118 <select id="<?php echo $this->get_field_id('layout'); ?>" name="<?php echo $this->get_field_name('layout'); ?>" class="widefat">
119 <?php echo $this->layouts($instance['layout']); ?>
120 </select>
121 </p>
122 <p>
123 <label for="<?php echo $this->get_field_id('theme'); ?>"><?php esc_html_e('Theme', 'quadmenu'); ?></label>
124 <select id="<?php echo $this->get_field_id('theme'); ?>" name="<?php echo $this->get_field_name('theme'); ?>" class="widefat">
125 <?php echo $this->themes($instance['theme']); ?>
126 </select>
127 </p>
128 <?php
129 }
130
131 }
132