PluginProbe
QuadMenu – Mega Menu / 3.3.7
QuadMenu – Mega Menu v3.3.7
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 / lib / class-widget.php

class-widget.php in QuadMenu – Mega Menu 3.3.7, at lib/class-widget.php

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