Version Description
If you have PHP Opcache enabled you may want to update to WordPress 5.5 before applying this update, as it includes this change:
https://make.wordpress.org/core/2020/07/27/opcode-cache-invalidation-in-wordpress-5-5/
This release continues to pave the way for the new Appearance > Menus screen coming in WordPress 5.6 by allowing all location related settings to be managed from the Mega Menu > Menu Locations page.
- Improvement: Click Event Behaviour, Mobile Menu Behaviour, Menu Item Descriptions, Unbind JavaScript Events, Prefix Menu Item Classes and Active Menu Instance options have been moved from the General Settings page and can now be configured per menu location on the updated Mega Menu > Menu Locations page.
- Improvement: Move theme import/export options to theme editor page
- Improvement: Improve flow for creating new menu locations
- Improvement: Add overflow-behaviour to offcanvas menu
- Improvement: Remove jquery accordion dependency on nav-menus.php
- Improvement: Trigger custom events when the mobile menu is opened and closed
- New: Add container option to specify whether menu should be wrapped in a
div
or anav
element - Experimental: Add sandbox option to preview your menu (without theme interference)
- Fix: Indent third level items in mobile menu
- Fix: Divi adding linting to Custom CSS area of menu theme
- Fix: Indent third level items in mobile menu
- Fix: Ensure page remains scrollable when off canvas mode is enabled, when the off canvas menu is open, and when the browser window is resized from mobile to desktop
Download this release
Release Info
Developer | megamenu |
Plugin | Max Mega Menu |
Version | 2.9 |
Comparing to | |
See all releases |
Code changes from version 2.8.0.3 to 2.9
- classes/menu-item-manager.class.php +1077 -1070
- classes/nav-menus.class.php +643 -569
- classes/pages/general.php +188 -208
- classes/pages/locations.php +1659 -1594
- classes/pages/page.php +278 -269
- classes/pages/themes.php +3127 -3106
- classes/pages/tools.php +180 -177
- classes/style-manager.class.php +1033 -1029
- classes/toggle-blocks.class.php +924 -914
- classes/walker.class.php +165 -163
- classes/widget-manager.class.php +1026 -1018
- classes/widgets/widget-elementor-template.class.php +85 -79
- classes/widgets/widget-reusable-block.class.php +78 -72
- classes/widgets/widget.class.php +112 -107
- css/admin/admin.css +105 -51
- css/admin/admin.scss +110 -20
- js/admin.js +17 -5
- js/maxmegamenu.js +6 -1
- js/settings.js +12 -5
- megamenu.php +1511 -1491
- readme.txt +19 -3
classes/menu-item-manager.class.php
CHANGED
@@ -1,1157 +1,1164 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Menu_Item_Manager') ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
*
|
11 |
-
* @since 1.4
|
12 |
-
*/
|
13 |
-
class Mega_Menu_Menu_Item_Manager {
|
14 |
-
|
15 |
-
var $menu_id = 0;
|
16 |
-
var $menu_item_id = 0;
|
17 |
-
var $menu_item_title = "";
|
18 |
-
var $menu_item_depth = 0;
|
19 |
-
var $menu_item_objects = array();
|
20 |
-
var $menu_item_meta = array();
|
21 |
-
|
22 |
|
23 |
/**
|
24 |
-
* Constructor
|
25 |
*
|
26 |
* @since 1.4
|
27 |
*/
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
$this->menu_item_meta = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Get the depth for a menu item ID
|
59 |
-
*
|
60 |
-
* @since 2.7.7
|
61 |
-
* @param int $menu_item_id
|
62 |
-
* @param array $menu_item_objects
|
63 |
-
* @return int
|
64 |
-
*/
|
65 |
-
public function get_menu_item_depth( $menu_item_id, $menu_item_objects ) {
|
66 |
-
$parents = array();
|
67 |
-
|
68 |
-
foreach ( $menu_item_objects as $key => $item ) {
|
69 |
-
if ( $item->menu_item_parent == 0 ) {
|
70 |
-
|
71 |
-
if ( $item->ID == $menu_item_id ) {
|
72 |
-
return 0; // top level item
|
73 |
-
}
|
74 |
-
|
75 |
-
$parents[] = $item->ID;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
if ( count( $parents ) ) {
|
80 |
-
foreach ( $menu_item_objects as $key => $item ) {
|
81 |
-
if ( in_array( $item->menu_item_parent, $parents ) ) {
|
82 |
-
if ( $item->ID == $menu_item_id ) {
|
83 |
-
return 1; // second level item
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
return 2; // third level item or above
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Save custom menu item fields.
|
95 |
-
*
|
96 |
-
* @since 1.4
|
97 |
-
*/
|
98 |
-
public static function ajax_save_menu_item_settings() {
|
99 |
|
100 |
-
check_ajax_referer( 'megamenu_edit' );
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
|
|
107 |
|
108 |
-
|
109 |
-
|
|
|
110 |
|
111 |
-
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
119 |
|
120 |
-
|
|
|
121 |
|
122 |
-
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true);
|
123 |
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
-
|
127 |
|
128 |
-
|
129 |
|
130 |
-
|
131 |
|
132 |
-
|
133 |
|
134 |
-
|
|
|
135 |
|
136 |
-
|
137 |
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
|
141 |
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
|
144 |
-
|
145 |
|
146 |
-
|
147 |
|
|
|
148 |
|
149 |
-
|
150 |
-
* Return the HTML to display in the Lightbox
|
151 |
-
*
|
152 |
-
* @since 1.4
|
153 |
-
* @return string
|
154 |
-
*/
|
155 |
-
public function ajax_get_lightbox_html() {
|
156 |
|
157 |
-
|
158 |
|
159 |
-
|
160 |
|
161 |
-
|
162 |
|
163 |
-
|
|
|
|
|
164 |
|
165 |
-
|
166 |
|
167 |
-
|
168 |
-
$response['active_tab'] = "general_settings";
|
169 |
-
}
|
170 |
|
171 |
-
$response = apply_filters( "megamenu_tabs", $response, $this->menu_item_id, $this->menu_id, $this->menu_item_depth, $this->menu_item_meta );
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
177 |
|
|
|
178 |
|
179 |
-
|
180 |
-
* Returns the menu ID for a specified menu item ID
|
181 |
-
*
|
182 |
-
* @since 2.7.5
|
183 |
-
* @param int $menu_item_id
|
184 |
-
* @return int $menu_id
|
185 |
-
*/
|
186 |
-
public function get_menu_id_for_menu_item_id( $menu_item_id ) {
|
187 |
-
$terms = get_the_terms( $menu_item_id, 'nav_menu' );
|
188 |
-
$menu_id = $terms[0]->term_id;
|
189 |
-
return $menu_id;
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Returns the title of a given menu item ID
|
195 |
-
*
|
196 |
-
* @since 2.7.5
|
197 |
-
* @param int $menu_item_id
|
198 |
-
* @return int $menu_id
|
199 |
-
*/
|
200 |
-
public function get_title_for_menu_item_id( $menu_item_id, $menu_item_objects ) {
|
201 |
-
foreach( $menu_item_objects as $key => $item ) {
|
202 |
-
if ( $item->ID == $menu_item_id ) {
|
203 |
-
return $item->title;
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
return false;
|
208 |
-
}
|
209 |
|
210 |
-
|
211 |
-
* Return the HTML to display in the 'Mega Menu' tab
|
212 |
-
*
|
213 |
-
* @since 1.7
|
214 |
-
* @return array
|
215 |
-
*/
|
216 |
-
public function add_mega_menu_tab( $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
217 |
-
if ( $menu_item_depth > 0 ) {
|
218 |
-
$tabs['mega_menu'] = array(
|
219 |
-
'title' => __('Sub Menu', 'megamenu'),
|
220 |
-
'content' => '<em>' . __( "Mega Menus can only be created on top level menu items.", "megamenu" ) . '</em>'
|
221 |
-
);
|
222 |
-
|
223 |
-
return $tabs;
|
224 |
-
}
|
225 |
-
|
226 |
-
$submenu_options = apply_filters("megamenu_submenu_options", array(
|
227 |
-
'flyout' => __("Flyout Menu", "megamenu"),
|
228 |
-
'grid' => __("Mega Menu - Grid Layout", "megamenu"),
|
229 |
-
'megamenu' => __("Mega Menu - Standard Layout", "megamenu")
|
230 |
-
), $menu_item_meta);
|
231 |
-
|
232 |
-
$return = "<label for='mm_enable_mega_menu'>" . __("Sub menu display mode", "megamenu") . "</label>";
|
233 |
-
|
234 |
-
$return .= "<select id='mm_enable_mega_menu' name='settings[type]'>";
|
235 |
-
|
236 |
-
foreach ( $submenu_options as $type => $label ) {
|
237 |
-
$return .= "<option id='{$type}' value='{$type}' " . selected( $menu_item_meta['type'], $type, false ) . ">{$label}</option>";
|
238 |
-
}
|
239 |
-
$return .= "</select>";
|
240 |
-
|
241 |
-
$widget_manager = new Mega_Menu_Widget_Manager();
|
242 |
-
|
243 |
-
$all_widgets = $widget_manager->get_available_widgets();
|
244 |
-
|
245 |
-
$return .= "<div class='mm_panel_options'>";
|
246 |
-
$return .= " <select id='mm_number_of_columns' name='settings[panel_columns]'>";
|
247 |
-
$return .= " <option value='1' " . selected( $menu_item_meta['panel_columns'], 1, false ) . ">1 " . __("column", "megamenu") . "</option>";
|
248 |
-
$return .= " <option value='2' " . selected( $menu_item_meta['panel_columns'], 2, false ) . ">2 " . __("columns", "megamenu") . "</option>";
|
249 |
-
$return .= " <option value='3' " . selected( $menu_item_meta['panel_columns'], 3, false ) . ">3 " . __("columns", "megamenu") . "</option>";
|
250 |
-
$return .= " <option value='4' " . selected( $menu_item_meta['panel_columns'], 4, false ) . ">4 " . __("columns", "megamenu") . "</option>";
|
251 |
-
$return .= " <option value='5' " . selected( $menu_item_meta['panel_columns'], 5, false ) . ">5 " . __("columns", "megamenu") . "</option>";
|
252 |
-
$return .= " <option value='6' " . selected( $menu_item_meta['panel_columns'], 6, false ) . ">6 " . __("columns", "megamenu") . "</option>";
|
253 |
-
$return .= " <option value='7' " . selected( $menu_item_meta['panel_columns'], 7, false ) . ">7 " . __("columns", "megamenu") . "</option>";
|
254 |
-
$return .= " <option value='8' " . selected( $menu_item_meta['panel_columns'], 8, false ) . ">8 " . __("columns", "megamenu") . "</option>";
|
255 |
-
$return .= " <option value='9' " . selected( $menu_item_meta['panel_columns'], 9, false ) . ">9 " . __("columns", "megamenu") . "</option>";
|
256 |
-
$return .= " <option value='10' " . selected( $menu_item_meta['panel_columns'], 10, false ) . ">10 " . __("columns", "megamenu") . "</option>";
|
257 |
-
$return .= " <option value='11' " . selected( $menu_item_meta['panel_columns'], 11, false ) . ">11 " . __("columns", "megamenu") . "</option>";
|
258 |
-
$return .= " <option value='12' " . selected( $menu_item_meta['panel_columns'], 12, false ) . ">12 " . __("columns", "megamenu") . "</option>";
|
259 |
-
$return .= " </select>";
|
260 |
-
|
261 |
-
$return .= " <select id='mm_widget_selector'>";
|
262 |
-
$return .= " <option value='disabled'>" . __("Select a Widget to add to the panel", "megamenu") . "</option>";
|
263 |
-
|
264 |
-
foreach ( $all_widgets as $widget ) {
|
265 |
-
$return .= " <option value='" . $widget['value'] . "'>" . $widget['text'] . "</option>";
|
266 |
-
}
|
267 |
-
|
268 |
-
$return .= " </select>";
|
269 |
-
$return .= "</div>";
|
270 |
-
|
271 |
-
$return .= $this->get_megamenu_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
272 |
-
|
273 |
-
$return .= $this->get_megamenu_grid_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
274 |
-
|
275 |
-
$tabs['mega_menu'] = array(
|
276 |
-
'title' => __('Mega Menu', 'megamenu'),
|
277 |
-
'content' => $return
|
278 |
-
);
|
279 |
-
|
280 |
-
return $tabs;
|
281 |
-
}
|
282 |
|
|
|
283 |
|
284 |
-
|
285 |
-
* Return the HTML for the grid layout
|
286 |
-
*
|
287 |
-
* @since 2.4
|
288 |
-
* @return string
|
289 |
-
*/
|
290 |
-
public function get_megamenu_grid_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
291 |
|
292 |
-
|
|
|
|
|
293 |
|
294 |
-
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
$return .= sprintf( __("Your menu CSS needs to be updated first. Please go to %s and Clear the CSS Cache (you will only need to do this once).", "megamenu") , $link);
|
300 |
-
$return .= "</p></div>";
|
301 |
-
$return .= "</div>";
|
302 |
|
303 |
-
|
304 |
-
|
305 |
|
306 |
-
$widget_manager = new Mega_Menu_Widget_Manager();
|
307 |
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
-
if ( count ( $grid ) ) {
|
311 |
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
|
314 |
-
|
|
|
315 |
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
}
|
323 |
|
324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
|
326 |
-
|
327 |
|
328 |
-
|
329 |
|
330 |
-
|
331 |
-
|
|
|
|
|
332 |
|
333 |
-
|
334 |
|
335 |
-
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
if ( ob_get_contents() ) ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
350 |
-
|
351 |
-
wp_send_json_success( $return );
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Return the HTML to display in the Lightbox
|
356 |
-
*
|
357 |
-
* @since 2.4
|
358 |
-
* @return string
|
359 |
-
*/
|
360 |
-
public function ajax_get_empty_grid_row() {
|
361 |
-
|
362 |
-
check_ajax_referer( 'megamenu_edit' );
|
363 |
-
|
364 |
-
$column_html = $this->get_grid_column();
|
365 |
-
|
366 |
-
$return = $this->get_grid_row( false, $column_html );
|
367 |
-
|
368 |
-
if ( ob_get_contents() ) ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
369 |
-
|
370 |
-
wp_send_json_success( $return );
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Return the HTML for a single row
|
375 |
-
*
|
376 |
-
* @param array $row_data
|
377 |
-
* @param string $column_html
|
378 |
-
* @since 2.4
|
379 |
-
* @return string
|
380 |
-
*/
|
381 |
-
public function get_grid_row( $row_data = false, $column_html = false ) {
|
382 |
-
|
383 |
-
$hide_on_desktop_checked = "false";
|
384 |
-
$hide_on_desktop = 'mega-enabled';
|
385 |
-
|
386 |
-
if ( isset( $row_data['meta']['hide-on-desktop'] ) && $row_data['meta']['hide-on-desktop'] == 'true' ) {
|
387 |
-
$hide_on_desktop = 'mega-disabled';
|
388 |
-
$hide_on_desktop_checked = "true";
|
389 |
-
}
|
390 |
-
|
391 |
-
$hide_on_mobile_checked = "false";
|
392 |
-
$hide_on_mobile = 'mega-enabled';
|
393 |
-
|
394 |
-
if ( isset( $row_data['meta']['hide-on-mobile'] ) && $row_data['meta']['hide-on-mobile'] == 'true' ) {
|
395 |
-
$hide_on_mobile = 'mega-disabled';
|
396 |
-
$hide_on_mobile_checked = "true";
|
397 |
-
}
|
398 |
-
|
399 |
-
$row_columns = 12;
|
400 |
-
|
401 |
-
if ( isset( $row_data['meta']['columns'] ) ) {
|
402 |
-
$row_columns = intval( $row_data['meta']['columns'] );
|
403 |
-
}
|
404 |
-
|
405 |
-
$desktop_tooltip_visible = __("Row", "megamenu") . ": " . __("Visible on desktop", "megamenu");
|
406 |
-
$desktop_tooltip_hidden = __("Row", "megamenu") . ": " . __("Hidden on desktop", "megamenu");
|
407 |
-
$mobile_tooltip_visible = __("Row", "megamenu") . ": " . __("Visible on mobile", "megamenu");
|
408 |
-
$mobile_tooltip_hidden = __("Row", "megamenu") . ": " . __("Hidden on mobile", "megamenu");
|
409 |
-
|
410 |
-
$row_class = isset( $row_data['meta']['class'] ) ? $row_data['meta']['class'] : "";
|
411 |
-
|
412 |
-
$return = "<div class='mega-row' data-available-cols='{$row_columns}'>";
|
413 |
-
$return .= " <div class='mega-row-header'>";
|
414 |
-
$return .= " <div class='mega-row-actions'>";
|
415 |
-
$return .= " <span class='dashicons dashicons-sort'></span>";
|
416 |
-
$return .= " <span class='dashicons dashicons-admin-generic'></span>";
|
417 |
-
$return .= " <span class='mega-tooltip {$hide_on_desktop}' data-tooltip-enabled='{$desktop_tooltip_visible}' data-tooltip-disabled='{$desktop_tooltip_hidden}'><span class='dashicons dashicons-desktop'></span></span>";
|
418 |
-
$return .= " <span class='mega-tooltip {$hide_on_mobile}' data-tooltip-enabled='{$mobile_tooltip_visible}' data-tooltip-disabled='{$mobile_tooltip_hidden}'><span class='dashicons dashicons-smartphone'></span></span>";
|
419 |
-
$return .= " <span class='dashicons dashicons-trash'></span>";
|
420 |
-
$return .= " </div>";
|
421 |
-
$return .= " <div class='mega-row-settings'>";
|
422 |
-
$return .= " <input name='mega-hide-on-mobile' type='hidden' value='{$hide_on_mobile_checked}' />";
|
423 |
-
$return .= " <input name='mega-hide-on-desktop' type='hidden' value='{$hide_on_desktop_checked}'/>";
|
424 |
-
$return .= " <div class='mega-settings-row'>";
|
425 |
-
$return .= " <label>" . __('Row class', 'megamenu') . "</label>";
|
426 |
-
$return .= " <input class='mega-row-class' type='text' value='{$row_class}' />";
|
427 |
-
$return .= " </div>";
|
428 |
-
$return .= " <div class='mega-settings-row'>";
|
429 |
-
$return .= " <label>" . __('Row columns', 'megamenu') . "</label>";
|
430 |
-
$return .= " <select class='mega-row-columns'>";
|
431 |
-
$return .= " <option value='1' " . selected( $row_columns, 1, false ) . ">1 " . __("column", "megamenu") . "</option>";
|
432 |
-
$return .= " <option value='2' " . selected( $row_columns, 2, false ) . ">2 " . __("columns", "megamenu") . "</option>";
|
433 |
-
$return .= " <option value='3' " . selected( $row_columns, 3, false ) . ">3 " . __("columns", "megamenu") . "</option>";
|
434 |
-
$return .= " <option value='4' " . selected( $row_columns, 4, false ) . ">4 " . __("columns", "megamenu") . "</option>";
|
435 |
-
$return .= " <option value='5' " . selected( $row_columns, 5, false ) . ">5 " . __("columns", "megamenu") . "</option>";
|
436 |
-
$return .= " <option value='6' " . selected( $row_columns, 6, false ) . ">6 " . __("columns", "megamenu") . "</option>";
|
437 |
-
$return .= " <option value='7' " . selected( $row_columns, 7, false ) . ">7 " . __("columns", "megamenu") . "</option>";
|
438 |
-
$return .= " <option value='8' " . selected( $row_columns, 8, false ) . ">8 " . __("columns", "megamenu") . "</option>";
|
439 |
-
$return .= " <option value='9' " . selected( $row_columns, 9, false ) . ">9 " . __("columns", "megamenu") . "</option>";
|
440 |
-
$return .= " <option value='10' " . selected( $row_columns, 10, false ) . ">10 " . __("columns", "megamenu") . "</option>";
|
441 |
-
$return .= " <option value='11' " . selected( $row_columns, 11, false ) . ">11 " . __("columns", "megamenu") . "</option>";
|
442 |
-
$return .= " <option value='12' " . selected( $row_columns, 12, false ) . ">12 " . __("columns", "megamenu") . "</option>";
|
443 |
-
$return .= " </select>";
|
444 |
-
$return .= " </div>";
|
445 |
-
$return .= " <button class='button button-primary mega-save-row-settings' type='submit'>" . __('Save', 'megamenu') . "</button>";
|
446 |
-
$return .= " </div>";
|
447 |
-
$return .= " <button class='button button-primary mega-add-column'><span class='dashicons dashicons-plus'></span>" . __("Column", "megamenu") . "</button>";
|
448 |
-
$return .= " </div>";
|
449 |
-
$return .= " <div class='error notice is-dismissible mega-too-many-cols'>";
|
450 |
-
$return .= " <p>" . __( 'You should rearrange the content of this row so that all columns fit onto a single line.', 'megamenu' ) . "</p>";
|
451 |
-
$return .= " </div>";
|
452 |
-
$return .= " <div class='error notice is-dismissible mega-row-is-full'>";
|
453 |
-
$return .= " <p>" . __( 'There is not enough space on this row to add a new column.', 'megamenu' ) . "</p>";
|
454 |
-
$return .= " </div>";
|
455 |
-
|
456 |
-
$return .= $column_html;
|
457 |
-
|
458 |
-
$return .= "</div>";
|
459 |
-
|
460 |
-
return $return;
|
461 |
-
}
|
462 |
-
|
463 |
-
/**
|
464 |
-
* Return the HTML for an individual grid column
|
465 |
-
*
|
466 |
-
* @param array $col_data
|
467 |
-
* @since 2.4
|
468 |
-
* @return string
|
469 |
-
*/
|
470 |
-
public function get_grid_column( $row_data = false, $col_data = false ) {
|
471 |
-
|
472 |
-
$col_span = 3;
|
473 |
-
$row_columns = 12;
|
474 |
-
|
475 |
-
if ( isset( $row_data['meta']['columns'] ) ) {
|
476 |
-
$row_columns = intval( $row_data['meta']['columns'] );
|
477 |
-
}
|
478 |
-
|
479 |
-
if ( isset( $col_data['meta']['span'] ) ) {
|
480 |
-
$col_span = $col_data['meta']['span'];
|
481 |
-
}
|
482 |
-
|
483 |
-
$hide_on_desktop_checked = "false";
|
484 |
-
$hide_on_desktop = 'mega-enabled';
|
485 |
-
|
486 |
-
if ( isset( $col_data['meta']['hide-on-desktop'] ) && $col_data['meta']['hide-on-desktop'] == 'true' ) {
|
487 |
-
$hide_on_desktop = 'mega-disabled';
|
488 |
-
$hide_on_desktop_checked = "true";
|
489 |
-
}
|
490 |
-
|
491 |
-
$hide_on_mobile_checked = "false";
|
492 |
-
$hide_on_mobile = 'mega-enabled';
|
493 |
-
|
494 |
-
if ( isset( $col_data['meta']['hide-on-mobile'] ) && $col_data['meta']['hide-on-mobile'] == 'true' ) {
|
495 |
-
$hide_on_mobile = 'mega-disabled';
|
496 |
-
$hide_on_mobile_checked = "true";
|
497 |
-
}
|
498 |
-
|
499 |
-
$desktop_tooltip_visible = __("Column", "megamenu") . ": " . __("Visible on desktop", "megamenu");
|
500 |
-
$desktop_tooltip_hidden = __("Column", "megamenu") . ": " . __("Hidden on desktop", "megamenu");
|
501 |
-
$mobile_tooltip_visible = __("Column", "megamenu") . ": " . __("Visible on mobile", "megamenu");
|
502 |
-
$mobile_tooltip_hidden = __("Column", "megamenu") . ": " . __("Hidden on mobile", "megamenu");
|
503 |
-
|
504 |
-
$col_class = isset( $col_data['meta']['class'] ) ? $col_data['meta']['class'] : "";
|
505 |
-
|
506 |
-
$return = "<div class='mega-col' data-span='{$col_span}'>";
|
507 |
-
$return .= " <div class='mega-col-wrap'>";
|
508 |
-
$return .= " <div class='mega-col-header'>";
|
509 |
-
$return .= " <div class='mega-col-description'>";
|
510 |
-
$return .= " <span class='dashicons dashicons-move'></span>";
|
511 |
-
$return .= " <span class='dashicons dashicons-admin-generic'></span>";
|
512 |
-
$return .= " <span class='mega-tooltip {$hide_on_desktop}' data-tooltip-enabled='{$desktop_tooltip_visible}' data-tooltip-disabled='{$desktop_tooltip_hidden}'><span class='dashicons dashicons-desktop'></span></span>";
|
513 |
-
$return .= " <span class='mega-tooltip {$hide_on_mobile}' data-tooltip-enabled='{$mobile_tooltip_visible}' data-tooltip-disabled='{$mobile_tooltip_hidden}'><span class='dashicons dashicons-smartphone'></span></span>";
|
514 |
-
$return .= " <span class='dashicons dashicons-trash'></span>";
|
515 |
-
$return .= " </div>";
|
516 |
-
$return .= ' <div class="mega-col-actions">';
|
517 |
-
$return .= ' <a class="mega-col-option mega-col-contract" title="' . esc_attr( __("Contract", "megamenu") ) . '"><span class="dashicons dashicons-arrow-left-alt2"></span></a>';
|
518 |
-
$return .= " <span class='mega-col-cols'><span class='mega-num-cols'>{$col_span}</span><span class='mega-of'>/</span><span class='mega-num-total-cols'>" . $row_columns . "</span></span>";
|
519 |
-
$return .= ' <a class="mega-col-options mega-col-expand" title="' . esc_attr( __("Expand", "megamenu") ) . '"><span class="dashicons dashicons-arrow-right-alt2"></span></a>';
|
520 |
-
$return .= ' </div>';
|
521 |
-
$return .= " </div>";
|
522 |
-
$return .= " <div class='mega-col-settings'>";
|
523 |
-
$return .= " <input name='mega-hide-on-mobile' type='hidden' value='{$hide_on_mobile_checked}' />";
|
524 |
-
$return .= " <input name='mega-hide-on-desktop' type='hidden' value='{$hide_on_desktop_checked}'/>";
|
525 |
-
$return .= " <label>" . __('Column class', 'megamenu') . "</label>";
|
526 |
-
$return .= " <input class='mega-column-class' type='text' value='{$col_class}' />";
|
527 |
-
$return .= " <button class='button button-primary mega-save-column-settings' type='submit'>" . __('Save', 'megamenu') . "</button>";
|
528 |
-
$return .= " </div>";
|
529 |
-
$return .= " <div class='mega-col-widgets'>";
|
530 |
-
|
531 |
-
if ( isset( $col_data['items'] ) && count( $col_data['items'] ) ) {
|
532 |
-
foreach ( $col_data['items'] as $item ) {
|
533 |
-
$return .= '<div class="widget" title="' . esc_attr( $item['title'] ) . '" id="' . esc_attr( $item['id'] ) . '" data-type="' . esc_attr( $item['type'] ) . '" data-id="' . esc_attr( $item['id'] ) . '">';
|
534 |
-
$return .= ' <div class="widget-top">';
|
535 |
-
$return .= ' <div class="widget-title">';
|
536 |
-
$return .= ' <h4>' . esc_html( $item['title'] ) . '</h4>';
|
537 |
-
$return .= ' <span class="widget-desc">' . esc_html( $item['description'] ) . '</span>';
|
538 |
-
$return .= ' </div>';
|
539 |
-
$return .= ' <div class="widget-title-action">';
|
540 |
-
$return .= ' <a class="widget-option widget-action" title="' . esc_attr( __("Edit", "megamenu") ) . '"></a>';
|
541 |
-
$return .= ' </div>';
|
542 |
-
$return .= ' </div>';
|
543 |
-
$return .= ' <div class="widget-inner widget-inside"></div>';
|
544 |
-
$return .= '</div>';
|
545 |
-
}
|
546 |
-
}
|
547 |
-
|
548 |
-
$return .= " </div>";
|
549 |
-
$return .= " </div>";
|
550 |
-
$return .= "</div>";
|
551 |
-
|
552 |
-
return $return;
|
553 |
-
}
|
554 |
-
|
555 |
-
|
556 |
-
/**
|
557 |
-
* Return the HTML for the standard (non grid) mega menu builder
|
558 |
-
*
|
559 |
-
* @return string
|
560 |
-
*/
|
561 |
-
public function get_megamenu_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
562 |
-
|
563 |
-
$widget_manager = new Mega_Menu_Widget_Manager();
|
564 |
-
|
565 |
-
$return = "<div id='widgets' data-columns='{$menu_item_meta['panel_columns']}'>";
|
566 |
-
|
567 |
-
$items = $widget_manager->get_widgets_and_menu_items_for_menu_id( $menu_item_id, $menu_id );
|
568 |
-
|
569 |
-
if ( count ( $items ) ) {
|
570 |
-
|
571 |
-
foreach ( $items as $item ) {
|
572 |
-
$return .= '<div class="widget" title="' . esc_attr( $item['title'] ) . '" id="' . esc_attr( $item['id'] ) . '" data-columns="' . esc_attr( $item['columns'] ) . '" data-type="' . esc_attr( $item['type'] ) . '" data-id="' . esc_attr( $item['id'] ) . '">';
|
573 |
-
$return .= ' <div class="widget-top">';
|
574 |
-
$return .= ' <div class="widget-title-action">';
|
575 |
-
$return .= ' <a class="widget-option widget-contract" title="' . esc_attr( __("Contract", "megamenu") ) . '"></a>';
|
576 |
-
$return .= ' <span class="widget-cols"><span class="widget-num-cols">' . $item['columns'] . '</span><span class="widget-of">/</span><span class="widget-total-cols">' . $menu_item_meta['panel_columns'] . '</span></span>';
|
577 |
-
$return .= ' <a class="widget-option widget-expand" title="' . esc_attr( __("Expand", "megamenu") ) . '"></a>';
|
578 |
-
$return .= ' <a class="widget-option widget-action" title="' . esc_attr( __("Edit", "megamenu") ) . '"></a>';
|
579 |
-
$return .= ' </div>';
|
580 |
-
$return .= ' <div class="widget-title">';
|
581 |
-
$return .= ' <h4>' . esc_html( $item['title'] ) . '</h4>';
|
582 |
-
$return .= ' </div>';
|
583 |
-
$return .= ' </div>';
|
584 |
-
$return .= ' <div class="widget-inner widget-inside"></div>';
|
585 |
-
$return .= '</div>';
|
586 |
-
}
|
587 |
-
|
588 |
-
} else {
|
589 |
-
$return .= "<p class='no_widgets'>" . __("No widgets found. Add a widget to this area using the Widget Selector (top right)", "megamenu") . "</p>";
|
590 |
-
}
|
591 |
-
|
592 |
-
$return .= "</div>";
|
593 |
-
|
594 |
-
return $return;
|
595 |
-
}
|
596 |
|
597 |
-
|
598 |
-
|
599 |
-
*
|
600 |
-
* @since 1.7
|
601 |
-
* @return array
|
602 |
-
*/
|
603 |
-
public function add_general_settings_tab( $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
604 |
-
|
605 |
-
$return = '<form>';
|
606 |
-
$return .= ' <input type="hidden" name="menu_item_id" value="' . esc_attr( $menu_item_id ) . '" />';
|
607 |
-
$return .= ' <input type="hidden" name="action" value="mm_save_menu_item_settings" />';
|
608 |
-
$return .= ' <input type="hidden" name="_wpnonce" value="' . wp_create_nonce('megamenu_edit') . '" />';
|
609 |
-
$return .= ' <input type="hidden" name="tab" value="general_settings" />';
|
610 |
-
$return .= ' <h4 class="first">' . __("Menu Item Settings", "megamenu") . '</h4>';
|
611 |
-
$return .= ' <table>';
|
612 |
-
$return .= ' <tr>';
|
613 |
-
$return .= ' <td class="mega-name">';
|
614 |
-
$return .= __("Hide Text", "megamenu");
|
615 |
-
$return .= ' </td>';
|
616 |
-
$return .= ' <td class="mega-value">';
|
617 |
-
$return .= ' <input type="checkbox" name="settings[hide_text]" value="true" ' . checked( $menu_item_meta['hide_text'], 'true', false ) . ' />';
|
618 |
-
$return .= ' </td>';
|
619 |
-
$return .= ' </tr>';
|
620 |
-
$return .= ' <tr>';
|
621 |
-
$return .= ' <td class="mega-name">';
|
622 |
-
$return .= __("Hide Arrow", "megamenu");
|
623 |
-
$return .= ' </td>';
|
624 |
-
$return .= ' <td class="mega-value">';
|
625 |
-
$return .= ' <input type="checkbox" name="settings[hide_arrow]" value="true" ' . checked( $menu_item_meta['hide_arrow'], 'true', false ) . ' />';
|
626 |
-
$return .= ' </td>';
|
627 |
-
$return .= ' </tr>';
|
628 |
-
$return .= ' <tr>';
|
629 |
-
$return .= ' <td class="mega-name">';
|
630 |
-
$return .= __("Disable Link", "megamenu");
|
631 |
-
$return .= ' </td>';
|
632 |
-
$return .= ' <td class="mega-value">';
|
633 |
-
$return .= ' <input type="checkbox" name="settings[disable_link]" value="true" ' . checked( $menu_item_meta['disable_link'], 'true', false ) . ' />';
|
634 |
-
$return .= ' </td>';
|
635 |
-
$return .= ' </tr>';
|
636 |
-
$return .= ' <tr>';
|
637 |
-
$return .= ' <td class="mega-name">';
|
638 |
-
$return .= __("Hide Item on Mobile", "megamenu");
|
639 |
-
$return .= ' </td>';
|
640 |
-
$return .= ' <td class="mega-value">';
|
641 |
-
$return .= ' <input type="checkbox" name="settings[hide_on_mobile]" value="true" ' . checked( $menu_item_meta['hide_on_mobile'], 'true', false ) . ' />';
|
642 |
-
$return .= ' </td>';
|
643 |
-
$return .= ' </tr>';
|
644 |
-
$return .= ' <tr>';
|
645 |
-
$return .= ' <td class="mega-name">';
|
646 |
-
$return .= __("Hide Item on Desktop", "megamenu");
|
647 |
-
$return .= ' </td>';
|
648 |
-
$return .= ' <td class="mega-value">';
|
649 |
-
$return .= ' <input type="checkbox" name="settings[hide_on_desktop]" value="true" ' . checked( $menu_item_meta['hide_on_desktop'], 'true', false ) . ' />';
|
650 |
-
$return .= ' </td>';
|
651 |
-
$return .= ' </tr>';
|
652 |
-
$return .= ' <tr class="mega-menu-item-align">';
|
653 |
-
$return .= ' <td class="mega-name">';
|
654 |
-
$return .= __("Menu Item Align", "megamenu");
|
655 |
-
$return .= ' </td>';
|
656 |
-
$return .= ' <td class="mega-value">';
|
657 |
-
|
658 |
-
if ( $menu_item_depth == 0 ) {
|
659 |
-
|
660 |
-
$item_align = $menu_item_meta['item_align'];
|
661 |
-
|
662 |
-
$float_left_display = $item_align == 'float-left' ? 'block' : 'none';
|
663 |
-
$left_display = $item_align == 'left' ? 'block' : 'none';
|
664 |
-
$right_display = $item_align == 'right' ? 'block' : 'none';
|
665 |
-
|
666 |
-
$return .= ' <select id="mega-item-align" name="settings[item_align]">';
|
667 |
-
$return .= ' <option value="float-left" ' . selected( $menu_item_meta['item_align'], 'float-left', false ) . '>' . __("Left", "megamenu") . '</option>';
|
668 |
-
$return .= ' <option value="left" ' . selected( $menu_item_meta['item_align'], 'left', false ) . '>' . __("Default", "megamenu") . '</option>';
|
669 |
-
$return .= ' <option value="right" ' . selected( $menu_item_meta['item_align'], 'right', false ) . '>' . __("Right", "megamenu") . '</option>';
|
670 |
-
$return .= ' </select>';
|
671 |
-
$return .= ' <div class="mega-description">';
|
672 |
-
$return .= " <div class='float-left' style='display:{$float_left_display}'></div>";
|
673 |
-
$return .= " <div class='left' style='display:{$left_display}'>" . __("Item will be aligned based on the 'Menu Items Align' option set in the Theme Editor", "megamenu") . "</div>";
|
674 |
-
$return .= " <div class='right' style='display:{$right_display}'>" . __("Right aligned items will appear in reverse order on the right hand side of the menu bar", "megamenu") . "</div>";
|
675 |
-
$return .= ' </div>';
|
676 |
-
} else {
|
677 |
-
$return .= '<em>' . __("Option only available for top level menu items", "megamenu") . '</em>';
|
678 |
-
}
|
679 |
-
|
680 |
-
$return .= ' </td>';
|
681 |
-
$return .= ' </tr>';
|
682 |
-
$return .= ' <tr class="mega-menu-icon-position">';
|
683 |
-
$return .= ' <td class="mega-name">';
|
684 |
-
$return .= __("Icon Position", "megamenu");
|
685 |
-
$return .= ' </td>';
|
686 |
-
$return .= ' <td class="mega-value">';
|
687 |
-
$return .= ' <select name="settings[icon_position]">';
|
688 |
-
$return .= ' <option value="left" ' . selected( $menu_item_meta['icon_position'], 'left', false ) . '>' . __("Left", "megamenu") . '</option>';
|
689 |
-
$return .= ' <option value="top" ' . selected( $menu_item_meta['icon_position'], 'top', false ) . '>' . __("Top", "megamenu") . '</option>';
|
690 |
-
$return .= ' <option value="right" ' . selected( $menu_item_meta['icon_position'], 'right', false ) . '>' . __("Right", "megamenu") . '</option>';
|
691 |
-
$return .= ' </select>';
|
692 |
-
|
693 |
-
$return .= ' </td>';
|
694 |
-
$return .= ' </tr>';
|
695 |
-
|
696 |
-
$return .= apply_filters("megamenu_after_menu_item_settings", "", $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
697 |
-
|
698 |
-
$return .= ' </table>';
|
699 |
-
|
700 |
-
$return .= ' <h4>' . __("Sub Menu Settings", "megamenu") . '</h4>';
|
701 |
-
|
702 |
-
$return .= ' <table>';
|
703 |
-
$return .= ' <tr class="mega-sub-menu-align">';
|
704 |
-
$return .= ' <td class="mega-name">';
|
705 |
-
$return .= __("Sub Menu Align", "megamenu");
|
706 |
-
$return .= ' </td>';
|
707 |
-
$return .= ' <td class="mega-value">';
|
708 |
-
|
709 |
-
if ( $menu_item_depth == 0 ) {
|
710 |
-
$return .= ' <select name="settings[align]">';
|
711 |
-
$return .= ' <option value="bottom-left" ' . selected( $menu_item_meta['align'], 'bottom-left', false ) . '>' . __("Left edge of Parent", "megamenu") . '</option>';
|
712 |
-
$return .= ' <option value="bottom-right" ' . selected( $menu_item_meta['align'], 'bottom-right', false ) . '>' . __("Right edge of Parent", "megamenu") . '</option>';
|
713 |
-
$return .= ' </select>';
|
714 |
-
$return .= ' <div class="mega-description">';
|
715 |
-
$return .= __("Right aligned flyout menus will expand to the left", "megamenu");
|
716 |
-
$return .= ' </div>';
|
717 |
-
} else {
|
718 |
-
$return .= '<em>' . __("Option only available for top level menu items", "megamenu") . '</em>';
|
719 |
-
}
|
720 |
-
|
721 |
-
$return .= ' </td>';
|
722 |
-
$return .= ' </tr>';
|
723 |
-
$return .= ' <tr>';
|
724 |
-
$return .= ' <td class="mega-name">';
|
725 |
-
$return .= __("Hide Sub Menu on Mobile", "megamenu");
|
726 |
-
$return .= ' </td>';
|
727 |
-
$return .= ' <td class="mega-value">';
|
728 |
-
$return .= ' <input type="checkbox" name="settings[hide_sub_menu_on_mobile]" value="true" ' . checked( $menu_item_meta['hide_sub_menu_on_mobile'], 'true', false ) . ' />';
|
729 |
-
$return .= ' </td>';
|
730 |
-
$return .= ' </tr>';
|
731 |
-
|
732 |
-
if ( $menu_item_depth > 0 ) {
|
733 |
-
$css_version = get_transient("megamenu_css_version");
|
734 |
-
$notice = "";
|
735 |
-
|
736 |
-
if ( $css_version && version_compare( $css_version, '2.6.1', '<' ) ) {
|
737 |
-
$link = "<a href='" . esc_attr( admin_url( 'admin.php?page=maxmegamenu_tools' ) ) . "'>" . __("Mega Menu") . " > " . __("Tools") . "</a>";
|
738 |
-
$notice = "<div class='notice notice-success'><p>";
|
739 |
-
$notice .= sprintf( __("Your menu CSS needs to be updated before you can use the following setting. Please go to %s and Clear the CSS Cache (you will only need to do this once).", "megamenu") , $link);
|
740 |
-
$notice .= "</p></div>";
|
741 |
-
$notice .= "</div><br />";
|
742 |
-
}
|
743 |
-
|
744 |
-
|
745 |
-
$return .= ' <tr>';
|
746 |
-
$return .= ' <td class="mega-name">';
|
747 |
-
$return .= __("Collapse sub menu", "megamenu");
|
748 |
-
$return .= ' </td>';
|
749 |
-
$return .= ' <td class="mega-value">';
|
750 |
-
$return .= $notice;
|
751 |
-
$return .= ' <input type="checkbox" name="settings[collapse_children]" value="true" ' . checked( $menu_item_meta['collapse_children'], 'true', false ) . ' />';
|
752 |
-
$return .= ' <em>' . __("Only applies to menu items displayed within mega sub menus.", "megamenu") . '</em>';
|
753 |
-
$return .= ' </td>';
|
754 |
-
$return .= ' </tr>';
|
755 |
-
}
|
756 |
-
|
757 |
-
$return .= apply_filters("megamenu_after_menu_item_submenu_settings", "", $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
758 |
-
|
759 |
-
$return .= ' </table>';
|
760 |
-
|
761 |
-
|
762 |
-
$return .= get_submit_button();
|
763 |
-
$return .= '</form>';
|
764 |
-
|
765 |
-
$tabs['general_settings'] = array(
|
766 |
-
'title' => __('Settings', 'megamenu'),
|
767 |
-
'content' => $return
|
768 |
-
);
|
769 |
-
|
770 |
-
return $tabs;
|
771 |
|
772 |
-
|
773 |
|
|
|
774 |
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
|
783 |
-
|
784 |
-
'dashicons' => array(
|
785 |
-
'title' => __("Dashicons", "megamenu"),
|
786 |
-
'active' => ! isset( $menu_item_meta['icon'] ) || ( isset( $menu_item_meta['icon'] ) && substr( $menu_item_meta['icon'], 0, strlen("dash") ) === "dash" || $menu_item_meta['icon'] == 'disabled' ),
|
787 |
-
'content' => $this->dashicon_selector()
|
788 |
-
),
|
789 |
-
'fontawesome' => array(
|
790 |
-
'title' => __("Font Awesome", "megamenu"),
|
791 |
-
'active' => false,
|
792 |
-
'content' => str_replace( "{link}", "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __("Max Mega Menu Pro", "megamenu") . "</a>", __("Get access to over 400 Font Awesome Icons with {link}", "megamenu") )
|
793 |
-
),
|
794 |
-
'genericons' => array(
|
795 |
-
'title' => __("Genericons", "megamenu"),
|
796 |
-
'active' => false,
|
797 |
-
'content' => str_replace( "{link}", "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __("Max Mega Menu Pro", "megamenu") . "</a>", __("Choose from over 100 genericons with {link}", "megamenu") )
|
798 |
-
),
|
799 |
-
'custom' => array(
|
800 |
-
'title' => __("Custom Icon", "megamenu"),
|
801 |
-
'active' => false,
|
802 |
-
'content' => str_replace( "{link}", "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __("Max Mega Menu Pro", "megamenu") . "</a>", __("Select icons from your media library with {link}", "megamenu") )
|
803 |
-
)
|
804 |
-
);
|
805 |
|
806 |
-
|
|
|
|
|
|
|
|
|
|
|
807 |
|
808 |
-
|
809 |
-
|
810 |
|
811 |
-
|
812 |
|
813 |
-
|
814 |
|
815 |
-
|
816 |
-
$return .= esc_html( $icon_tab['title'] );
|
817 |
-
$return .= "</li>";
|
818 |
|
819 |
-
|
820 |
|
821 |
-
|
822 |
|
823 |
-
|
824 |
|
825 |
-
|
|
|
|
|
|
|
826 |
|
827 |
-
|
828 |
|
829 |
-
|
830 |
-
|
831 |
-
$return .= " <input type='hidden' name='_wpnonce' value='" . wp_create_nonce('megamenu_edit') . "' />";
|
832 |
-
$return .= " <input type='hidden' name='menu_item_id' value='" . esc_attr( $menu_item_id ) . "' />";
|
833 |
-
$return .= " <input type='hidden' name='action' value='mm_save_menu_item_settings' />";
|
834 |
-
$return .= $icon_tab['content'];
|
835 |
-
$return .= " </form>";
|
836 |
-
$return .= "</div>";
|
837 |
|
838 |
-
|
|
|
839 |
|
840 |
-
|
841 |
-
'title' => __('Icon', 'megamenu'),
|
842 |
-
'content' => $return
|
843 |
-
);
|
844 |
|
845 |
-
|
846 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
}
|
848 |
|
849 |
-
|
850 |
-
* Return the form to select a dashicon
|
851 |
-
*
|
852 |
-
* @since 1.5.2
|
853 |
-
* @return string
|
854 |
-
*/
|
855 |
-
private function dashicon_selector() {
|
856 |
-
|
857 |
-
$return = "<div class='disabled'><input id='disabled' class='radio' type='radio' rel='disabled' name='settings[icon]' value='disabled' " . checked( $this->menu_item_meta['icon'], 'disabled', false ) . " />";
|
858 |
-
$return .= "<label for='disabled'></label></div>";
|
859 |
-
|
860 |
-
foreach ( $this->all_icons() as $code => $class ) {
|
861 |
-
|
862 |
-
$bits = explode( "-", $code );
|
863 |
-
$code = "&#x" . $bits[1] . "";
|
864 |
-
$type = $bits[0];
|
865 |
-
|
866 |
-
$return .= "<div class='{$type}'>";
|
867 |
-
$return .= " <input class='radio' id='{$class}' type='radio' rel='{$code}' name='settings[icon]' value='{$class}' " . checked( $this->menu_item_meta['icon'], $class, false ) . " />";
|
868 |
-
$return .= " <label rel='{$code}' for='{$class}' title='{$class}'></label>";
|
869 |
-
$return .= "</div>";
|
870 |
-
|
871 |
-
}
|
872 |
-
|
873 |
-
return $return;
|
874 |
-
}
|
875 |
-
|
876 |
-
|
877 |
-
/**
|
878 |
-
* List of all available DashIcon classes.
|
879 |
-
*
|
880 |
-
* @since 1.0
|
881 |
-
* @return array - Sorted list of icon classes
|
882 |
-
*/
|
883 |
-
public function all_icons() {
|
884 |
-
|
885 |
-
$icons = array(
|
886 |
-
'dash-f333' => 'dashicons-menu',
|
887 |
-
'dash-f319' => 'dashicons-admin-site',
|
888 |
-
'dash-f226' => 'dashicons-dashboard',
|
889 |
-
'dash-f109' => 'dashicons-admin-post',
|
890 |
-
'dash-f104' => 'dashicons-admin-media',
|
891 |
-
'dash-f103' => 'dashicons-admin-links',
|
892 |
-
'dash-f105' => 'dashicons-admin-page',
|
893 |
-
'dash-f101' => 'dashicons-admin-comments',
|
894 |
-
'dash-f100' => 'dashicons-admin-appearance',
|
895 |
-
'dash-f106' => 'dashicons-admin-plugins',
|
896 |
-
'dash-f110' => 'dashicons-admin-users',
|
897 |
-
'dash-f107' => 'dashicons-admin-tools',
|
898 |
-
'dash-f108' => 'dashicons-admin-settings',
|
899 |
-
'dash-f112' => 'dashicons-admin-network',
|
900 |
-
'dash-f102' => 'dashicons-admin-home',
|
901 |
-
'dash-f111' => 'dashicons-admin-generic',
|
902 |
-
'dash-f148' => 'dashicons-admin-collapse',
|
903 |
-
'dash-f536' => 'dashicons-filter',
|
904 |
-
'dash-f540' => 'dashicons-admin-customizer',
|
905 |
-
'dash-f541' => 'dashicons-admin-multisite',
|
906 |
-
'dash-f119' => 'dashicons-welcome-write-blog',
|
907 |
-
'dash-f133' => 'dashicons-welcome-add-page',
|
908 |
-
'dash-f115' => 'dashicons-welcome-view-site',
|
909 |
-
'dash-f116' => 'dashicons-welcome-widgets-menus',
|
910 |
-
'dash-f117' => 'dashicons-welcome-comments',
|
911 |
-
'dash-f118' => 'dashicons-welcome-learn-more',
|
912 |
-
'dash-f123' => 'dashicons-format-aside',
|
913 |
-
'dash-f128' => 'dashicons-format-image',
|
914 |
-
'dash-f161' => 'dashicons-format-gallery',
|
915 |
-
'dash-f126' => 'dashicons-format-video',
|
916 |
-
'dash-f130' => 'dashicons-format-status',
|
917 |
-
'dash-f122' => 'dashicons-format-quote',
|
918 |
-
'dash-f125' => 'dashicons-format-chat',
|
919 |
-
'dash-f127' => 'dashicons-format-audio',
|
920 |
-
'dash-f306' => 'dashicons-camera',
|
921 |
-
'dash-f232' => 'dashicons-images-alt',
|
922 |
-
'dash-f233' => 'dashicons-images-alt2',
|
923 |
-
'dash-f234' => 'dashicons-video-alt',
|
924 |
-
'dash-f235' => 'dashicons-video-alt2',
|
925 |
-
'dash-f236' => 'dashicons-video-alt3',
|
926 |
-
'dash-f501' => 'dashicons-media-archive',
|
927 |
-
'dash-f500' => 'dashicons-media-audio',
|
928 |
-
'dash-f499' => 'dashicons-media-code',
|
929 |
-
'dash-f498' => 'dashicons-media-default',
|
930 |
-
'dash-f497' => 'dashicons-media-document',
|
931 |
-
'dash-f496' => 'dashicons-media-interactive',
|
932 |
-
'dash-f495' => 'dashicons-media-spreadsheet',
|
933 |
-
'dash-f491' => 'dashicons-media-text',
|
934 |
-
'dash-f490' => 'dashicons-media-video',
|
935 |
-
'dash-f492' => 'dashicons-playlist-audio',
|
936 |
-
'dash-f493' => 'dashicons-playlist-video',
|
937 |
-
'dash-f522' => 'dashicons-controls-play',
|
938 |
-
'dash-f523' => 'dashicons-controls-pause',
|
939 |
-
'dash-f519' => 'dashicons-controls-forward',
|
940 |
-
'dash-f517' => 'dashicons-controls-skipforward',
|
941 |
-
'dash-f518' => 'dashicons-controls-back',
|
942 |
-
'dash-f516' => 'dashicons-controls-skipback',
|
943 |
-
'dash-f515' => 'dashicons-controls-repeat',
|
944 |
-
'dash-f521' => 'dashicons-controls-volumeon',
|
945 |
-
'dash-f520' => 'dashicons-controls-volumeoff',
|
946 |
-
'dash-f165' => 'dashicons-image-crop',
|
947 |
-
'dash-f531' => 'dashicons-image-rotate',
|
948 |
-
'dash-f166' => 'dashicons-image-rotate-left',
|
949 |
-
'dash-f167' => 'dashicons-image-rotate-right',
|
950 |
-
'dash-f168' => 'dashicons-image-flip-vertical',
|
951 |
-
'dash-f169' => 'dashicons-image-flip-horizontal',
|
952 |
-
'dash-f533' => 'dashicons-image-filter',
|
953 |
-
'dash-f171' => 'dashicons-undo',
|
954 |
-
'dash-f172' => 'dashicons-redo',
|
955 |
-
'dash-f200' => 'dashicons-editor-bold',
|
956 |
-
'dash-f201' => 'dashicons-editor-italic',
|
957 |
-
'dash-f203' => 'dashicons-editor-ul',
|
958 |
-
'dash-f204' => 'dashicons-editor-ol',
|
959 |
-
'dash-f205' => 'dashicons-editor-quote',
|
960 |
-
'dash-f206' => 'dashicons-editor-alignleft',
|
961 |
-
'dash-f207' => 'dashicons-editor-aligncenter',
|
962 |
-
'dash-f208' => 'dashicons-editor-alignright',
|
963 |
-
'dash-f209' => 'dashicons-editor-insertmore',
|
964 |
-
'dash-f210' => 'dashicons-editor-spellcheck',
|
965 |
-
'dash-f211' => 'dashicons-editor-expand',
|
966 |
-
'dash-f506' => 'dashicons-editor-contract',
|
967 |
-
'dash-f212' => 'dashicons-editor-kitchensink',
|
968 |
-
'dash-f213' => 'dashicons-editor-underline',
|
969 |
-
'dash-f214' => 'dashicons-editor-justify',
|
970 |
-
'dash-f215' => 'dashicons-editor-textcolor',
|
971 |
-
'dash-f216' => 'dashicons-editor-paste-word',
|
972 |
-
'dash-f217' => 'dashicons-editor-paste-text',
|
973 |
-
'dash-f218' => 'dashicons-editor-removeformatting',
|
974 |
-
'dash-f219' => 'dashicons-editor-video',
|
975 |
-
'dash-f220' => 'dashicons-editor-customchar',
|
976 |
-
'dash-f221' => 'dashicons-editor-outdent',
|
977 |
-
'dash-f222' => 'dashicons-editor-indent',
|
978 |
-
'dash-f223' => 'dashicons-editor-help',
|
979 |
-
'dash-f224' => 'dashicons-editor-strikethrough',
|
980 |
-
'dash-f225' => 'dashicons-editor-unlink',
|
981 |
-
'dash-f320' => 'dashicons-editor-rtl',
|
982 |
-
'dash-f474' => 'dashicons-editor-break',
|
983 |
-
'dash-f475' => 'dashicons-editor-code',
|
984 |
-
'dash-f476' => 'dashicons-editor-paragraph',
|
985 |
-
'dash-f535' => 'dashicons-editor-table',
|
986 |
-
'dash-f135' => 'dashicons-align-left',
|
987 |
-
'dash-f136' => 'dashicons-align-right',
|
988 |
-
'dash-f134' => 'dashicons-align-center',
|
989 |
-
'dash-f138' => 'dashicons-align-none',
|
990 |
-
'dash-f160' => 'dashicons-lock',
|
991 |
-
'dash-f528' => 'dashicons-unlock',
|
992 |
-
'dash-f145' => 'dashicons-calendar',
|
993 |
-
'dash-f508' => 'dashicons-calendar-alt',
|
994 |
-
'dash-f177' => 'dashicons-visibility',
|
995 |
-
'dash-f530' => 'dashicons-hidden',
|
996 |
-
'dash-f173' => 'dashicons-post-status',
|
997 |
-
'dash-f464' => 'dashicons-edit',
|
998 |
-
'dash-f182' => 'dashicons-trash',
|
999 |
-
'dash-f537' => 'dashicons-sticky',
|
1000 |
-
'dash-f504' => 'dashicons-external',
|
1001 |
-
'dash-f142' => 'dashicons-arrow-up',
|
1002 |
-
'dash-f140' => 'dashicons-arrow-down',
|
1003 |
-
'dash-f139' => 'dashicons-arrow-right',
|
1004 |
-
'dash-f141' => 'dashicons-arrow-left',
|
1005 |
-
'dash-f342' => 'dashicons-arrow-up-alt',
|
1006 |
-
'dash-f346' => 'dashicons-arrow-down-alt',
|
1007 |
-
'dash-f344' => 'dashicons-arrow-right-alt',
|
1008 |
-
'dash-f340' => 'dashicons-arrow-left-alt',
|
1009 |
-
'dash-f343' => 'dashicons-arrow-up-alt2',
|
1010 |
-
'dash-f347' => 'dashicons-arrow-down-alt2',
|
1011 |
-
'dash-f345' => 'dashicons-arrow-right-alt2',
|
1012 |
-
'dash-f341' => 'dashicons-arrow-left-alt2',
|
1013 |
-
'dash-f156' => 'dashicons-sort',
|
1014 |
-
'dash-f229' => 'dashicons-leftright',
|
1015 |
-
'dash-f503' => 'dashicons-randomize',
|
1016 |
-
'dash-f163' => 'dashicons-list-view',
|
1017 |
-
'dash-f164' => 'dashicons-exerpt-view',
|
1018 |
-
'dash-f509' => 'dashicons-grid-view',
|
1019 |
-
'dash-f237' => 'dashicons-share',
|
1020 |
-
'dash-f240' => 'dashicons-share-alt',
|
1021 |
-
'dash-f242' => 'dashicons-share-alt2',
|
1022 |
-
'dash-f301' => 'dashicons-twitter',
|
1023 |
-
'dash-f303' => 'dashicons-rss',
|
1024 |
-
'dash-f465' => 'dashicons-email',
|
1025 |
-
'dash-f466' => 'dashicons-email-alt',
|
1026 |
-
'dash-f304' => 'dashicons-facebook',
|
1027 |
-
'dash-f305' => 'dashicons-facebook-alt',
|
1028 |
-
'dash-f462' => 'dashicons-googleplus',
|
1029 |
-
'dash-f325' => 'dashicons-networking',
|
1030 |
-
'dash-f308' => 'dashicons-hammer',
|
1031 |
-
'dash-f309' => 'dashicons-art',
|
1032 |
-
'dash-f310' => 'dashicons-migrate',
|
1033 |
-
'dash-f311' => 'dashicons-performance',
|
1034 |
-
'dash-f483' => 'dashicons-universal-access',
|
1035 |
-
'dash-f507' => 'dashicons-universal-access-alt',
|
1036 |
-
'dash-f486' => 'dashicons-tickets',
|
1037 |
-
'dash-f484' => 'dashicons-nametag',
|
1038 |
-
'dash-f481' => 'dashicons-clipboard',
|
1039 |
-
'dash-f487' => 'dashicons-heart',
|
1040 |
-
'dash-f488' => 'dashicons-megaphone',
|
1041 |
-
'dash-f489' => 'dashicons-schedule',
|
1042 |
-
'dash-f120' => 'dashicons-wordpress',
|
1043 |
-
'dash-f324' => 'dashicons-wordpress-alt',
|
1044 |
-
'dash-f157' => 'dashicons-pressthis',
|
1045 |
-
'dash-f463' => 'dashicons-update',
|
1046 |
-
'dash-f180' => 'dashicons-screenoptions',
|
1047 |
-
'dash-f348' => 'dashicons-info',
|
1048 |
-
'dash-f174' => 'dashicons-cart',
|
1049 |
-
'dash-f175' => 'dashicons-feedback',
|
1050 |
-
'dash-f176' => 'dashicons-cloud',
|
1051 |
-
'dash-f326' => 'dashicons-translation',
|
1052 |
-
'dash-f323' => 'dashicons-tag',
|
1053 |
-
'dash-f318' => 'dashicons-category',
|
1054 |
-
'dash-f480' => 'dashicons-archive',
|
1055 |
-
'dash-f479' => 'dashicons-tagcloud',
|
1056 |
-
'dash-f478' => 'dashicons-text',
|
1057 |
-
'dash-f147' => 'dashicons-yes',
|
1058 |
-
'dash-f158' => 'dashicons-no',
|
1059 |
-
'dash-f335' => 'dashicons-no-alt',
|
1060 |
-
'dash-f132' => 'dashicons-plus',
|
1061 |
-
'dash-f502' => 'dashicons-plus-alt',
|
1062 |
-
'dash-f460' => 'dashicons-minus',
|
1063 |
-
'dash-f153' => 'dashicons-dismiss',
|
1064 |
-
'dash-f159' => 'dashicons-marker',
|
1065 |
-
'dash-f155' => 'dashicons-star-filled',
|
1066 |
-
'dash-f459' => 'dashicons-star-half',
|
1067 |
-
'dash-f154' => 'dashicons-star-empty',
|
1068 |
-
'dash-f227' => 'dashicons-flag',
|
1069 |
-
'dash-f534' => 'dashicons-warning',
|
1070 |
-
'dash-f230' => 'dashicons-location',
|
1071 |
-
'dash-f231' => 'dashicons-location-alt',
|
1072 |
-
'dash-f178' => 'dashicons-vault',
|
1073 |
-
'dash-f332' => 'dashicons-shield',
|
1074 |
-
'dash-f334' => 'dashicons-shield-alt',
|
1075 |
-
'dash-f468' => 'dashicons-sos',
|
1076 |
-
'dash-f179' => 'dashicons-search',
|
1077 |
-
'dash-f181' => 'dashicons-slides',
|
1078 |
-
'dash-f183' => 'dashicons-analytics',
|
1079 |
-
'dash-f184' => 'dashicons-chart-pie',
|
1080 |
-
'dash-f185' => 'dashicons-chart-bar',
|
1081 |
-
'dash-f238' => 'dashicons-chart-line',
|
1082 |
-
'dash-f239' => 'dashicons-chart-area',
|
1083 |
-
'dash-f307' => 'dashicons-groups',
|
1084 |
-
'dash-f338' => 'dashicons-businessman',
|
1085 |
-
'dash-f336' => 'dashicons-id',
|
1086 |
-
'dash-f337' => 'dashicons-id-alt',
|
1087 |
-
'dash-f312' => 'dashicons-products',
|
1088 |
-
'dash-f313' => 'dashicons-awards',
|
1089 |
-
'dash-f314' => 'dashicons-forms',
|
1090 |
-
'dash-f473' => 'dashicons-testimonial',
|
1091 |
-
'dash-f322' => 'dashicons-portfolio',
|
1092 |
-
'dash-f330' => 'dashicons-book',
|
1093 |
-
'dash-f331' => 'dashicons-book-alt',
|
1094 |
-
'dash-f316' => 'dashicons-download',
|
1095 |
-
'dash-f317' => 'dashicons-upload',
|
1096 |
-
'dash-f321' => 'dashicons-backup',
|
1097 |
-
'dash-f469' => 'dashicons-clock',
|
1098 |
-
'dash-f339' => 'dashicons-lightbulb',
|
1099 |
-
'dash-f482' => 'dashicons-microphone',
|
1100 |
-
'dash-f472' => 'dashicons-desktop',
|
1101 |
-
'dash-f471' => 'dashicons-tablet',
|
1102 |
-
'dash-f470' => 'dashicons-smartphone',
|
1103 |
-
'dash-f525' => 'dashicons-phone',
|
1104 |
-
'dash-f510' => 'dashicons-index-card',
|
1105 |
-
'dash-f511' => 'dashicons-carrot',
|
1106 |
-
'dash-f512' => 'dashicons-building',
|
1107 |
-
'dash-f513' => 'dashicons-store',
|
1108 |
-
'dash-f514' => 'dashicons-album',
|
1109 |
-
'dash-f527' => 'dashicons-palmtree',
|
1110 |
-
'dash-f524' => 'dashicons-tickets-alt',
|
1111 |
-
'dash-f526' => 'dashicons-money',
|
1112 |
-
'dash-f328' => 'dashicons-smiley',
|
1113 |
-
'dash-f529' => 'dashicons-thumbs-up',
|
1114 |
-
'dash-f542' => 'dashicons-thumbs-down',
|
1115 |
-
'dash-f538' => 'dashicons-layout',
|
1116 |
-
'dash-f452' => 'dashicons-buddicons-activity',
|
1117 |
-
'dash-f477' => 'dashicons-buddicons-bbpress-logo',
|
1118 |
-
'dash-f448' => 'dashicons-buddicons-buddypress-logo',
|
1119 |
-
'dash-f453' => 'dashicons-buddicons-community',
|
1120 |
-
'dash-f449' => 'dashicons-buddicons-forums',
|
1121 |
-
'dash-f454' => 'dashicons-buddicons-friends',
|
1122 |
-
'dash-f456' => 'dashicons-buddicons-groups',
|
1123 |
-
'dash-f457' => 'dashicons-buddicons-pm',
|
1124 |
-
'dash-f451' => 'dashicons-buddicons-replies',
|
1125 |
-
'dash-f450' => 'dashicons-buddicons-topics',
|
1126 |
-
'dash-f455' => 'dashicons-buddicons-tracking',
|
1127 |
-
'dash-f12c' => 'dashicons-editor-ol-rtl',
|
1128 |
-
'dash-f10c' => 'dashicons-editor-ltr',
|
1129 |
-
'dash-f10d' => 'dashicons-tide',
|
1130 |
-
'dash-f124' => 'dashicons-rest-api',
|
1131 |
-
'dash-f13a' => 'dashicons-code-standards',
|
1132 |
-
'dash-f11d' => 'dashicons-admin-site-alt',
|
1133 |
-
'dash-f11e' => 'dashicons-admin-site-alt2',
|
1134 |
-
'dash-f11f' => 'dashicons-admin-site-alt3',
|
1135 |
-
'dash-f228' => 'dashicons-menu-alt',
|
1136 |
-
'dash-f329' => 'dashicons-menu-alt2',
|
1137 |
-
'dash-f349' => 'dashicons-menu-alt3',
|
1138 |
-
'dash-f12d' => 'dashicons-instagram',
|
1139 |
-
'dash-f12f' => 'dashicons-businesswoman',
|
1140 |
-
'dash-f12e' => 'dashicons-businessperson',
|
1141 |
-
'dash-f467' => 'dashicons-email-alt2',
|
1142 |
-
'dash-f12a' => 'dashicons-yes-alt',
|
1143 |
-
'dash-f129' => 'dashicons-camera-alt',
|
1144 |
-
'dash-f485' => 'dashicons-plugins-checked',
|
1145 |
-
'dash-f113' => 'dashicons-update-alt',
|
1146 |
-
'dash-f121' => 'dashicons-text-page',
|
1147 |
-
);
|
1148 |
-
|
1149 |
-
$icons = apply_filters( "megamenu_dashicons", $icons );
|
1150 |
-
|
1151 |
-
ksort( $icons );
|
1152 |
-
|
1153 |
-
return $icons;
|
1154 |
-
}
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Menu_Item_Manager' ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
/**
|
|
|
10 |
*
|
11 |
* @since 1.4
|
12 |
*/
|
13 |
+
class Mega_Menu_Menu_Item_Manager {
|
14 |
+
|
15 |
+
var $menu_id = 0;
|
16 |
+
var $menu_item_id = 0;
|
17 |
+
var $menu_item_title = '';
|
18 |
+
var $menu_item_depth = 0;
|
19 |
+
var $menu_item_objects = array();
|
20 |
+
var $menu_item_meta = array();
|
21 |
+
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Constructor
|
25 |
+
*
|
26 |
+
* @since 1.4
|
27 |
+
*/
|
28 |
+
public function __construct() {
|
29 |
+
add_action( 'wp_ajax_mm_get_lightbox_html', array( $this, 'ajax_get_lightbox_html' ) );
|
30 |
+
add_action( 'wp_ajax_mm_get_empty_grid_column', array( $this, 'ajax_get_empty_grid_column' ) );
|
31 |
+
add_action( 'wp_ajax_mm_get_empty_grid_row', array( $this, 'ajax_get_empty_grid_row' ) );
|
32 |
+
add_action( 'wp_ajax_mm_save_menu_item_settings', array( $this, 'ajax_save_menu_item_settings' ) );
|
33 |
+
|
34 |
+
add_filter( 'megamenu_tabs', array( $this, 'add_mega_menu_tab' ), 10, 5 );
|
35 |
+
add_filter( 'megamenu_tabs', array( $this, 'add_general_settings_tab' ), 10, 5 );
|
36 |
+
add_filter( 'megamenu_tabs', array( $this, 'add_icon_tab' ), 10, 5 );
|
37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
|
|
39 |
|
40 |
+
/**
|
41 |
+
* Set up the class
|
42 |
+
*
|
43 |
+
* @since 1.4
|
44 |
+
*/
|
45 |
+
private function init() {
|
46 |
+
if ( isset( $_POST['menu_item_id'] ) ) {
|
47 |
+
$this->menu_item_id = absint( $_POST['menu_item_id'] );
|
48 |
+
$this->menu_id = $this->get_menu_id_for_menu_item_id( $this->menu_item_id );
|
49 |
+
$this->menu_item_objects = wp_get_nav_menu_items( $this->menu_id );
|
50 |
+
$this->menu_item_title = $this->get_title_for_menu_item_id( $this->menu_item_id, $this->menu_item_objects );
|
51 |
+
$this->menu_item_depth = $this->get_menu_item_depth( $this->menu_item_id, $this->menu_item_objects );
|
52 |
+
$saved_settings = array_filter( (array) get_post_meta( $this->menu_item_id, '_megamenu', true ) );
|
53 |
+
$this->menu_item_meta = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
54 |
+
}
|
55 |
+
}
|
56 |
|
57 |
+
/**
|
58 |
+
* Get the depth for a menu item ID
|
59 |
+
*
|
60 |
+
* @since 2.7.7
|
61 |
+
* @param int $menu_item_id
|
62 |
+
* @param array $menu_item_objects
|
63 |
+
* @return int
|
64 |
+
*/
|
65 |
+
public function get_menu_item_depth( $menu_item_id, $menu_item_objects ) {
|
66 |
+
$parents = array();
|
67 |
|
68 |
+
foreach ( $menu_item_objects as $key => $item ) {
|
69 |
+
if ( $item->menu_item_parent == 0 ) {
|
70 |
|
71 |
+
if ( $item->ID == $menu_item_id ) {
|
72 |
+
return 0; // top level item
|
73 |
+
}
|
74 |
|
75 |
+
$parents[] = $item->ID;
|
76 |
+
}
|
77 |
+
}
|
78 |
|
79 |
+
if ( count( $parents ) ) {
|
80 |
+
foreach ( $menu_item_objects as $key => $item ) {
|
81 |
+
if ( in_array( $item->menu_item_parent, $parents ) ) {
|
82 |
+
if ( $item->ID == $menu_item_id ) {
|
83 |
+
return 1; // second level item
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
|
89 |
+
return 2; // third level item or above
|
90 |
+
}
|
91 |
|
|
|
92 |
|
93 |
+
/**
|
94 |
+
* Save custom menu item fields.
|
95 |
+
*
|
96 |
+
* @since 1.4
|
97 |
+
*/
|
98 |
+
public static function ajax_save_menu_item_settings() {
|
99 |
|
100 |
+
check_ajax_referer( 'megamenu_edit' );
|
101 |
|
102 |
+
$submitted_settings = isset( $_POST['settings'] ) ? $_POST['settings'] : array();
|
103 |
|
104 |
+
$menu_item_id = absint( $_POST['menu_item_id'] );
|
105 |
|
106 |
+
if ( $menu_item_id > 0 && is_array( $submitted_settings ) ) {
|
107 |
|
108 |
+
// only check the checkbox values if the general settings form was submitted
|
109 |
+
if ( isset( $_POST['tab'] ) && $_POST['tab'] == 'general_settings' ) {
|
110 |
|
111 |
+
$checkboxes = array( 'hide_text', 'disable_link', 'hide_arrow', 'hide_on_mobile', 'hide_on_desktop', 'hide_sub_menu_on_mobile', 'collapse_children' );
|
112 |
|
113 |
+
foreach ( $checkboxes as $checkbox ) {
|
114 |
+
if ( ! isset( $submitted_settings[ $checkbox ] ) ) {
|
115 |
+
$submitted_settings[ $checkbox ] = 'false';
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
|
120 |
+
$submitted_settings = apply_filters( 'megamenu_menu_item_submitted_settings', $submitted_settings, $menu_item_id );
|
121 |
|
122 |
+
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true );
|
123 |
+
|
124 |
+
if ( is_array( $existing_settings ) ) {
|
125 |
+
|
126 |
+
$submitted_settings = array_merge( $existing_settings, $submitted_settings );
|
127 |
|
128 |
+
}
|
129 |
|
130 |
+
update_post_meta( $menu_item_id, '_megamenu', $submitted_settings );
|
131 |
|
132 |
+
do_action( 'megamenu_save_menu_item_settings', $menu_item_id );
|
133 |
|
134 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
+
if ( isset( $_POST['clear_cache'] ) ) {
|
137 |
|
138 |
+
do_action( 'megamenu_delete_cache' );
|
139 |
|
140 |
+
}
|
141 |
|
142 |
+
if ( ob_get_contents() ) {
|
143 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
144 |
+
}
|
145 |
|
146 |
+
wp_send_json_success();
|
147 |
|
148 |
+
}
|
|
|
|
|
149 |
|
|
|
150 |
|
151 |
+
/**
|
152 |
+
* Return the HTML to display in the Lightbox
|
153 |
+
*
|
154 |
+
* @since 1.4
|
155 |
+
* @return string
|
156 |
+
*/
|
157 |
+
public function ajax_get_lightbox_html() {
|
158 |
|
159 |
+
check_ajax_referer( 'megamenu_edit' );
|
160 |
|
161 |
+
$this->init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
+
$response = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
+
$response['title'] = $this->menu_item_title;
|
166 |
|
167 |
+
$response['active_tab'] = 'mega_menu';
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
+
if ( $this->menu_item_depth > 0 ) {
|
170 |
+
$response['active_tab'] = 'general_settings';
|
171 |
+
}
|
172 |
|
173 |
+
$response = apply_filters( 'megamenu_tabs', $response, $this->menu_item_id, $this->menu_id, $this->menu_item_depth, $this->menu_item_meta );
|
174 |
|
175 |
+
if ( ob_get_contents() ) {
|
176 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
177 |
+
}
|
|
|
|
|
|
|
178 |
|
179 |
+
wp_send_json_success( json_encode( $response ) );
|
180 |
+
}
|
181 |
|
|
|
182 |
|
183 |
+
/**
|
184 |
+
* Returns the menu ID for a specified menu item ID
|
185 |
+
*
|
186 |
+
* @since 2.7.5
|
187 |
+
* @param int $menu_item_id
|
188 |
+
* @return int $menu_id
|
189 |
+
*/
|
190 |
+
public function get_menu_id_for_menu_item_id( $menu_item_id ) {
|
191 |
+
$terms = get_the_terms( $menu_item_id, 'nav_menu' );
|
192 |
+
$menu_id = $terms[0]->term_id;
|
193 |
+
return $menu_id;
|
194 |
+
}
|
195 |
|
|
|
196 |
|
197 |
+
/**
|
198 |
+
* Returns the title of a given menu item ID
|
199 |
+
*
|
200 |
+
* @since 2.7.5
|
201 |
+
* @param int $menu_item_id
|
202 |
+
* @return int $menu_id
|
203 |
+
*/
|
204 |
+
public function get_title_for_menu_item_id( $menu_item_id, $menu_item_objects ) {
|
205 |
+
foreach ( $menu_item_objects as $key => $item ) {
|
206 |
+
if ( $item->ID == $menu_item_id ) {
|
207 |
+
return $item->title;
|
208 |
+
}
|
209 |
+
}
|
210 |
|
211 |
+
return false;
|
212 |
+
}
|
213 |
|
214 |
+
/**
|
215 |
+
* Return the HTML to display in the 'Mega Menu' tab
|
216 |
+
*
|
217 |
+
* @since 1.7
|
218 |
+
* @return array
|
219 |
+
*/
|
220 |
+
public function add_mega_menu_tab( $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
221 |
+
if ( $menu_item_depth > 0 ) {
|
222 |
+
$tabs['mega_menu'] = array(
|
223 |
+
'title' => __( 'Sub Menu', 'megamenu' ),
|
224 |
+
'content' => '<em>' . __( 'Mega Menus can only be created on top level menu items.', 'megamenu' ) . '</em>',
|
225 |
+
);
|
226 |
|
227 |
+
return $tabs;
|
228 |
+
}
|
|
|
|
|
|
|
229 |
|
230 |
+
$submenu_options = apply_filters(
|
231 |
+
'megamenu_submenu_options',
|
232 |
+
array(
|
233 |
+
'flyout' => __( 'Flyout Menu', 'megamenu' ),
|
234 |
+
'grid' => __( 'Mega Menu - Grid Layout', 'megamenu' ),
|
235 |
+
'megamenu' => __( 'Mega Menu - Standard Layout', 'megamenu' ),
|
236 |
+
),
|
237 |
+
$menu_item_meta
|
238 |
+
);
|
239 |
|
240 |
+
$return = "<label for='mm_enable_mega_menu'>" . __( 'Sub menu display mode', 'megamenu' ) . '</label>';
|
241 |
|
242 |
+
$return .= "<select id='mm_enable_mega_menu' name='settings[type]'>";
|
243 |
|
244 |
+
foreach ( $submenu_options as $type => $label ) {
|
245 |
+
$return .= "<option id='{$type}' value='{$type}' " . selected( $menu_item_meta['type'], $type, false ) . ">{$label}</option>";
|
246 |
+
}
|
247 |
+
$return .= '</select>';
|
248 |
|
249 |
+
$widget_manager = new Mega_Menu_Widget_Manager();
|
250 |
|
251 |
+
$all_widgets = $widget_manager->get_available_widgets();
|
252 |
|
253 |
+
$return .= "<div class='mm_panel_options'>";
|
254 |
+
$return .= " <select id='mm_number_of_columns' name='settings[panel_columns]'>";
|
255 |
+
$return .= " <option value='1' " . selected( $menu_item_meta['panel_columns'], 1, false ) . '>1 ' . __( 'column', 'megamenu' ) . '</option>';
|
256 |
+
$return .= " <option value='2' " . selected( $menu_item_meta['panel_columns'], 2, false ) . '>2 ' . __( 'columns', 'megamenu' ) . '</option>';
|
257 |
+
$return .= " <option value='3' " . selected( $menu_item_meta['panel_columns'], 3, false ) . '>3 ' . __( 'columns', 'megamenu' ) . '</option>';
|
258 |
+
$return .= " <option value='4' " . selected( $menu_item_meta['panel_columns'], 4, false ) . '>4 ' . __( 'columns', 'megamenu' ) . '</option>';
|
259 |
+
$return .= " <option value='5' " . selected( $menu_item_meta['panel_columns'], 5, false ) . '>5 ' . __( 'columns', 'megamenu' ) . '</option>';
|
260 |
+
$return .= " <option value='6' " . selected( $menu_item_meta['panel_columns'], 6, false ) . '>6 ' . __( 'columns', 'megamenu' ) . '</option>';
|
261 |
+
$return .= " <option value='7' " . selected( $menu_item_meta['panel_columns'], 7, false ) . '>7 ' . __( 'columns', 'megamenu' ) . '</option>';
|
262 |
+
$return .= " <option value='8' " . selected( $menu_item_meta['panel_columns'], 8, false ) . '>8 ' . __( 'columns', 'megamenu' ) . '</option>';
|
263 |
+
$return .= " <option value='9' " . selected( $menu_item_meta['panel_columns'], 9, false ) . '>9 ' . __( 'columns', 'megamenu' ) . '</option>';
|
264 |
+
$return .= " <option value='10' " . selected( $menu_item_meta['panel_columns'], 10, false ) . '>10 ' . __( 'columns', 'megamenu' ) . '</option>';
|
265 |
+
$return .= " <option value='11' " . selected( $menu_item_meta['panel_columns'], 11, false ) . '>11 ' . __( 'columns', 'megamenu' ) . '</option>';
|
266 |
+
$return .= " <option value='12' " . selected( $menu_item_meta['panel_columns'], 12, false ) . '>12 ' . __( 'columns', 'megamenu' ) . '</option>';
|
267 |
+
$return .= ' </select>';
|
268 |
+
|
269 |
+
$return .= " <select id='mm_widget_selector'>";
|
270 |
+
$return .= " <option value='disabled'>" . __( 'Select a Widget to add to the panel', 'megamenu' ) . '</option>';
|
271 |
|
272 |
+
foreach ( $all_widgets as $widget ) {
|
273 |
+
$return .= " <option value='" . $widget['value'] . "'>" . $widget['text'] . '</option>';
|
274 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
|
276 |
+
$return .= ' </select>';
|
277 |
+
$return .= '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
+
$return .= $this->get_megamenu_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
280 |
|
281 |
+
$return .= $this->get_megamenu_grid_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
282 |
|
283 |
+
$tabs['mega_menu'] = array(
|
284 |
+
'title' => __( 'Mega Menu', 'megamenu' ),
|
285 |
+
'content' => $return,
|
286 |
+
);
|
287 |
+
|
288 |
+
return $tabs;
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Return the HTML for the grid layout
|
294 |
+
*
|
295 |
+
* @since 2.4
|
296 |
+
* @return string
|
297 |
+
*/
|
298 |
+
public function get_megamenu_grid_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
299 |
+
|
300 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
301 |
|
302 |
+
$return = "<div id='megamenu-grid'>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
+
if ( $css_version && version_compare( $css_version, '2.3.9', '<=' ) ) {
|
305 |
+
$link = "<a href='" . esc_attr( admin_url( 'admin.php?page=maxmegamenu_tools' ) ) . "'>" . __( 'Mega Menu' ) . ' > ' . __( 'Tools' ) . '</a>';
|
306 |
+
$return .= "<div class='notice notice-success'><p>";
|
307 |
+
$return .= sprintf( __( 'Your menu CSS needs to be updated first. Please go to %s and Clear the CSS Cache (you will only need to do this once).', 'megamenu' ), $link );
|
308 |
+
$return .= '</p></div>';
|
309 |
+
$return .= '</div>';
|
310 |
|
311 |
+
return $return;
|
312 |
+
}
|
313 |
|
314 |
+
$widget_manager = new Mega_Menu_Widget_Manager();
|
315 |
|
316 |
+
$grid = $widget_manager->get_grid_widgets_and_menu_items_for_menu_id( $menu_item_id, $menu_id );
|
317 |
|
318 |
+
if ( count( $grid ) ) {
|
|
|
|
|
319 |
|
320 |
+
foreach ( $grid as $row => $row_data ) {
|
321 |
|
322 |
+
$column_html = '';
|
323 |
|
324 |
+
if ( isset( $row_data['columns'] ) && count( $row_data['columns'] ) ) {
|
325 |
|
326 |
+
foreach ( $row_data['columns'] as $col => $col_data ) {
|
327 |
+
$column_html .= $this->get_grid_column( $row_data, $col_data );
|
328 |
+
}
|
329 |
+
}
|
330 |
|
331 |
+
$return .= $this->get_grid_row( $row_data, $column_html );
|
332 |
|
333 |
+
}
|
334 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
$return .= " <button class='button button-primary mega-add-row'><span class='dashicons dashicons-plus'></span>" . __( 'Row', 'megamenu' ) . '</button>';
|
337 |
+
$return .= '</div>';
|
338 |
|
339 |
+
return $return;
|
|
|
|
|
|
|
340 |
|
341 |
+
}
|
342 |
|
343 |
+
/**
|
344 |
+
* Return the HTML to display in the Lightbox
|
345 |
+
*
|
346 |
+
* @since 2.4
|
347 |
+
* @return string
|
348 |
+
*/
|
349 |
+
public function ajax_get_empty_grid_column() {
|
350 |
+
|
351 |
+
check_ajax_referer( 'megamenu_edit' );
|
352 |
+
|
353 |
+
$return = $this->get_grid_column();
|
354 |
+
|
355 |
+
if ( ob_get_contents() ) {
|
356 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
357 |
+
}
|
358 |
+
|
359 |
+
wp_send_json_success( $return );
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Return the HTML to display in the Lightbox
|
364 |
+
*
|
365 |
+
* @since 2.4
|
366 |
+
* @return string
|
367 |
+
*/
|
368 |
+
public function ajax_get_empty_grid_row() {
|
369 |
+
|
370 |
+
check_ajax_referer( 'megamenu_edit' );
|
371 |
+
|
372 |
+
$column_html = $this->get_grid_column();
|
373 |
+
|
374 |
+
$return = $this->get_grid_row( false, $column_html );
|
375 |
+
|
376 |
+
if ( ob_get_contents() ) {
|
377 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
378 |
+
}
|
379 |
+
|
380 |
+
wp_send_json_success( $return );
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Return the HTML for a single row
|
385 |
+
*
|
386 |
+
* @param array $row_data
|
387 |
+
* @param string $column_html
|
388 |
+
* @since 2.4
|
389 |
+
* @return string
|
390 |
+
*/
|
391 |
+
public function get_grid_row( $row_data = false, $column_html = false ) {
|
392 |
+
|
393 |
+
$hide_on_desktop_checked = 'false';
|
394 |
+
$hide_on_desktop = 'mega-enabled';
|
395 |
+
|
396 |
+
if ( isset( $row_data['meta']['hide-on-desktop'] ) && $row_data['meta']['hide-on-desktop'] == 'true' ) {
|
397 |
+
$hide_on_desktop = 'mega-disabled';
|
398 |
+
$hide_on_desktop_checked = 'true';
|
399 |
+
}
|
400 |
+
|
401 |
+
$hide_on_mobile_checked = 'false';
|
402 |
+
$hide_on_mobile = 'mega-enabled';
|
403 |
+
|
404 |
+
if ( isset( $row_data['meta']['hide-on-mobile'] ) && $row_data['meta']['hide-on-mobile'] == 'true' ) {
|
405 |
+
$hide_on_mobile = 'mega-disabled';
|
406 |
+
$hide_on_mobile_checked = 'true';
|
407 |
+
}
|
408 |
+
|
409 |
+
$row_columns = 12;
|
410 |
+
|
411 |
+
if ( isset( $row_data['meta']['columns'] ) ) {
|
412 |
+
$row_columns = intval( $row_data['meta']['columns'] );
|
413 |
+
}
|
414 |
+
|
415 |
+
$desktop_tooltip_visible = __( 'Row', 'megamenu' ) . ': ' . __( 'Visible on desktop', 'megamenu' );
|
416 |
+
$desktop_tooltip_hidden = __( 'Row', 'megamenu' ) . ': ' . __( 'Hidden on desktop', 'megamenu' );
|
417 |
+
$mobile_tooltip_visible = __( 'Row', 'megamenu' ) . ': ' . __( 'Visible on mobile', 'megamenu' );
|
418 |
+
$mobile_tooltip_hidden = __( 'Row', 'megamenu' ) . ': ' . __( 'Hidden on mobile', 'megamenu' );
|
419 |
+
|
420 |
+
$row_class = isset( $row_data['meta']['class'] ) ? $row_data['meta']['class'] : '';
|
421 |
+
|
422 |
+
$return = "<div class='mega-row' data-available-cols='{$row_columns}'>";
|
423 |
+
$return .= " <div class='mega-row-header'>";
|
424 |
+
$return .= " <div class='mega-row-actions'>";
|
425 |
+
$return .= " <span class='dashicons dashicons-sort'></span>";
|
426 |
+
$return .= " <span class='dashicons dashicons-admin-generic'></span>";
|
427 |
+
$return .= " <span class='mega-tooltip {$hide_on_desktop}' data-tooltip-enabled='{$desktop_tooltip_visible}' data-tooltip-disabled='{$desktop_tooltip_hidden}'><span class='dashicons dashicons-desktop'></span></span>";
|
428 |
+
$return .= " <span class='mega-tooltip {$hide_on_mobile}' data-tooltip-enabled='{$mobile_tooltip_visible}' data-tooltip-disabled='{$mobile_tooltip_hidden}'><span class='dashicons dashicons-smartphone'></span></span>";
|
429 |
+
$return .= " <span class='dashicons dashicons-trash'></span>";
|
430 |
+
$return .= ' </div>';
|
431 |
+
$return .= " <div class='mega-row-settings'>";
|
432 |
+
$return .= " <input name='mega-hide-on-mobile' type='hidden' value='{$hide_on_mobile_checked}' />";
|
433 |
+
$return .= " <input name='mega-hide-on-desktop' type='hidden' value='{$hide_on_desktop_checked}'/>";
|
434 |
+
$return .= " <div class='mega-settings-row'>";
|
435 |
+
$return .= ' <label>' . __( 'Row class', 'megamenu' ) . '</label>';
|
436 |
+
$return .= " <input class='mega-row-class' type='text' value='{$row_class}' />";
|
437 |
+
$return .= ' </div>';
|
438 |
+
$return .= " <div class='mega-settings-row'>";
|
439 |
+
$return .= ' <label>' . __( 'Row columns', 'megamenu' ) . '</label>';
|
440 |
+
$return .= " <select class='mega-row-columns'>";
|
441 |
+
$return .= " <option value='1' " . selected( $row_columns, 1, false ) . '>1 ' . __( 'column', 'megamenu' ) . '</option>';
|
442 |
+
$return .= " <option value='2' " . selected( $row_columns, 2, false ) . '>2 ' . __( 'columns', 'megamenu' ) . '</option>';
|
443 |
+
$return .= " <option value='3' " . selected( $row_columns, 3, false ) . '>3 ' . __( 'columns', 'megamenu' ) . '</option>';
|
444 |
+
$return .= " <option value='4' " . selected( $row_columns, 4, false ) . '>4 ' . __( 'columns', 'megamenu' ) . '</option>';
|
445 |
+
$return .= " <option value='5' " . selected( $row_columns, 5, false ) . '>5 ' . __( 'columns', 'megamenu' ) . '</option>';
|
446 |
+
$return .= " <option value='6' " . selected( $row_columns, 6, false ) . '>6 ' . __( 'columns', 'megamenu' ) . '</option>';
|
447 |
+
$return .= " <option value='7' " . selected( $row_columns, 7, false ) . '>7 ' . __( 'columns', 'megamenu' ) . '</option>';
|
448 |
+
$return .= " <option value='8' " . selected( $row_columns, 8, false ) . '>8 ' . __( 'columns', 'megamenu' ) . '</option>';
|
449 |
+
$return .= " <option value='9' " . selected( $row_columns, 9, false ) . '>9 ' . __( 'columns', 'megamenu' ) . '</option>';
|
450 |
+
$return .= " <option value='10' " . selected( $row_columns, 10, false ) . '>10 ' . __( 'columns', 'megamenu' ) . '</option>';
|
451 |
+
$return .= " <option value='11' " . selected( $row_columns, 11, false ) . '>11 ' . __( 'columns', 'megamenu' ) . '</option>';
|
452 |
+
$return .= " <option value='12' " . selected( $row_columns, 12, false ) . '>12 ' . __( 'columns', 'megamenu' ) . '</option>';
|
453 |
+
$return .= ' </select>';
|
454 |
+
$return .= ' </div>';
|
455 |
+
$return .= " <button class='button button-primary mega-save-row-settings' type='submit'>" . __( 'Save', 'megamenu' ) . '</button>';
|
456 |
+
$return .= ' </div>';
|
457 |
+
$return .= " <button class='button button-primary mega-add-column'><span class='dashicons dashicons-plus'></span>" . __( 'Column', 'megamenu' ) . '</button>';
|
458 |
+
$return .= ' </div>';
|
459 |
+
$return .= " <div class='error notice is-dismissible mega-too-many-cols'>";
|
460 |
+
$return .= ' <p>' . __( 'You should rearrange the content of this row so that all columns fit onto a single line.', 'megamenu' ) . '</p>';
|
461 |
+
$return .= ' </div>';
|
462 |
+
$return .= " <div class='error notice is-dismissible mega-row-is-full'>";
|
463 |
+
$return .= ' <p>' . __( 'There is not enough space on this row to add a new column.', 'megamenu' ) . '</p>';
|
464 |
+
$return .= ' </div>';
|
465 |
+
|
466 |
+
$return .= $column_html;
|
467 |
+
|
468 |
+
$return .= '</div>';
|
469 |
+
|
470 |
+
return $return;
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Return the HTML for an individual grid column
|
475 |
+
*
|
476 |
+
* @param array $col_data
|
477 |
+
* @since 2.4
|
478 |
+
* @return string
|
479 |
+
*/
|
480 |
+
public function get_grid_column( $row_data = false, $col_data = false ) {
|
481 |
+
|
482 |
+
$col_span = 3;
|
483 |
+
$row_columns = 12;
|
484 |
+
|
485 |
+
if ( isset( $row_data['meta']['columns'] ) ) {
|
486 |
+
$row_columns = intval( $row_data['meta']['columns'] );
|
487 |
+
}
|
488 |
+
|
489 |
+
if ( isset( $col_data['meta']['span'] ) ) {
|
490 |
+
$col_span = $col_data['meta']['span'];
|
491 |
+
}
|
492 |
+
|
493 |
+
$hide_on_desktop_checked = 'false';
|
494 |
+
$hide_on_desktop = 'mega-enabled';
|
495 |
+
|
496 |
+
if ( isset( $col_data['meta']['hide-on-desktop'] ) && $col_data['meta']['hide-on-desktop'] == 'true' ) {
|
497 |
+
$hide_on_desktop = 'mega-disabled';
|
498 |
+
$hide_on_desktop_checked = 'true';
|
499 |
+
}
|
500 |
+
|
501 |
+
$hide_on_mobile_checked = 'false';
|
502 |
+
$hide_on_mobile = 'mega-enabled';
|
503 |
+
|
504 |
+
if ( isset( $col_data['meta']['hide-on-mobile'] ) && $col_data['meta']['hide-on-mobile'] == 'true' ) {
|
505 |
+
$hide_on_mobile = 'mega-disabled';
|
506 |
+
$hide_on_mobile_checked = 'true';
|
507 |
+
}
|
508 |
+
|
509 |
+
$desktop_tooltip_visible = __( 'Column', 'megamenu' ) . ': ' . __( 'Visible on desktop', 'megamenu' );
|
510 |
+
$desktop_tooltip_hidden = __( 'Column', 'megamenu' ) . ': ' . __( 'Hidden on desktop', 'megamenu' );
|
511 |
+
$mobile_tooltip_visible = __( 'Column', 'megamenu' ) . ': ' . __( 'Visible on mobile', 'megamenu' );
|
512 |
+
$mobile_tooltip_hidden = __( 'Column', 'megamenu' ) . ': ' . __( 'Hidden on mobile', 'megamenu' );
|
513 |
+
|
514 |
+
$col_class = isset( $col_data['meta']['class'] ) ? $col_data['meta']['class'] : '';
|
515 |
+
|
516 |
+
$return = "<div class='mega-col' data-span='{$col_span}'>";
|
517 |
+
$return .= " <div class='mega-col-wrap'>";
|
518 |
+
$return .= " <div class='mega-col-header'>";
|
519 |
+
$return .= " <div class='mega-col-description'>";
|
520 |
+
$return .= " <span class='dashicons dashicons-move'></span>";
|
521 |
+
$return .= " <span class='dashicons dashicons-admin-generic'></span>";
|
522 |
+
$return .= " <span class='mega-tooltip {$hide_on_desktop}' data-tooltip-enabled='{$desktop_tooltip_visible}' data-tooltip-disabled='{$desktop_tooltip_hidden}'><span class='dashicons dashicons-desktop'></span></span>";
|
523 |
+
$return .= " <span class='mega-tooltip {$hide_on_mobile}' data-tooltip-enabled='{$mobile_tooltip_visible}' data-tooltip-disabled='{$mobile_tooltip_hidden}'><span class='dashicons dashicons-smartphone'></span></span>";
|
524 |
+
$return .= " <span class='dashicons dashicons-trash'></span>";
|
525 |
+
$return .= ' </div>';
|
526 |
+
$return .= ' <div class="mega-col-actions">';
|
527 |
+
$return .= ' <a class="mega-col-option mega-col-contract" title="' . esc_attr( __( 'Contract', 'megamenu' ) ) . '"><span class="dashicons dashicons-arrow-left-alt2"></span></a>';
|
528 |
+
$return .= " <span class='mega-col-cols'><span class='mega-num-cols'>{$col_span}</span><span class='mega-of'>/</span><span class='mega-num-total-cols'>" . $row_columns . '</span></span>';
|
529 |
+
$return .= ' <a class="mega-col-options mega-col-expand" title="' . esc_attr( __( 'Expand', 'megamenu' ) ) . '"><span class="dashicons dashicons-arrow-right-alt2"></span></a>';
|
530 |
+
$return .= ' </div>';
|
531 |
+
$return .= ' </div>';
|
532 |
+
$return .= " <div class='mega-col-settings'>";
|
533 |
+
$return .= " <input name='mega-hide-on-mobile' type='hidden' value='{$hide_on_mobile_checked}' />";
|
534 |
+
$return .= " <input name='mega-hide-on-desktop' type='hidden' value='{$hide_on_desktop_checked}'/>";
|
535 |
+
$return .= ' <label>' . __( 'Column class', 'megamenu' ) . '</label>';
|
536 |
+
$return .= " <input class='mega-column-class' type='text' value='{$col_class}' />";
|
537 |
+
$return .= " <button class='button button-primary mega-save-column-settings' type='submit'>" . __( 'Save', 'megamenu' ) . '</button>';
|
538 |
+
$return .= ' </div>';
|
539 |
+
$return .= " <div class='mega-col-widgets'>";
|
540 |
+
|
541 |
+
if ( isset( $col_data['items'] ) && count( $col_data['items'] ) ) {
|
542 |
+
foreach ( $col_data['items'] as $item ) {
|
543 |
+
$return .= '<div class="widget" title="' . esc_attr( $item['title'] ) . '" id="' . esc_attr( $item['id'] ) . '" data-type="' . esc_attr( $item['type'] ) . '" data-id="' . esc_attr( $item['id'] ) . '">';
|
544 |
+
$return .= ' <div class="widget-top">';
|
545 |
+
$return .= ' <div class="widget-title">';
|
546 |
+
$return .= ' <h4>' . esc_html( $item['title'] ) . '</h4>';
|
547 |
+
$return .= ' <span class="widget-desc">' . esc_html( $item['description'] ) . '</span>';
|
548 |
+
$return .= ' </div>';
|
549 |
+
$return .= ' <div class="widget-title-action">';
|
550 |
+
$return .= ' <a class="widget-option widget-action" title="' . esc_attr( __( 'Edit', 'megamenu' ) ) . '"></a>';
|
551 |
+
$return .= ' </div>';
|
552 |
+
$return .= ' </div>';
|
553 |
+
$return .= ' <div class="widget-inner widget-inside"></div>';
|
554 |
+
$return .= '</div>';
|
555 |
+
}
|
556 |
+
}
|
557 |
+
|
558 |
+
$return .= ' </div>';
|
559 |
+
$return .= ' </div>';
|
560 |
+
$return .= '</div>';
|
561 |
+
|
562 |
+
return $return;
|
563 |
+
}
|
564 |
+
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Return the HTML for the standard (non grid) mega menu builder
|
568 |
+
*
|
569 |
+
* @return string
|
570 |
+
*/
|
571 |
+
public function get_megamenu_html( $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
572 |
+
|
573 |
+
$widget_manager = new Mega_Menu_Widget_Manager();
|
574 |
+
|
575 |
+
$return = "<div id='widgets' data-columns='{$menu_item_meta['panel_columns']}'>";
|
576 |
+
|
577 |
+
$items = $widget_manager->get_widgets_and_menu_items_for_menu_id( $menu_item_id, $menu_id );
|
578 |
+
|
579 |
+
if ( count( $items ) ) {
|
580 |
+
|
581 |
+
foreach ( $items as $item ) {
|
582 |
+
$return .= '<div class="widget" title="' . esc_attr( $item['title'] ) . '" id="' . esc_attr( $item['id'] ) . '" data-columns="' . esc_attr( $item['columns'] ) . '" data-type="' . esc_attr( $item['type'] ) . '" data-id="' . esc_attr( $item['id'] ) . '">';
|
583 |
+
$return .= ' <div class="widget-top">';
|
584 |
+
$return .= ' <div class="widget-title-action">';
|
585 |
+
$return .= ' <a class="widget-option widget-contract" title="' . esc_attr( __( 'Contract', 'megamenu' ) ) . '"></a>';
|
586 |
+
$return .= ' <span class="widget-cols"><span class="widget-num-cols">' . $item['columns'] . '</span><span class="widget-of">/</span><span class="widget-total-cols">' . $menu_item_meta['panel_columns'] . '</span></span>';
|
587 |
+
$return .= ' <a class="widget-option widget-expand" title="' . esc_attr( __( 'Expand', 'megamenu' ) ) . '"></a>';
|
588 |
+
$return .= ' <a class="widget-option widget-action" title="' . esc_attr( __( 'Edit', 'megamenu' ) ) . '"></a>';
|
589 |
+
$return .= ' </div>';
|
590 |
+
$return .= ' <div class="widget-title">';
|
591 |
+
$return .= ' <h4>' . esc_html( $item['title'] ) . '</h4>';
|
592 |
+
$return .= ' </div>';
|
593 |
+
$return .= ' </div>';
|
594 |
+
$return .= ' <div class="widget-inner widget-inside"></div>';
|
595 |
+
$return .= '</div>';
|
596 |
+
}
|
597 |
+
} else {
|
598 |
+
$return .= "<p class='no_widgets'>" . __( 'No widgets found. Add a widget to this area using the Widget Selector (top right)', 'megamenu' ) . '</p>';
|
599 |
+
}
|
600 |
+
|
601 |
+
$return .= '</div>';
|
602 |
+
|
603 |
+
return $return;
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Return the HTML to display in the 'General Settings' tab
|
608 |
+
*
|
609 |
+
* @since 1.7
|
610 |
+
* @return array
|
611 |
+
*/
|
612 |
+
public function add_general_settings_tab( $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
613 |
+
|
614 |
+
$return = '<form>';
|
615 |
+
$return .= ' <input type="hidden" name="menu_item_id" value="' . esc_attr( $menu_item_id ) . '" />';
|
616 |
+
$return .= ' <input type="hidden" name="action" value="mm_save_menu_item_settings" />';
|
617 |
+
$return .= ' <input type="hidden" name="_wpnonce" value="' . wp_create_nonce( 'megamenu_edit' ) . '" />';
|
618 |
+
$return .= ' <input type="hidden" name="tab" value="general_settings" />';
|
619 |
+
$return .= ' <h4 class="first">' . __( 'Menu Item Settings', 'megamenu' ) . '</h4>';
|
620 |
+
$return .= ' <table>';
|
621 |
+
$return .= ' <tr>';
|
622 |
+
$return .= ' <td class="mega-name">';
|
623 |
+
$return .= __( 'Hide Text', 'megamenu' );
|
624 |
+
$return .= ' </td>';
|
625 |
+
$return .= ' <td class="mega-value">';
|
626 |
+
$return .= ' <input type="checkbox" name="settings[hide_text]" value="true" ' . checked( $menu_item_meta['hide_text'], 'true', false ) . ' />';
|
627 |
+
$return .= ' </td>';
|
628 |
+
$return .= ' </tr>';
|
629 |
+
$return .= ' <tr>';
|
630 |
+
$return .= ' <td class="mega-name">';
|
631 |
+
$return .= __( 'Hide Arrow', 'megamenu' );
|
632 |
+
$return .= ' </td>';
|
633 |
+
$return .= ' <td class="mega-value">';
|
634 |
+
$return .= ' <input type="checkbox" name="settings[hide_arrow]" value="true" ' . checked( $menu_item_meta['hide_arrow'], 'true', false ) . ' />';
|
635 |
+
$return .= ' </td>';
|
636 |
+
$return .= ' </tr>';
|
637 |
+
$return .= ' <tr>';
|
638 |
+
$return .= ' <td class="mega-name">';
|
639 |
+
$return .= __( 'Disable Link', 'megamenu' );
|
640 |
+
$return .= ' </td>';
|
641 |
+
$return .= ' <td class="mega-value">';
|
642 |
+
$return .= ' <input type="checkbox" name="settings[disable_link]" value="true" ' . checked( $menu_item_meta['disable_link'], 'true', false ) . ' />';
|
643 |
+
$return .= ' </td>';
|
644 |
+
$return .= ' </tr>';
|
645 |
+
$return .= ' <tr>';
|
646 |
+
$return .= ' <td class="mega-name">';
|
647 |
+
$return .= __( 'Hide Item on Mobile', 'megamenu' );
|
648 |
+
$return .= ' </td>';
|
649 |
+
$return .= ' <td class="mega-value">';
|
650 |
+
$return .= ' <input type="checkbox" name="settings[hide_on_mobile]" value="true" ' . checked( $menu_item_meta['hide_on_mobile'], 'true', false ) . ' />';
|
651 |
+
$return .= ' </td>';
|
652 |
+
$return .= ' </tr>';
|
653 |
+
$return .= ' <tr>';
|
654 |
+
$return .= ' <td class="mega-name">';
|
655 |
+
$return .= __( 'Hide Item on Desktop', 'megamenu' );
|
656 |
+
$return .= ' </td>';
|
657 |
+
$return .= ' <td class="mega-value">';
|
658 |
+
$return .= ' <input type="checkbox" name="settings[hide_on_desktop]" value="true" ' . checked( $menu_item_meta['hide_on_desktop'], 'true', false ) . ' />';
|
659 |
+
$return .= ' </td>';
|
660 |
+
$return .= ' </tr>';
|
661 |
+
$return .= ' <tr class="mega-menu-item-align">';
|
662 |
+
$return .= ' <td class="mega-name">';
|
663 |
+
$return .= __( 'Menu Item Align', 'megamenu' );
|
664 |
+
$return .= ' </td>';
|
665 |
+
$return .= ' <td class="mega-value">';
|
666 |
+
|
667 |
+
if ( $menu_item_depth == 0 ) {
|
668 |
+
|
669 |
+
$item_align = $menu_item_meta['item_align'];
|
670 |
+
|
671 |
+
$float_left_display = $item_align == 'float-left' ? 'block' : 'none';
|
672 |
+
$left_display = $item_align == 'left' ? 'block' : 'none';
|
673 |
+
$right_display = $item_align == 'right' ? 'block' : 'none';
|
674 |
+
|
675 |
+
$return .= ' <select id="mega-item-align" name="settings[item_align]">';
|
676 |
+
$return .= ' <option value="float-left" ' . selected( $menu_item_meta['item_align'], 'float-left', false ) . '>' . __( 'Left', 'megamenu' ) . '</option>';
|
677 |
+
$return .= ' <option value="left" ' . selected( $menu_item_meta['item_align'], 'left', false ) . '>' . __( 'Default', 'megamenu' ) . '</option>';
|
678 |
+
$return .= ' <option value="right" ' . selected( $menu_item_meta['item_align'], 'right', false ) . '>' . __( 'Right', 'megamenu' ) . '</option>';
|
679 |
+
$return .= ' </select>';
|
680 |
+
$return .= ' <div class="mega-description">';
|
681 |
+
$return .= " <div class='float-left' style='display:{$float_left_display}'></div>";
|
682 |
+
$return .= " <div class='left' style='display:{$left_display}'>" . __( "Item will be aligned based on the 'Menu Items Align' option set in the Theme Editor", 'megamenu' ) . '</div>';
|
683 |
+
$return .= " <div class='right' style='display:{$right_display}'>" . __( 'Right aligned items will appear in reverse order on the right hand side of the menu bar', 'megamenu' ) . '</div>';
|
684 |
+
$return .= ' </div>';
|
685 |
+
} else {
|
686 |
+
$return .= '<em>' . __( 'Option only available for top level menu items', 'megamenu' ) . '</em>';
|
687 |
+
}
|
688 |
+
|
689 |
+
$return .= ' </td>';
|
690 |
+
$return .= ' </tr>';
|
691 |
+
$return .= ' <tr class="mega-menu-icon-position">';
|
692 |
+
$return .= ' <td class="mega-name">';
|
693 |
+
$return .= __( 'Icon Position', 'megamenu' );
|
694 |
+
$return .= ' </td>';
|
695 |
+
$return .= ' <td class="mega-value">';
|
696 |
+
$return .= ' <select name="settings[icon_position]">';
|
697 |
+
$return .= ' <option value="left" ' . selected( $menu_item_meta['icon_position'], 'left', false ) . '>' . __( 'Left', 'megamenu' ) . '</option>';
|
698 |
+
$return .= ' <option value="top" ' . selected( $menu_item_meta['icon_position'], 'top', false ) . '>' . __( 'Top', 'megamenu' ) . '</option>';
|
699 |
+
$return .= ' <option value="right" ' . selected( $menu_item_meta['icon_position'], 'right', false ) . '>' . __( 'Right', 'megamenu' ) . '</option>';
|
700 |
+
$return .= ' </select>';
|
701 |
+
|
702 |
+
$return .= ' </td>';
|
703 |
+
$return .= ' </tr>';
|
704 |
+
|
705 |
+
$return .= apply_filters( 'megamenu_after_menu_item_settings', '', $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
706 |
+
|
707 |
+
$return .= ' </table>';
|
708 |
+
|
709 |
+
$return .= ' <h4>' . __( 'Sub Menu Settings', 'megamenu' ) . '</h4>';
|
710 |
+
|
711 |
+
$return .= ' <table>';
|
712 |
+
$return .= ' <tr class="mega-sub-menu-align">';
|
713 |
+
$return .= ' <td class="mega-name">';
|
714 |
+
$return .= __( 'Sub Menu Align', 'megamenu' );
|
715 |
+
$return .= ' </td>';
|
716 |
+
$return .= ' <td class="mega-value">';
|
717 |
+
|
718 |
+
if ( $menu_item_depth == 0 ) {
|
719 |
+
$return .= ' <select name="settings[align]">';
|
720 |
+
$return .= ' <option value="bottom-left" ' . selected( $menu_item_meta['align'], 'bottom-left', false ) . '>' . __( 'Left edge of Parent', 'megamenu' ) . '</option>';
|
721 |
+
$return .= ' <option value="bottom-right" ' . selected( $menu_item_meta['align'], 'bottom-right', false ) . '>' . __( 'Right edge of Parent', 'megamenu' ) . '</option>';
|
722 |
+
$return .= ' </select>';
|
723 |
+
$return .= ' <div class="mega-description">';
|
724 |
+
$return .= __( 'Right aligned flyout menus will expand to the left', 'megamenu' );
|
725 |
+
$return .= ' </div>';
|
726 |
+
} else {
|
727 |
+
$return .= '<em>' . __( 'Option only available for top level menu items', 'megamenu' ) . '</em>';
|
728 |
+
}
|
729 |
+
|
730 |
+
$return .= ' </td>';
|
731 |
+
$return .= ' </tr>';
|
732 |
+
$return .= ' <tr>';
|
733 |
+
$return .= ' <td class="mega-name">';
|
734 |
+
$return .= __( 'Hide Sub Menu on Mobile', 'megamenu' );
|
735 |
+
$return .= ' </td>';
|
736 |
+
$return .= ' <td class="mega-value">';
|
737 |
+
$return .= ' <input type="checkbox" name="settings[hide_sub_menu_on_mobile]" value="true" ' . checked( $menu_item_meta['hide_sub_menu_on_mobile'], 'true', false ) . ' />';
|
738 |
+
$return .= ' </td>';
|
739 |
+
$return .= ' </tr>';
|
740 |
+
|
741 |
+
if ( $menu_item_depth > 0 ) {
|
742 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
743 |
+
$notice = '';
|
744 |
+
|
745 |
+
if ( $css_version && version_compare( $css_version, '2.6.1', '<' ) ) {
|
746 |
+
$link = "<a href='" . esc_attr( admin_url( 'admin.php?page=maxmegamenu_tools' ) ) . "'>" . __( 'Mega Menu' ) . ' > ' . __( 'Tools' ) . '</a>';
|
747 |
+
$notice = "<div class='notice notice-success'><p>";
|
748 |
+
$notice .= sprintf( __( 'Your menu CSS needs to be updated before you can use the following setting. Please go to %s and Clear the CSS Cache (you will only need to do this once).', 'megamenu' ), $link );
|
749 |
+
$notice .= '</p></div>';
|
750 |
+
$notice .= '</div><br />';
|
751 |
+
}
|
752 |
+
|
753 |
+
$return .= ' <tr>';
|
754 |
+
$return .= ' <td class="mega-name">';
|
755 |
+
$return .= __( 'Collapse sub menu', 'megamenu' );
|
756 |
+
$return .= ' </td>';
|
757 |
+
$return .= ' <td class="mega-value">';
|
758 |
+
$return .= $notice;
|
759 |
+
$return .= ' <input type="checkbox" name="settings[collapse_children]" value="true" ' . checked( $menu_item_meta['collapse_children'], 'true', false ) . ' />';
|
760 |
+
$return .= ' <em>' . __( 'Only applies to menu items displayed within mega sub menus.', 'megamenu' ) . '</em>';
|
761 |
+
$return .= ' </td>';
|
762 |
+
$return .= ' </tr>';
|
763 |
+
}
|
764 |
+
|
765 |
+
$return .= apply_filters( 'megamenu_after_menu_item_submenu_settings', '', $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
766 |
+
|
767 |
+
$return .= ' </table>';
|
768 |
+
|
769 |
+
$return .= get_submit_button();
|
770 |
+
$return .= '</form>';
|
771 |
+
|
772 |
+
$tabs['general_settings'] = array(
|
773 |
+
'title' => __( 'Settings', 'megamenu' ),
|
774 |
+
'content' => $return,
|
775 |
+
);
|
776 |
+
|
777 |
+
return $tabs;
|
778 |
+
|
779 |
+
}
|
780 |
+
|
781 |
+
|
782 |
+
/**
|
783 |
+
* Return the HTML to display in the 'menu icon' tab
|
784 |
+
*
|
785 |
+
* @since 1.7
|
786 |
+
* @return array
|
787 |
+
*/
|
788 |
+
public function add_icon_tab( $tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta ) {
|
789 |
+
|
790 |
+
$icon_tabs = array(
|
791 |
+
'dashicons' => array(
|
792 |
+
'title' => __( 'Dashicons', 'megamenu' ),
|
793 |
+
'active' => ! isset( $menu_item_meta['icon'] ) || ( isset( $menu_item_meta['icon'] ) && substr( $menu_item_meta['icon'], 0, strlen( 'dash' ) ) === 'dash' || $menu_item_meta['icon'] == 'disabled' ),
|
794 |
+
'content' => $this->dashicon_selector(),
|
795 |
+
),
|
796 |
+
'fontawesome' => array(
|
797 |
+
'title' => __( 'Font Awesome', 'megamenu' ),
|
798 |
+
'active' => false,
|
799 |
+
'content' => str_replace( '{link}', "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __( 'Max Mega Menu Pro', 'megamenu' ) . '</a>', __( 'Get access to over 400 Font Awesome Icons with {link}', 'megamenu' ) ),
|
800 |
+
),
|
801 |
+
'genericons' => array(
|
802 |
+
'title' => __( 'Genericons', 'megamenu' ),
|
803 |
+
'active' => false,
|
804 |
+
'content' => str_replace( '{link}', "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __( 'Max Mega Menu Pro', 'megamenu' ) . '</a>', __( 'Choose from over 100 genericons with {link}', 'megamenu' ) ),
|
805 |
+
),
|
806 |
+
'custom' => array(
|
807 |
+
'title' => __( 'Custom Icon', 'megamenu' ),
|
808 |
+
'active' => false,
|
809 |
+
'content' => str_replace( '{link}', "<a target='_blank' href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=icon&utm_campaign=pro'>" . __( 'Max Mega Menu Pro', 'megamenu' ) . '</a>', __( 'Select icons from your media library with {link}', 'megamenu' ) ),
|
810 |
+
),
|
811 |
+
);
|
812 |
+
|
813 |
+
$icon_tabs = apply_filters( 'megamenu_icon_tabs', $icon_tabs, $menu_item_id, $menu_id, $menu_item_depth, $menu_item_meta );
|
814 |
+
|
815 |
+
$return = "<h4 class='first'>" . __( 'Menu Item Icon', 'megamenu' ) . '</h4>';
|
816 |
+
$return .= "<ul class='mm_tabs horizontal'>";
|
817 |
+
|
818 |
+
foreach ( $icon_tabs as $id => $icon_tab ) {
|
819 |
+
|
820 |
+
$active = $icon_tab['active'] || count( $icon_tabs ) === 1 ? 'active' : '';
|
821 |
+
|
822 |
+
$return .= "<li rel='mm_tab_{$id}' class='mm_tab_horizontal {$active}'>";
|
823 |
+
$return .= esc_html( $icon_tab['title'] );
|
824 |
+
$return .= '</li>';
|
825 |
+
|
826 |
+
}
|
827 |
+
|
828 |
+
$return .= '</ul>';
|
829 |
+
|
830 |
+
$return .= "<input type='text' class='filter_icons' placeholder='" . __( 'Search', 'megamenu' ) . "' /><div class='clear'></div>";
|
831 |
+
|
832 |
+
foreach ( $icon_tabs as $id => $icon_tab ) {
|
833 |
+
|
834 |
+
$display = $icon_tab['active'] ? 'block' : 'none';
|
835 |
+
|
836 |
+
$return .= "<div class='mm_tab_{$id}' style='display: {$display}'>";
|
837 |
+
$return .= " <form class='icon_selector icon_selector_{$id}'>";
|
838 |
+
$return .= " <input type='hidden' name='_wpnonce' value='" . wp_create_nonce( 'megamenu_edit' ) . "' />";
|
839 |
+
$return .= " <input type='hidden' name='menu_item_id' value='" . esc_attr( $menu_item_id ) . "' />";
|
840 |
+
$return .= " <input type='hidden' name='action' value='mm_save_menu_item_settings' />";
|
841 |
+
$return .= $icon_tab['content'];
|
842 |
+
$return .= ' </form>';
|
843 |
+
$return .= '</div>';
|
844 |
+
|
845 |
+
}
|
846 |
+
|
847 |
+
$tabs['menu_icon'] = array(
|
848 |
+
'title' => __( 'Icon', 'megamenu' ),
|
849 |
+
'content' => $return,
|
850 |
+
);
|
851 |
+
|
852 |
+
return $tabs;
|
853 |
+
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Return the form to select a dashicon
|
858 |
+
*
|
859 |
+
* @since 1.5.2
|
860 |
+
* @return string
|
861 |
+
*/
|
862 |
+
private function dashicon_selector() {
|
863 |
+
|
864 |
+
$return = "<div class='disabled'><input id='disabled' class='radio' type='radio' rel='disabled' name='settings[icon]' value='disabled' " . checked( $this->menu_item_meta['icon'], 'disabled', false ) . ' />';
|
865 |
+
$return .= "<label for='disabled'></label></div>";
|
866 |
+
|
867 |
+
foreach ( $this->all_icons() as $code => $class ) {
|
868 |
+
|
869 |
+
$bits = explode( '-', $code );
|
870 |
+
$code = '&#x' . $bits[1] . '';
|
871 |
+
$type = $bits[0];
|
872 |
+
|
873 |
+
$return .= "<div class='{$type}'>";
|
874 |
+
$return .= " <input class='radio' id='{$class}' type='radio' rel='{$code}' name='settings[icon]' value='{$class}' " . checked( $this->menu_item_meta['icon'], $class, false ) . ' />';
|
875 |
+
$return .= " <label rel='{$code}' for='{$class}' title='{$class}'></label>";
|
876 |
+
$return .= '</div>';
|
877 |
+
|
878 |
+
}
|
879 |
+
|
880 |
+
return $return;
|
881 |
+
}
|
882 |
+
|
883 |
+
|
884 |
+
/**
|
885 |
+
* List of all available DashIcon classes.
|
886 |
+
*
|
887 |
+
* @since 1.0
|
888 |
+
* @return array - Sorted list of icon classes
|
889 |
+
*/
|
890 |
+
public function all_icons() {
|
891 |
+
|
892 |
+
$icons = array(
|
893 |
+
'dash-f333' => 'dashicons-menu',
|
894 |
+
'dash-f319' => 'dashicons-admin-site',
|
895 |
+
'dash-f226' => 'dashicons-dashboard',
|
896 |
+
'dash-f109' => 'dashicons-admin-post',
|
897 |
+
'dash-f104' => 'dashicons-admin-media',
|
898 |
+
'dash-f103' => 'dashicons-admin-links',
|
899 |
+
'dash-f105' => 'dashicons-admin-page',
|
900 |
+
'dash-f101' => 'dashicons-admin-comments',
|
901 |
+
'dash-f100' => 'dashicons-admin-appearance',
|
902 |
+
'dash-f106' => 'dashicons-admin-plugins',
|
903 |
+
'dash-f110' => 'dashicons-admin-users',
|
904 |
+
'dash-f107' => 'dashicons-admin-tools',
|
905 |
+
'dash-f108' => 'dashicons-admin-settings',
|
906 |
+
'dash-f112' => 'dashicons-admin-network',
|
907 |
+
'dash-f102' => 'dashicons-admin-home',
|
908 |
+
'dash-f111' => 'dashicons-admin-generic',
|
909 |
+
'dash-f148' => 'dashicons-admin-collapse',
|
910 |
+
'dash-f536' => 'dashicons-filter',
|
911 |
+
'dash-f540' => 'dashicons-admin-customizer',
|
912 |
+
'dash-f541' => 'dashicons-admin-multisite',
|
913 |
+
'dash-f119' => 'dashicons-welcome-write-blog',
|
914 |
+
'dash-f133' => 'dashicons-welcome-add-page',
|
915 |
+
'dash-f115' => 'dashicons-welcome-view-site',
|
916 |
+
'dash-f116' => 'dashicons-welcome-widgets-menus',
|
917 |
+
'dash-f117' => 'dashicons-welcome-comments',
|
918 |
+
'dash-f118' => 'dashicons-welcome-learn-more',
|
919 |
+
'dash-f123' => 'dashicons-format-aside',
|
920 |
+
'dash-f128' => 'dashicons-format-image',
|
921 |
+
'dash-f161' => 'dashicons-format-gallery',
|
922 |
+
'dash-f126' => 'dashicons-format-video',
|
923 |
+
'dash-f130' => 'dashicons-format-status',
|
924 |
+
'dash-f122' => 'dashicons-format-quote',
|
925 |
+
'dash-f125' => 'dashicons-format-chat',
|
926 |
+
'dash-f127' => 'dashicons-format-audio',
|
927 |
+
'dash-f306' => 'dashicons-camera',
|
928 |
+
'dash-f232' => 'dashicons-images-alt',
|
929 |
+
'dash-f233' => 'dashicons-images-alt2',
|
930 |
+
'dash-f234' => 'dashicons-video-alt',
|
931 |
+
'dash-f235' => 'dashicons-video-alt2',
|
932 |
+
'dash-f236' => 'dashicons-video-alt3',
|
933 |
+
'dash-f501' => 'dashicons-media-archive',
|
934 |
+
'dash-f500' => 'dashicons-media-audio',
|
935 |
+
'dash-f499' => 'dashicons-media-code',
|
936 |
+
'dash-f498' => 'dashicons-media-default',
|
937 |
+
'dash-f497' => 'dashicons-media-document',
|
938 |
+
'dash-f496' => 'dashicons-media-interactive',
|
939 |
+
'dash-f495' => 'dashicons-media-spreadsheet',
|
940 |
+
'dash-f491' => 'dashicons-media-text',
|
941 |
+
'dash-f490' => 'dashicons-media-video',
|
942 |
+
'dash-f492' => 'dashicons-playlist-audio',
|
943 |
+
'dash-f493' => 'dashicons-playlist-video',
|
944 |
+
'dash-f522' => 'dashicons-controls-play',
|
945 |
+
'dash-f523' => 'dashicons-controls-pause',
|
946 |
+
'dash-f519' => 'dashicons-controls-forward',
|
947 |
+
'dash-f517' => 'dashicons-controls-skipforward',
|
948 |
+
'dash-f518' => 'dashicons-controls-back',
|
949 |
+
'dash-f516' => 'dashicons-controls-skipback',
|
950 |
+
'dash-f515' => 'dashicons-controls-repeat',
|
951 |
+
'dash-f521' => 'dashicons-controls-volumeon',
|
952 |
+
'dash-f520' => 'dashicons-controls-volumeoff',
|
953 |
+
'dash-f165' => 'dashicons-image-crop',
|
954 |
+
'dash-f531' => 'dashicons-image-rotate',
|
955 |
+
'dash-f166' => 'dashicons-image-rotate-left',
|
956 |
+
'dash-f167' => 'dashicons-image-rotate-right',
|
957 |
+
'dash-f168' => 'dashicons-image-flip-vertical',
|
958 |
+
'dash-f169' => 'dashicons-image-flip-horizontal',
|
959 |
+
'dash-f533' => 'dashicons-image-filter',
|
960 |
+
'dash-f171' => 'dashicons-undo',
|
961 |
+
'dash-f172' => 'dashicons-redo',
|
962 |
+
'dash-f200' => 'dashicons-editor-bold',
|
963 |
+
'dash-f201' => 'dashicons-editor-italic',
|
964 |
+
'dash-f203' => 'dashicons-editor-ul',
|
965 |
+
'dash-f204' => 'dashicons-editor-ol',
|
966 |
+
'dash-f205' => 'dashicons-editor-quote',
|
967 |
+
'dash-f206' => 'dashicons-editor-alignleft',
|
968 |
+
'dash-f207' => 'dashicons-editor-aligncenter',
|
969 |
+
'dash-f208' => 'dashicons-editor-alignright',
|
970 |
+
'dash-f209' => 'dashicons-editor-insertmore',
|
971 |
+
'dash-f210' => 'dashicons-editor-spellcheck',
|
972 |
+
'dash-f211' => 'dashicons-editor-expand',
|
973 |
+
'dash-f506' => 'dashicons-editor-contract',
|
974 |
+
'dash-f212' => 'dashicons-editor-kitchensink',
|
975 |
+
'dash-f213' => 'dashicons-editor-underline',
|
976 |
+
'dash-f214' => 'dashicons-editor-justify',
|
977 |
+
'dash-f215' => 'dashicons-editor-textcolor',
|
978 |
+
'dash-f216' => 'dashicons-editor-paste-word',
|
979 |
+
'dash-f217' => 'dashicons-editor-paste-text',
|
980 |
+
'dash-f218' => 'dashicons-editor-removeformatting',
|
981 |
+
'dash-f219' => 'dashicons-editor-video',
|
982 |
+
'dash-f220' => 'dashicons-editor-customchar',
|
983 |
+
'dash-f221' => 'dashicons-editor-outdent',
|
984 |
+
'dash-f222' => 'dashicons-editor-indent',
|
985 |
+
'dash-f223' => 'dashicons-editor-help',
|
986 |
+
'dash-f224' => 'dashicons-editor-strikethrough',
|
987 |
+
'dash-f225' => 'dashicons-editor-unlink',
|
988 |
+
'dash-f320' => 'dashicons-editor-rtl',
|
989 |
+
'dash-f474' => 'dashicons-editor-break',
|
990 |
+
'dash-f475' => 'dashicons-editor-code',
|
991 |
+
'dash-f476' => 'dashicons-editor-paragraph',
|
992 |
+
'dash-f535' => 'dashicons-editor-table',
|
993 |
+
'dash-f135' => 'dashicons-align-left',
|
994 |
+
'dash-f136' => 'dashicons-align-right',
|
995 |
+
'dash-f134' => 'dashicons-align-center',
|
996 |
+
'dash-f138' => 'dashicons-align-none',
|
997 |
+
'dash-f160' => 'dashicons-lock',
|
998 |
+
'dash-f528' => 'dashicons-unlock',
|
999 |
+
'dash-f145' => 'dashicons-calendar',
|
1000 |
+
'dash-f508' => 'dashicons-calendar-alt',
|
1001 |
+
'dash-f177' => 'dashicons-visibility',
|
1002 |
+
'dash-f530' => 'dashicons-hidden',
|
1003 |
+
'dash-f173' => 'dashicons-post-status',
|
1004 |
+
'dash-f464' => 'dashicons-edit',
|
1005 |
+
'dash-f182' => 'dashicons-trash',
|
1006 |
+
'dash-f537' => 'dashicons-sticky',
|
1007 |
+
'dash-f504' => 'dashicons-external',
|
1008 |
+
'dash-f142' => 'dashicons-arrow-up',
|
1009 |
+
'dash-f140' => 'dashicons-arrow-down',
|
1010 |
+
'dash-f139' => 'dashicons-arrow-right',
|
1011 |
+
'dash-f141' => 'dashicons-arrow-left',
|
1012 |
+
'dash-f342' => 'dashicons-arrow-up-alt',
|
1013 |
+
'dash-f346' => 'dashicons-arrow-down-alt',
|
1014 |
+
'dash-f344' => 'dashicons-arrow-right-alt',
|
1015 |
+
'dash-f340' => 'dashicons-arrow-left-alt',
|
1016 |
+
'dash-f343' => 'dashicons-arrow-up-alt2',
|
1017 |
+
'dash-f347' => 'dashicons-arrow-down-alt2',
|
1018 |
+
'dash-f345' => 'dashicons-arrow-right-alt2',
|
1019 |
+
'dash-f341' => 'dashicons-arrow-left-alt2',
|
1020 |
+
'dash-f156' => 'dashicons-sort',
|
1021 |
+
'dash-f229' => 'dashicons-leftright',
|
1022 |
+
'dash-f503' => 'dashicons-randomize',
|
1023 |
+
'dash-f163' => 'dashicons-list-view',
|
1024 |
+
'dash-f164' => 'dashicons-exerpt-view',
|
1025 |
+
'dash-f509' => 'dashicons-grid-view',
|
1026 |
+
'dash-f237' => 'dashicons-share',
|
1027 |
+
'dash-f240' => 'dashicons-share-alt',
|
1028 |
+
'dash-f242' => 'dashicons-share-alt2',
|
1029 |
+
'dash-f301' => 'dashicons-twitter',
|
1030 |
+
'dash-f303' => 'dashicons-rss',
|
1031 |
+
'dash-f465' => 'dashicons-email',
|
1032 |
+
'dash-f466' => 'dashicons-email-alt',
|
1033 |
+
'dash-f304' => 'dashicons-facebook',
|
1034 |
+
'dash-f305' => 'dashicons-facebook-alt',
|
1035 |
+
'dash-f462' => 'dashicons-googleplus',
|
1036 |
+
'dash-f325' => 'dashicons-networking',
|
1037 |
+
'dash-f308' => 'dashicons-hammer',
|
1038 |
+
'dash-f309' => 'dashicons-art',
|
1039 |
+
'dash-f310' => 'dashicons-migrate',
|
1040 |
+
'dash-f311' => 'dashicons-performance',
|
1041 |
+
'dash-f483' => 'dashicons-universal-access',
|
1042 |
+
'dash-f507' => 'dashicons-universal-access-alt',
|
1043 |
+
'dash-f486' => 'dashicons-tickets',
|
1044 |
+
'dash-f484' => 'dashicons-nametag',
|
1045 |
+
'dash-f481' => 'dashicons-clipboard',
|
1046 |
+
'dash-f487' => 'dashicons-heart',
|
1047 |
+
'dash-f488' => 'dashicons-megaphone',
|
1048 |
+
'dash-f489' => 'dashicons-schedule',
|
1049 |
+
'dash-f120' => 'dashicons-wordpress',
|
1050 |
+
'dash-f324' => 'dashicons-wordpress-alt',
|
1051 |
+
'dash-f157' => 'dashicons-pressthis',
|
1052 |
+
'dash-f463' => 'dashicons-update',
|
1053 |
+
'dash-f180' => 'dashicons-screenoptions',
|
1054 |
+
'dash-f348' => 'dashicons-info',
|
1055 |
+
'dash-f174' => 'dashicons-cart',
|
1056 |
+
'dash-f175' => 'dashicons-feedback',
|
1057 |
+
'dash-f176' => 'dashicons-cloud',
|
1058 |
+
'dash-f326' => 'dashicons-translation',
|
1059 |
+
'dash-f323' => 'dashicons-tag',
|
1060 |
+
'dash-f318' => 'dashicons-category',
|
1061 |
+
'dash-f480' => 'dashicons-archive',
|
1062 |
+
'dash-f479' => 'dashicons-tagcloud',
|
1063 |
+
'dash-f478' => 'dashicons-text',
|
1064 |
+
'dash-f147' => 'dashicons-yes',
|
1065 |
+
'dash-f158' => 'dashicons-no',
|
1066 |
+
'dash-f335' => 'dashicons-no-alt',
|
1067 |
+
'dash-f132' => 'dashicons-plus',
|
1068 |
+
'dash-f502' => 'dashicons-plus-alt',
|
1069 |
+
'dash-f460' => 'dashicons-minus',
|
1070 |
+
'dash-f153' => 'dashicons-dismiss',
|
1071 |
+
'dash-f159' => 'dashicons-marker',
|
1072 |
+
'dash-f155' => 'dashicons-star-filled',
|
1073 |
+
'dash-f459' => 'dashicons-star-half',
|
1074 |
+
'dash-f154' => 'dashicons-star-empty',
|
1075 |
+
'dash-f227' => 'dashicons-flag',
|
1076 |
+
'dash-f534' => 'dashicons-warning',
|
1077 |
+
'dash-f230' => 'dashicons-location',
|
1078 |
+
'dash-f231' => 'dashicons-location-alt',
|
1079 |
+
'dash-f178' => 'dashicons-vault',
|
1080 |
+
'dash-f332' => 'dashicons-shield',
|
1081 |
+
'dash-f334' => 'dashicons-shield-alt',
|
1082 |
+
'dash-f468' => 'dashicons-sos',
|
1083 |
+
'dash-f179' => 'dashicons-search',
|
1084 |
+
'dash-f181' => 'dashicons-slides',
|
1085 |
+
'dash-f183' => 'dashicons-analytics',
|
1086 |
+
'dash-f184' => 'dashicons-chart-pie',
|
1087 |
+
'dash-f185' => 'dashicons-chart-bar',
|
1088 |
+
'dash-f238' => 'dashicons-chart-line',
|
1089 |
+
'dash-f239' => 'dashicons-chart-area',
|
1090 |
+
'dash-f307' => 'dashicons-groups',
|
1091 |
+
'dash-f338' => 'dashicons-businessman',
|
1092 |
+
'dash-f336' => 'dashicons-id',
|
1093 |
+
'dash-f337' => 'dashicons-id-alt',
|
1094 |
+
'dash-f312' => 'dashicons-products',
|
1095 |
+
'dash-f313' => 'dashicons-awards',
|
1096 |
+
'dash-f314' => 'dashicons-forms',
|
1097 |
+
'dash-f473' => 'dashicons-testimonial',
|
1098 |
+
'dash-f322' => 'dashicons-portfolio',
|
1099 |
+
'dash-f330' => 'dashicons-book',
|
1100 |
+
'dash-f331' => 'dashicons-book-alt',
|
1101 |
+
'dash-f316' => 'dashicons-download',
|
1102 |
+
'dash-f317' => 'dashicons-upload',
|
1103 |
+
'dash-f321' => 'dashicons-backup',
|
1104 |
+
'dash-f469' => 'dashicons-clock',
|
1105 |
+
'dash-f339' => 'dashicons-lightbulb',
|
1106 |
+
'dash-f482' => 'dashicons-microphone',
|
1107 |
+
'dash-f472' => 'dashicons-desktop',
|
1108 |
+
'dash-f471' => 'dashicons-tablet',
|
1109 |
+
'dash-f470' => 'dashicons-smartphone',
|
1110 |
+
'dash-f525' => 'dashicons-phone',
|
1111 |
+
'dash-f510' => 'dashicons-index-card',
|
1112 |
+
'dash-f511' => 'dashicons-carrot',
|
1113 |
+
'dash-f512' => 'dashicons-building',
|
1114 |
+
'dash-f513' => 'dashicons-store',
|
1115 |
+
'dash-f514' => 'dashicons-album',
|
1116 |
+
'dash-f527' => 'dashicons-palmtree',
|
1117 |
+
'dash-f524' => 'dashicons-tickets-alt',
|
1118 |
+
'dash-f526' => 'dashicons-money',
|
1119 |
+
'dash-f328' => 'dashicons-smiley',
|
1120 |
+
'dash-f529' => 'dashicons-thumbs-up',
|
1121 |
+
'dash-f542' => 'dashicons-thumbs-down',
|
1122 |
+
'dash-f538' => 'dashicons-layout',
|
1123 |
+
'dash-f452' => 'dashicons-buddicons-activity',
|
1124 |
+
'dash-f477' => 'dashicons-buddicons-bbpress-logo',
|
1125 |
+
'dash-f448' => 'dashicons-buddicons-buddypress-logo',
|
1126 |
+
'dash-f453' => 'dashicons-buddicons-community',
|
1127 |
+
'dash-f449' => 'dashicons-buddicons-forums',
|
1128 |
+
'dash-f454' => 'dashicons-buddicons-friends',
|
1129 |
+
'dash-f456' => 'dashicons-buddicons-groups',
|
1130 |
+
'dash-f457' => 'dashicons-buddicons-pm',
|
1131 |
+
'dash-f451' => 'dashicons-buddicons-replies',
|
1132 |
+
'dash-f450' => 'dashicons-buddicons-topics',
|
1133 |
+
'dash-f455' => 'dashicons-buddicons-tracking',
|
1134 |
+
'dash-f12c' => 'dashicons-editor-ol-rtl',
|
1135 |
+
'dash-f10c' => 'dashicons-editor-ltr',
|
1136 |
+
'dash-f10d' => 'dashicons-tide',
|
1137 |
+
'dash-f124' => 'dashicons-rest-api',
|
1138 |
+
'dash-f13a' => 'dashicons-code-standards',
|
1139 |
+
'dash-f11d' => 'dashicons-admin-site-alt',
|
1140 |
+
'dash-f11e' => 'dashicons-admin-site-alt2',
|
1141 |
+
'dash-f11f' => 'dashicons-admin-site-alt3',
|
1142 |
+
'dash-f228' => 'dashicons-menu-alt',
|
1143 |
+
'dash-f329' => 'dashicons-menu-alt2',
|
1144 |
+
'dash-f349' => 'dashicons-menu-alt3',
|
1145 |
+
'dash-f12d' => 'dashicons-instagram',
|
1146 |
+
'dash-f12f' => 'dashicons-businesswoman',
|
1147 |
+
'dash-f12e' => 'dashicons-businessperson',
|
1148 |
+
'dash-f467' => 'dashicons-email-alt2',
|
1149 |
+
'dash-f12a' => 'dashicons-yes-alt',
|
1150 |
+
'dash-f129' => 'dashicons-camera-alt',
|
1151 |
+
'dash-f485' => 'dashicons-plugins-checked',
|
1152 |
+
'dash-f113' => 'dashicons-update-alt',
|
1153 |
+
'dash-f121' => 'dashicons-text-page',
|
1154 |
+
);
|
1155 |
+
|
1156 |
+
$icons = apply_filters( 'megamenu_dashicons', $icons );
|
1157 |
+
|
1158 |
+
ksort( $icons );
|
1159 |
+
|
1160 |
+
return $icons;
|
1161 |
+
}
|
1162 |
}
|
1163 |
|
1164 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/nav-menus.class.php
CHANGED
@@ -1,575 +1,649 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Nav_Menus' ) ) :
|
8 |
-
/**
|
9 |
-
|
10 |
-
|
11 |
-
class Mega_Menu_Nav_Menus {
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
}
|
574 |
-
|
575 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Nav_Menus' ) ) :
|
8 |
+
/**
|
9 |
+
* Handles all admin related functionality.
|
10 |
+
*/
|
11 |
+
class Mega_Menu_Nav_Menus {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Return the default settings for each menu item
|
15 |
+
*
|
16 |
+
* @since 1.5
|
17 |
+
*/
|
18 |
+
public static function get_menu_item_defaults() {
|
19 |
+
|
20 |
+
$defaults = array(
|
21 |
+
'type' => 'flyout',
|
22 |
+
'align' => 'bottom-left',
|
23 |
+
'icon' => 'disabled',
|
24 |
+
'hide_text' => 'false',
|
25 |
+
'disable_link' => 'false',
|
26 |
+
'hide_on_mobile' => 'false',
|
27 |
+
'hide_on_desktop' => 'false',
|
28 |
+
'hide_sub_menu_on_mobile' => 'false',
|
29 |
+
'hide_arrow' => 'false',
|
30 |
+
'item_align' => 'left',
|
31 |
+
'icon_position' => 'left',
|
32 |
+
'panel_columns' => 6, // total number of columns displayed in the panel.
|
33 |
+
'mega_menu_columns' => 1, // for sub menu items, how many columns to span in the panel.
|
34 |
+
'mega_menu_order' => 0,
|
35 |
+
'collapse_children' => 'false',
|
36 |
+
'submenu_columns' => 1,
|
37 |
+
);
|
38 |
+
|
39 |
+
return apply_filters( 'megamenu_menu_item_defaults', $defaults );
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Constructor
|
46 |
+
*
|
47 |
+
* @since 1.0
|
48 |
+
*/
|
49 |
+
public function __construct() {
|
50 |
+
add_action( 'admin_init', array( $this, 'register_nav_meta_box' ), 9 );
|
51 |
+
add_action( 'megamenu_nav_menus_scripts', array( $this, 'enqueue_menu_page_scripts' ), 10 );
|
52 |
+
add_action( 'wp_ajax_mm_save_settings', array( $this, 'save' ) );
|
53 |
+
add_filter( 'hidden_meta_boxes', array( $this, 'show_mega_menu_metabox' ) );
|
54 |
+
|
55 |
+
add_filter( 'siteorigin_panels_is_admin_page', array( $this, 'enable_site_origin_page_builder' ) );
|
56 |
+
|
57 |
+
if ( function_exists( 'siteorigin_panels_admin_enqueue_scripts' ) ) {
|
58 |
+
add_action( 'admin_print_scripts-nav-menus.php', array( $this, 'siteorigin_panels_admin_enqueue_scripts' ) );
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( function_exists( 'siteorigin_panels_admin_enqueue_styles' ) ) {
|
62 |
+
add_action( 'admin_print_styles-nav-menus.php', array( $this, 'siteorigin_panels_admin_enqueue_styles' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Enqueue Site Origin Page Builder scripts on nav-menus page.
|
70 |
+
*
|
71 |
+
* @since 2.3.7
|
72 |
+
* @param bool $enabled - Whether or not to load the Page Builder scripts
|
73 |
+
*/
|
74 |
+
public function enable_site_origin_page_builder( $enabled ) {
|
75 |
+
$screen = get_current_screen();
|
76 |
+
|
77 |
+
if ( 'nav-menus' === $screen->base ) {
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
|
81 |
+
return $enabled;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Enqueue Page Builder scripts (https://wordpress.org/plugins/siteorigin-panels/)
|
86 |
+
*
|
87 |
+
* @since 1.9
|
88 |
+
*/
|
89 |
+
public function siteorigin_panels_admin_enqueue_scripts() {
|
90 |
+
siteorigin_panels_admin_enqueue_scripts( '', true );
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Enqueue Page Builder styles (https://wordpress.org/plugins/siteorigin-panels/)
|
96 |
+
*
|
97 |
+
* @since 1.9
|
98 |
+
*/
|
99 |
+
public function siteorigin_panels_admin_enqueue_styles() {
|
100 |
+
siteorigin_panels_admin_enqueue_styles( '', true );
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* By default the mega menu meta box is hidden - show it.
|
106 |
+
*
|
107 |
+
* @since 1.0
|
108 |
+
* @param array $hidden Meta boxes that are hidden from the nav-menus.php page
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function show_mega_menu_metabox( $hidden ) {
|
112 |
+
|
113 |
+
if ( is_array( $hidden ) && count( $hidden ) > 0 ) {
|
114 |
+
foreach ( $hidden as $key => $value ) {
|
115 |
+
if ( 'mega_menu_meta_box' === $value ) {
|
116 |
+
unset( $hidden[ $key ] );
|
117 |
+
}
|
118 |
+
if ( 'add-product_cat' === $value ) {
|
119 |
+
unset( $hidden[ $key ] );
|
120 |
+
}
|
121 |
+
if ( 'add-product_tag' === $value ) {
|
122 |
+
unset( $hidden[ $key ] );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
return $hidden;
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Adds the meta box container
|
133 |
+
*
|
134 |
+
* @since 1.0
|
135 |
+
*/
|
136 |
+
public function register_nav_meta_box() {
|
137 |
+
global $pagenow;
|
138 |
+
|
139 |
+
if ( 'nav-menus.php' === $pagenow ) {
|
140 |
+
add_meta_box(
|
141 |
+
'mega_menu_meta_box',
|
142 |
+
__( 'Max Mega Menu Settings', 'megamenu' ),
|
143 |
+
array( $this, 'metabox_contents' ),
|
144 |
+
'nav-menus',
|
145 |
+
'side',
|
146 |
+
'high'
|
147 |
+
);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Enqueue required CSS and JS for the mega menu lightbox and meta options
|
154 |
+
*
|
155 |
+
* @since 1.0
|
156 |
+
*/
|
157 |
+
public function enqueue_menu_page_scripts( $hook ) {
|
158 |
+
if ( ! in_array( $hook, array( 'nav-menus.php' ) ) ) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
// Compatibility fix for SlideDeck Pro
|
163 |
+
wp_deregister_script( 'codemirror' );
|
164 |
+
wp_deregister_style( 'codemirror' );
|
165 |
+
|
166 |
+
// Compatibility fix for Pinboard Theme
|
167 |
+
wp_deregister_script( 'colorbox' );
|
168 |
+
wp_deregister_style( 'colorbox' );
|
169 |
+
|
170 |
+
// Compatibility fix for AGP Font Awesome Collection
|
171 |
+
wp_deregister_script( 'colorbox-js' );
|
172 |
+
wp_deregister_style( 'colorbox-css' );
|
173 |
+
|
174 |
+
// Compatibility fix for purple-xmls-google-product-feed-for-woocommerce
|
175 |
+
wp_deregister_script( 'cart-product-colorbox' );
|
176 |
+
wp_deregister_style( 'cart-product-colorstyle' );
|
177 |
+
|
178 |
+
// Compatibility fix for WordFence
|
179 |
+
wp_deregister_script( 'jquery.wfcolorbox' );
|
180 |
+
wp_deregister_style( 'wordfence-colorbox-style' );
|
181 |
+
|
182 |
+
// Compatibility fix for Profit Builder
|
183 |
+
wp_deregister_script( 'color-box-min' );
|
184 |
+
wp_deregister_script( 'color-box' );
|
185 |
+
wp_deregister_style( 'color-box-css' );
|
186 |
+
|
187 |
+
// Compatibility fix for Reamaze
|
188 |
+
wp_deregister_script( 'jquery-colorbox' );
|
189 |
+
wp_deregister_style( 'colorbox-css' );
|
190 |
+
|
191 |
+
// Compatibility fix for WP Disquz media uploader
|
192 |
+
wp_deregister_script( 'wmu-colorbox-js' );
|
193 |
+
wp_deregister_style( 'wmu-colorbox-css' );
|
194 |
+
|
195 |
+
// Compatibility fix for TemplatesNext ToolKit
|
196 |
+
wp_deregister_script( 'tx-main' );
|
197 |
+
wp_deregister_style( 'tx-toolkit-admin-style' );
|
198 |
+
|
199 |
+
wp_enqueue_style( 'colorbox', MEGAMENU_BASE_URL . 'js/colorbox/colorbox.css', false, MEGAMENU_VERSION );
|
200 |
+
wp_enqueue_style( 'maxmegamenu', MEGAMENU_BASE_URL . 'css/admin/admin.css', false, MEGAMENU_VERSION );
|
201 |
+
|
202 |
+
wp_enqueue_script(
|
203 |
+
'maxmegamenu',
|
204 |
+
MEGAMENU_BASE_URL . 'js/admin.js',
|
205 |
+
array(
|
206 |
+
'jquery',
|
207 |
+
'jquery-ui-core',
|
208 |
+
'jquery-ui-sortable',
|
209 |
+
),
|
210 |
+
MEGAMENU_VERSION
|
211 |
+
);
|
212 |
+
|
213 |
+
wp_enqueue_script( 'colorbox', MEGAMENU_BASE_URL . 'js/colorbox/jquery.colorbox-min.js', array( 'jquery' ), MEGAMENU_VERSION );
|
214 |
+
|
215 |
+
$settings = get_option( 'megamenu_settings' );
|
216 |
+
|
217 |
+
$prefix = isset( $settings['prefix'] ) ? $settings['prefix'] : 'true';
|
218 |
+
|
219 |
+
wp_localize_script(
|
220 |
+
'maxmegamenu',
|
221 |
+
'megamenu',
|
222 |
+
array(
|
223 |
+
'debug_launched' => __( 'Launched for Menu ID', 'megamenu' ),
|
224 |
+
'launch_lightbox' => __( 'Mega Menu', 'megamenu' ),
|
225 |
+
'is_disabled_error' => __( 'Please enable Max Mega Menu using the settings on the left of this page.', 'megamenu' ),
|
226 |
+
'save_menu' => __( 'Please save the menu structure to enable this option.', 'megamenu' ),
|
227 |
+
'unsaved_changes' => __( 'The changes you made will be lost if you navigate away from this page.', 'megamenu'),
|
228 |
+
'saving' => __( 'Saving', 'megamenu' ),
|
229 |
+
'nonce' => wp_create_nonce( 'megamenu_edit' ),
|
230 |
+
'nonce_check_failed' => __( 'Oops. Something went wrong. Please reload the page.', 'megamenu' ),
|
231 |
+
'css_prefix' => $prefix,
|
232 |
+
'css_prefix_message' => __( "Custom CSS Classes will be prefixed with 'mega-'", 'megamenu' ),
|
233 |
+
'row_is_full' => __( 'There is not enough space in this row to add a new column. Make space by reducing the width of the columns within the row or create a new row.', 'megamenu' ),
|
234 |
+
)
|
235 |
+
);
|
236 |
+
|
237 |
+
do_action( 'megamenu_enqueue_admin_scripts' );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Show the Meta Menu settings
|
242 |
+
*
|
243 |
+
* @since 1.0
|
244 |
+
*/
|
245 |
+
public function metabox_contents() {
|
246 |
+
$menu_id = $this->get_selected_menu_id();
|
247 |
+
$this->print_enable_megamenu_options( $menu_id );
|
248 |
+
}
|
249 |
+
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Save the mega menu settings (submitted from Menus Page Meta Box)
|
253 |
+
*
|
254 |
+
* @since 1.0
|
255 |
+
*/
|
256 |
+
public function save() {
|
257 |
+
check_ajax_referer( 'megamenu_edit', 'nonce' );
|
258 |
+
|
259 |
+
if ( isset( $_POST['menu'] ) && $_POST['menu'] > 0 && is_nav_menu( $_POST['menu'] ) && isset( $_POST['megamenu_meta'] ) ) {
|
260 |
+
$raw_submitted_settings = $_POST['megamenu_meta'];
|
261 |
+
$parsed_submitted_settings = json_decode( stripslashes( $raw_submitted_settings ), true );
|
262 |
+
$submitted_settings = array();
|
263 |
+
|
264 |
+
foreach ( $parsed_submitted_settings as $index => $value ) {
|
265 |
+
$name = $value['name'];
|
266 |
+
|
267 |
+
preg_match_all( '/\[(.*?)\]/', $name, $matches ); // find values between square brackets.
|
268 |
+
|
269 |
+
if ( isset( $matches[1][0] ) && isset( $matches[1][1] ) ) {
|
270 |
+
$location = $matches[1][0];
|
271 |
+
$setting = $matches[1][1];
|
272 |
+
$submitted_settings[ $location ][ $setting ] = $value['value'];
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
$submitted_settings = apply_filters( 'megamenu_submitted_settings_meta', $submitted_settings );
|
277 |
+
|
278 |
+
if ( ! get_option( 'megamenu_settings' ) ) {
|
279 |
+
update_option( 'megamenu_settings', $submitted_settings );
|
280 |
+
} else {
|
281 |
+
$existing_settings = get_option( 'megamenu_settings' );
|
282 |
+
|
283 |
+
foreach ( $submitted_settings as $location => $settings ) {
|
284 |
+
if ( isset( $existing_settings[ $location ] ) ) {
|
285 |
+
$existing_settings[ $location ] = array_merge( $existing_settings[ $location ], $settings );
|
286 |
+
|
287 |
+
if ( ! isset( $settings['enabled'] ) ) {
|
288 |
+
unset( $existing_settings[ $location ]['enabled'] );
|
289 |
+
}
|
290 |
+
} else {
|
291 |
+
$existing_settings[ $location ] = $settings;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
update_option( 'megamenu_settings', $existing_settings );
|
296 |
+
}
|
297 |
+
|
298 |
+
do_action( 'megamenu_after_save_settings' );
|
299 |
+
do_action( 'megamenu_delete_cache' );
|
300 |
+
}
|
301 |
+
|
302 |
+
wp_die();
|
303 |
+
}
|
304 |
+
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Print the custom Meta Box settings
|
308 |
+
*
|
309 |
+
* @param int $menu_id
|
310 |
+
* @since 1.0
|
311 |
+
*/
|
312 |
+
public function print_enable_megamenu_options( $menu_id ) {
|
313 |
+
$tagged_menu_locations = $this->get_tagged_theme_locations_for_menu_id( $menu_id );
|
314 |
+
$theme_locations = get_registered_nav_menus();
|
315 |
+
$saved_settings = get_option( 'megamenu_settings' );
|
316 |
+
|
317 |
+
if ( ! count( $theme_locations ) ) {
|
318 |
+
echo "<div style='padding: 15px;'>";
|
319 |
+
$link = '<a href="https://www.megamenu.com/documentation/widget/?utm_source=free&utm_medium=link&utm_campaign=pro" target="_blank">' . __( 'here', 'megamenu' ) . '</a>';
|
320 |
+
echo '<p>' . esc_html__( 'This theme does not register any menu locations.', 'megamenu' ) . '</p>';
|
321 |
+
echo '<p>' . esc_html__( 'You will need to create a new menu location and use the Max Mega Menu widget or shortcode to display the menu on your site.', 'megamenu' ) . '</p>';
|
322 |
+
echo '<p>' . str_replace( '{link}', $link, esc_html__( 'Click {link} for instructions.', 'megamenu' ) ) . '</p>';
|
323 |
+
echo "</div>";
|
324 |
+
} elseif ( ! count( $tagged_menu_locations ) ) {
|
325 |
+
echo "<div style='padding: 15px;'>";
|
326 |
+
echo '<p>' . esc_html__( 'Please assign this menu to a theme location to enable the Mega Menu settings.', 'megamenu' ) . '</p>';
|
327 |
+
echo '<p>' . esc_html__( "To assign this menu to a theme location, scroll to the bottom of this page and tag the menu to a 'Display location'.", 'megamenu' ) . '</p>';
|
328 |
+
echo "</div>";
|
329 |
+
|
330 |
+
} else { ?>
|
331 |
+
<div class='mega-accordion'>
|
332 |
+
<?php
|
333 |
+
$i = 0;
|
334 |
+
foreach ( $theme_locations as $location => $name ) {
|
335 |
+
if ( isset( $tagged_menu_locations[ $location ] ) ) {
|
336 |
+
$open_class = count( $tagged_menu_locations ) === 1 ? ' mega-accordion-open' : '';
|
337 |
+
$last_class = $i + 1 == count( $tagged_menu_locations ) ? ' mega-last' : '';
|
338 |
+
$edit_url = admin_url( "admin.php?page=maxmegamenu&location={$location}" );
|
339 |
+
$i++;
|
340 |
+
|
341 |
+
$is_enabled_class = '';
|
342 |
+
if ( max_mega_menu_is_enabled( $location ) ) {
|
343 |
+
$is_enabled_class = ' mega-location-enabled';
|
344 |
+
}
|
345 |
+
|
346 |
+
$has_active_location_class = '';
|
347 |
+
$active_instance = 0;
|
348 |
+
|
349 |
+
if ( isset( $saved_settings[ $location ]['active_instance'] ) ) {
|
350 |
+
$active_instance = $saved_settings[ $location ]['active_instance'];
|
351 |
+
} elseif ( isset( $saved_settings['instances'][ $location ] ) ) {
|
352 |
+
$active_instance = $saved_settings['instances'][ $location ];
|
353 |
+
}
|
354 |
+
|
355 |
+
if ( $active_instance > 0 ) {
|
356 |
+
$has_active_location_class = ' mega-has-active-location';
|
357 |
+
}
|
358 |
+
|
359 |
+
?>
|
360 |
+
<div class='mega-accordion-title<?php echo esc_attr( $open_class ); ?><?php echo esc_attr( $last_class ); ?><?php echo esc_attr( $is_enabled_class ); ?><?php echo esc_attr( $has_active_location_class ); ?>'>
|
361 |
+
<h4><span class='dashicons dashicons-location'></span><?php esc_html_e( $name ); ?></h4>
|
362 |
+
<span class='mega-tooltip'>
|
363 |
+
<span class='dashicons dashicons-yes'></span>
|
364 |
+
</span>
|
365 |
+
<div class='mega-ellipsis mega-ellipsis-left'>
|
366 |
+
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
|
367 |
+
<path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"></path>
|
368 |
+
</svg>
|
369 |
+
<ul class='mega-ellipsis-content'>
|
370 |
+
<li><a href='<?php esc_attr_e( $edit_url ); ?>'><span class='dashicons dashicons-external'></span><?php esc_html_e( 'More options', 'megamenu' ); ?></a></li>
|
371 |
+
</ul>
|
372 |
+
</div>
|
373 |
+
</div>
|
374 |
+
<div class='mega-accordion-content'>
|
375 |
+
<?php $this->settings_table( $location, $saved_settings ); ?>
|
376 |
+
<?php submit_button( __( 'Save' ), 'max-mega-menu-save button-primary alignright' ); ?>
|
377 |
+
<span class='spinner'></span>
|
378 |
+
</div>
|
379 |
+
|
380 |
+
<?php
|
381 |
+
}
|
382 |
+
}
|
383 |
+
?>
|
384 |
+
</div>
|
385 |
+
|
386 |
+
<?php
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Print the list of Mega Menu settings
|
392 |
+
*
|
393 |
+
* @since 1.0
|
394 |
+
*/
|
395 |
+
public function settings_table( $location, $settings ) {
|
396 |
+
?>
|
397 |
+
<table>
|
398 |
+
<tr>
|
399 |
+
<td><?php esc_html_e( 'Enable', 'megamenu' ); ?></td>
|
400 |
+
<td>
|
401 |
+
<input type='checkbox' class='megamenu_enabled' name='megamenu_meta[<?php echo $location; ?>][enabled]' value='1' <?php checked( isset( $settings[ $location ]['enabled'] ) ); ?> />
|
402 |
+
</td>
|
403 |
+
</tr>
|
404 |
+
<tr>
|
405 |
+
<td><?php esc_html_e( 'Event', 'megamenu' ); ?></td>
|
406 |
+
<td>
|
407 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][event]'>
|
408 |
+
<option value='hover' <?php selected( isset( $settings[ $location ]['event'] ) && $settings[ $location ]['event'] == 'hover' ); ?>><?php _e( 'Hover Intent', 'megamenu' ); ?></option>
|
409 |
+
<option value='hover_' <?php selected( isset( $settings[ $location ]['event'] ) && $settings[ $location ]['event'] == 'hover_' ); ?>><?php _e( 'Hover', 'megamenu' ); ?></option>
|
410 |
+
<option value='click' <?php selected( isset( $settings[ $location ]['event'] ) && $settings[ $location ]['event'] == 'click' ); ?>><?php _e( 'Click', 'megamenu' ); ?></option>
|
411 |
+
</select>
|
412 |
+
</td>
|
413 |
+
</tr>
|
414 |
+
<tr>
|
415 |
+
<td><?php esc_html_e( 'Effect', 'megamenu' ); ?></td>
|
416 |
+
<td>
|
417 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][effect]'>
|
418 |
+
<?php
|
419 |
+
|
420 |
+
$selected = isset( $settings[ $location ]['effect'] ) ? $settings[ $location ]['effect'] : 'fade_up';
|
421 |
+
|
422 |
+
$options = apply_filters(
|
423 |
+
'megamenu_transition_effects',
|
424 |
+
array(
|
425 |
+
'disabled' => array(
|
426 |
+
'label' => __( 'None', 'megamenu' ),
|
427 |
+
'selected' => $selected === 'disabled',
|
428 |
+
),
|
429 |
+
'fade' => array(
|
430 |
+
'label' => __( 'Fade', 'megamenu' ),
|
431 |
+
'selected' => $selected === 'fade',
|
432 |
+
),
|
433 |
+
'fade_up' => array(
|
434 |
+
'label' => __( 'Fade Up', 'megamenu' ),
|
435 |
+
'selected' => $selected === 'fade_up' || $selected === 'fadeUp',
|
436 |
+
),
|
437 |
+
'slide' => array(
|
438 |
+
'label' => __( 'Slide', 'megamenu' ),
|
439 |
+
'selected' => $selected === 'slide',
|
440 |
+
),
|
441 |
+
'slide_up' => array(
|
442 |
+
'label' => __( 'Slide Up', 'megamenu' ),
|
443 |
+
'selected' => $selected === 'slide_up',
|
444 |
+
),
|
445 |
+
),
|
446 |
+
$selected
|
447 |
+
);
|
448 |
+
|
449 |
+
foreach ( $options as $key => $value ) {
|
450 |
+
?>
|
451 |
+
<option value='<?php echo esc_attr( $key ); ?>' <?php selected( $value['selected'] ); ?>><?php echo esc_html( $value['label'] ); ?></option>
|
452 |
+
<?php
|
453 |
+
}
|
454 |
+
|
455 |
+
?>
|
456 |
+
</select>
|
457 |
+
|
458 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][effect_speed]'>
|
459 |
+
<?php
|
460 |
+
|
461 |
+
$selected = isset( $settings[ $location ]['effect_speed'] ) ? $settings[ $location ]['effect_speed'] : '200';
|
462 |
+
|
463 |
+
$options = apply_filters(
|
464 |
+
'megamenu_effect_speed',
|
465 |
+
array(
|
466 |
+
'600' => __( 'Slow', 'megamenu' ),
|
467 |
+
'400' => __( 'Med', 'megamenu' ),
|
468 |
+
'200' => __( 'Fast', 'megamenu' ),
|
469 |
+
),
|
470 |
+
$selected
|
471 |
+
);
|
472 |
+
|
473 |
+
ksort( $options );
|
474 |
+
|
475 |
+
foreach ( $options as $key => $value ) {
|
476 |
+
?>
|
477 |
+
<option value='<?php echo esc_attr( $key ); ?>' <?php selected( $key === $selected ); ?>><?php echo esc_html( $value ); ?></option>
|
478 |
+
<?php
|
479 |
+
}
|
480 |
+
|
481 |
+
?>
|
482 |
+
</select>
|
483 |
+
</td>
|
484 |
+
</tr>
|
485 |
+
<tr>
|
486 |
+
<td><?php esc_html_e( 'Effect (Mobile)', 'megamenu' ); ?></td>
|
487 |
+
<td>
|
488 |
+
<select class='megamenu_effect_mobile' name='megamenu_meta[<?php echo $location; ?>][effect_mobile]'>
|
489 |
+
<?php
|
490 |
+
|
491 |
+
$selected = isset( $settings[ $location ]['effect_mobile'] ) ? $settings[ $location ]['effect_mobile'] : 'disabled';
|
492 |
+
|
493 |
+
$options = apply_filters(
|
494 |
+
'megamenu_transition_effects_mobile',
|
495 |
+
array(
|
496 |
+
'disabled' => array(
|
497 |
+
'label' => __( 'None', 'megamenu' ),
|
498 |
+
'selected' => $selected == 'disabled',
|
499 |
+
),
|
500 |
+
'slide' => array(
|
501 |
+
'label' => __( 'Slide Down', 'megamenu' ),
|
502 |
+
'selected' => $selected == 'slide',
|
503 |
+
),
|
504 |
+
'slide_left' => array(
|
505 |
+
'label' => __( 'Slide Left (Off Canvas)', 'megamenu' ),
|
506 |
+
'selected' => $selected == 'slide_left',
|
507 |
+
),
|
508 |
+
'slide_right' => array(
|
509 |
+
'label' => __( 'Slide Right (Off Canvas)', 'megamenu' ),
|
510 |
+
'selected' => $selected == 'slide_right',
|
511 |
+
),
|
512 |
+
),
|
513 |
+
$selected
|
514 |
+
);
|
515 |
+
|
516 |
+
foreach ( $options as $key => $value ) {
|
517 |
+
?>
|
518 |
+
<option value='<?php echo $key; ?>' <?php selected( $value['selected'] ); ?>><?php echo $value['label']; ?></option>
|
519 |
+
<?php
|
520 |
+
}
|
521 |
+
|
522 |
+
?>
|
523 |
+
</select>
|
524 |
+
|
525 |
+
<select name='megamenu_meta[<?php echo $location; ?>][effect_speed_mobile]'>
|
526 |
+
<?php
|
527 |
+
|
528 |
+
$selected = isset( $settings[ $location ]['effect_speed_mobile'] ) ? $settings[ $location ]['effect_speed_mobile'] : '200';
|
529 |
+
|
530 |
+
$options = apply_filters(
|
531 |
+
'megamenu_effect_speed_mobile',
|
532 |
+
array(
|
533 |
+
'600' => __( 'Slow', 'megamenu' ),
|
534 |
+
'400' => __( 'Med', 'megamenu' ),
|
535 |
+
'200' => __( 'Fast', 'megamenu' ),
|
536 |
+
),
|
537 |
+
$selected
|
538 |
+
);
|
539 |
+
|
540 |
+
ksort( $options );
|
541 |
+
|
542 |
+
foreach ( $options as $key => $value ) {
|
543 |
+
?>
|
544 |
+
<option value='<?php echo $key; ?>' <?php selected( $key == $selected ); ?>><?php echo $value; ?></option>
|
545 |
+
<?php
|
546 |
+
}
|
547 |
+
|
548 |
+
?>
|
549 |
+
</select>
|
550 |
+
</td>
|
551 |
+
</tr>
|
552 |
+
<tr>
|
553 |
+
<td><?php esc_html_e( 'Theme', 'megamenu' ); ?></td>
|
554 |
+
<td>
|
555 |
+
|
556 |
+
<select name='megamenu_meta[<?php echo $location; ?>][theme]'>
|
557 |
+
<?php
|
558 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
559 |
+
$themes = $style_manager->get_themes();
|
560 |
+
$selected_theme = isset( $settings[ $location ]['theme'] ) ? $settings[ $location ]['theme'] : 'default';
|
561 |
+
|
562 |
+
foreach ( $themes as $key => $theme ) {
|
563 |
+
echo "<option value='" . esc_attr( $key ) . "' " . selected( $selected_theme, $key ) . '>' . esc_html( $theme['title'] ) . '</option>';
|
564 |
+
}
|
565 |
+
?>
|
566 |
+
</select>
|
567 |
+
</td>
|
568 |
+
</tr>
|
569 |
+
|
570 |
+
<?php do_action( 'megamenu_settings_table', $location, $settings ); ?>
|
571 |
+
</table>
|
572 |
+
<?php
|
573 |
+
}
|
574 |
+
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Return the locations that a specific menu ID has been tagged to.
|
578 |
+
*
|
579 |
+
* @param $menu_id int
|
580 |
+
* @return array
|
581 |
+
*/
|
582 |
+
public function get_tagged_theme_locations_for_menu_id( $menu_id ) {
|
583 |
+
|
584 |
+
$locations = array();
|
585 |
+
|
586 |
+
$nav_menu_locations = get_nav_menu_locations();
|
587 |
+
|
588 |
+
foreach ( get_registered_nav_menus() as $id => $name ) {
|
589 |
+
|
590 |
+
if ( isset( $nav_menu_locations[ $id ] ) && $nav_menu_locations[ $id ] == $menu_id ) {
|
591 |
+
$locations[ $id ] = $name;
|
592 |
+
}
|
593 |
+
}
|
594 |
+
|
595 |
+
return $locations;
|
596 |
+
}
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Get the current menu ID.
|
600 |
+
*
|
601 |
+
* Most of this taken from wp-admin/nav-menus.php (no built in functions to do this)
|
602 |
+
*
|
603 |
+
* @since 1.0
|
604 |
+
* @return int
|
605 |
+
*/
|
606 |
+
public function get_selected_menu_id() {
|
607 |
+
|
608 |
+
$nav_menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
|
609 |
+
|
610 |
+
$menu_count = count( $nav_menus );
|
611 |
+
|
612 |
+
$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
|
613 |
+
|
614 |
+
$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
|
615 |
+
|
616 |
+
// If we have one theme location, and zero menus, we take them right into editing their first menu.
|
617 |
+
$page_count = wp_count_posts( 'page' );
|
618 |
+
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
|
619 |
+
|
620 |
+
// Get recently edited nav menu.
|
621 |
+
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
|
622 |
+
if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) {
|
623 |
+
$recently_edited = $nav_menu_selected_id;
|
624 |
+
}
|
625 |
+
|
626 |
+
// Use $recently_edited if none are selected.
|
627 |
+
if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) {
|
628 |
+
$nav_menu_selected_id = $recently_edited;
|
629 |
+
}
|
630 |
+
|
631 |
+
// On deletion of menu, if another menu exists, show it.
|
632 |
+
if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) {
|
633 |
+
$nav_menu_selected_id = $nav_menus[0]->term_id;
|
634 |
+
}
|
635 |
+
|
636 |
+
// Set $nav_menu_selected_id to 0 if no menus.
|
637 |
+
if ( $one_theme_location_no_menus ) {
|
638 |
+
$nav_menu_selected_id = 0;
|
639 |
+
} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
|
640 |
+
// if we have no selection yet, and we have menus, set to the first one in the list.
|
641 |
+
$nav_menu_selected_id = $nav_menus[0]->term_id;
|
642 |
+
}
|
643 |
+
|
644 |
+
return $nav_menu_selected_id;
|
645 |
+
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
endif;
|
classes/pages/general.php
CHANGED
@@ -1,215 +1,195 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_General' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_General {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if ( isset( $_GET['delete_data'] ) && $_GET['delete_data'] == 'true' ) {
|
198 |
-
echo "<p class='success'>" . __("All plugin data removed", "megamenu") . "</p>";
|
199 |
-
}
|
200 |
-
|
201 |
-
if ( is_plugin_active('clearfy/clearfy.php') ) {
|
202 |
-
if ( $clearfy_options = get_option('wbcr_clearfy_cache_options') ) {
|
203 |
-
if ( $clearfy_options['disable_dashicons'] == true ) {
|
204 |
-
echo "<p class='fail'>" . __("Please enable Dashicons in the Clearfy plugin options. Max Mega Menu requires Dashicons.", "megamenu") . "</p>";
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
do_action("megamenu_print_messages");
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
}
|
214 |
-
|
215 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access.
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_General' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Handles the Mega Menu > Menu Settings page
|
11 |
+
*/
|
12 |
+
class Mega_Menu_General {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
+
*
|
17 |
+
* @since 1.0
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
add_action( 'admin_post_megamenu_save_settings', array( $this, 'save_settings' ) );
|
21 |
+
add_action( 'admin_post_megamenu_clear_css_cache', array( $this, 'tools_clear_css_cache' ) );
|
22 |
+
add_action( 'admin_post_megamenu_delete_data', array( $this, 'delete_data' ) );
|
23 |
+
|
24 |
+
add_filter( 'megamenu_menu_tabs', array( $this, 'add_general_tab' ), 4 );
|
25 |
+
add_action( 'megamenu_page_general_settings', array( $this, 'general_settings_page' ) );
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Add the Menu Locations tab to our available tabs
|
32 |
+
*
|
33 |
+
* @param array $tabs
|
34 |
+
* @since 2.8
|
35 |
+
*/
|
36 |
+
public function add_general_tab( $tabs ) {
|
37 |
+
$tabs['general_settings'] = __( 'General Settings', 'megamenu' );
|
38 |
+
return $tabs;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Sanitize multidimensional array
|
43 |
+
*
|
44 |
+
* @since 2.7.5
|
45 |
+
*/
|
46 |
+
public function sanitize_array( &$array ) {
|
47 |
+
foreach ( $array as &$value ) {
|
48 |
+
if ( ! is_array( $value ) ) {
|
49 |
+
$value = sanitize_textarea_field( $value );
|
50 |
+
} else {
|
51 |
+
$this->sanitize_array( $value );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
return $array;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Save menu general settings.
|
60 |
+
*
|
61 |
+
* @since 1.0
|
62 |
+
*/
|
63 |
+
public function save_settings() {
|
64 |
+
check_admin_referer( 'megamenu_save_settings' );
|
65 |
+
|
66 |
+
if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) {
|
67 |
+
$settings = $this->sanitize_array( $_POST['settings'] );
|
68 |
+
$submitted_settings = apply_filters( 'megamenu_submitted_settings', $settings );
|
69 |
+
$existing_settings = get_option( 'megamenu_settings' );
|
70 |
+
$new_settings = array_merge( (array) $existing_settings, $submitted_settings );
|
71 |
+
|
72 |
+
update_option( 'megamenu_settings', $new_settings );
|
73 |
+
}
|
74 |
+
|
75 |
+
delete_transient( 'megamenu_failed_to_write_css_to_filesystem' );
|
76 |
+
|
77 |
+
do_action( 'megamenu_after_save_general_settings' );
|
78 |
+
do_action( 'megamenu_delete_cache' );
|
79 |
+
|
80 |
+
$url = isset( $_POST['_wp_http_referer'] ) ? $_POST['_wp_http_referer'] : admin_url( 'admin.php?page=maxmegamenu&saved=true' );
|
81 |
+
|
82 |
+
$this->redirect( $url );
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Redirect and exit
|
88 |
+
*
|
89 |
+
* @since 1.8
|
90 |
+
*/
|
91 |
+
public function redirect( $url ) {
|
92 |
+
wp_redirect( $url );
|
93 |
+
exit;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Content for 'Settings' tab
|
99 |
+
*
|
100 |
+
* @since 1.4
|
101 |
+
*/
|
102 |
+
public function general_settings_page( $saved_settings ) {
|
103 |
+
|
104 |
+
$css = isset( $saved_settings['css'] ) ? $saved_settings['css'] : 'fs';
|
105 |
+
$js = isset( $saved_settings['js'] ) ? $saved_settings['js'] : 'footer';
|
106 |
+
|
107 |
+
$locations = get_registered_nav_menus();
|
108 |
+
|
109 |
+
?>
|
110 |
+
|
111 |
+
<div class='menu_settings menu_settings_general_settings'>
|
112 |
+
|
113 |
+
<form action="<?php echo esc_attr( admin_url( 'admin-post.php' ) ); ?>" method="post">
|
114 |
+
<input type="hidden" name="action" value="megamenu_save_settings" />
|
115 |
+
<?php wp_nonce_field( 'megamenu_save_settings' ); ?>
|
116 |
+
|
117 |
+
<h3 class='first'><?php esc_html_e( 'General Settings', 'megamenu' ); ?></h3>
|
118 |
+
|
119 |
+
<table>
|
120 |
+
<tr>
|
121 |
+
<td class='mega-name'>
|
122 |
+
<?php esc_html_e( 'CSS Output', 'megamenu' ); ?>
|
123 |
+
<div class='mega-description'>
|
124 |
+
</div>
|
125 |
+
</td>
|
126 |
+
<td class='mega-value'>
|
127 |
+
<select name='settings[css]' id='mega_css'>
|
128 |
+
<option value='fs' <?php echo selected( 'fs' === $css ); ?>><?php esc_html_e( 'Save to filesystem', 'megamenu' ); ?>
|
129 |
+
<?php
|
130 |
+
if ( get_transient( 'megamenu_failed_to_write_css_to_filesystem' ) ) {
|
131 |
+
echo ' ' . esc_html( '(Action required: Check upload folder permissions)', 'megamenu' );
|
132 |
+
}
|
133 |
+
?>
|
134 |
+
</option>
|
135 |
+
<option value='head' <?php echo selected( 'head' === $css ); ?>><?php esc_html_e( 'Output in <head>', 'megamenu' ); ?></option>
|
136 |
+
<option value='disabled' <?php echo selected( 'disabled' === $css ); ?>><?php esc_html_e( "Don't output CSS", 'megamenu' ); ?></option>
|
137 |
+
<select>
|
138 |
+
<div class='mega-description'>
|
139 |
+
<div class='fs' style='display: <?php echo 'fs' === $css ? 'block' : 'none'; ?>'><?php esc_html_e( 'CSS will be saved to wp-content/uploads/maxmegamenu/style.css and enqueued from there.', 'megamenu' ); ?></div>
|
140 |
+
<div class='head' style='display: <?php echo 'head' === $css ? 'block' : 'none'; ?>'><?php esc_html_e( 'CSS will be loaded from the cache in a <style> tag in the <head> of the page.', 'megamenu' ); ?></div>
|
141 |
+
<div class='disabled' style='display: <?php echo 'disabled' === $css ? 'block' : 'none'; ?>'>
|
142 |
+
<?php esc_html_e( 'CSS will not be output, you must enqueue the CSS for the menu manually.', 'megamenu' ); ?>
|
143 |
+
<div class='fail'><?php esc_html_e( 'Selecting this option will effectively disable the theme editor and many of the features available in Max Mega Menu and Max Mega Menu Pro. Only enable this option if you fully understand the consequences.', 'megamenu' ); ?>
|
144 |
+
</div>
|
145 |
+
</div>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<tr>
|
149 |
+
<td class='mega-name'>
|
150 |
+
<?php esc_html_e( 'More options', 'megamenu' ); ?>
|
151 |
+
<div class='mega-description'>
|
152 |
+
</div>
|
153 |
+
</td>
|
154 |
+
<td class='mega-value'>
|
155 |
+
|
156 |
+
<?php
|
157 |
+
$locations_url = add_query_arg(
|
158 |
+
array(
|
159 |
+
'page' => 'maxmegamenu',
|
160 |
+
),
|
161 |
+
admin_url( 'admin.php' )
|
162 |
+
);
|
163 |
+
?>
|
164 |
+
|
165 |
+
<p>Looking for the <b>Click Event Behaviour</b>, <b>Mobile Menu Behaviour</b>, <b>Menu Item Descriptions</b>, <b>Unbind JavaScript Events</b>, <b>Prefix Menu Item Classes</b> or <b>Active Menu Instance</b> options?</p>
|
166 |
+
<p>These can now be defined <em>per menu location</em> on the <em><a href='<?php echo esc_attr( $locations_url ); ?>'>Mega Menu > Menu Locations</a></em> page (expand a menu location and look within the 'Advanced' tab).</p>
|
167 |
+
</td>
|
168 |
+
</tr>
|
169 |
+
<!--tr>
|
170 |
+
<td class='mega-name'>
|
171 |
+
<?php esc_html_e( 'JavaScript Output', 'megamenu' ); ?>
|
172 |
+
<div class='mega-description'>
|
173 |
+
</div>
|
174 |
+
</td>
|
175 |
+
<td class='mega-value'>
|
176 |
+
<select name='settings[js]' id='mega_css'>
|
177 |
+
<option value='footer' <?php echo selected( 'footer' === $js ); ?>><?php esc_html_e( 'Footer (default)', 'megamenu' ); ?></option>
|
178 |
+
<option value='head' <?php echo selected( 'head' === $js ); ?>><?php esc_html_e( 'Output in <head>', 'megamenu' ); ?></option>
|
179 |
+
<select>
|
180 |
+
</td>
|
181 |
+
</tr-->
|
182 |
+
</table>
|
183 |
+
|
184 |
+
<?php do_action( 'megamenu_general_settings', $saved_settings ); ?>
|
185 |
+
|
186 |
+
<?php submit_button(); ?>
|
187 |
+
</form>
|
188 |
+
</div>
|
189 |
+
|
190 |
+
<?php
|
191 |
+
}
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pages/locations.php
CHANGED
@@ -1,1603 +1,1668 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Locations' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_Locations {
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access.
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Locations' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Handles the Mega Menu > Menu Settings page
|
11 |
+
*/
|
12 |
+
class Mega_Menu_Locations {
|
13 |
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
+
*
|
17 |
+
* @since 2.8
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
add_action( 'admin_post_megamenu_add_menu_location', array( $this, 'add_menu_location' ) );
|
21 |
+
add_action( 'admin_post_megamenu_delete_menu_location', array( $this, 'delete_menu_location' ) );
|
22 |
+
add_action( 'admin_post_megamenu_save_menu_location', array( $this, 'save_menu_location' ) );
|
23 |
+
|
24 |
+
add_action( 'admin_post_megamenu_sandbox', array( $this, 'sandbox' ) );
|
25 |
+
add_action( 'wp_print_scripts', array( $this, 'sandbox_remove_unnecessary_scripts' ) );
|
26 |
+
add_action( 'wp_print_styles', array( $this, 'sandbox_remove_unnecessary_styles' ) );
|
27 |
+
|
28 |
+
add_filter( 'megamenu_menu_tabs', array( $this, 'add_locations_tab' ), 1 );
|
29 |
+
add_action( 'megamenu_page_menu_locations', array( $this, 'menu_locations_page' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Add the Menu Locations tab to our available tabs
|
35 |
+
*
|
36 |
+
* @param array $tabs array of available tabs.
|
37 |
+
* @since 2.8
|
38 |
+
*/
|
39 |
+
public function add_locations_tab( $tabs ) {
|
40 |
+
$tabs['menu_locations'] = __( 'Menu Locations', 'megamenu' );
|
41 |
+
return $tabs;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Add a new menu location.
|
47 |
+
*
|
48 |
+
* @since 2.8
|
49 |
+
*/
|
50 |
+
public function add_menu_location() {
|
51 |
+
check_admin_referer( 'megamenu_add_menu_location' );
|
52 |
+
|
53 |
+
$locations = get_option( 'megamenu_locations' );
|
54 |
+
$next_id = $this->get_next_menu_location_id();
|
55 |
+
$new_menu_location_id = 'max_mega_menu_' . $next_id;
|
56 |
+
|
57 |
+
$title = 'Max Mega Menu Location ' . $next_id;
|
58 |
|
59 |
+
if ( isset( $_POST['title'] ) ) {
|
60 |
+
$title = esc_attr( wp_unslash( $_POST['title'] ) );
|
61 |
+
}
|
62 |
+
|
63 |
+
$locations[ $new_menu_location_id ] = esc_attr( $title );
|
64 |
+
|
65 |
+
update_option( 'megamenu_locations', $locations );
|
66 |
+
|
67 |
+
$menu_id = 0;
|
68 |
+
|
69 |
+
if ( isset( $_POST['menu_id'] ) ) {
|
70 |
+
$menu_id = absint( $_POST['menu_id'] );
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( $menu_id > 0 ) {
|
74 |
+
$locations = get_theme_mod( 'nav_menu_locations' );
|
75 |
+
|
76 |
+
$locations[ $new_menu_location_id ] = $menu_id;
|
77 |
+
set_theme_mod( 'nav_menu_locations', $locations );
|
78 |
+
}
|
79 |
+
|
80 |
+
do_action( 'megamenu_after_add_menu_location' );
|
81 |
+
|
82 |
+
$redirect_url = add_query_arg(
|
83 |
+
array(
|
84 |
+
'page' => 'maxmegamenu',
|
85 |
+
'location_added' => 'true',
|
86 |
+
'location' => $new_menu_location_id,
|
87 |
+
),
|
88 |
+
admin_url( 'admin.php' )
|
89 |
+
);
|
90 |
+
|
91 |
+
$this->redirect( $redirect_url );
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Delete a menu location.
|
98 |
+
*
|
99 |
+
* @since 2.8
|
100 |
+
*/
|
101 |
+
public function delete_menu_location() {
|
102 |
+
check_admin_referer( 'megamenu_delete_menu_location' );
|
103 |
+
|
104 |
+
$locations = get_option( 'megamenu_locations' );
|
105 |
+
$location_to_delete = esc_attr( $_GET['location'] );
|
106 |
+
|
107 |
+
if ( isset( $locations[ $location_to_delete ] ) ) {
|
108 |
+
unset( $locations[ $location_to_delete ] );
|
109 |
+
update_option( 'megamenu_locations', $locations );
|
110 |
+
}
|
111 |
+
|
112 |
+
do_action( 'megamenu_after_delete_menu_location' );
|
113 |
+
do_action( 'megamenu_delete_cache' );
|
114 |
+
|
115 |
+
$redirect_url = add_query_arg(
|
116 |
+
array(
|
117 |
+
'page' => 'maxmegamenu',
|
118 |
+
'delete_location' => 'true',
|
119 |
+
),
|
120 |
+
admin_url( 'admin.php' )
|
121 |
+
);
|
122 |
+
|
123 |
+
$this->redirect( $redirect_url );
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Save a menu location
|
128 |
+
*
|
129 |
+
* @since 2.0
|
130 |
+
*/
|
131 |
+
public function save_menu_location() {
|
132 |
+
check_admin_referer( 'megamenu_save_menu_location' );
|
133 |
+
|
134 |
+
$location = false;
|
135 |
+
|
136 |
+
if ( isset( $_POST['location'] ) ) {
|
137 |
+
$location = esc_attr( $_POST['location'] );
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( $location ) {
|
141 |
+
$submitted_settings = apply_filters( 'megamenu_submitted_settings_meta', $_POST['megamenu_meta'] );
|
142 |
+
|
143 |
+
if ( isset( $submitted_settings[ $location ]['enabled'] ) ) {
|
144 |
+
$submitted_settings[ $location ]['enabled'] = '1';
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( ! isset( $submitted_settings[ $location ]['unbind'] ) ) {
|
148 |
+
$submitted_settings[ $location ]['unbind'] = 'disabled';
|
149 |
+
}
|
150 |
+
|
151 |
+
if ( ! isset( $submitted_settings[ $location ]['descriptions'] ) ) {
|
152 |
+
$submitted_settings[ $location ]['descriptions'] = 'disabled';
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( ! isset( $submitted_settings[ $location ]['prefix'] ) ) {
|
156 |
+
$submitted_settings[ $location ]['prefix'] = 'disabled';
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( ! get_option( 'megamenu_settings' ) ) {
|
160 |
+
update_option( 'megamenu_settings', $submitted_settings );
|
161 |
+
} else {
|
162 |
+
$existing_settings = get_option( 'megamenu_settings' );
|
163 |
+
$new_settings = array_merge( $existing_settings, $submitted_settings );
|
164 |
+
|
165 |
+
update_option( 'megamenu_settings', $new_settings );
|
166 |
+
}
|
167 |
+
|
168 |
+
do_action( 'megamenu_after_save_settings' );
|
169 |
+
do_action( 'megamenu_delete_cache' );
|
170 |
+
}
|
171 |
+
|
172 |
+
/* Save custom location description **/
|
173 |
+
if ( isset( $_POST['custom_location'] ) && is_array( $_POST['custom_location'] ) ) {
|
174 |
+
$custom_location = array_map( 'sanitize_text_field', $_POST['custom_location'] );
|
175 |
+
$locations = get_option( 'megamenu_locations' );
|
176 |
+
$new_locations = array_merge( (array) $locations, $custom_location );
|
177 |
+
|
178 |
+
update_option( 'megamenu_locations', $new_locations );
|
179 |
+
}
|
180 |
+
|
181 |
+
$args = array(
|
182 |
+
'page' => 'maxmegamenu',
|
183 |
+
'location' => urlencode( $location ),
|
184 |
+
'save_location' => 'true',
|
185 |
+
);
|
186 |
+
|
187 |
+
if ( ! isset( $submitted_settings[ $location ]['enabled'] ) ) {
|
188 |
+
unset( $args['location'] );
|
189 |
+
}
|
190 |
+
|
191 |
+
$redirect_url = add_query_arg(
|
192 |
+
$args,
|
193 |
+
admin_url( 'admin.php' )
|
194 |
+
);
|
195 |
+
|
196 |
+
$this->redirect( $redirect_url );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Redirect and exit
|
201 |
+
*
|
202 |
+
* @since 2.8
|
203 |
+
*/
|
204 |
+
public function redirect( $url ) {
|
205 |
+
wp_redirect( $url );
|
206 |
+
exit;
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Returns the next available menu location ID
|
212 |
+
*
|
213 |
+
* @since 2.8
|
214 |
+
*/
|
215 |
+
public function get_next_menu_location_id() {
|
216 |
+
$last_id = 0;
|
217 |
+
|
218 |
+
if ( $locations = get_option( 'megamenu_locations' ) ) {
|
219 |
+
foreach ( $locations as $key => $value ) {
|
220 |
+
if ( strpos( $key, 'max_mega_menu_' ) !== false ) {
|
221 |
+
$parts = explode( '_', $key );
|
222 |
+
$menu_id = end( $parts );
|
223 |
+
|
224 |
+
if ( $menu_id > $last_id ) {
|
225 |
+
$last_id = $menu_id;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
$next_id = $last_id + 1;
|
232 |
+
|
233 |
+
return $next_id;
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Content for Menu Locations page
|
239 |
+
*
|
240 |
+
* @since 2.8
|
241 |
+
*/
|
242 |
+
public function menu_locations_page( $saved_settings ) {
|
243 |
+
if ( isset( $_GET['add_location'] ) ) {
|
244 |
+
$this->add_location_page();
|
245 |
+
return;
|
246 |
+
}
|
247 |
+
|
248 |
+
$all_locations = $this->get_registered_locations();
|
249 |
+
$enabled_locations = array();
|
250 |
+
$disabled_locations = array();
|
251 |
+
|
252 |
+
foreach ( $all_locations as $id => $description ) {
|
253 |
+
if ( max_mega_menu_is_enabled( $id ) ) {
|
254 |
+
$enabled_locations[ $id ] = $description;
|
255 |
+
} else {
|
256 |
+
$disabled_locations[ $id ] = $description;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
?>
|
260 |
+
|
261 |
+
<div class='menu_settings menu_settings_menu_locations'>
|
262 |
+
|
263 |
+
<?php $this->print_messages(); ?>
|
264 |
+
|
265 |
+
<h3 class='first'><?php esc_html_e( 'Menu Locations', 'megamenu' ); ?></h3>
|
266 |
+
|
267 |
+
<table>
|
268 |
+
<tr>
|
269 |
+
<td class='mega-name'>
|
270 |
+
<?php esc_html_e( 'Registered Menu Locations', 'megamenu' ); ?>
|
271 |
+
<div class='mega-description'>
|
272 |
+
<p><?php esc_html_e( 'This is an overview of the menu locations supported by your theme.', 'megamenu' ); ?></p>
|
273 |
+
<p><?php esc_html_e( 'Use these options to enable Max Mega Menu and define the behaviour of each menu location.', 'megamenu' ); ?></p>
|
274 |
+
</div>
|
275 |
+
</td>
|
276 |
+
<td class='mega-value mega-vartical-align-top'>
|
277 |
+
<?php
|
278 |
+
|
279 |
+
if ( ! count( $enabled_locations + $disabled_locations ) ) {
|
280 |
+
echo '<p>';
|
281 |
+
esc_html_e( 'Your theme does not natively support menus, but you can add a new menu location using Max Mega Menu and display the menu using the Max Mega Menu widget or shortcode.', 'megamenu' );
|
282 |
+
echo '</p>';
|
283 |
+
}
|
284 |
+
|
285 |
+
echo "<div class='mega-enabled-locations'>";
|
286 |
+
if ( count( $enabled_locations ) ) {
|
287 |
+
foreach ( $enabled_locations as $location => $description ) {
|
288 |
+
$this->show_location_accordion_header( $all_locations, $location, $description, $saved_settings );
|
289 |
+
}
|
290 |
+
}
|
291 |
+
echo "</div>";
|
292 |
+
|
293 |
+
echo "<div class='mega-disabled-locations'>";
|
294 |
+
if ( count( $disabled_locations ) ) {
|
295 |
+
foreach ( $disabled_locations as $location => $description ) {
|
296 |
+
$this->show_location_accordion_header( $all_locations, $location, $description, $saved_settings );
|
297 |
+
}
|
298 |
+
}
|
299 |
+
echo "</div>";
|
300 |
+
|
301 |
+
$add_location_url = esc_url(
|
302 |
+
add_query_arg(
|
303 |
+
array(
|
304 |
+
'page' => 'maxmegamenu',
|
305 |
+
'add_location' => 'true',
|
306 |
+
),
|
307 |
+
admin_url( 'admin.php' )
|
308 |
+
)
|
309 |
+
);
|
310 |
+
|
311 |
+
echo "<p><a class='button button-secondary mega-add-location' href='{$add_location_url}'>" . esc_html__( 'Add another menu location', 'megamenu' ) . '</a></p>';
|
312 |
+
|
313 |
+
?>
|
314 |
+
|
315 |
+
</td>
|
316 |
+
</tr>
|
317 |
+
</table>
|
318 |
+
|
319 |
+
<?php do_action( 'megamenu_menu_locations', $saved_settings ); ?>
|
320 |
+
|
321 |
+
</div>
|
322 |
+
|
323 |
+
<?php
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Output the HTML for a location accordion header
|
328 |
+
*
|
329 |
+
* @param array $locations All available locations
|
330 |
+
* @param array $location the current location
|
331 |
+
* @param string $description the location description
|
332 |
+
*/
|
333 |
+
private function show_location_accordion_header( $locations, $location, $description, $saved_settings ) {
|
334 |
+
$open_class = ( isset( $_GET['location'] ) && $_GET['location'] === $location ) ? ' mega-accordion-open' : '';
|
335 |
+
$is_enabled_class = 'mega-location-disabled';
|
336 |
+
$tooltip = '';
|
337 |
+
|
338 |
+
if ( max_mega_menu_is_enabled( $location ) ) {
|
339 |
+
$is_enabled_class = 'mega-location-enabled';
|
340 |
+
} elseif ( ! has_nav_menu( $location ) ) {
|
341 |
+
$is_enabled_class .= ' mega-location-disabled-assign-menu';
|
342 |
+
}
|
343 |
+
|
344 |
+
$has_active_location_class = '';
|
345 |
+
|
346 |
+
$active_instance = 0;
|
347 |
+
|
348 |
+
if ( isset( $saved_settings[ $location ]['active_instance'] ) ) {
|
349 |
+
$active_instance = $saved_settings[ $location ]['active_instance'];
|
350 |
+
} elseif ( isset( $saved_settings['instances'][ $location ] ) ) {
|
351 |
+
$active_instance = $saved_settings['instances'][ $location ];
|
352 |
+
}
|
353 |
+
|
354 |
+
if ( $active_instance > 0 ) {
|
355 |
+
$has_active_location_class = ' mega-has-active-location';
|
356 |
+
$tooltip = __( 'Active for Instance' ) . ' ' . esc_attr( $active_instance );
|
357 |
+
}
|
358 |
+
|
359 |
+
?>
|
360 |
+
|
361 |
+
<div class='mega-location <?php echo esc_attr( $is_enabled_class ); ?><?php echo esc_attr( $has_active_location_class ); ?>'>
|
362 |
+
<div class='mega-accordion-title<?php echo esc_attr( $open_class ); ?>'>
|
363 |
+
<span class='dashicons dashicons-location'></span>
|
364 |
+
<h4><?php echo esc_html( $description ); ?></h4>
|
365 |
+
<?php
|
366 |
+
|
367 |
+
$tooltip_attr = '';
|
368 |
+
|
369 |
+
if ( strlen( $tooltip ) > 0 ) {
|
370 |
+
$tooltip_attr = " data-tooltip='{$tooltip}'";
|
371 |
+
}
|
372 |
+
?>
|
373 |
+
<span class='mega-tooltip'<?php echo $tooltip_attr; ?>>
|
374 |
+
<span class='dashicons dashicons-yes'></span>
|
375 |
+
</span>
|
376 |
+
|
377 |
+
<div class='mega-ellipsis'>
|
378 |
+
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
|
379 |
+
<path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"></path>
|
380 |
+
</svg>
|
381 |
+
<ul class='mega-ellipsis-content'>
|
382 |
+
<li><?php echo $this->assigned_menu_link( $location ); ?></li>
|
383 |
+
<li><?php echo $this->sandbox_link( $location ); ?></li>
|
384 |
+
<?php
|
385 |
+
if ( strpos( $location, 'max_mega_menu_' ) !== false ) {
|
386 |
+
echo '<li>' . $this->delete_location_link( $location ) . '</li>';
|
387 |
+
}
|
388 |
+
?>
|
389 |
+
</ul>
|
390 |
+
</div>
|
391 |
+
</div>
|
392 |
+
<div class='mega-accordion-content'>
|
393 |
+
<?php
|
394 |
+
// if no menu has been assigned to the location
|
395 |
+
if ( ! has_nav_menu( $location ) ) {
|
396 |
+
echo "<p class='mega-warning'><span class='dashicons dashicons-warning'></span>";
|
397 |
+
echo " <a href='" . admin_url( 'nav-menus.php?action=locations' ) . "'>" . esc_html__( 'Assign a menu', 'megamenu' ) . '</a> ';
|
398 |
+
echo __( 'to this location to enable these options.', 'megamenu' );
|
399 |
+
echo '</p>';
|
400 |
+
} else {
|
401 |
+
$this->show_menu_locations_options( $locations, $location, $description );
|
402 |
+
}
|
403 |
+
?>
|
404 |
+
</div>
|
405 |
+
</div>
|
406 |
+
<?php
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Content for Menu Locations page
|
411 |
+
*
|
412 |
+
* @since 2.8
|
413 |
+
*/
|
414 |
+
public function add_location_page() {
|
415 |
+
?>
|
416 |
+
|
417 |
+
<div class='menu_settings menu_settings_add_location'>
|
418 |
+
|
419 |
+
<h3 class='first'><?php esc_html_e( 'Add Menu Location', 'megamenu' ); ?></h3>
|
420 |
+
|
421 |
+
<form action="<?php echo esc_attr( admin_url( 'admin-post.php' ) ); ?>" method="post">
|
422 |
+
<input type="hidden" name="action" value="megamenu_add_menu_location" />
|
423 |
+
<?php wp_nonce_field( 'megamenu_add_menu_location' ); ?>
|
424 |
+
|
425 |
+
<table>
|
426 |
+
<tr>
|
427 |
+
<td class='mega-name'>
|
428 |
+
<?php esc_html_e( 'Location Name', 'megamenu' ); ?>
|
429 |
+
<div class='mega-description'>
|
430 |
+
<p><?php esc_html_e( 'Give the location a name that describes where the menu will be displayed on your site.', 'megamenu' ); ?></p>
|
431 |
+
</div>
|
432 |
+
</td>
|
433 |
+
<td class='mega-value mega-vartical-align-top'>
|
434 |
+
<input class='wide' type='text' name='title' required='required' placeholder='<?php esc_attr_e( 'E.g. Footer, Blog Sidebar, Header', 'megamenu' ); ?>' />
|
435 |
+
</td>
|
436 |
+
</tr>
|
437 |
+
<tr>
|
438 |
+
<td class='mega-name'>
|
439 |
+
<?php esc_html_e( 'Assign a menu', 'megamenu' ); ?>
|
440 |
+
<div class='mega-description'>
|
441 |
+
<p><?php esc_html_e( 'Select a menu to be assigned to this location. This can be changed later using the Appearance > Menus > Manage Location page.', 'megamenu' ); ?></p>
|
442 |
+
</div>
|
443 |
+
</td>
|
444 |
+
<td class='mega-value mega-vartical-align-top'>
|
445 |
+
<?php
|
446 |
+
|
447 |
+
$menus = wp_get_nav_menus();
|
448 |
+
|
449 |
+
if ( count( $menus ) ) {
|
450 |
+
foreach ( $menus as $menu ) {
|
451 |
+
echo '<div class="mega-radio-row"><input type="radio" id="' . esc_attr( $menu->slug ) . '" name="menu_id" value="' . esc_attr( $menu->term_id ) . '" /><label for="' . esc_attr( $menu->slug ) . '">' . esc_attr( $menu->name ) . '</label></div>';
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
echo '<div class="mega-radio-row"><input checked="checked" type="radio" id="0" name="menu_id" value="0" /><label for="0">' . esc_html__( "Skip - I'll assign a menu later", 'megamenu' ) . '</label></div>';
|
456 |
+
?>
|
457 |
+
</td>
|
458 |
+
</tr>
|
459 |
+
</table>
|
460 |
+
<?php submit_button( __( 'Add menu location', 'megamenu' ) ); ?>
|
461 |
+
</form>
|
462 |
+
</div>
|
463 |
+
|
464 |
+
<?php
|
465 |
+
}
|
466 |
+
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Display a link showing the menu assigned to the specified location
|
470 |
+
*
|
471 |
+
* @param string $location
|
472 |
+
* @since 2.8
|
473 |
+
*/
|
474 |
+
public function assigned_menu_link( $location ) {
|
475 |
+
$menu_id = $this->get_menu_id_for_location( $location );
|
476 |
+
|
477 |
+
if ( $menu_id ) {
|
478 |
+
return "<a href='" . admin_url( "nav-menus.php?action=edit&menu={$menu_id}" ) . "'><span class='dashicons dashicons-menu-alt2'></span>" . esc_html( $this->get_menu_name_for_location( $location ) ) . '</a>';
|
479 |
+
} else {
|
480 |
+
return "<a href='" . admin_url( 'nav-menus.php?action=locations' ) . "'><span class='dashicons dashicons-menu-alt2'></span>" . esc_html__( 'Assign a menu', 'megamenu' ) . '</a>';
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Display a link showing the menu assigned to the specified location
|
486 |
+
*
|
487 |
+
* @param string $location
|
488 |
+
* @since 2.8
|
489 |
+
*/
|
490 |
+
public function sandbox_link( $location ) {
|
491 |
+
return "<a target='megamenu_sandbox' href='" . admin_url( "admin-post.php?action=megamenu_sandbox&location={$location}" ) . "'><span class='dashicons dashicons-external'></span>" . esc_html__( 'View in Sandbox', 'megamenu' ) . '</a>';
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Display a link showing the menu assigned to the specified location
|
497 |
+
*
|
498 |
+
* @param string $location
|
499 |
+
* @since 2.8
|
500 |
+
*/
|
501 |
+
public function delete_location_link( $location ) {
|
502 |
+
$delete_location_url = esc_url(
|
503 |
+
add_query_arg(
|
504 |
+
array(
|
505 |
+
'action' => 'megamenu_delete_menu_location',
|
506 |
+
'location' => $location,
|
507 |
+
),
|
508 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_delete_menu_location' )
|
509 |
+
)
|
510 |
+
);
|
511 |
+
|
512 |
+
return "<a class='confirm' href='{$delete_location_url}'><span class='dashicons dashicons-trash'></span>" . esc_html__( 'Delete location', 'megamenu' ) . '</a>';
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Remove unnecessary scripts from the sandbox page
|
517 |
+
*
|
518 |
+
* @since 2.9
|
519 |
+
*/
|
520 |
+
public function sandbox_remove_unnecessary_scripts() {
|
521 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] === 'megamenu_sandbox' ) {
|
522 |
+
global $wp_scripts;
|
523 |
+
|
524 |
+
$queue_items = $wp_scripts->queue;
|
525 |
+
$wp_scripts->queue = array();
|
526 |
+
|
527 |
+
do_action( 'megamenu_enqueue_scripts' );
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Remove unnecessary styles from the sandbox page
|
533 |
+
*
|
534 |
+
* @since 2.9
|
535 |
+
*/
|
536 |
+
public function sandbox_remove_unnecessary_styles() {
|
537 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] === 'megamenu_sandbox' ) {
|
538 |
+
global $wp_styles;
|
539 |
+
|
540 |
+
$queue_items = $wp_styles->queue;
|
541 |
+
$wp_styles->queue = array();
|
542 |
+
|
543 |
+
do_action( 'megamenu_enqueue_styles' );
|
544 |
+
}
|
545 |
+
}
|
546 |
+
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Content for Sandbox page
|
550 |
+
*
|
551 |
+
* @since 2.9
|
552 |
+
*/
|
553 |
+
public function sandbox() {
|
554 |
+
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
|
555 |
+
remove_action( 'wp_head', '_admin_bar_bump_cb' );
|
556 |
+
|
557 |
+
if ( isset( $_GET['location'] ) ) {
|
558 |
+
$location = esc_attr( $_GET['location'] );
|
559 |
+
|
560 |
+
?>
|
561 |
+
<!DOCTYPE html>
|
562 |
+
<html>
|
563 |
+
<head>
|
564 |
+
<title>Sandbox: <?php echo $location; ?></title>
|
565 |
+
<style type='text/css'>
|
566 |
+
body, html {
|
567 |
+
margin: 0;
|
568 |
+
padding: 0;
|
569 |
+
min-height: 200vh;
|
570 |
+
}
|
571 |
+
body {
|
572 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
573 |
+
background-image:
|
574 |
+
linear-gradient(45deg, #eee 25%, transparent 25%),
|
575 |
+
linear-gradient(135deg, #eee 25%, transparent 25%),
|
576 |
+
linear-gradient(45deg, transparent 75%, #eee 75%),
|
577 |
+
linear-gradient(135deg, transparent 75%, #eee 75%);
|
578 |
+
background-size:25px 25px;
|
579 |
+
background-position:0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px;
|
580 |
+
}
|
581 |
+
#query-monitor-main {
|
582 |
+
display: none;
|
583 |
+
}
|
584 |
+
.menu_wrapper {
|
585 |
+
max-width: 1280px;
|
586 |
+
margin: 0 auto;
|
587 |
+
margin-top: 20px;
|
588 |
+
}
|
589 |
+
</style>
|
590 |
+
<?php wp_head(); ?>
|
591 |
+
</head>
|
592 |
+
<body>
|
593 |
+
<div class='menu_wrapper'>
|
594 |
+
<?php echo do_shortcode( "[maxmegamenu location={$location}]" ); ?>
|
595 |
+
</div>
|
596 |
+
<?php wp_footer(); ?>
|
597 |
+
</body>
|
598 |
+
</html>
|
599 |
+
<?php
|
600 |
+
}
|
601 |
+
|
602 |
+
die();
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Content for Menu Location options
|
607 |
+
*
|
608 |
+
* @since 2.8
|
609 |
+
*/
|
610 |
+
public function show_menu_locations_options( $all_locations, $location, $description ) {
|
611 |
+
|
612 |
+
$menu_id = $this->get_menu_id_for_location( $location );
|
613 |
+
$is_custom_location = strpos( $location, 'max_mega_menu_' ) !== false;
|
614 |
+
$plugin_settings = get_option( 'megamenu_settings' );
|
615 |
+
$location_settings = isset( $plugin_settings[ $location ] ) ? $plugin_settings[ $location ] : array();
|
616 |
+
|
617 |
+
?>
|
618 |
+
|
619 |
+
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post">
|
620 |
+
<input type="hidden" name="action" value="megamenu_save_menu_location" />
|
621 |
+
<input type="hidden" name="location" value="<?php echo esc_attr( $location ); ?>" />
|
622 |
+
<?php wp_nonce_field( 'megamenu_save_menu_location' ); ?>
|
623 |
+
<?php
|
624 |
+
|
625 |
+
$settings = apply_filters(
|
626 |
+
'megamenu_location_settings',
|
627 |
+
array(
|
628 |
+
|
629 |
+
'general' => array(
|
630 |
+
'priority' => 10,
|
631 |
+
'title' => __( 'General Settings', 'megamenu' ),
|
632 |
+
'settings' => array(
|
633 |
+
'enabled' => array(
|
634 |
+
'priority' => 10,
|
635 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
636 |
+
'description' => __( 'Enable Max Mega Menu for this menu location?', 'megamenu' ),
|
637 |
+
'settings' => array(
|
638 |
+
array(
|
639 |
+
'type' => 'checkbox_enabled',
|
640 |
+
'key' => 'enabled',
|
641 |
+
'value' => isset( $location_settings['enabled'] ) ? $location_settings['enabled'] : 0,
|
642 |
+
),
|
643 |
+
),
|
644 |
+
),
|
645 |
+
'event' => array(
|
646 |
+
'priority' => 20,
|
647 |
+
'title' => __( 'Event', 'megamenu' ),
|
648 |
+
'description' => __( 'Select the event to trigger sub menus', 'megamenu' ),
|
649 |
+
'settings' => array(
|
650 |
+
array(
|
651 |
+
'type' => 'event',
|
652 |
+
'key' => 'event',
|
653 |
+
'value' => isset( $location_settings['event'] ) ? $location_settings['event'] : 'hover',
|
654 |
+
),
|
655 |
+
),
|
656 |
+
),
|
657 |
+
'effect' => array(
|
658 |
+
'priority' => 30,
|
659 |
+
'title' => __( 'Effect', 'megamenu' ),
|
660 |
+
'description' => __( 'Select the sub menu animation type', 'megamenu' ),
|
661 |
+
'settings' => array(
|
662 |
+
array(
|
663 |
+
'type' => 'effect',
|
664 |
+
'key' => 'effect',
|
665 |
+
'value' => isset( $location_settings['effect'] ) ? $location_settings['effect'] : 'fade_up',
|
666 |
+
'title' => __( 'Animation' ),
|
667 |
+
),
|
668 |
+
array(
|
669 |
+
'type' => 'effect_speed',
|
670 |
+
'key' => 'effect_speed',
|
671 |
+
'value' => isset( $location_settings['effect_speed'] ) ? $location_settings['effect_speed'] : '200',
|
672 |
+
'title' => __( 'Speed' ),
|
673 |
+
),
|
674 |
+
),
|
675 |
+
),
|
676 |
+
'effect_mobile' => array(
|
677 |
+
'priority' => 40,
|
678 |
+
'title' => __( 'Effect (Mobile)', 'megamenu' ),
|
679 |
+
'description' => __( 'Choose a style for your mobile menu', 'megamenu' ),
|
680 |
+
'settings' => array(
|
681 |
+
array(
|
682 |
+
'type' => 'effect_mobile',
|
683 |
+
'key' => 'effect_mobile',
|
684 |
+
'value' => isset( $location_settings['effect_mobile'] ) ? $location_settings['effect_mobile'] : 'none',
|
685 |
+
'title' => __( 'Style' ),
|
686 |
+
),
|
687 |
+
array(
|
688 |
+
'type' => 'effect_speed_mobile',
|
689 |
+
'key' => 'effect_speed_mobile',
|
690 |
+
'value' => isset( $location_settings['effect_speed_mobile'] ) ? $location_settings['effect_speed_mobile'] : '200',
|
691 |
+
'title' => __( 'Speed' ),
|
692 |
+
),
|
693 |
+
),
|
694 |
+
),
|
695 |
+
'theme' => array(
|
696 |
+
'priority' => 50,
|
697 |
+
'title' => __( 'Theme', 'megamenu' ),
|
698 |
+
'description' => __( 'Select a theme to be applied to the menu', 'megamenu' ),
|
699 |
+
'settings' => array(
|
700 |
+
array(
|
701 |
+
'type' => 'theme_selector',
|
702 |
+
'key' => 'theme',
|
703 |
+
'value' => isset( $location_settings['theme'] ) ? $location_settings['theme'] : 'default',
|
704 |
+
),
|
705 |
+
),
|
706 |
+
),
|
707 |
+
),
|
708 |
+
),
|
709 |
+
'advanced' => array(
|
710 |
+
'priority' => 25,
|
711 |
+
'title' => __( 'Advanced', 'megamenu' ),
|
712 |
+
'settings' => array(
|
713 |
+
'click_behaviour' => array(
|
714 |
+
'priority' => 10,
|
715 |
+
'title' => __( 'Click Event Behaviour', 'megamenu' ),
|
716 |
+
'description' => __( "Define what should happen when the event is set to 'click'. This also applies to mobiles.", 'megamenu' ),
|
717 |
+
'settings' => array(
|
718 |
+
array(
|
719 |
+
'type' => 'click_behaviour',
|
720 |
+
'key' => 'click_behaviour',
|
721 |
+
'value' => $plugin_settings,
|
722 |
+
),
|
723 |
+
),
|
724 |
+
),
|
725 |
+
'mobile_behaviour' => array(
|
726 |
+
'priority' => 20,
|
727 |
+
'title' => __( 'Mobile Menu Behaviour', 'megamenu' ),
|
728 |
+
'description' => __( 'Define the sub menu toggle behaviour for the mobile menu.', 'megamenu' ),
|
729 |
+
'settings' => array(
|
730 |
+
array(
|
731 |
+
'type' => 'mobile_behaviour',
|
732 |
+
'key' => 'mobile_behaviour',
|
733 |
+
'value' => $plugin_settings,
|
734 |
+
),
|
735 |
+
),
|
736 |
+
),
|
737 |
+
'descriptions' => array(
|
738 |
+
'priority' => 20,
|
739 |
+
'title' => __( 'Menu Item Descriptions', 'megamenu' ),
|
740 |
+
'description' => __( 'Enable output of menu item descriptions.', 'megamenu' ),
|
741 |
+
'settings' => array(
|
742 |
+
array(
|
743 |
+
'type' => 'descriptions',
|
744 |
+
'key' => 'descriptions',
|
745 |
+
'value' => $plugin_settings,
|
746 |
+
),
|
747 |
+
),
|
748 |
+
),
|
749 |
+
'unbind' => array(
|
750 |
+
'priority' => 20,
|
751 |
+
'title' => __( 'Unbind JavaScript Events', 'megamenu' ),
|
752 |
+
'description' => __( 'To avoid conflicts with theme menu systems, JavaScript events which have been added to menu items will be removed by default.', 'megamenu' ),
|
753 |
+
'settings' => array(
|
754 |
+
array(
|
755 |
+
'type' => 'unbind',
|
756 |
+
'key' => 'unbind',
|
757 |
+
'value' => $plugin_settings,
|
758 |
+
),
|
759 |
+
),
|
760 |
+
),
|
761 |
+
'prefix' => array(
|
762 |
+
'priority' => 20,
|
763 |
+
'title' => __( 'Prefix Menu Item Classes', 'megamenu' ),
|
764 |
+
'description' => __( "Prefix custom menu item classes with 'mega-'?", 'megamenu' ),
|
765 |
+
'settings' => array(
|
766 |
+
array(
|
767 |
+
'type' => 'prefix',
|
768 |
+
'key' => 'prefix',
|
769 |
+
'value' => $plugin_settings,
|
770 |
+
),
|
771 |
+
),
|
772 |
+
),
|
773 |
+
'container' => array(
|
774 |
+
'priority' => 20,
|
775 |
+
'title' => __( 'Container', 'megamenu' ),
|
776 |
+
'description' => __( 'Use nav or div element for menu wrapper?', 'megamenu' ),
|
777 |
+
'settings' => array(
|
778 |
+
array(
|
779 |
+
'type' => 'container',
|
780 |
+
'key' => 'container',
|
781 |
+
'value' => $plugin_settings,
|
782 |
+
),
|
783 |
+
),
|
784 |
+
),
|
785 |
+
'active_instance' => array(
|
786 |
+
'priority' => 30,
|
787 |
+
'title' => __( 'Active Menu Instance', 'megamenu' ),
|
788 |
+
'info' => array( __( '0: Apply to all instances. 1: Apply to first instance. 2: Apply to second instance', 'megamenu' ) . '…' ),
|
789 |
+
'description' => __( 'Some themes will output this menu location multiple times on the same page. For example, it may be output once for the main menu, then again for the mobile menu. This setting can be used to make sure Max Mega Menu is only applied to one of those instances.', 'megamenu' ),
|
790 |
+
'settings' => array(
|
791 |
+
array(
|
792 |
+
'type' => 'active_instance',
|
793 |
+
'key' => 'active_instance',
|
794 |
+
'value' => $plugin_settings,
|
795 |
+
),
|
796 |
+
),
|
797 |
+
),
|
798 |
+
),
|
799 |
+
),
|
800 |
+
'output_options' => array(
|
801 |
+
'priority' => 30,
|
802 |
+
'title' => __( 'Display Options', 'megamenu' ),
|
803 |
+
'settings' => array(
|
804 |
+
'location_php_function' => array(
|
805 |
+
'priority' => 10,
|
806 |
+
'title' => __( 'PHP Function', 'megamenu' ),
|
807 |
+
'description' => __( 'For use in a theme template (usually header.php)', 'megamenu' ),
|
808 |
+
'settings' => array(
|
809 |
+
array(
|
810 |
+
'type' => 'location_php_function',
|
811 |
+
'key' => 'location_php_function',
|
812 |
+
'value' => $location,
|
813 |
+
),
|
814 |
+
),
|
815 |
+
),
|
816 |
+
'location_shortcode' => array(
|
817 |
+
'priority' => 20,
|
818 |
+
'title' => __( 'Shortcode', 'megamenu' ),
|
819 |
+
'description' => __( 'For use in a post or page.', 'megamenu' ),
|
820 |
+
'settings' => array(
|
821 |
+
array(
|
822 |
+
'type' => 'location_shortcode',
|
823 |
+
'key' => 'location_shortcode',
|
824 |
+
'value' => $location,
|
825 |
+
),
|
826 |
+
),
|
827 |
+
),
|
828 |
+
'location_widget' => array(
|
829 |
+
'priority' => 30,
|
830 |
+
'title' => __( 'Widget', 'megamenu' ),
|
831 |
+
'description' => __( 'For use in a widget area.', 'megamenu' ),
|
832 |
+
'settings' => array(
|
833 |
+
array(
|
834 |
+
'type' => 'location_widget',
|
835 |
+
'key' => 'location_widget',
|
836 |
+
'value' => $location,
|
837 |
+
),
|
838 |
+
),
|
839 |
+
),
|
840 |
+
),
|
841 |
+
),
|
842 |
+
),
|
843 |
+
$location,
|
844 |
+
$plugin_settings
|
845 |
+
);
|
846 |
+
|
847 |
+
if ( $is_custom_location ) {
|
848 |
+
|
849 |
+
$settings['general']['settings']['location_description'] = array(
|
850 |
+
'priority' => 15,
|
851 |
+
'title' => __( 'Location Description', 'megamenu' ),
|
852 |
+
'description' => __( 'Update the custom location description', 'megamenu' ),
|
853 |
+
'settings' => array(
|
854 |
+
array(
|
855 |
+
'type' => 'location_description',
|
856 |
+
'key' => 'location_description',
|
857 |
+
'value' => $description,
|
858 |
+
),
|
859 |
+
),
|
860 |
+
);
|
861 |
+
}
|
862 |
+
|
863 |
+
$initial_version = get_option( 'megamenu_initial_version' );
|
864 |
+
|
865 |
+
if ( $initial_version && version_compare( $initial_version, '2.8', '>' ) ) {
|
866 |
+
//unset( $settings['advanced']['settings']['prefix'] ); // users who started out with 2.8.1+ will not see this option.
|
867 |
+
}
|
868 |
+
|
869 |
+
echo "<div class='mega-accordion-content-wrapper'>";
|
870 |
+
|
871 |
+
echo "<h2 class='nav-tab-wrapper'>";
|
872 |
+
|
873 |
+
$is_first = true;
|
874 |
+
|
875 |
+
uasort( $settings, array( $this, 'compare_elems' ) );
|
876 |
+
|
877 |
+
foreach ( $settings as $section_id => $section ) {
|
878 |
+
|
879 |
+
if ( $is_first ) {
|
880 |
+
$active = 'nav-tab-active';
|
881 |
+
$is_first = false;
|
882 |
+
} else {
|
883 |
+
$active = '';
|
884 |
+
}
|
885 |
+
|
886 |
+
echo "<a class='mega-tab nav-tab {$active}' data-tab='mega-tab-content-{$section_id}'>" . esc_html( $section['title'] ) . '</a>';
|
887 |
+
|
888 |
+
}
|
889 |
+
|
890 |
+
echo '</h2>';
|
891 |
+
|
892 |
+
$is_first = true;
|
893 |
+
|
894 |
+
foreach ( $settings as $section_id => $section ) {
|
895 |
+
|
896 |
+
if ( $is_first ) {
|
897 |
+
$display = 'block';
|
898 |
+
$is_first = false;
|
899 |
+
} else {
|
900 |
+
$display = 'none';
|
901 |
+
}
|
902 |
+
|
903 |
+
echo "<div class='mega-tab-content mega-tab-content-{$section_id}' style='display: {$display}'>";
|
904 |
+
|
905 |
+
if ( $section_id == 'output_options' && ! $is_custom_location ) {
|
906 |
+
echo "<p class='mega-warning '><span class='dashicons dashicons-warning'></span>" . __( 'This menu location is registered by your theme. Your theme should already include the code required to display this menu location on your site.', 'megamenu' ) . '</p>';
|
907 |
+
}
|
908 |
+
|
909 |
+
echo "<table class='{$section_id}'>";
|
910 |
+
|
911 |
+
// order the fields by priority
|
912 |
+
uasort( $section['settings'], array( $this, 'compare_elems' ) );
|
913 |
+
|
914 |
+
foreach ( $section['settings'] as $group_id => $group ) {
|
915 |
+
|
916 |
+
echo "<tr class='" . esc_attr( 'mega-' . $group_id ) . "'>";
|
917 |
+
|
918 |
+
if ( isset( $group['settings'] ) ) {
|
919 |
+
|
920 |
+
echo "<td class='mega-name'>";
|
921 |
+
if ( isset( $group['icon'] ) ) {
|
922 |
+
echo "<span class='dashicons dashicons-" . esc_html( $group['icon'] ) . "'></span>";
|
923 |
+
}
|
924 |
+
echo esc_html( $group['title'] );
|
925 |
+
echo "<div class='mega-description'>" . esc_html( $group['description'] ) . '</div>';
|
926 |
+
echo '</td>';
|
927 |
+
echo "<td class='mega-value'>";
|
928 |
+
|
929 |
+
foreach ( $group['settings'] as $setting_id => $setting ) {
|
930 |
+
|
931 |
+
echo "<label class='" . esc_attr( 'mega-' . $setting['key'] ) . "'>";
|
932 |
+
|
933 |
+
if ( isset( $setting['title'] ) ) {
|
934 |
+
echo "<span class='mega-short-desc'>" . esc_html( $setting['title'] ) . '</span>';
|
935 |
+
}
|
936 |
+
|
937 |
+
switch ( $setting['type'] ) {
|
938 |
+
case 'freetext':
|
939 |
+
$this->print_location_freetext_option( $location, $setting['key'], $setting['value'] );
|
940 |
+
break;
|
941 |
+
case 'textarea':
|
942 |
+
$this->print_location_textarea_option( $location, $setting['key'] );
|
943 |
+
break;
|
944 |
+
case 'checkbox_enabled':
|
945 |
+
$this->print_location_enabled_option( $location, $setting['key'], $setting['value'] );
|
946 |
+
break;
|
947 |
+
case 'event':
|
948 |
+
$this->print_location_event_option( $location, $setting['key'], $setting['value'] );
|
949 |
+
break;
|
950 |
+
case 'effect':
|
951 |
+
$this->print_location_effect_option( $location, $setting['key'], $setting['value'] );
|
952 |
+
break;
|
953 |
+
case 'effect_speed':
|
954 |
+
$this->print_location_effect_speed_option( $location, $setting['key'], $setting['value'] );
|
955 |
+
break;
|
956 |
+
case 'effect_mobile':
|
957 |
+
$this->print_location_effect_mobile_option( $location, $setting['key'], $setting['value'] );
|
958 |
+
break;
|
959 |
+
case 'effect_speed_mobile':
|
960 |
+
$this->print_location_effect_speed_mobile_option( $location, $setting['key'], $setting['value'] );
|
961 |
+
break;
|
962 |
+
case 'theme_selector':
|
963 |
+
$this->print_location_theme_selector_option( $location, $setting['key'], $setting['value'] );
|
964 |
+
break;
|
965 |
+
case 'location_description':
|
966 |
+
$this->print_location_description_option( $location, $setting['key'], $setting['value'] );
|
967 |
+
break;
|
968 |
+
case 'checkbox':
|
969 |
+
$this->print_location_checkbox_option( $location, $setting['key'], $setting['value'] );
|
970 |
+
break;
|
971 |
+
case 'location_php_function':
|
972 |
+
$this->print_location_php_function_option( $location, $setting['value'] );
|
973 |
+
break;
|
974 |
+
case 'location_shortcode':
|
975 |
+
$this->print_location_shortcode_option( $location, $setting['value'] );
|
976 |
+
break;
|
977 |
+
case 'location_widget':
|
978 |
+
$this->print_location_widget_option( $location, $setting['key'], $setting['value'] );
|
979 |
+
break;
|
980 |
+
case 'active_instance':
|
981 |
+
$this->print_active_instance_option( $location, $setting['value'] );
|
982 |
+
break;
|
983 |
+
case 'click_behaviour':
|
984 |
+
$this->print_click_behaviour_option( $location, $setting['value'] );
|
985 |
+
break;
|
986 |
+
case 'mobile_behaviour':
|
987 |
+
$this->print_mobile_behaviour_option( $location, $setting['value'] );
|
988 |
+
break;
|
989 |
+
case 'container':
|
990 |
+
$this->print_container_option( $location, $setting['value'] );
|
991 |
+
break;
|
992 |
+
case 'descriptions':
|
993 |
+
$this->print_descriptions_option( $location, $setting['value'] );
|
994 |
+
break;
|
995 |
+
case 'unbind':
|
996 |
+
$this->print_unbind_option( $location, $setting['value'] );
|
997 |
+
break;
|
998 |
+
case 'prefix':
|
999 |
+
$this->print_prefix_option( $location, $setting['value'] );
|
1000 |
+
break;
|
1001 |
+
default:
|
1002 |
+
do_action( "megamenu_print_location_option_{$setting['type']}", $setting['key'], $this->id );
|
1003 |
+
break;
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
echo '</label>';
|
1007 |
+
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
if ( isset( $group['info'] ) ) {
|
1011 |
+
foreach ( $group['info'] as $paragraph ) {
|
1012 |
+
echo "<div class='mega-info'>{$paragraph}</div>";
|
1013 |
+
}
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
echo '</td>';
|
1017 |
+
} else {
|
1018 |
+
echo "<td colspan='2'><h5>{$group['title']}</h5></td>";
|
1019 |
+
}
|
1020 |
+
echo '</tr>';
|
1021 |
+
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
if ( $section_id == 'general' ) {
|
1025 |
+
do_action( 'megamenu_settings_table', $location, $plugin_settings );
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
echo '</table>';
|
1029 |
+
echo '</div>';
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
?>
|
1033 |
+
|
1034 |
+
</div>
|
1035 |
+
<div class='megamenu_submit'>
|
1036 |
+
<?php submit_button( $text = null ); ?>
|
1037 |
+
</div>
|
1038 |
+
</form>
|
1039 |
+
|
1040 |
+
<?php
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
|
1044 |
+
/**
|
1045 |
+
* Return a list of all registed menu locations
|
1046 |
+
*
|
1047 |
+
* @since 2.8
|
1048 |
+
* @return array
|
1049 |
+
*/
|
1050 |
+
public function get_registered_locations() {
|
1051 |
+
$all_locations = get_registered_nav_menus();
|
1052 |
+
|
1053 |
+
// PolyLang - remove auto created/translated menu locations
|
1054 |
+
if ( function_exists( 'pll_default_language' ) ) {
|
1055 |
+
$default_lang = pll_default_language( 'name' );
|
1056 |
+
|
1057 |
+
foreach ( $all_locations as $loc => $description ) {
|
1058 |
+
if ( false !== strpos( $loc, '___' ) ) {
|
1059 |
+
// Remove locations created by Polylang
|
1060 |
+
unregister_nav_menu( $loc );
|
1061 |
+
} else {
|
1062 |
+
// Remove the language name appended to the original locations
|
1063 |
+
register_nav_menu( $loc, str_replace( ' ' . $default_lang, '', $description ) );
|
1064 |
+
}
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
$all_locations = get_registered_nav_menus();
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
$locations = array();
|
1071 |
+
$custom_locations = get_option( 'megamenu_locations' );
|
1072 |
+
|
1073 |
+
if ( is_array( $custom_locations ) ) {
|
1074 |
+
$all_locations = array_merge( $custom_locations, $all_locations );
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
if ( count( $all_locations ) ) {
|
1078 |
+
$megamenu_locations = array();
|
1079 |
+
|
1080 |
+
// reorder locations so custom MMM locations are listed at the bottom
|
1081 |
+
foreach ( $all_locations as $location => $val ) {
|
1082 |
+
if ( strpos( $location, 'max_mega_menu_' ) === false ) {
|
1083 |
+
$locations[ $location ] = $val;
|
1084 |
+
} else {
|
1085 |
+
$megamenu_locations[ $location ] = $val;
|
1086 |
+
}
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
$locations = array_merge( $locations, $megamenu_locations );
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
return $locations;
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
|
1096 |
+
/**
|
1097 |
+
* Returns the menu ID for a specified menu location, defaults to 0
|
1098 |
+
*
|
1099 |
+
* @since 2.8
|
1100 |
+
* @param string $location
|
1101 |
+
*/
|
1102 |
+
private function get_menu_id_for_location( $location ) {
|
1103 |
+
$locations = get_nav_menu_locations();
|
1104 |
+
$id = isset( $locations[ $location ] ) ? $locations[ $location ] : 0;
|
1105 |
+
return $id;
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Returns the menu name for a specified menu location
|
1111 |
+
*
|
1112 |
+
* @since 2.8
|
1113 |
+
* @param string $location
|
1114 |
+
*/
|
1115 |
+
private function get_menu_name_for_location( $location ) {
|
1116 |
+
$id = $this->get_menu_id_for_location( $location );
|
1117 |
+
|
1118 |
+
$menus = wp_get_nav_menus();
|
1119 |
+
|
1120 |
+
foreach ( $menus as $menu ) {
|
1121 |
+
if ( $menu->term_id == $id ) {
|
1122 |
+
return $menu->name;
|
1123 |
+
}
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
return false;
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
|
1130 |
+
/**
|
1131 |
+
* Display messages to the user
|
1132 |
+
*
|
1133 |
+
* @since 2.0
|
1134 |
+
*/
|
1135 |
+
public function print_messages() {
|
1136 |
+
if ( isset( $_GET['location_added'] ) ) {
|
1137 |
+
?>
|
1138 |
+
<div class="notice notice-success is-dismissible">
|
1139 |
+
<p><?php _e( 'New Menu Location Created', 'megamenu' ) ?></p>
|
1140 |
+
</div>
|
1141 |
+
<?php
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
if ( isset( $_GET['delete_location'] ) ) {
|
1145 |
+
?>
|
1146 |
+
<div class="notice notice-success is-dismissible">
|
1147 |
+
<p><?php _e( 'Menu Location Deleted', 'megamenu' ) ?></p>
|
1148 |
+
</div>
|
1149 |
+
<?php
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
if ( isset( $_GET['save_location'] ) ) {
|
1153 |
+
?>
|
1154 |
+
<div class="notice notice-success is-dismissible">
|
1155 |
+
<p><?php _e( 'Menu Location Saved', 'megamenu' ) ?></p>
|
1156 |
+
</div>
|
1157 |
+
<?php
|
1158 |
+
}
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* Print a checkbox option for enabling/disabling MMM for a specific location
|
1164 |
+
*
|
1165 |
+
* @since 2.8
|
1166 |
+
* @param string $key
|
1167 |
+
* @param string $value
|
1168 |
+
*/
|
1169 |
+
public function print_location_enabled_option( $location, $key, $value ) {
|
1170 |
+
?>
|
1171 |
+
<input type='checkbox' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]' <?php checked( $value, '1' ); ?> />
|
1172 |
+
<?php
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
|
1176 |
+
/**
|
1177 |
+
* Print a generic checkbox option
|
1178 |
+
*
|
1179 |
+
* @since 2.8
|
1180 |
+
* @param string $key
|
1181 |
+
* @param string $value
|
1182 |
+
*/
|
1183 |
+
public function print_location_checkbox_option( $location, $key, $value ) {
|
1184 |
+
?>
|
1185 |
+
<input type='checkbox' value='true' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]' <?php checked( $value, 'true' ); ?> />
|
1186 |
+
<?php
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
|
1190 |
+
/**
|
1191 |
+
* Print the active instance option
|
1192 |
+
*
|
1193 |
+
* @since 2.8
|
1194 |
+
* @param string $key
|
1195 |
+
* @param string $value
|
1196 |
+
*/
|
1197 |
+
public function print_active_instance_option( $location, $plugin_settings ) {
|
1198 |
+
$active_instance = 0;
|
1199 |
+
|
1200 |
+
if ( isset( $plugin_settings[ $location ]['active_instance'] ) ) {
|
1201 |
+
$active_instance = $plugin_settings[ $location ]['active_instance'];
|
1202 |
+
} elseif ( isset( $plugin_settings['instances'][ $location ] ) ) {
|
1203 |
+
$active_instance = $plugin_settings['instances'][ $location ];
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
?>
|
1207 |
+
<input type='text' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][active_instance]' value='<?php echo esc_attr( $active_instance ); ?>' />
|
1208 |
+
<?php
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
/**
|
1212 |
+
* Print the click behaviour option
|
1213 |
+
*
|
1214 |
+
* @since 2.8
|
1215 |
+
* @param string $key
|
1216 |
+
* @param string $value
|
1217 |
+
*/
|
1218 |
+
public function print_click_behaviour_option( $location, $plugin_settings ) {
|
1219 |
+
$second_click = 'go';
|
1220 |
+
|
1221 |
+
if ( isset( $plugin_settings[ $location ]['second_click'] ) ) {
|
1222 |
+
$second_click = $plugin_settings[ $location ]['second_click'];
|
1223 |
+
} elseif ( isset( $plugin_settings['second_click'] ) ) {
|
1224 |
+
$second_click = $plugin_settings['second_click'];
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
?>
|
1228 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][second_click]'>
|
1229 |
+
<option value='close' <?php echo selected( $second_click == 'close' ); ?>><?php _e( 'First click will open a sub menu, second click will close the sub menu.', 'megamenu' ); ?></option>
|
1230 |
+
<option value='go' <?php echo selected( $second_click == 'go' ); ?>><?php _e( 'First click will open a sub menu, second click will follow the link.', 'megamenu' ); ?></option>
|
1231 |
+
<select>
|
1232 |
+
<?php
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Print the mobile menu behaviour option
|
1238 |
+
*
|
1239 |
+
* @since 2.8
|
1240 |
+
* @param string $key
|
1241 |
+
* @param string $value
|
1242 |
+
*/
|
1243 |
+
public function print_mobile_behaviour_option( $location, $plugin_settings ) {
|
1244 |
+
$mobile_behaviour = 'standard';
|
1245 |
+
|
1246 |
+
if ( isset( $plugin_settings[ $location ]['mobile_behaviour'] ) ) {
|
1247 |
+
$mobile_behaviour = $plugin_settings[ $location ]['mobile_behaviour'];
|
1248 |
+
} elseif ( isset( $plugin_settings['mobile_behaviour'] ) ) {
|
1249 |
+
$mobile_behaviour = $plugin_settings['mobile_behaviour'];
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
?>
|
1253 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][mobile_behaviour]'>
|
1254 |
+
<option value='standard' <?php echo selected( $mobile_behaviour == 'standard' ); ?>><?php _e( 'Standard - Open sub menus will remain open until closed by the user.', 'megamenu' ); ?></option>
|
1255 |
+
<option value='accordion' <?php echo selected( $mobile_behaviour == 'accordion' ); ?>><?php _e( 'Accordion - Open sub menus will automatically close when another one is opened.', 'megamenu' ); ?></option>
|
1256 |
+
<select>
|
1257 |
+
<?php
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
|
1261 |
+
/**
|
1262 |
+
* Print the container option select box
|
1263 |
+
*
|
1264 |
+
* @since 2.9
|
1265 |
+
* @param string $key
|
1266 |
+
* @param string $value
|
1267 |
+
*/
|
1268 |
+
public function print_container_option( $location, $plugin_settings ) {
|
1269 |
+
$container = 'div';
|
1270 |
+
|
1271 |
+
if ( isset( $plugin_settings[ $location ]['container'] ) ) {
|
1272 |
+
$container = $plugin_settings[ $location ]['container'];
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
?>
|
1276 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][container]'>
|
1277 |
+
<option value='div' <?php echo selected( $container == 'div' ); ?>><div></option>
|
1278 |
+
<option value='nav' <?php echo selected( $container == 'nav' ); ?>><nav></option>
|
1279 |
+
<select>
|
1280 |
+
<?php
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* Print the checkbox option for enabling menu item descriptions
|
1286 |
+
*
|
1287 |
+
* @since 2.8
|
1288 |
+
* @param string $key
|
1289 |
+
* @param string $value
|
1290 |
+
*/
|
1291 |
+
public function print_descriptions_option( $location, $plugin_settings ) {
|
1292 |
+
$descriptions = 'disabled';
|
1293 |
+
|
1294 |
+
if ( isset( $plugin_settings[ $location ]['descriptions'] ) ) {
|
1295 |
+
$descriptions = $plugin_settings[ $location ]['descriptions'];
|
1296 |
+
} elseif ( isset( $plugin_settings['descriptions'] ) ) {
|
1297 |
+
$descriptions = $plugin_settings['descriptions'];
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
?>
|
1301 |
+
|
1302 |
+
<input type='checkbox' value='enabled' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][descriptions]' <?php checked( $descriptions, 'enabled' ); ?> />
|
1303 |
+
|
1304 |
+
<?php
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
|
1308 |
+
/**
|
1309 |
+
* Print the checkbox option for prefixing menu items with 'mega-'
|
1310 |
+
*
|
1311 |
+
* @since 2.8
|
1312 |
+
* @param string $key
|
1313 |
+
* @param string $value
|
1314 |
+
*/
|
1315 |
+
public function print_prefix_option( $location, $plugin_settings ) {
|
1316 |
+
$prefix = 'disabled';
|
1317 |
+
|
1318 |
+
if ( isset( $plugin_settings[ $location ]['prefix'] ) ) {
|
1319 |
+
$prefix = $plugin_settings[ $location ]['prefix'];
|
1320 |
+
} elseif ( isset( $plugin_settings['prefix'] ) ) {
|
1321 |
+
$prefix = $plugin_settings['prefix'];
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
?>
|
1325 |
+
|
1326 |
+
<input type='checkbox' value='enabled' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][prefix]' <?php checked( $prefix, 'enabled' ); ?> />
|
1327 |
+
|
1328 |
+
<?php
|
1329 |
+
}
|
1330 |
+
|
1331 |
+
|
1332 |
+
/**
|
1333 |
+
* Print the checkbox option for the Unbind JavaScript Events option
|
1334 |
+
*
|
1335 |
+
* @since 2.8
|
1336 |
+
* @param string $key
|
1337 |
+
* @param string $value
|
1338 |
+
*/
|
1339 |
+
public function print_unbind_option( $location, $plugin_settings ) {
|
1340 |
+
|
1341 |
+
$unbind = 'enabled';
|
1342 |
+
|
1343 |
+
if ( isset( $plugin_settings[ $location ]['unbind'] ) ) {
|
1344 |
+
$unbind = $plugin_settings[ $location ]['unbind'];
|
1345 |
+
} elseif ( isset( $plugin_settings['unbind'] ) ) {
|
1346 |
+
$unbind = $plugin_settings['unbind'];
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
?>
|
1350 |
+
|
1351 |
+
<input type='checkbox' value='enabled' name='megamenu_meta[<?php echo esc_attr( $location ); ?>][unbind]' <?php checked( $unbind, 'enabled' ); ?> />
|
1352 |
+
|
1353 |
+
<?php
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
|
1357 |
+
/**
|
1358 |
+
* Print a select box containing all available sub menu trigger events
|
1359 |
+
*
|
1360 |
+
* @since 2.8
|
1361 |
+
* @param string $key
|
1362 |
+
* @param string $value
|
1363 |
+
*/
|
1364 |
+
public function print_location_event_option( $location, $key, $value ) {
|
1365 |
+
|
1366 |
+
$options = apply_filters(
|
1367 |
+
'megamenu_event_options',
|
1368 |
+
array(
|
1369 |
+
'hover' => __( 'Hover Intent', 'megamenu' ),
|
1370 |
+
'hover_' => __( 'Hover', 'megamenu' ),
|
1371 |
+
'click' => __( 'Click', 'megamenu' ),
|
1372 |
+
)
|
1373 |
+
);
|
1374 |
+
|
1375 |
+
?>
|
1376 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1377 |
+
<?php
|
1378 |
+
|
1379 |
+
foreach ( $options as $type => $name ) {
|
1380 |
+
echo "<option value='" . esc_attr( $type ) . "' " . selected( $value, $type, false ) . '>' . esc_html( $name ) . '</option>';
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
echo '</select>';
|
1384 |
+
|
1385 |
+
}
|
1386 |
+
|
1387 |
+
/**
|
1388 |
+
* Print a select box containing all available sub menu animation options
|
1389 |
+
*
|
1390 |
+
* @since 2.8
|
1391 |
+
* @param string $key
|
1392 |
+
* @param string $value
|
1393 |
+
*/
|
1394 |
+
public function print_location_effect_option( $location, $key, $value ) {
|
1395 |
+
?>
|
1396 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1397 |
+
<?php
|
1398 |
+
|
1399 |
+
$selected = strlen( $value ) ? $value : 'fade_up';
|
1400 |
+
|
1401 |
+
$options = apply_filters(
|
1402 |
+
'megamenu_transition_effects',
|
1403 |
+
array(
|
1404 |
+
'disabled' => array(
|
1405 |
+
'label' => __( 'None', 'megamenu' ),
|
1406 |
+
'selected' => $selected == 'disabled',
|
1407 |
+
),
|
1408 |
+
'fade' => array(
|
1409 |
+
'label' => __( 'Fade', 'megamenu' ),
|
1410 |
+
'selected' => $selected == 'fade',
|
1411 |
+
),
|
1412 |
+
'fade_up' => array(
|
1413 |
+
'label' => __( 'Fade Up', 'megamenu' ),
|
1414 |
+
'selected' => $selected == 'fade_up' || $selected == 'fadeUp',
|
1415 |
+
),
|
1416 |
+
'slide' => array(
|
1417 |
+
'label' => __( 'Slide', 'megamenu' ),
|
1418 |
+
'selected' => $selected == 'slide',
|
1419 |
+
),
|
1420 |
+
'slide_up' => array(
|
1421 |
+
'label' => __( 'Slide Up', 'megamenu' ),
|
1422 |
+
'selected' => $selected == 'slide_up',
|
1423 |
+
),
|
1424 |
+
),
|
1425 |
+
$selected
|
1426 |
+
);
|
1427 |
+
|
1428 |
+
foreach ( $options as $key => $value ) {
|
1429 |
+
echo "<option value='" . esc_attr( $key ) . "' " . selected( $value['selected'] ) . '>' . esc_html( $value['label'] ) . '</option>';
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
echo '</select>';
|
1433 |
+
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
|
1437 |
+
/**
|
1438 |
+
* Print a select box containing all available effect speeds (desktop)
|
1439 |
+
*
|
1440 |
+
* @since 2.8
|
1441 |
+
* @param string $key
|
1442 |
+
* @param string $value
|
1443 |
+
*/
|
1444 |
+
public function print_location_effect_speed_option( $location, $key, $value ) {
|
1445 |
+
?>
|
1446 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1447 |
+
<?php
|
1448 |
+
|
1449 |
+
$selected = strlen( $value ) ? $value : '200';
|
1450 |
+
|
1451 |
+
$options = apply_filters(
|
1452 |
+
'megamenu_effect_speed',
|
1453 |
+
array(
|
1454 |
+
'600' => __( 'Slow', 'megamenu' ),
|
1455 |
+
'400' => __( 'Med', 'megamenu' ),
|
1456 |
+
'200' => __( 'Fast', 'megamenu' ),
|
1457 |
+
),
|
1458 |
+
$selected
|
1459 |
+
);
|
1460 |
+
|
1461 |
+
ksort( $options );
|
1462 |
+
|
1463 |
+
foreach ( $options as $key => $value ) {
|
1464 |
+
echo "<option value='" . esc_attr( $key ) . "' " . selected( $selected, $key ) . '>' . esc_html( $value ) . '</option>';
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
echo '</select>';
|
1468 |
+
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
|
1472 |
+
/**
|
1473 |
+
* Print the textbox containing the various mobile menu options
|
1474 |
+
*
|
1475 |
+
* @since 2.8
|
1476 |
+
* @param string $key
|
1477 |
+
* @param string $value
|
1478 |
+
*/
|
1479 |
+
public function print_location_effect_mobile_option( $location, $key, $value ) {
|
1480 |
+
?>
|
1481 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1482 |
+
<?php
|
1483 |
+
|
1484 |
+
$selected = strlen( $value ) ? $value : 'disabled';
|
1485 |
+
|
1486 |
+
$options = apply_filters(
|
1487 |
+
'megamenu_transition_effects_mobile',
|
1488 |
+
array(
|
1489 |
+
'disabled' => array(
|
1490 |
+
'label' => __( 'None', 'megamenu' ),
|
1491 |
+
'selected' => $selected == 'disabled',
|
1492 |
+
),
|
1493 |
+
'slide' => array(
|
1494 |
+
'label' => __( 'Slide Down', 'megamenu' ),
|
1495 |
+
'selected' => $selected == 'slide',
|
1496 |
+
),
|
1497 |
+
'slide_left' => array(
|
1498 |
+
'label' => __( 'Slide Left (Off Canvas)', 'megamenu' ),
|
1499 |
+
'selected' => $selected == 'slide_left',
|
1500 |
+
),
|
1501 |
+
'slide_right' => array(
|
1502 |
+
'label' => __( 'Slide Right (Off Canvas)', 'megamenu' ),
|
1503 |
+
'selected' => $selected == 'slide_right',
|
1504 |
+
),
|
1505 |
+
),
|
1506 |
+
$selected
|
1507 |
+
);
|
1508 |
+
|
1509 |
+
foreach ( $options as $key => $value ) {
|
1510 |
+
echo "<option value='" . esc_attr( $key ) . "' " . selected( $value['selected'] ) . '>' . esc_html( $value['label'] ) . '</option>';
|
1511 |
+
}
|
1512 |
+
|
1513 |
+
echo '</select>';
|
1514 |
+
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
|
1518 |
+
/**
|
1519 |
+
* Print a select box containing all available effect speeds (mobile)
|
1520 |
+
*
|
1521 |
+
* @since 2.8
|
1522 |
+
* @param string $key
|
1523 |
+
* @param string $value
|
1524 |
+
*/
|
1525 |
+
public function print_location_effect_speed_mobile_option( $location, $key, $value ) {
|
1526 |
+
?>
|
1527 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1528 |
+
<?php
|
1529 |
+
|
1530 |
+
$selected = strlen( $value ) ? $value : '200';
|
1531 |
+
|
1532 |
+
$options = apply_filters(
|
1533 |
+
'megamenu_effect_speed_mobile',
|
1534 |
+
array(
|
1535 |
+
'600' => __( 'Slow', 'megamenu' ),
|
1536 |
+
'400' => __( 'Med', 'megamenu' ),
|
1537 |
+
'200' => __( 'Fast', 'megamenu' ),
|
1538 |
+
),
|
1539 |
+
$selected
|
1540 |
+
);
|
1541 |
+
|
1542 |
+
ksort( $options );
|
1543 |
+
|
1544 |
+
foreach ( $options as $key => $value ) {
|
1545 |
+
echo "<option value='" . esc_attr( $key ) . "' " . selected( $selected, $key ) . '>' . esc_html( $value ) . '</option>';
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
echo '</select>';
|
1549 |
+
|
1550 |
+
}
|
1551 |
+
|
1552 |
+
|
1553 |
+
/**
|
1554 |
+
* Print a select box containing all available menu themes
|
1555 |
+
*
|
1556 |
+
* @since 2.8
|
1557 |
+
* @param string $key
|
1558 |
+
* @param string $value
|
1559 |
+
*/
|
1560 |
+
public function print_location_theme_selector_option( $location, $key, $value ) {
|
1561 |
+
?>
|
1562 |
+
<select name='megamenu_meta[<?php echo esc_attr( $location ); ?>][<?php echo esc_attr( $key ); ?>]'>
|
1563 |
+
<?php
|
1564 |
+
|
1565 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
1566 |
+
$themes = $style_manager->get_themes();
|
1567 |
+
$selected_theme = strlen( $value ) ? $value : 'default';
|
1568 |
+
|
1569 |
+
foreach ( $themes as $key => $theme ) {
|
1570 |
+
$edit_theme_url = esc_url(
|
1571 |
+
add_query_arg(
|
1572 |
+
array(
|
1573 |
+
'page' => 'maxmegamenu_theme_editor',
|
1574 |
+
'theme' => $key,
|
1575 |
+
),
|
1576 |
+
admin_url( 'admin.php' )
|
1577 |
+
)
|
1578 |
+
);
|
1579 |
+
|
1580 |
+
echo "<option data-url='" . esc_attr($edit_theme_url) . "' value='" . esc_attr( $key ) . "' " . selected( $selected_theme, $key ) . '>' . esc_html( $theme['title'] ) . '</option>';
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
echo '</select>';
|
1584 |
+
echo "<span class='dashicons dashicons-edit megamenu-edit-theme'>";
|
1585 |
+
|
1586 |
+
}
|
1587 |
+
|
1588 |
+
|
1589 |
+
/**
|
1590 |
+
* Print the textbox containing the sample PHP code to output a menu location
|
1591 |
+
*
|
1592 |
+
* @since 2.8
|
1593 |
+
* @param string $key
|
1594 |
+
* @param string $value
|
1595 |
+
*/
|
1596 |
+
public function print_location_php_function_option( $location, $value ) {
|
1597 |
+
?>
|
1598 |
+
<textarea readonly="readonly"><?php wp_nav_menu( array( 'theme_location' => '<?php echo esc_attr( $value ); ?>' ) ); ?></textarea>
|
1599 |
+
<?php
|
1600 |
+
}
|
1601 |
+
|
1602 |
+
|
1603 |
+
/**
|
1604 |
+
* Print the textbox containing the sample shortcode to output a menu location
|
1605 |
+
*
|
1606 |
+
* @since 2.8
|
1607 |
+
* @param string $key
|
1608 |
+
* @param string $value
|
1609 |
+
*/
|
1610 |
+
public function print_location_shortcode_option( $location, $value ) {
|
1611 |
+
?>
|
1612 |
+
<textarea readonly="readonly">[maxmegamenu location=<?php echo esc_attr( $value ); ?>]</textarea>
|
1613 |
+
<?php
|
1614 |
+
}
|
1615 |
+
|
1616 |
+
|
1617 |
+
/**
|
1618 |
+
* Print the textbox containing instructions on how to display this menu location using a widget
|
1619 |
+
*
|
1620 |
+
* @since 2.8
|
1621 |
+
* @param string $key
|
1622 |
+
* @param string $value
|
1623 |
+
*/
|
1624 |
+
public function print_location_widget_option( $location, $value ) {
|
1625 |
+
?>
|
1626 |
+
<textarea readonly="readonly"><?php _e( "Add the 'Max Mega Menu' widget to a widget area.", 'megamenu' ); ?></textarea>
|
1627 |
+
<?php
|
1628 |
+
}
|
1629 |
+
|
1630 |
+
|
1631 |
+
/**
|
1632 |
+
* Print a standard text input box
|
1633 |
+
*
|
1634 |
+
* @since 2.8
|
1635 |
+
* @param string $key
|
1636 |
+
* @param string $value
|
1637 |
+
*/
|
1638 |
+
public function print_location_freetext_option( $location, $key, $value ) {
|
1639 |
+
echo "<input class='" . esc_attr( 'mega-setting-' . $key ) . "' type='text' name='megamenu_meta[$location][$key]' value='" . esc_attr( $value ) . "' />";
|
1640 |
+
}
|
1641 |
+
|
1642 |
+
|
1643 |
+
/**
|
1644 |
+
* Print a text input box allowing the user to change the name of a custom menu location
|
1645 |
+
*
|
1646 |
+
* @since 2.8
|
1647 |
+
* @param string $key
|
1648 |
+
* @param string $value
|
1649 |
+
*/
|
1650 |
+
public function print_location_description_option( $location, $key, $value ) {
|
1651 |
+
echo "<input class='" . esc_attr( 'mega-setting-' . $key ) . " wide' type='text' name='custom_location[$location]' value='" . esc_attr( $value ) . "' />";
|
1652 |
+
}
|
1653 |
+
|
1654 |
+
|
1655 |
+
/**
|
1656 |
+
* Compare array values
|
1657 |
+
*
|
1658 |
+
* @since 2.8
|
1659 |
+
* @param array $elem1
|
1660 |
+
* @param array $elem2
|
1661 |
+
* @return bool
|
1662 |
+
*/
|
1663 |
+
private function compare_elems( $elem1, $elem2 ) {
|
1664 |
+
return $elem1['priority'] > $elem2['priority'];
|
1665 |
+
}
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
endif;
|
classes/pages/page.php
CHANGED
@@ -1,280 +1,289 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Page' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_Page {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
* @since 1.8.3
|
234 |
-
*/
|
235 |
-
public function enqueue_scripts() {
|
236 |
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
-
|
241 |
-
wp_enqueue_style( 'mega-menu-settings', MEGAMENU_BASE_URL . 'css/admin/admin.css', false, MEGAMENU_VERSION );
|
242 |
-
wp_enqueue_style( 'select2', MEGAMENU_BASE_URL . 'js/select2/select2.css', false, MEGAMENU_VERSION );
|
243 |
-
|
244 |
-
wp_enqueue_script( 'spectrum', MEGAMENU_BASE_URL . 'js/spectrum/spectrum.js', array( 'jquery' ), MEGAMENU_VERSION );
|
245 |
-
|
246 |
-
wp_localize_script( 'spectrum', 'megamenu_spectrum_settings',
|
247 |
-
apply_filters("megamenu_spectrum_localisation", array())
|
248 |
-
);
|
249 |
-
|
250 |
-
wp_enqueue_script( 'mega-menu-select2', MEGAMENU_BASE_URL . 'js/select2/select2.min.js', array(), MEGAMENU_VERSION );
|
251 |
-
|
252 |
-
wp_enqueue_script( 'mega-menu-theme-editor', MEGAMENU_BASE_URL . 'js/settings.js', array( 'jquery', 'spectrum', 'code-editor' ), MEGAMENU_VERSION );
|
253 |
-
|
254 |
-
wp_localize_script( 'mega-menu-theme-editor', 'megamenu_settings',
|
255 |
-
array(
|
256 |
-
'saving' => __("Saving", "megamenu"),
|
257 |
-
'confirm' => __("Are you sure?", "megamenu"),
|
258 |
-
"theme_save_error" => __("Error saving theme.", "megamenu"),
|
259 |
-
"theme_save_error_refresh" => __("Please try refreshing the page.", "megamenu"),
|
260 |
-
"theme_save_error_exhausted" => __("The server ran out of memory whilst trying to regenerate the menu CSS.", "megamenu"),
|
261 |
-
"theme_save_error_memory_limit" => __("Try disabling unusued plugins to increase the available memory. Alternatively, for details on how to increase your server memory limit see:", "megamenu"),
|
262 |
-
"theme_save_error_500" => __("The server returned a 500 error. The server did not provide an error message (you should find details of the error in your server error log), but this is usually due to your server memory limit being reached.", "megamenu"),
|
263 |
-
"increase_memory_limit_url" => "http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/",
|
264 |
-
"increase_memory_limit_anchor_text" => "How to increase the WordPress memory limit"
|
265 |
-
)
|
266 |
-
);
|
267 |
-
|
268 |
-
if ( function_exists('wp_enqueue_code_editor') ) {
|
269 |
-
wp_deregister_style('codemirror');
|
270 |
-
wp_deregister_script('codemirror');
|
271 |
-
|
272 |
-
$cm_settings['codeEditor'] = wp_enqueue_code_editor(array('type' => 'text/x-scss'));
|
273 |
-
wp_localize_script('mega-menu-theme-editor', 'cm_settings', $cm_settings);
|
274 |
-
wp_enqueue_style('wp-codemirror');
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Page' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Handles all admin related functionality.
|
11 |
+
*/
|
12 |
+
class Mega_Menu_Page {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
+
*
|
17 |
+
* @since 1.0
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
add_action( 'admin_menu', array( $this, 'megamenu_settings_page' ) );
|
21 |
+
add_action( 'megamenu_admin_scripts', array( $this, 'enqueue_scripts' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Adds the "Menu Themes" menu item and page.
|
27 |
+
*
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
public function megamenu_settings_page() {
|
31 |
+
|
32 |
+
$svg = 'PHN2ZyB2ZXJzaW9uPSIxLjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEyNy4wMDAwMDBwdCIgaGVpZ2h0PSIxMjcuMDAwMDAwcHQiIHZpZXdCb3g9IjAgMCAxMjcuMDAwMDAwIDEyNy4wMDAwMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIG1lZXQiPgogICAgICAgICAgICAgICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAuMDAwMDAwLDEyNy4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiIGZpbGw9IiMwMDAwMDAiIHN0cm9rZT0ibm9uZSI+CiAgICAgICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0zMzAgMTEyNyBsLTI0NSAtMTQzIC03IC0xODAgYy01IC05OCAtNyAtMjUzIC01IC0zNDQgbDIgLTE2NSAxMzAKICAgICAgICAgICAgICAgICAgICAgICAgLTc2IGMyOTUgLTE3MyAzNDUgLTIwNCAzNDUgLTIxMSAwIC00IDI0IC04IDU0IC04IDQ4IDAgNjUgNyAxNjcgNjYgMjIzIDEyOQogICAgICAgICAgICAgICAgICAgICAgICAzNzYgMjI0IDM5MCAyNDAgMTggMjEgMjYgNTkzIDEwIDYzNyAtMTIgMzAgLTczIDcyIC0yNzYgMTkwIC03MSA0MiAtMTUyIDkwCiAgICAgICAgICAgICAgICAgICAgICAgIC0xNzkgMTA2IC0zNiAyMyAtNjAgMzEgLTk1IDMxIC00MSAwIC03MiAtMTYgLTI5MSAtMTQzeiBtNDEwIC03NyBjMTMxIC03NgogICAgICAgICAgICAgICAgICAgICAgICAxNDEgLTg1IDExNSAtMTA1IC00MyAtMzEgLTIyMSAtMTI1IC0yMzkgLTEyNSAtMjEgMCAtMjE3IDExMiAtMjM1IDEzNCAtOCAxMAogICAgICAgICAgICAgICAgICAgICAgICAtNiAxNyA3IDI4IDM3IDMyIDIwNyAxMjggMjI2IDEyOCAxMiAwIDY4IC0yNyAxMjYgLTYweiBtLTM2MSAtMjc5IGM4OCAtNTAKICAgICAgICAgICAgICAgICAgICAgICAgMTgxIC05OSAyMDcgLTExMCBsNDcgLTIxIDEyMSA2OSBjMTY4IDk2IDI1NSAxNDEgMjcyIDE0MSAxMiAwIDE0IC0zOCAxNCAtMjI4CiAgICAgICAgICAgICAgICAgICAgICAgIGwwIC0yMjggLTc3IC00NyAtNzggLTQ3IC03IDE0NiBjLTMgODAgLTggMTQ3IC0xMCAxNDkgLTIgMiAtNTMgLTI1IC0xMTMgLTYwCiAgICAgICAgICAgICAgICAgICAgICAgIC02MSAtMzUgLTExOSAtNjQgLTEyOSAtNjUgLTExIDAgLTcwIDI3IC0xMzIgNjAgLTYyIDMzIC0xMTUgNjAgLTExNyA2MCAtMyAwCiAgICAgICAgICAgICAgICAgICAgICAgIC04IC02MyAtMTIgLTE0MCAtNCAtNzcgLTExIC0xNDAgLTE2IC0xNDAgLTQgMCAtMzkgMTkgLTc4IDQyIGwtNzAgNDIgLTMgMTI2CiAgICAgICAgICAgICAgICAgICAgICAgIGMtNCAxODIgMSAzNDAgMTIgMzQwIDUgMCA4MSAtNDAgMTY5IC04OXogbTE5NSAtNDU4IGw1NSAtMjcgNDEgMjggYzIzIDE1IDQ4CiAgICAgICAgICAgICAgICAgICAgICAgIDI1IDU2IDIyIDE1IC02IDIwIC03OSA4IC0xMTEgLTcgLTE4IC05NCAtNjUgLTEyMSAtNjUgLTIyIDAgLTgzIDM1IC0xMDAgNTgKICAgICAgICAgICAgICAgICAgICAgICAgLTE4IDIyIC0xNSAxMjIgMyAxMjIgMiAwIDI4IC0xMiA1OCAtMjd6Ii8+CiAgICAgICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICAgICAgPC9zdmc+';
|
33 |
+
|
34 |
+
$icon = 'data:image/svg+xml;base64,' . $svg;
|
35 |
+
|
36 |
+
$capability = apply_filters( 'megamenu_options_capability', 'edit_theme_options' );
|
37 |
+
|
38 |
+
$page = add_menu_page( __( 'Max Mega Menu', 'megamenu' ), __( 'Mega Menu', 'megamenu' ), $capability, 'maxmegamenu', array( $this, 'page' ), $icon );
|
39 |
+
|
40 |
+
$tabs = apply_filters( 'megamenu_menu_tabs', array() );
|
41 |
+
|
42 |
+
foreach ( $tabs as $key => $title ) {
|
43 |
+
if ( $key == 'menu_locations' ) {
|
44 |
+
add_submenu_page( 'maxmegamenu', __( 'Max Mega Menu', 'megamenu' ) . ' - ' . $title, $title, $capability, 'maxmegamenu', array( $this, 'page' ) );
|
45 |
+
} else {
|
46 |
+
add_submenu_page( 'maxmegamenu', __( 'Max Mega Menu', 'megamenu' ) . ' - ' . $title, $title, $capability, 'maxmegamenu_' . $key, array( $this, 'page' ) );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Main settings page wrapper.
|
56 |
+
*
|
57 |
+
* @since 1.4
|
58 |
+
*/
|
59 |
+
public function page() {
|
60 |
+
|
61 |
+
$tab = isset( $_GET['page'] ) ? substr( $_GET['page'], 12 ) : false;
|
62 |
+
|
63 |
+
// backwards compatibility
|
64 |
+
if ( isset( $_GET['tab'] ) ) {
|
65 |
+
$tab = $_GET['tab'];
|
66 |
+
}
|
67 |
+
|
68 |
+
if ( ! $tab ) {
|
69 |
+
$tab = 'menu_locations';
|
70 |
+
}
|
71 |
+
|
72 |
+
$header_links = apply_filters(
|
73 |
+
'megamenu_header_links',
|
74 |
+
array(
|
75 |
+
'homepage' => array(
|
76 |
+
'url' => 'https://www.megamenu.com/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
77 |
+
'target' => '_mmmpro',
|
78 |
+
'text' => __( 'Homepage', 'megamenu' ),
|
79 |
+
'class' => '',
|
80 |
+
),
|
81 |
+
'documentation' => array(
|
82 |
+
'url' => 'https://www.megamenu.com/documentation/installation/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
83 |
+
'text' => __( 'Documentation', 'megamenu' ),
|
84 |
+
'target' => '_mmmpro',
|
85 |
+
'class' => '',
|
86 |
+
),
|
87 |
+
'troubleshooting' => array(
|
88 |
+
'url' => 'https://www.megamenu.com/articles/troubleshooting/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
89 |
+
'text' => __( 'Troubleshooting', 'megamenu' ),
|
90 |
+
'target' => '_mmmpro',
|
91 |
+
'class' => '',
|
92 |
+
),
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
if ( ! is_plugin_active( 'megamenu-pro/megamenu-pro.php' ) ) {
|
97 |
+
$header_links['pro'] = array(
|
98 |
+
'url' => 'https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=settings&utm_campaign=pro',
|
99 |
+
'target' => '_mmmpro',
|
100 |
+
'text' => __( 'Upgrade to Pro', 'megamenu' ),
|
101 |
+
'class' => 'mega-highlight',
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
$versions = apply_filters(
|
106 |
+
'megamenu_versions',
|
107 |
+
array(
|
108 |
+
'core' => array(
|
109 |
+
'version' => MEGAMENU_VERSION,
|
110 |
+
'text' => __( 'Core version', 'megamenu' ),
|
111 |
+
),
|
112 |
+
'pro' => array(
|
113 |
+
'version' => "<a href='https://www.megamenu.com/upgrade/?utm_source=free&utm_medium=settings&utm_campaign=pro' target='_mmmpro'>not installed</a>",
|
114 |
+
'text' => __( 'Pro extension', 'megamenu' ),
|
115 |
+
),
|
116 |
+
)
|
117 |
+
);
|
118 |
+
|
119 |
+
?>
|
120 |
+
|
121 |
+
<div class='megamenu_outer_wrap'>
|
122 |
+
<div class='megamenu_header_top'>
|
123 |
+
<ul>
|
124 |
+
<?php
|
125 |
+
foreach ( $header_links as $id => $data ) {
|
126 |
+
echo "<li class='{$data['class']}'><a href='{$data['url']}' target='{$data['target']}'>{$data['text']}";
|
127 |
+
echo '</a>';
|
128 |
+
echo '</li>';
|
129 |
+
}
|
130 |
+
?>
|
131 |
+
</ul>
|
132 |
+
</div>
|
133 |
+
<div class='megamenu_header'>
|
134 |
+
<div class='megamenu_header_left'>
|
135 |
+
<h2><?php _e( 'Max Mega Menu', 'megamenu' ); ?></h2>
|
136 |
+
<div class='version'>
|
137 |
+
<?php
|
138 |
+
|
139 |
+
$total = count( $versions );
|
140 |
+
$count = 0;
|
141 |
+
$separator = ' - ';
|
142 |
+
|
143 |
+
foreach ( $versions as $id => $data ) {
|
144 |
+
echo $data['text'] . ': <b>' . $data['version'] . '</b>';
|
145 |
+
|
146 |
+
$count = $count + 1;
|
147 |
+
|
148 |
+
if ( $total > 0 && $count != $total ) {
|
149 |
+
echo $separator;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
?>
|
153 |
+
</div>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
|
157 |
+
<div class='megamenu_wrap'>
|
158 |
+
<div class='megamenu_left'>
|
159 |
+
<ul class='mega-page-navigation'>
|
160 |
+
<?php
|
161 |
+
$tabs = apply_filters( 'megamenu_menu_tabs', array() );
|
162 |
+
|
163 |
+
foreach ( $tabs as $key => $title ) {
|
164 |
+
$class = $tab == $key ? 'active' : '';
|
165 |
+
|
166 |
+
if ( $key == 'menu_locations' ) {
|
167 |
+
$args = array( 'page' => 'maxmegamenu' );
|
168 |
+
} else {
|
169 |
+
$args = array( 'page' => 'maxmegamenu_' . $key );
|
170 |
+
}
|
171 |
+
|
172 |
+
$url = esc_url( add_query_arg( $args, admin_url( 'admin.php' ) ) );
|
173 |
+
|
174 |
+
echo "<li class='{$key}'><a class='{$class}' href='{$url}'>{$title}</a></li>";
|
175 |
+
}
|
176 |
+
?>
|
177 |
+
</ul>
|
178 |
+
</div>
|
179 |
+
<div class='megamenu_right'>
|
180 |
+
<?php $this->print_messages(); ?>
|
181 |
+
|
182 |
+
<?php
|
183 |
+
|
184 |
+
$saved_settings = get_option( 'megamenu_settings' );
|
185 |
+
|
186 |
+
if ( has_action( "megamenu_page_{$tab}" ) ) {
|
187 |
+
do_action( "megamenu_page_{$tab}", $saved_settings );
|
188 |
+
} else {
|
189 |
+
do_action( 'megamenu_page_menu_locations', $saved_settings );
|
190 |
+
}
|
191 |
+
|
192 |
+
?>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
+
</div>
|
199 |
+
|
200 |
+
<?php
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Redirect and exit
|
206 |
+
*
|
207 |
+
* @since 1.8
|
208 |
+
*/
|
209 |
+
public function redirect( $url ) {
|
210 |
+
wp_redirect( $url );
|
211 |
+
exit;
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Display messages to the user
|
217 |
+
*
|
218 |
+
* @since 1.0
|
219 |
+
*/
|
220 |
+
public function print_messages() {
|
221 |
+
|
222 |
+
if ( is_plugin_active( 'clearfy/clearfy.php' ) ) {
|
223 |
+
if ( $clearfy_options = get_option( 'wbcr_clearfy_cache_options' ) ) {
|
224 |
+
if ( $clearfy_options['disable_dashicons'] == true ) {
|
225 |
+
echo "<p class='fail'>" . __( 'Please enable Dashicons in the Clearfy plugin options. Max Mega Menu requires Dashicons.', 'megamenu' ) . '</p>';
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
do_action( 'megamenu_print_messages' );
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Enqueue admin scripts
|
237 |
+
*
|
238 |
+
* @since 1.8.3
|
239 |
+
*/
|
240 |
+
public function enqueue_scripts( $hook ) {
|
241 |
+
|
242 |
+
wp_deregister_style( 'select2' );
|
243 |
+
wp_deregister_script( 'select2' );
|
244 |
+
|
245 |
+
wp_enqueue_style( 'select2', MEGAMENU_BASE_URL . 'js/select2/select2.css', false, MEGAMENU_VERSION );
|
246 |
+
wp_enqueue_script( 'mega-menu-select2', MEGAMENU_BASE_URL . 'js/select2/select2.min.js', array(), MEGAMENU_VERSION );
|
247 |
+
|
248 |
+
wp_enqueue_style( 'mega-menu-settings', MEGAMENU_BASE_URL . 'css/admin/admin.css', false, MEGAMENU_VERSION );
|
249 |
+
|
250 |
+
wp_enqueue_style( 'spectrum', MEGAMENU_BASE_URL . 'js/spectrum/spectrum.css', false, MEGAMENU_VERSION );
|
251 |
+
wp_enqueue_script( 'spectrum', MEGAMENU_BASE_URL . 'js/spectrum/spectrum.js', array( 'jquery' ), MEGAMENU_VERSION );
|
252 |
+
|
253 |
+
wp_localize_script(
|
254 |
+
'spectrum',
|
255 |
+
'megamenu_spectrum_settings',
|
256 |
+
apply_filters( 'megamenu_spectrum_localisation', array() )
|
257 |
+
);
|
258 |
+
|
259 |
+
wp_enqueue_script( 'mega-menu-theme-editor', MEGAMENU_BASE_URL . 'js/settings.js', array( 'jquery', 'spectrum', 'code-editor' ), MEGAMENU_VERSION );
|
260 |
|
261 |
+
wp_localize_script(
|
262 |
+
'mega-menu-theme-editor',
|
263 |
+
'megamenu_settings',
|
264 |
+
array(
|
265 |
+
'saving' => __( 'Saving', 'megamenu' ),
|
266 |
+
'confirm' => __( 'Are you sure?', 'megamenu' ),
|
267 |
+
'theme_save_error' => __( 'Error saving theme.', 'megamenu' ),
|
268 |
+
'theme_save_error_refresh' => __( 'Please try refreshing the page.', 'megamenu' ),
|
269 |
+
'theme_save_error_exhausted' => __( 'The server ran out of memory whilst trying to regenerate the menu CSS.', 'megamenu' ),
|
270 |
+
'theme_save_error_memory_limit' => __( 'Try disabling unusued plugins to increase the available memory. Alternatively, for details on how to increase your server memory limit see:', 'megamenu' ),
|
271 |
+
'theme_save_error_500' => __( 'The server returned a 500 error. The server did not provide an error message (you should find details of the error in your server error log), but this is usually due to your server memory limit being reached.', 'megamenu' ),
|
272 |
+
'increase_memory_limit_url' => 'http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/',
|
273 |
+
'increase_memory_limit_anchor_text' => 'How to increase the WordPress memory limit',
|
274 |
+
)
|
275 |
+
);
|
276 |
|
277 |
+
if ( function_exists( 'wp_enqueue_code_editor' ) ) {
|
278 |
+
wp_deregister_style( 'codemirror' );
|
279 |
+
wp_deregister_script( 'codemirror' );
|
|
|
|
|
|
|
280 |
|
281 |
+
$cm_settings['codeEditor'] = wp_enqueue_code_editor( array( 'type' => 'text/x-scss' ) );
|
282 |
+
wp_localize_script( 'mega-menu-theme-editor', 'cm_settings', $cm_settings );
|
283 |
+
wp_enqueue_style( 'wp-codemirror' );
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
}
|
288 |
|
289 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pages/themes.php
CHANGED
@@ -1,3282 +1,3303 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Themes' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_Themes {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
|
|
|
|
14 |
|
15 |
-
/**
|
16 |
-
* All themes (default and custom)
|
17 |
-
*/
|
18 |
-
var $themes = array();
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
* Active theme
|
23 |
-
*/
|
24 |
-
var $active_theme = array();
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
var $id = "";
|
31 |
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
* @since 1.0
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
add_action( 'admin_post_megamenu_delete_theme', array( $this, 'delete_theme') );
|
44 |
-
add_action( 'admin_post_megamenu_revert_theme', array( $this, 'revert_theme') );
|
45 |
-
add_action( 'admin_post_megamenu_duplicate_theme', array( $this, 'duplicate_theme') );
|
46 |
-
add_action( 'admin_post_megamenu_import_theme', array( $this, 'import_theme') );
|
47 |
|
48 |
-
|
49 |
-
add_action( 'megamenu_page_theme_editor', array( $this, 'theme_editor_page'));
|
50 |
|
51 |
-
|
52 |
-
|
53 |
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] == 'maxmegamenu_theme_editor' ) {
|
62 |
-
$settings['codemirror']['lint'] = false;
|
63 |
-
$settings['codemirror']['gutters'] = array();
|
64 |
-
return $settings;
|
65 |
-
}
|
66 |
-
}
|
67 |
|
|
|
68 |
|
69 |
-
|
70 |
-
* Add the Menu Locations tab to our available tabs
|
71 |
-
*
|
72 |
-
* @param array $tabs
|
73 |
-
* @since 2.8
|
74 |
-
*/
|
75 |
-
public function add_themes_tab($tabs) {
|
76 |
|
77 |
-
|
78 |
-
return $tabs;
|
79 |
-
}
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
*/
|
85 |
-
public function init() {
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
$this->themes = $style_manager->get_themes();
|
91 |
|
92 |
-
|
|
|
93 |
|
94 |
-
|
|
|
95 |
|
96 |
-
|
|
|
|
|
|
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
} else {
|
101 |
-
$this->id = $preselected_theme;
|
102 |
-
}
|
103 |
|
104 |
-
$this->active_theme = $this->themes[$this->id];
|
105 |
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
* Returns the next available custom theme ID
|
112 |
-
*
|
113 |
-
* @since 1.0
|
114 |
-
*/
|
115 |
-
public function get_next_theme_id() {
|
116 |
-
$last_id = 0;
|
117 |
|
118 |
-
|
119 |
-
foreach ( $saved_themes as $key => $value ) {
|
120 |
-
if ( strpos( $key, 'custom_theme' ) !== FALSE ) {
|
121 |
-
$parts = explode( "_", $key );
|
122 |
-
$theme_id = end( $parts );
|
123 |
|
124 |
-
|
125 |
-
$last_id = $theme_id;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
|
131 |
-
|
132 |
|
133 |
-
|
134 |
-
}
|
135 |
|
136 |
-
|
137 |
-
*
|
138 |
-
* @since 2.4.1
|
139 |
-
*/
|
140 |
-
public function ajax_save_theme() {
|
141 |
|
142 |
-
|
143 |
|
144 |
-
|
145 |
|
146 |
-
|
147 |
|
148 |
-
|
149 |
-
wp_send_json_error( $test->get_error_message() );
|
150 |
-
} else {
|
151 |
-
$this->save_theme(true);
|
152 |
-
wp_send_json_success( "Saved" );
|
153 |
-
}
|
154 |
|
155 |
-
|
156 |
|
157 |
-
|
158 |
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
165 |
|
166 |
-
|
167 |
|
168 |
-
|
169 |
-
foreach ( $_POST['checkboxes'] as $checkbox => $value ) {
|
170 |
-
if ( isset( $submitted_settings[ $checkbox ] ) ) {
|
171 |
-
$submitted_settings[ $checkbox ] = 'on';
|
172 |
-
} else {
|
173 |
-
$submitted_settings[ $checkbox ] = 'off';
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
|
178 |
-
|
179 |
-
$submitted_settings['responsive_breakpoint'] = $submitted_settings['responsive_breakpoint'] . "px";
|
180 |
-
}
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
$submitted_settings['panel_width'] = trim( $submitted_settings['panel_width'] );
|
188 |
-
}
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
|
194 |
-
|
195 |
|
196 |
-
|
197 |
|
198 |
-
|
199 |
|
200 |
-
|
201 |
-
* Save changes to an exiting theme.
|
202 |
-
*
|
203 |
-
* @since 1.0
|
204 |
-
*/
|
205 |
-
public function save_theme($is_ajax = false) {
|
206 |
|
207 |
-
|
208 |
|
209 |
-
$theme = esc_attr( $_POST['theme_id'] );
|
210 |
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
-
|
214 |
-
unset( $saved_themes[ $theme ] );
|
215 |
-
}
|
216 |
|
217 |
-
|
218 |
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
|
|
223 |
|
224 |
-
|
225 |
-
do_action("megamenu_delete_cache");
|
226 |
|
227 |
-
|
228 |
-
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&saved=true" ) );
|
229 |
-
return;
|
230 |
-
}
|
231 |
|
232 |
-
|
233 |
|
234 |
-
|
235 |
|
|
|
236 |
|
237 |
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
|
245 |
-
|
246 |
|
247 |
-
|
248 |
|
249 |
-
|
250 |
|
251 |
-
|
252 |
|
253 |
-
|
254 |
|
255 |
-
|
|
|
256 |
|
257 |
-
|
258 |
|
259 |
-
|
260 |
|
261 |
-
|
262 |
|
263 |
-
|
264 |
|
265 |
-
|
266 |
|
267 |
-
|
268 |
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
|
|
271 |
|
272 |
-
|
273 |
-
* Delete a theme
|
274 |
-
*
|
275 |
-
* @since 1.0
|
276 |
-
*/
|
277 |
-
public function delete_theme() {
|
278 |
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
-
|
282 |
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
}
|
294 |
|
295 |
-
max_mega_menu_save_themes( $saved_themes );
|
296 |
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
|
313 |
-
|
314 |
|
315 |
-
|
316 |
|
317 |
-
|
|
|
|
|
|
|
|
|
318 |
|
319 |
-
|
320 |
-
|
321 |
-
}
|
322 |
|
323 |
-
|
324 |
|
325 |
-
|
|
|
|
|
326 |
|
327 |
-
|
|
|
|
|
328 |
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
-
|
|
|
|
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
|
341 |
-
|
|
|
|
|
342 |
|
343 |
-
|
344 |
|
345 |
-
|
346 |
|
347 |
-
$next_id = $this->get_next_theme_id();
|
348 |
|
349 |
-
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
352 |
-
$new_theme = $style_manager->get_default_theme();
|
353 |
|
354 |
-
|
355 |
|
356 |
-
|
357 |
|
358 |
-
|
359 |
|
360 |
-
|
361 |
|
362 |
-
|
363 |
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
-
|
367 |
-
* Duplicate an existing theme.
|
368 |
-
*
|
369 |
-
* @since 1.8
|
370 |
-
*/
|
371 |
-
public function import_theme() {
|
372 |
-
check_admin_referer( 'megamenu_import_theme' );
|
373 |
|
374 |
-
|
375 |
|
376 |
-
|
377 |
|
378 |
-
|
379 |
-
|
380 |
-
$sanitized[$key] = sanitize_textarea_field( $value );
|
381 |
-
} else {
|
382 |
-
$sanitized[$key] = sanitize_text_field( $value );
|
383 |
-
}
|
384 |
-
}
|
385 |
|
386 |
-
$import = $sanitized;
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
|
|
396 |
|
397 |
-
|
398 |
-
array(
|
399 |
-
'page' => 'maxmegamenu_theme_editor',
|
400 |
-
'theme' => $new_theme_id,
|
401 |
-
'imported' => 'true'
|
402 |
-
),
|
403 |
-
admin_url("admin.php")
|
404 |
-
);
|
405 |
|
406 |
-
|
407 |
-
$url = add_query_arg(
|
408 |
-
array(
|
409 |
-
'page' => 'maxmegamenu_theme_editor',
|
410 |
-
'imported' => 'false'
|
411 |
-
),
|
412 |
-
admin_url("admin.php")
|
413 |
-
);
|
414 |
-
}
|
415 |
|
416 |
-
$this->redirect( $url );
|
417 |
|
418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
|
|
|
420 |
|
421 |
-
|
422 |
-
* Redirect and exit
|
423 |
-
*
|
424 |
-
* @since 1.8
|
425 |
-
*/
|
426 |
-
public function redirect( $url ) {
|
427 |
|
428 |
-
|
429 |
-
|
|
|
|
|
|
|
430 |
|
431 |
-
|
|
|
432 |
|
433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
|
435 |
-
|
436 |
-
* Checks to see if a certain theme is in use.
|
437 |
-
*
|
438 |
-
* @since 1.0
|
439 |
-
* @param string $theme
|
440 |
-
*/
|
441 |
-
public function theme_is_being_used_by_location( $theme ) {
|
442 |
-
$settings = get_option( "megamenu_settings" );
|
443 |
|
444 |
-
|
445 |
-
return false;
|
446 |
-
}
|
447 |
|
448 |
-
|
|
|
449 |
|
450 |
-
$menus = get_registered_nav_menus();
|
451 |
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
-
|
455 |
|
456 |
-
|
457 |
|
458 |
-
|
459 |
-
|
460 |
-
|
|
|
461 |
|
462 |
-
|
|
|
463 |
|
464 |
-
if ( count( $theme_in_use_locations ) ) {
|
465 |
-
return $theme_in_use_locations;
|
466 |
-
}
|
467 |
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
-
|
471 |
-
}
|
472 |
|
|
|
473 |
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
*/
|
479 |
-
public function print_messages() {
|
480 |
|
481 |
-
|
|
|
482 |
|
483 |
-
$style_manager = new Mega_Menu_Style_Manager();
|
484 |
|
485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
|
487 |
-
|
488 |
-
echo "<p class='fail'>" . $test->get_error_message() . "</p>";
|
489 |
-
}
|
490 |
|
491 |
-
|
492 |
-
echo "<p class='fail'>" . __("Failed to delete theme. The theme is in use by a menu.", "megamenu") . "</p>";
|
493 |
-
}
|
494 |
|
495 |
-
|
496 |
-
|
497 |
-
}
|
498 |
|
499 |
-
|
500 |
-
|
501 |
-
}
|
502 |
|
503 |
-
if ( isset( $_GET['reverted'] ) ) {
|
504 |
-
echo "<p class='success'>" . __("Theme Reverted", "megamenu") . "</p>";
|
505 |
-
}
|
506 |
|
507 |
-
|
508 |
-
|
509 |
-
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
-
|
512 |
|
513 |
-
|
514 |
|
|
|
|
|
|
|
515 |
|
516 |
-
|
517 |
-
* Lists the available themes
|
518 |
-
*
|
519 |
-
* @since 1.0
|
520 |
-
*/
|
521 |
-
public function theme_selector() {
|
522 |
|
523 |
-
|
|
|
|
|
|
|
|
|
524 |
|
525 |
-
|
|
|
526 |
|
527 |
-
|
|
|
528 |
|
529 |
-
$selected = $id == $this->id ? 'selected=selected' : '';
|
530 |
|
531 |
-
$list_items .= "<option {$selected} value='" . admin_url("admin.php?page=maxmegamenu_theme_editor&theme={$id}") . "'>";
|
532 |
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
|
535 |
-
|
536 |
-
$title .= " (" . implode( ", ", $locations ) . ")";
|
537 |
-
}
|
538 |
|
539 |
-
|
|
|
|
|
540 |
|
541 |
-
|
542 |
-
|
|
|
|
|
|
|
543 |
|
544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
/**
|
549 |
-
* Checks to see if a given string contains any of the provided search terms
|
550 |
-
*
|
551 |
-
* @param srgin $key
|
552 |
-
* @param array $needles
|
553 |
-
* @since 1.0
|
554 |
-
*/
|
555 |
-
private function string_contains( $key, $needles ) {
|
556 |
-
|
557 |
-
foreach ( $needles as $needle ) {
|
558 |
-
|
559 |
-
if ( strpos( $key, $needle ) !== FALSE ) {
|
560 |
-
return true;
|
561 |
-
}
|
562 |
-
}
|
563 |
-
|
564 |
-
return false;
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
/**
|
571 |
-
*
|
572 |
-
* @since 2.9
|
573 |
-
*/
|
574 |
-
public function export_theme() {
|
575 |
-
$style_manager = new Mega_Menu_Style_Manager();
|
576 |
-
$default_theme = $style_manager->get_default_theme();
|
577 |
-
|
578 |
-
$theme_to_export = $this->active_theme;
|
579 |
-
|
580 |
-
$diff = array();
|
581 |
-
|
582 |
-
foreach ( $default_theme as $key => $value ) {
|
583 |
-
if ( isset( $theme_to_export[$key] ) && $theme_to_export[$key] != $value || $key == 'title') {
|
584 |
-
$diff[$key] = $theme_to_export[$key];
|
585 |
-
}
|
586 |
-
}
|
587 |
-
|
588 |
-
?>
|
589 |
-
|
590 |
-
<div class='menu_settings menu_settings_menu_themes'>
|
591 |
-
<h3 class='first'><?php _e("Export Theme", "megamenu"); ?></h3>
|
592 |
-
<table>
|
593 |
-
<tr>
|
594 |
-
<td class='mega-name'>
|
595 |
-
<?php _e("JSON Format", "megamenu"); ?>
|
596 |
-
<div class='mega-description'><?php _e("Log into the site you wish to import the theme to. Go to Mega Menu > Tools and paste this into the 'Import Theme' text area:", "megamenu"); ?></div>
|
597 |
-
</td>
|
598 |
-
<td class='mega-value'>
|
599 |
-
<?php echo "<textarea class='mega-export'>" . sanitize_textarea_field( htmlentities( json_encode( $diff ) ) ) . "</textarea>"; ?>
|
600 |
-
</td>
|
601 |
-
</tr>
|
602 |
-
<tr>
|
603 |
-
<td class='mega-name'>
|
604 |
-
<?php _e("PHP Format", "megamenu"); ?>
|
605 |
-
<div class='mega-description'><?php _e("Paste this code into your themes functions.php file:", "megamenu"); ?></div>
|
606 |
-
</td>
|
607 |
-
<td class='mega-value'>
|
608 |
-
<?php
|
609 |
-
$key = strtolower( str_replace(" ", "_", $theme_to_export['title'] ) );
|
610 |
-
$key .= "_" . time();
|
611 |
-
echo "<textarea class='mega-export'>";
|
612 |
-
echo 'function megamenu_add_theme_' . $key . '($themes) {';
|
613 |
-
echo "\n" . ' $themes["' . $key .'"] = array(';
|
614 |
-
|
615 |
-
foreach ($diff as $theme_key => $value) {
|
616 |
-
echo "\n '" . $theme_key . "' => '" . $value . "',";
|
617 |
-
}
|
618 |
-
|
619 |
-
echo "\n" . ' );';
|
620 |
-
echo "\n" . ' return $themes;';
|
621 |
-
echo "\n" . '}';
|
622 |
-
echo "\n" . 'add_filter("megamenu_themes", "megamenu_add_theme_' . $key . '");';
|
623 |
-
echo '</textarea>';
|
624 |
-
?>
|
625 |
-
</td>
|
626 |
-
</tr>
|
627 |
-
</table>
|
628 |
-
</div>
|
629 |
-
|
630 |
-
<?php
|
631 |
-
}
|
632 |
-
|
633 |
-
public function import_theme_page() {
|
634 |
-
|
635 |
-
?>
|
636 |
-
|
637 |
-
<div class='menu_settings menu_settings_menu_themes'>
|
638 |
-
<h3 class='first'><?php _e("Import Theme", "megamenu"); ?></h3>
|
639 |
-
<table>
|
640 |
-
<tr>
|
641 |
-
<td class='mega-name'>
|
642 |
-
<?php _e("Import Theme", "megamenu"); ?>
|
643 |
-
<div class='mega-description'><?php _e("Import a menu theme in JSON format", "megamenu"); ?></div>
|
644 |
-
</td>
|
645 |
-
<td class='mega-value'>
|
646 |
-
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
|
647 |
-
<?php wp_nonce_field( 'megamenu_import_theme' ); ?>
|
648 |
-
<input type="hidden" name="action" value="megamenu_import_theme" />
|
649 |
-
<textarea name='data'></textarea>
|
650 |
-
<input type='submit' class='button button-primary' value='<?php _e("Import Theme", "megamenu"); ?>' />
|
651 |
-
</form>
|
652 |
-
</td>
|
653 |
-
</tr>
|
654 |
-
</table>
|
655 |
-
</div>
|
656 |
-
|
657 |
-
<?php
|
658 |
-
}
|
659 |
-
|
660 |
-
|
661 |
-
/**
|
662 |
-
* Displays the theme editor form.
|
663 |
-
*
|
664 |
-
* @since 1.0
|
665 |
-
*/
|
666 |
-
public function theme_editor_page( $saved_settings ) {
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
$this->init();
|
671 |
-
|
672 |
-
if ( isset($_GET['export'] )) {
|
673 |
-
$this->export_theme();
|
674 |
-
return;
|
675 |
-
}
|
676 |
-
|
677 |
-
if ( isset($_GET['import'] )) {
|
678 |
-
$this->import_theme_page();
|
679 |
-
return;
|
680 |
-
}
|
681 |
-
|
682 |
-
$create_url = esc_url( add_query_arg(
|
683 |
-
array(
|
684 |
-
'action'=>'megamenu_add_theme'
|
685 |
-
),
|
686 |
-
wp_nonce_url( admin_url("admin-post.php"), 'megamenu_create_theme' )
|
687 |
-
) );
|
688 |
-
|
689 |
-
$duplicate_url = esc_url( add_query_arg(
|
690 |
-
array(
|
691 |
-
'action'=>'megamenu_duplicate_theme',
|
692 |
-
'theme_id' => $this->id
|
693 |
-
),
|
694 |
-
wp_nonce_url( admin_url("admin-post.php"), 'megamenu_duplicate_theme' )
|
695 |
-
) );
|
696 |
-
|
697 |
-
$delete_url = esc_url( add_query_arg(
|
698 |
-
array(
|
699 |
-
'action'=>'megamenu_delete_theme',
|
700 |
-
'theme_id' => $this->id
|
701 |
-
),
|
702 |
-
wp_nonce_url( admin_url("admin-post.php"), 'megamenu_delete_theme' )
|
703 |
-
) );
|
704 |
-
|
705 |
-
$revert_url = esc_url( add_query_arg(
|
706 |
-
array(
|
707 |
-
'action'=>'megamenu_revert_theme',
|
708 |
-
'theme_id' => $this->id
|
709 |
-
),
|
710 |
-
wp_nonce_url( admin_url("admin-post.php"), 'megamenu_revert_theme' )
|
711 |
-
) );
|
712 |
-
|
713 |
-
$export_url = esc_url( add_query_arg(
|
714 |
-
array(
|
715 |
-
'page'=>'maxmegamenu_theme_editor',
|
716 |
-
'theme_id' => $this->id,
|
717 |
-
'export' => 'true'
|
718 |
-
),
|
719 |
-
admin_url("admin.php")
|
720 |
-
) );
|
721 |
-
|
722 |
-
$import_url = esc_url( add_query_arg(
|
723 |
-
array(
|
724 |
-
'page'=>'maxmegamenu_theme_editor',
|
725 |
-
'import' => 'true'
|
726 |
-
),
|
727 |
-
admin_url("admin.php")
|
728 |
-
) );
|
729 |
-
|
730 |
-
?>
|
731 |
-
|
732 |
-
<?php $this->print_messages() ?>
|
733 |
-
|
734 |
-
<div class='menu_settings menu_settings_menu_themes'>
|
735 |
-
|
736 |
-
<div class='theme_selector'>
|
737 |
-
<?php _e("Select theme to edit", "megamenu"); ?> <?php echo $this->theme_selector(); ?>
|
738 |
-
</div>
|
739 |
-
|
740 |
-
<div class='mega-ellipsis'>
|
741 |
-
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
|
742 |
-
<path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"></path>
|
743 |
-
</svg>
|
744 |
-
<ul class='mega-ellipsis-content'>
|
745 |
-
<li class='mega-create-theme'><a href='<?php echo $create_url ?>'><span class='dashicons dashicons-welcome-add-page'></span><?php _e("Add new theme", "megamenu"); ?></a></li>
|
746 |
-
<li class='mega-duplicate-theme'><a href='<?php echo $duplicate_url ?>'><span class='dashicons dashicons-images-alt2'></span><?php _e("Duplicate theme", "megamenu"); ?></a></li>
|
747 |
-
<li class='mega-export-theme'><a href='<?php echo $export_url ?>'><span class='dashicons dashicons-upload'></span><?php _e("Export theme", "megamenu"); ?></a></li>
|
748 |
-
<li class='mega-import-theme'><a href='<?php echo $import_url ?>'><span class='dashicons dashicons-download'></span><?php _e("Import a theme", "megamenu"); ?></a></li>
|
749 |
-
<?php if ( $this->string_contains( $this->id, array("custom") ) ) : ?>
|
750 |
-
<li class='mega-delete-theme'><a class='delete confirm' href='<?php echo $delete_url; ?>'><span class='dashicons dashicons-trash'></span><?php _e("Delete theme", "megamenu"); ?></a></li>
|
751 |
-
<?php else : ?>
|
752 |
-
<li class='mega-revert-theme'><a class='confirm' href='<?php echo $revert_url; ?>'><span class='dashicons dashicons-update-alt'></span><?php _e("Revert theme", "megamenu"); ?></a></li>
|
753 |
-
<?php endif; ?>
|
754 |
-
</ul>
|
755 |
-
</div>
|
756 |
-
|
757 |
-
<h3 class='editing_theme'><?php echo __("Editing theme", "megamenu") . ": " . esc_html( $this->active_theme['title'] ); ?></h3>
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
<?php
|
762 |
-
|
763 |
-
$saved_settings = get_option("megamenu_settings");
|
764 |
-
|
765 |
-
if (isset($saved_settings['css']) && $saved_settings['css'] == 'disabled') {
|
766 |
-
?>
|
767 |
-
<div class='fail'><?php _e("CSS Output (under Mega Menu > General Settings) has been disabled. Therefore, changes made within the theme editor will not be applied to your menu.", "megamenu"); ?></div>
|
768 |
-
<?php
|
769 |
-
}
|
770 |
-
|
771 |
-
$locations = $this->theme_is_being_used_by_location( $this->id );
|
772 |
-
|
773 |
-
if ( ! $locations && ! isset($_GET['created'] ) ) {
|
774 |
-
?>
|
775 |
-
<div class='warning'><?php _e("This menu theme is not currently active as it has not been applied to any menu locations. You may wish to check you are editing the correct menu theme - you can choose a different theme to edit using the 'Select theme to edit' selector above. Alternatively, to apply this theme to a menu go to <i>Appearance > Menus > Max Mega Menu Settings</i> and select this theme from the 'Theme' dropdown.", "megamenu"); ?></div>
|
776 |
-
<?php
|
777 |
-
}
|
778 |
-
|
779 |
-
?>
|
780 |
-
|
781 |
-
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post" class="theme_editor">
|
782 |
-
<input type="hidden" name="theme_id" value="<?php echo esc_attr( $this->id ); ?>" />
|
783 |
-
<input type="hidden" name="action" value="megamenu_save_theme" />
|
784 |
-
<?php wp_nonce_field( 'megamenu_save_theme' ); ?>
|
785 |
-
|
786 |
-
<?php
|
787 |
-
|
788 |
-
$settings = apply_filters( 'megamenu_theme_editor_settings', array(
|
789 |
-
|
790 |
-
'general' => array(
|
791 |
-
'title' => __( "General Settings", "megamenu" ),
|
792 |
-
'settings' => array(
|
793 |
-
'title' => array(
|
794 |
-
'priority' => 10,
|
795 |
-
'title' => __( "Theme Title", "megamenu" ),
|
796 |
-
'description' => "",
|
797 |
-
'settings' => array(
|
798 |
-
array(
|
799 |
-
'title' => "",
|
800 |
-
'type' => 'freetext',
|
801 |
-
'key' => 'title'
|
802 |
-
)
|
803 |
-
)
|
804 |
-
),
|
805 |
-
'arrow' => array(
|
806 |
-
'priority' => 20,
|
807 |
-
'title' => __( "Arrow", "megamenu" ),
|
808 |
-
'description' => __( "Select the arrow styles.", "megamenu" ),
|
809 |
-
'settings' => array(
|
810 |
-
array(
|
811 |
-
'title' => __( "Up", "megamenu" ),
|
812 |
-
'type' => 'arrow',
|
813 |
-
'key' => 'arrow_up'
|
814 |
-
),
|
815 |
-
array(
|
816 |
-
'title' => __( "Down", "megamenu" ),
|
817 |
-
'type' => 'arrow',
|
818 |
-
'key' => 'arrow_down'
|
819 |
-
),
|
820 |
-
array(
|
821 |
-
'title' => __( "Left", "megamenu" ),
|
822 |
-
'type' => 'arrow',
|
823 |
-
'key' => 'arrow_left'
|
824 |
-
),
|
825 |
-
array(
|
826 |
-
'title' => __( "Right", "megamenu" ),
|
827 |
-
'type' => 'arrow',
|
828 |
-
'key' => 'arrow_right'
|
829 |
-
)
|
830 |
-
)
|
831 |
-
),
|
832 |
-
'line_height' => array(
|
833 |
-
'priority' => 30,
|
834 |
-
'title' => __( "Line Height", "megamenu" ),
|
835 |
-
'description' => __( "Set the general line height to use in the sub menu contents.", "megamenu" ),
|
836 |
-
'settings' => array(
|
837 |
-
array(
|
838 |
-
'title' => "",
|
839 |
-
'type' => 'freetext',
|
840 |
-
'key' => 'line_height'
|
841 |
-
)
|
842 |
-
)
|
843 |
-
),
|
844 |
-
'z_index' => array(
|
845 |
-
'priority' => 40,
|
846 |
-
'title' => __( "Z Index", "megamenu" ),
|
847 |
-
'description' => __( "Set the z-index to ensure the sub menus appear ontop of other content.", "megamenu" ),
|
848 |
-
'settings' => array(
|
849 |
-
array(
|
850 |
-
'title' => "",
|
851 |
-
'type' => 'freetext',
|
852 |
-
'key' => 'z_index',
|
853 |
-
'validation' => 'int'
|
854 |
-
)
|
855 |
-
)
|
856 |
-
),
|
857 |
-
'shadow' => array(
|
858 |
-
'priority' => 50,
|
859 |
-
'title' => __( "Shadow", "megamenu" ),
|
860 |
-
'description' => __( "Apply a shadow to mega and flyout menus.", "megamenu" ),
|
861 |
-
'settings' => array(
|
862 |
-
array(
|
863 |
-
'title' => __( "Enabled", "megamenu" ),
|
864 |
-
'type' => 'checkbox',
|
865 |
-
'key' => 'shadow'
|
866 |
-
),
|
867 |
-
array(
|
868 |
-
'title' => __( "Horizontal", "megamenu" ),
|
869 |
-
'type' => 'freetext',
|
870 |
-
'key' => 'shadow_horizontal',
|
871 |
-
'validation' => 'px'
|
872 |
-
),
|
873 |
-
array(
|
874 |
-
'title' => __( "Vertical", "megamenu" ),
|
875 |
-
'type' => 'freetext',
|
876 |
-
'key' => 'shadow_vertical',
|
877 |
-
'validation' => 'px'
|
878 |
-
),
|
879 |
-
array(
|
880 |
-
'title' => __( "Blur", "megamenu" ),
|
881 |
-
'type' => 'freetext',
|
882 |
-
'key' => 'shadow_blur',
|
883 |
-
'validation' => 'px'
|
884 |
-
),
|
885 |
-
array(
|
886 |
-
'title' => __( "Spread", "megamenu" ),
|
887 |
-
'type' => 'freetext',
|
888 |
-
'key' => 'shadow_spread',
|
889 |
-
'validation' => 'px'
|
890 |
-
),
|
891 |
-
array(
|
892 |
-
'title' => __( "Color", "megamenu" ),
|
893 |
-
'type' => 'color',
|
894 |
-
'key' => 'shadow_color'
|
895 |
-
)
|
896 |
-
)
|
897 |
-
),
|
898 |
-
'transitions' => array(
|
899 |
-
'priority' => 60,
|
900 |
-
'title' => __( "Hover Transitions", "megamenu" ),
|
901 |
-
'description' => __( "Apply hover transitions to menu items. Note: Transitions will not apply to gradient backgrounds.", "megamenu" ),
|
902 |
-
'settings' => array(
|
903 |
-
array(
|
904 |
-
'title' => __( "Enabled", "megamenu" ),
|
905 |
-
'type' => 'checkbox',
|
906 |
-
'key' => 'transitions'
|
907 |
-
)
|
908 |
-
)
|
909 |
-
),
|
910 |
-
'resets' => array(
|
911 |
-
'priority' => 70,
|
912 |
-
'title' => __( "Reset Widget Styling", "megamenu" ),
|
913 |
-
'description' => __( "Caution: Reset the styling of widgets within the mega menu? This may break the styling of widgets that you have added to your sub menus. Default: Disabled.", "megamenu" ),
|
914 |
-
'settings' => array(
|
915 |
-
array(
|
916 |
-
'title' => __( "Enabled", "megamenu" ),
|
917 |
-
'type' => 'checkbox',
|
918 |
-
'key' => 'resets'
|
919 |
-
)
|
920 |
-
)
|
921 |
-
)
|
922 |
-
)
|
923 |
-
),
|
924 |
-
'menu_bar' => array(
|
925 |
-
'title' => __( "Menu Bar", "megamenu" ),
|
926 |
-
'settings' => array(
|
927 |
-
'menu_item_height' => array(
|
928 |
-
'priority' => 05,
|
929 |
-
'title' => __( "Menu Height", "megamenu" ),
|
930 |
-
'description' => __( "Define the height of each top level menu item link. This value plus the Menu Padding (top and bottom) settings define the overall height of the menu bar.", "megamenu" ),
|
931 |
-
'settings' => array(
|
932 |
-
array(
|
933 |
-
'title' => "",
|
934 |
-
'type' => 'freetext',
|
935 |
-
'key' => 'menu_item_link_height',
|
936 |
-
'validation' => 'px'
|
937 |
-
)
|
938 |
-
)
|
939 |
-
),
|
940 |
-
'menu_background' => array(
|
941 |
-
'priority' => 10,
|
942 |
-
'title' => __( "Menu Background", "megamenu" ),
|
943 |
-
'description' => __( "The background color for the main menu bar. Set each value to transparent for a 'button' style menu.", "megamenu" ),
|
944 |
-
'settings' => array(
|
945 |
-
array(
|
946 |
-
'title' => __( "From", "megamenu" ),
|
947 |
-
'type' => 'color',
|
948 |
-
'key' => 'container_background_from'
|
949 |
-
),
|
950 |
-
array(
|
951 |
-
'title' => __( "Copy", "megamenu" ),
|
952 |
-
'type' => 'copy_color',
|
953 |
-
'key' => 'copy_color'
|
954 |
-
),
|
955 |
-
array(
|
956 |
-
'title' => __( "To", "megamenu" ),
|
957 |
-
'type' => 'color',
|
958 |
-
'key' => 'container_background_to'
|
959 |
-
)
|
960 |
-
)
|
961 |
-
),
|
962 |
-
'menu_padding' => array(
|
963 |
-
'priority' => 20,
|
964 |
-
'title' => __( "Menu Padding", "megamenu" ),
|
965 |
-
'description' => __( "Padding for the main menu bar.", "megamenu" ),
|
966 |
-
'settings' => array(
|
967 |
-
array(
|
968 |
-
'title' => __( "Top", "megamenu" ),
|
969 |
-
'type' => 'freetext',
|
970 |
-
'key' => 'container_padding_top',
|
971 |
-
'validation' => 'px'
|
972 |
-
),
|
973 |
-
array(
|
974 |
-
'title' => __( "Right", "megamenu" ),
|
975 |
-
'type' => 'freetext',
|
976 |
-
'key' => 'container_padding_right',
|
977 |
-
'validation' => 'px'
|
978 |
-
),
|
979 |
-
array(
|
980 |
-
'title' => __( "Bottom", "megamenu" ),
|
981 |
-
'type' => 'freetext',
|
982 |
-
'key' => 'container_padding_bottom',
|
983 |
-
'validation' => 'px'
|
984 |
-
),
|
985 |
-
array(
|
986 |
-
'title' => __( "Left", "megamenu" ),
|
987 |
-
'type' => 'freetext',
|
988 |
-
'key' => 'container_padding_left',
|
989 |
-
'validation' => 'px'
|
990 |
-
)
|
991 |
-
)
|
992 |
-
),
|
993 |
-
'menu_border_radius' => array(
|
994 |
-
'priority' => 30,
|
995 |
-
'title' => __( "Menu Border Radius", "megamenu" ),
|
996 |
-
'description' => __( "Set a border radius on the main menu bar.", "megamenu" ),
|
997 |
-
'settings' => array(
|
998 |
-
array(
|
999 |
-
'title' => __( "Top Left", "megamenu" ),
|
1000 |
-
'type' => 'freetext',
|
1001 |
-
'key' => 'container_border_radius_top_left',
|
1002 |
-
'validation' => 'px'
|
1003 |
-
),
|
1004 |
-
array(
|
1005 |
-
'title' => __( "Top Right", "megamenu" ),
|
1006 |
-
'type' => 'freetext',
|
1007 |
-
'key' => 'container_border_radius_top_right',
|
1008 |
-
'validation' => 'px'
|
1009 |
-
),
|
1010 |
-
array(
|
1011 |
-
'title' => __( "Bottom Right", "megamenu" ),
|
1012 |
-
'type' => 'freetext',
|
1013 |
-
'key' => 'container_border_radius_bottom_right',
|
1014 |
-
'validation' => 'px'
|
1015 |
-
),
|
1016 |
-
array(
|
1017 |
-
'title' => __( "Bottom Left", "megamenu" ),
|
1018 |
-
'type' => 'freetext',
|
1019 |
-
'key' => 'container_border_radius_bottom_left',
|
1020 |
-
'validation' => 'px'
|
1021 |
-
)
|
1022 |
-
)
|
1023 |
-
),
|
1024 |
-
'top_level_menu_items' => array(
|
1025 |
-
'priority' => 50,
|
1026 |
-
'title' => __( "Top Level Menu Items", "megamenu" ),
|
1027 |
-
'description' => '',
|
1028 |
-
),
|
1029 |
-
'menu_item_align' => array(
|
1030 |
-
'priority' => 55,
|
1031 |
-
'title' => __( "Menu Items Align", "megamenu" ),
|
1032 |
-
'description' => __( "Align <i>all</i> menu items to the left (default), centrally or to the right.", "megamenu" ),
|
1033 |
-
'info' => array( __( "This option will apply to all menu items. To align an individual menu item to the right, edit the menu item itself and set 'Menu Item Align' to 'Right'.", "megamenu" ) ),
|
1034 |
-
'settings' => array(
|
1035 |
-
array(
|
1036 |
-
'title' => "",
|
1037 |
-
'type' => 'align',
|
1038 |
-
'key' => 'menu_item_align'
|
1039 |
-
)
|
1040 |
-
)
|
1041 |
-
),
|
1042 |
-
'menu_item_font' => array(
|
1043 |
-
'priority' => 60,
|
1044 |
-
'title' => __( "Item Font", "megamenu" ),
|
1045 |
-
'description' => __( "The font to use for each top level menu item.", "megamenu" ),
|
1046 |
-
'settings' => array(
|
1047 |
-
array(
|
1048 |
-
'title' => __( "Color", "megamenu" ),
|
1049 |
-
'type' => 'color',
|
1050 |
-
'key' => 'menu_item_link_color'
|
1051 |
-
),
|
1052 |
-
array(
|
1053 |
-
'title' => __( "Size", "megamenu" ),
|
1054 |
-
'type' => 'freetext',
|
1055 |
-
'key' => 'menu_item_link_font_size',
|
1056 |
-
'validation' => 'px'
|
1057 |
-
),
|
1058 |
-
array(
|
1059 |
-
'title' => __( "Family", "megamenu" ),
|
1060 |
-
'type' => 'font',
|
1061 |
-
'key' => 'menu_item_link_font'
|
1062 |
-
),
|
1063 |
-
array(
|
1064 |
-
'title' => __( "Transform", "megamenu" ),
|
1065 |
-
'type' => 'transform',
|
1066 |
-
'key' => 'menu_item_link_text_transform'
|
1067 |
-
),
|
1068 |
-
array(
|
1069 |
-
'title' => __( "Weight", "megamenu" ),
|
1070 |
-
'type' => 'weight',
|
1071 |
-
'key' => 'menu_item_link_weight'
|
1072 |
-
),
|
1073 |
-
array(
|
1074 |
-
'title' => __( "Decoration", "megamenu" ),
|
1075 |
-
'type' => 'decoration',
|
1076 |
-
'key' => 'menu_item_link_text_decoration'
|
1077 |
-
),
|
1078 |
-
array(
|
1079 |
-
'title' => __( "Align", "megamenu" ),
|
1080 |
-
'type' => 'align',
|
1081 |
-
'key' => 'menu_item_link_text_align'
|
1082 |
-
)
|
1083 |
-
)
|
1084 |
-
),
|
1085 |
-
'menu_item_font_hover' => array(
|
1086 |
-
'priority' => 65,
|
1087 |
-
'title' => __( "Item Font (Hover)", "megamenu" ),
|
1088 |
-
'description' => __( "Set the font to use for each top level menu item (on hover).", "megamenu" ),
|
1089 |
-
'settings' => array(
|
1090 |
-
array(
|
1091 |
-
'title' => __( "Color", "megamenu" ),
|
1092 |
-
'type' => 'color',
|
1093 |
-
'key' => 'menu_item_link_color_hover'
|
1094 |
-
),
|
1095 |
-
array(
|
1096 |
-
'title' => __( "Weight", "megamenu" ),
|
1097 |
-
'type' => 'weight',
|
1098 |
-
'key' => 'menu_item_link_weight_hover'
|
1099 |
-
),
|
1100 |
-
array(
|
1101 |
-
'title' => __( "Decoration", "megamenu" ),
|
1102 |
-
'type' => 'decoration',
|
1103 |
-
'key' => 'menu_item_link_text_decoration_hover'
|
1104 |
-
),
|
1105 |
-
)
|
1106 |
-
),
|
1107 |
-
'menu_item_background' => array(
|
1108 |
-
'priority' => 70,
|
1109 |
-
'title' => __( "Item Background", "megamenu" ),
|
1110 |
-
'description' => __( "The background color for each top level menu item. Tip: Set these values to transparent if you've already set a background color on the menu bar.", "megamenu" ),
|
1111 |
-
'settings' => array(
|
1112 |
-
array(
|
1113 |
-
'title' => __( "From", "megamenu" ),
|
1114 |
-
'type' => 'color',
|
1115 |
-
'key' => 'menu_item_background_from'
|
1116 |
-
),
|
1117 |
-
array(
|
1118 |
-
'title' => __( "Copy", "megamenu" ),
|
1119 |
-
'type' => 'copy_color',
|
1120 |
-
'key' => 'copy_color'
|
1121 |
-
),
|
1122 |
-
array(
|
1123 |
-
'title' => __( "To", "megamenu" ),
|
1124 |
-
'type' => 'color',
|
1125 |
-
'key' => 'menu_item_background_to'
|
1126 |
-
)
|
1127 |
-
)
|
1128 |
-
),
|
1129 |
-
'menu_item_background_hover' => array(
|
1130 |
-
'priority' => 75,
|
1131 |
-
'title' => __( "Item Background (Hover)", "megamenu" ),
|
1132 |
-
'description' => __( "The background color for a top level menu item (on hover).", "megamenu" ),
|
1133 |
-
'settings' => array(
|
1134 |
-
array(
|
1135 |
-
'title' => __( "From", "megamenu" ),
|
1136 |
-
'type' => 'color',
|
1137 |
-
'key' => 'menu_item_background_hover_from'
|
1138 |
-
),
|
1139 |
-
array(
|
1140 |
-
'title' => __( "Copy", "megamenu" ),
|
1141 |
-
'type' => 'copy_color',
|
1142 |
-
'key' => 'copy_color'
|
1143 |
-
),
|
1144 |
-
array(
|
1145 |
-
'title' => __( "To", "megamenu" ),
|
1146 |
-
'type' => 'color',
|
1147 |
-
'key' => 'menu_item_background_hover_to'
|
1148 |
-
)
|
1149 |
-
)
|
1150 |
-
),
|
1151 |
-
'menu_item_spacing' => array(
|
1152 |
-
'priority' => 80,
|
1153 |
-
'title' => __( "Item Spacing", "megamenu" ),
|
1154 |
-
'description' => __( "Define the size of the gap between each top level menu item.", "megamenu" ),
|
1155 |
-
'settings' => array(
|
1156 |
-
array(
|
1157 |
-
'title' => "",
|
1158 |
-
'type' => 'freetext',
|
1159 |
-
'key' => 'menu_item_spacing',
|
1160 |
-
'validation' => 'px'
|
1161 |
-
)
|
1162 |
-
)
|
1163 |
-
),
|
1164 |
-
|
1165 |
-
'menu_item_padding' => array(
|
1166 |
-
'priority' => 85,
|
1167 |
-
'title' => __( "Item Padding", "megamenu" ),
|
1168 |
-
'description' => __( "Set the padding for each top level menu item.", "megamenu" ),
|
1169 |
-
'info' => array( __( "Generally we advise against using the Top and Bottom options here. Use the 'Menu Height' setting to determine the height of your top level menu items.", "megamenu" ) ),
|
1170 |
-
'settings' => array(
|
1171 |
-
array(
|
1172 |
-
'title' => __( "Top", "megamenu" ),
|
1173 |
-
'type' => 'freetext',
|
1174 |
-
'key' => 'menu_item_link_padding_top',
|
1175 |
-
'validation' => 'px'
|
1176 |
-
),
|
1177 |
-
array(
|
1178 |
-
'title' => __( "Right", "megamenu" ),
|
1179 |
-
'type' => 'freetext',
|
1180 |
-
'key' => 'menu_item_link_padding_right',
|
1181 |
-
'validation' => 'px'
|
1182 |
-
),
|
1183 |
-
array(
|
1184 |
-
'title' => __( "Bottom", "megamenu" ),
|
1185 |
-
'type' => 'freetext',
|
1186 |
-
'key' => 'menu_item_link_padding_bottom',
|
1187 |
-
'validation' => 'px'
|
1188 |
-
),
|
1189 |
-
array(
|
1190 |
-
'title' => __( "Left", "megamenu" ),
|
1191 |
-
'type' => 'freetext',
|
1192 |
-
'key' => 'menu_item_link_padding_left',
|
1193 |
-
'validation' => 'px'
|
1194 |
-
)
|
1195 |
-
)
|
1196 |
-
),
|
1197 |
-
'menu_item_border' => array(
|
1198 |
-
'priority' => 90,
|
1199 |
-
'title' => __( "Item Border", "megamenu" ),
|
1200 |
-
'description' => __( "Set the border to display on each top level menu item.", "megamenu" ),
|
1201 |
-
'settings' => array(
|
1202 |
-
array(
|
1203 |
-
'title' => __( "Color", "megamenu" ),
|
1204 |
-
'type' => 'color',
|
1205 |
-
'key' => 'menu_item_border_color'
|
1206 |
-
),
|
1207 |
-
array(
|
1208 |
-
'title' => __( "Color (Hover)", "megamenu" ),
|
1209 |
-
'type' => 'color',
|
1210 |
-
'key' => 'menu_item_border_color_hover'
|
1211 |
-
),
|
1212 |
-
array(
|
1213 |
-
'title' => __( "Top", "megamenu" ),
|
1214 |
-
'type' => 'freetext',
|
1215 |
-
'key' => 'menu_item_border_top',
|
1216 |
-
'validation' => 'px'
|
1217 |
-
),
|
1218 |
-
array(
|
1219 |
-
'title' => __( "Right", "megamenu" ),
|
1220 |
-
'type' => 'freetext',
|
1221 |
-
'key' => 'menu_item_border_right',
|
1222 |
-
'validation' => 'px'
|
1223 |
-
),
|
1224 |
-
array(
|
1225 |
-
'title' => __( "Bottom", "megamenu" ),
|
1226 |
-
'type' => 'freetext',
|
1227 |
-
'key' => 'menu_item_border_bottom',
|
1228 |
-
'validation' => 'px'
|
1229 |
-
),
|
1230 |
-
array(
|
1231 |
-
'title' => __( "Left", "megamenu" ),
|
1232 |
-
'type' => 'freetext',
|
1233 |
-
'key' => 'menu_item_border_left',
|
1234 |
-
'validation' => 'px'
|
1235 |
-
)
|
1236 |
-
)
|
1237 |
-
),
|
1238 |
-
'menu_item_border_radius' => array(
|
1239 |
-
'priority' => 95,
|
1240 |
-
'title' => __( "Item Border Radius", "megamenu" ),
|
1241 |
-
'description' => __( "Set rounded corners for each top level menu item.", "megamenu" ),
|
1242 |
-
'settings' => array(
|
1243 |
-
array(
|
1244 |
-
'title' => __( "Top Left", "megamenu" ),
|
1245 |
-
'type' => 'freetext',
|
1246 |
-
'key' => 'menu_item_link_border_radius_top_left',
|
1247 |
-
'validation' => 'px'
|
1248 |
-
),
|
1249 |
-
array(
|
1250 |
-
'title' => __( "Top Right", "megamenu" ),
|
1251 |
-
'type' => 'freetext',
|
1252 |
-
'key' => 'menu_item_link_border_radius_top_right',
|
1253 |
-
'validation' => 'px'
|
1254 |
-
),
|
1255 |
-
array(
|
1256 |
-
'title' => __( "Bottom Right", "megamenu" ),
|
1257 |
-
'type' => 'freetext',
|
1258 |
-
'key' => 'menu_item_link_border_radius_bottom_right',
|
1259 |
-
'validation' => 'px'
|
1260 |
-
),
|
1261 |
-
array(
|
1262 |
-
'title' => __( "Bottom Left", "megamenu" ),
|
1263 |
-
'type' => 'freetext',
|
1264 |
-
'key' => 'menu_item_link_border_radius_bottom_left',
|
1265 |
-
'validation' => 'px'
|
1266 |
-
)
|
1267 |
-
)
|
1268 |
-
),
|
1269 |
-
'menu_item_divider' => array(
|
1270 |
-
'priority' => 160,
|
1271 |
-
'title' => __( "Item Divider", "megamenu" ),
|
1272 |
-
'description' => __( "Show a small divider bar between each menu item.", "megamenu" ),
|
1273 |
-
'settings' => array(
|
1274 |
-
array(
|
1275 |
-
'title' => __( "Enabled", "megamenu" ),
|
1276 |
-
'type' => 'checkbox',
|
1277 |
-
'key' => 'menu_item_divider'
|
1278 |
-
),
|
1279 |
-
array(
|
1280 |
-
'title' => __( "Color", "megamenu" ),
|
1281 |
-
'type' => 'color',
|
1282 |
-
'key' => 'menu_item_divider_color'
|
1283 |
-
),
|
1284 |
-
array(
|
1285 |
-
'title' => __( "Glow Opacity", "megamenu" ),
|
1286 |
-
'type' => 'freetext',
|
1287 |
-
'key' => 'menu_item_divider_glow_opacity',
|
1288 |
-
'validation' => 'float'
|
1289 |
-
)
|
1290 |
-
)
|
1291 |
-
),
|
1292 |
-
'menu_item_highlight' => array(
|
1293 |
-
'priority' => 170,
|
1294 |
-
'title' => __( "Highlight Current Item", "megamenu" ),
|
1295 |
-
'description' => __( "Apply the 'hover' styling to current menu items. Applies to top level menu items only.", "megamenu" ),
|
1296 |
-
'settings' => array(
|
1297 |
-
array(
|
1298 |
-
'title' => __( "Enabled", "megamenu" ),
|
1299 |
-
'type' => 'checkbox',
|
1300 |
-
'key' => 'menu_item_highlight_current'
|
1301 |
-
)
|
1302 |
-
),
|
1303 |
-
'info' => array(
|
1304 |
-
"<a href='https://www.megamenu.com/documentation/highlight-active-menu-items/' target='blank'>" . __("Documentation: Highlighting Menu Items", "megamenu") . '</a>'
|
1305 |
-
),
|
1306 |
-
)
|
1307 |
-
)
|
1308 |
-
),
|
1309 |
-
'mega_panels' => array(
|
1310 |
-
'title' => __( "Mega Menus", "megamenu" ),
|
1311 |
-
'settings' => array(
|
1312 |
-
'panel_background' => array(
|
1313 |
-
'priority' => 10,
|
1314 |
-
'title' => __( "Panel Background", "megamenu" ),
|
1315 |
-
'description' => __( "Set a background color for a whole sub menu.", "megamenu" ),
|
1316 |
-
'settings' => array(
|
1317 |
-
array(
|
1318 |
-
'title' => __( "From", "megamenu" ),
|
1319 |
-
'type' => 'color',
|
1320 |
-
'key' => 'panel_background_from'
|
1321 |
-
),
|
1322 |
-
array(
|
1323 |
-
'title' => __( "Copy", "megamenu" ),
|
1324 |
-
'type' => 'copy_color',
|
1325 |
-
'key' => 'copy_color'
|
1326 |
-
),
|
1327 |
-
array(
|
1328 |
-
'title' => __( "To", "megamenu" ),
|
1329 |
-
'type' => 'color',
|
1330 |
-
'key' => 'panel_background_to'
|
1331 |
-
)
|
1332 |
-
)
|
1333 |
-
),
|
1334 |
-
'panel_width' => array(
|
1335 |
-
'priority' => 20,
|
1336 |
-
'title' => __( "Panel Width", "megamenu" ),
|
1337 |
-
'description' => __( "Mega Panel width.", "megamenu" ),
|
1338 |
-
'info' => array(
|
1339 |
-
__("A 100% wide panel will only ever be as wide as the menu itself. For a fixed sub menu width set this to a pixel value.", "megamenu"),
|
1340 |
-
__("Advanced: Enter a jQuery selector to synchronize the width and position of the sub menu with existing page element (e.g. body, #container, .page).", "megamenu"),
|
1341 |
-
"<a href='https://www.megamenu.com/documentation/adjust-sub-menu-width/' target='blank'>" . __("Documentation: Configuring the sub menu width", "megamenu") . '</a>'
|
1342 |
-
),
|
1343 |
-
'settings' => array(
|
1344 |
-
array(
|
1345 |
-
'title' => __( "Outer Width", "megamenu" ),
|
1346 |
-
'type' => 'freetext',
|
1347 |
-
'key' => 'panel_width'
|
1348 |
-
),
|
1349 |
-
array(
|
1350 |
-
'title' => __( "Inner Width", "megamenu" ),
|
1351 |
-
'type' => 'freetext',
|
1352 |
-
'key' => 'panel_inner_width'
|
1353 |
-
)
|
1354 |
-
)
|
1355 |
-
),
|
1356 |
-
'panel_padding' => array(
|
1357 |
-
'priority' => 30,
|
1358 |
-
'title' => __( "Panel Padding", "megamenu" ),
|
1359 |
-
'description' => __( "Set the padding for the whole sub menu. Set these values 0px if you wish your sub menu content to go edge-to-edge.", "megamenu" ),
|
1360 |
-
'settings' => array(
|
1361 |
-
array(
|
1362 |
-
'title' => __( "Top", "megamenu" ),
|
1363 |
-
'type' => 'freetext',
|
1364 |
-
'key' => 'panel_padding_top',
|
1365 |
-
'validation' => 'px'
|
1366 |
-
),
|
1367 |
-
array(
|
1368 |
-
'title' => __( "Right", "megamenu" ),
|
1369 |
-
'type' => 'freetext',
|
1370 |
-
'key' => 'panel_padding_right',
|
1371 |
-
'validation' => 'px'
|
1372 |
-
),
|
1373 |
-
array(
|
1374 |
-
'title' => __( "Bottom", "megamenu" ),
|
1375 |
-
'type' => 'freetext',
|
1376 |
-
'key' => 'panel_padding_bottom',
|
1377 |
-
'validation' => 'px'
|
1378 |
-
),
|
1379 |
-
array(
|
1380 |
-
'title' => __( "Left", "megamenu" ),
|
1381 |
-
'type' => 'freetext',
|
1382 |
-
'key' => 'panel_padding_left',
|
1383 |
-
'validation' => 'px'
|
1384 |
-
)
|
1385 |
-
)
|
1386 |
-
),
|
1387 |
-
'panel_border' => array(
|
1388 |
-
'priority' => 40,
|
1389 |
-
'title' => __( "Panel Border", "megamenu" ),
|
1390 |
-
'description' => __( "Set the border to display on the sub menu.", "megamenu" ),
|
1391 |
-
'settings' => array(
|
1392 |
-
array(
|
1393 |
-
'title' => __( "Color", "megamenu" ),
|
1394 |
-
'type' => 'color',
|
1395 |
-
'key' => 'panel_border_color'
|
1396 |
-
),
|
1397 |
-
array(
|
1398 |
-
'title' => __( "Top", "megamenu" ),
|
1399 |
-
'type' => 'freetext',
|
1400 |
-
'key' => 'panel_border_top',
|
1401 |
-
'validation' => 'px'
|
1402 |
-
),
|
1403 |
-
array(
|
1404 |
-
'title' => __( "Right", "megamenu" ),
|
1405 |
-
'type' => 'freetext',
|
1406 |
-
'key' => 'panel_border_right',
|
1407 |
-
'validation' => 'px'
|
1408 |
-
),
|
1409 |
-
array(
|
1410 |
-
'title' => __( "Bottom", "megamenu" ),
|
1411 |
-
'type' => 'freetext',
|
1412 |
-
'key' => 'panel_border_bottom',
|
1413 |
-
'validation' => 'px'
|
1414 |
-
),
|
1415 |
-
array(
|
1416 |
-
'title' => __( "Left", "megamenu" ),
|
1417 |
-
'type' => 'freetext',
|
1418 |
-
'key' => 'panel_border_left',
|
1419 |
-
'validation' => 'px'
|
1420 |
-
)
|
1421 |
-
)
|
1422 |
-
),
|
1423 |
-
'panel_border_radius' => array(
|
1424 |
-
'priority' => 50,
|
1425 |
-
'title' => __( "Panel Border Radius", "megamenu" ),
|
1426 |
-
'description' => __( "Set rounded corners for the sub menu.", "megamenu" ),
|
1427 |
-
'settings' => array(
|
1428 |
-
array(
|
1429 |
-
'title' => __( "Top Left", "megamenu" ),
|
1430 |
-
'type' => 'freetext',
|
1431 |
-
'key' => 'panel_border_radius_top_left',
|
1432 |
-
'validation' => 'px'
|
1433 |
-
),
|
1434 |
-
array(
|
1435 |
-
'title' => __( "Top Right", "megamenu" ),
|
1436 |
-
'type' => 'freetext',
|
1437 |
-
'key' => 'panel_border_radius_top_right',
|
1438 |
-
'validation' => 'px'
|
1439 |
-
),
|
1440 |
-
array(
|
1441 |
-
'title' => __( "Bottom Right", "megamenu" ),
|
1442 |
-
'type' => 'freetext',
|
1443 |
-
'key' => 'panel_border_radius_bottom_right',
|
1444 |
-
'validation' => 'px'
|
1445 |
-
),
|
1446 |
-
array(
|
1447 |
-
'title' => __( "Bottom Left", "megamenu" ),
|
1448 |
-
'type' => 'freetext',
|
1449 |
-
'key' => 'panel_border_radius_bottom_left',
|
1450 |
-
'validation' => 'px'
|
1451 |
-
)
|
1452 |
-
)
|
1453 |
-
),
|
1454 |
-
'widget_padding' => array(
|
1455 |
-
'priority' => 60,
|
1456 |
-
'title' => __( "Column Padding", "megamenu" ),
|
1457 |
-
'description' => __( "Use this to define the amount of space around each widget / set of menu items within the sub menu.", "megamenu" ),
|
1458 |
-
'settings' => array(
|
1459 |
-
array(
|
1460 |
-
'title' => __( "Top", "megamenu" ),
|
1461 |
-
'type' => 'freetext',
|
1462 |
-
'key' => 'panel_widget_padding_top',
|
1463 |
-
'validation' => 'px'
|
1464 |
-
),
|
1465 |
-
array(
|
1466 |
-
'title' => __( "Right", "megamenu" ),
|
1467 |
-
'type' => 'freetext',
|
1468 |
-
'key' => 'panel_widget_padding_right',
|
1469 |
-
'validation' => 'px'
|
1470 |
-
),
|
1471 |
-
array(
|
1472 |
-
'title' => __( "Bottom", "megamenu" ),
|
1473 |
-
'type' => 'freetext',
|
1474 |
-
'key' => 'panel_widget_padding_bottom',
|
1475 |
-
'validation' => 'px'
|
1476 |
-
),
|
1477 |
-
array(
|
1478 |
-
'title' => __( "Left", "megamenu" ),
|
1479 |
-
'type' => 'freetext',
|
1480 |
-
'key' => 'panel_widget_padding_left',
|
1481 |
-
'validation' => 'px'
|
1482 |
-
)
|
1483 |
-
)
|
1484 |
-
),
|
1485 |
-
'mega_menu_widgets' => array(
|
1486 |
-
'priority' => 65,
|
1487 |
-
'title' => __( "Widgets", "megamenu" ),
|
1488 |
-
'description' => '',
|
1489 |
-
),
|
1490 |
-
'widget_heading_font' => array(
|
1491 |
-
'priority' => 70,
|
1492 |
-
'title' => __( "Title Font", "megamenu" ),
|
1493 |
-
'description' => __( "Set the font to use Widget headers in the mega menu. Tip: set this to the same style as the Second Level Menu Item Font to keep your styling consistent.", "megamenu" ),
|
1494 |
-
'settings' => array(
|
1495 |
-
array(
|
1496 |
-
'title' => __( "Color", "megamenu" ),
|
1497 |
-
'type' => 'color',
|
1498 |
-
'key' => 'panel_header_color'
|
1499 |
-
),
|
1500 |
-
array(
|
1501 |
-
'title' => __( "Size", "megamenu" ),
|
1502 |
-
'type' => 'freetext',
|
1503 |
-
'key' => 'panel_header_font_size',
|
1504 |
-
'validation' => 'px'
|
1505 |
-
),
|
1506 |
-
array(
|
1507 |
-
'title' => __( "Family", "megamenu" ),
|
1508 |
-
'type' => 'font',
|
1509 |
-
'key' => 'panel_header_font'
|
1510 |
-
),
|
1511 |
-
array(
|
1512 |
-
'title' => __( "Transform", "megamenu" ),
|
1513 |
-
'type' => 'transform',
|
1514 |
-
'key' => 'panel_header_text_transform'
|
1515 |
-
),
|
1516 |
-
array(
|
1517 |
-
'title' => __( "Weight", "megamenu" ),
|
1518 |
-
'type' => 'weight',
|
1519 |
-
'key' => 'panel_header_font_weight'
|
1520 |
-
),
|
1521 |
-
array(
|
1522 |
-
'title' => __( "Decoration", "megamenu" ),
|
1523 |
-
'type' => 'decoration',
|
1524 |
-
'key' => 'panel_header_text_decoration'
|
1525 |
-
),
|
1526 |
-
array(
|
1527 |
-
'title' => __( "Align", "megamenu" ),
|
1528 |
-
'type' => 'align',
|
1529 |
-
'key' => 'panel_header_text_align'
|
1530 |
-
),
|
1531 |
-
)
|
1532 |
-
),
|
1533 |
-
'widget_heading_padding' => array(
|
1534 |
-
'priority' => 90,
|
1535 |
-
'title' => __( "Title Padding", "megamenu" ),
|
1536 |
-
'description' => __( "Set the padding for the widget headings.", "megamenu" ),
|
1537 |
-
'settings' => array(
|
1538 |
-
array(
|
1539 |
-
'title' => __( "Top", "megamenu" ),
|
1540 |
-
'type' => 'freetext',
|
1541 |
-
'key' => 'panel_header_padding_top',
|
1542 |
-
'validation' => 'px'
|
1543 |
-
),
|
1544 |
-
array(
|
1545 |
-
'title' => __( "Right", "megamenu" ),
|
1546 |
-
'type' => 'freetext',
|
1547 |
-
'key' => 'panel_header_padding_right',
|
1548 |
-
'validation' => 'px'
|
1549 |
-
),
|
1550 |
-
array(
|
1551 |
-
'title' => __( "Bottom", "megamenu" ),
|
1552 |
-
'type' => 'freetext',
|
1553 |
-
'key' => 'panel_header_padding_bottom',
|
1554 |
-
'validation' => 'px'
|
1555 |
-
),
|
1556 |
-
array(
|
1557 |
-
'title' => __( "Left", "megamenu" ),
|
1558 |
-
'type' => 'freetext',
|
1559 |
-
'key' => 'panel_header_padding_left',
|
1560 |
-
'validation' => 'px'
|
1561 |
-
)
|
1562 |
-
)
|
1563 |
-
),
|
1564 |
-
'widget_heading_margin' => array(
|
1565 |
-
'priority' => 100,
|
1566 |
-
'title' => __( "Title Margin", "megamenu" ),
|
1567 |
-
'description' => __( "Set the margin for the widget headings.", "megamenu" ),
|
1568 |
-
'settings' => array(
|
1569 |
-
array(
|
1570 |
-
'title' => __( "Top", "megamenu" ),
|
1571 |
-
'type' => 'freetext',
|
1572 |
-
'key' => 'panel_header_margin_top',
|
1573 |
-
'validation' => 'px'
|
1574 |
-
),
|
1575 |
-
array(
|
1576 |
-
'title' => __( "Right", "megamenu" ),
|
1577 |
-
'type' => 'freetext',
|
1578 |
-
'key' => 'panel_header_margin_right',
|
1579 |
-
'validation' => 'px'
|
1580 |
-
),
|
1581 |
-
array(
|
1582 |
-
'title' => __( "Bottom", "megamenu" ),
|
1583 |
-
'type' => 'freetext',
|
1584 |
-
'key' => 'panel_header_margin_bottom',
|
1585 |
-
'validation' => 'px'
|
1586 |
-
),
|
1587 |
-
array(
|
1588 |
-
'title' => __( "Left", "megamenu" ),
|
1589 |
-
'type' => 'freetext',
|
1590 |
-
'key' => 'panel_header_margin_left',
|
1591 |
-
'validation' => 'px'
|
1592 |
-
)
|
1593 |
-
)
|
1594 |
-
),
|
1595 |
-
'widget_header_border' => array(
|
1596 |
-
'priority' => 110,
|
1597 |
-
'title' => __( "Title Border", "megamenu" ),
|
1598 |
-
'description' => __( "Set the border for the widget headings.", "megamenu" ),
|
1599 |
-
'settings' => array(
|
1600 |
-
array(
|
1601 |
-
'title' => __( "Color", "megamenu" ),
|
1602 |
-
'type' => 'color',
|
1603 |
-
'key' => 'panel_header_border_color'
|
1604 |
-
),
|
1605 |
-
array(
|
1606 |
-
'title' => __( "Color (Hover)", "megamenu" ),
|
1607 |
-
'type' => 'color',
|
1608 |
-
'key' => 'panel_header_border_color_hover'
|
1609 |
-
),
|
1610 |
-
array(
|
1611 |
-
'title' => __( "Top", "megamenu" ),
|
1612 |
-
'type' => 'freetext',
|
1613 |
-
'key' => 'panel_header_border_top',
|
1614 |
-
'validation' => 'px'
|
1615 |
-
),
|
1616 |
-
array(
|
1617 |
-
'title' => __( "Right", "megamenu" ),
|
1618 |
-
'type' => 'freetext',
|
1619 |
-
'key' => 'panel_header_border_right',
|
1620 |
-
'validation' => 'px'
|
1621 |
-
),
|
1622 |
-
array(
|
1623 |
-
'title' => __( "Bottom", "megamenu" ),
|
1624 |
-
'type' => 'freetext',
|
1625 |
-
'key' => 'panel_header_border_bottom',
|
1626 |
-
'validation' => 'px'
|
1627 |
-
),
|
1628 |
-
array(
|
1629 |
-
'title' => __( "Left", "megamenu" ),
|
1630 |
-
'type' => 'freetext',
|
1631 |
-
'key' => 'panel_header_border_left',
|
1632 |
-
'validation' => 'px'
|
1633 |
-
)
|
1634 |
-
)
|
1635 |
-
),
|
1636 |
-
'widget_content_font' => array(
|
1637 |
-
'priority' => 115,
|
1638 |
-
'title' => __( "Content Font", "megamenu" ),
|
1639 |
-
'description' => __( "Set the font to use for panel contents.", "megamenu" ),
|
1640 |
-
'settings' => array(
|
1641 |
-
array(
|
1642 |
-
'title' => __( "Color", "megamenu" ),
|
1643 |
-
'type' => 'color',
|
1644 |
-
'key' => 'panel_font_color'
|
1645 |
-
),
|
1646 |
-
array(
|
1647 |
-
'title' => __( "Size", "megamenu" ),
|
1648 |
-
'type' => 'freetext',
|
1649 |
-
'key' => 'panel_font_size',
|
1650 |
-
'validation' => 'px'
|
1651 |
-
),
|
1652 |
-
array(
|
1653 |
-
'title' => __( "Family", "megamenu" ),
|
1654 |
-
'type' => 'font',
|
1655 |
-
'key' => 'panel_font_family'
|
1656 |
-
)
|
1657 |
-
)
|
1658 |
-
),
|
1659 |
-
'second_level_menu_items' => array(
|
1660 |
-
'priority' => 120,
|
1661 |
-
'title' => __( "Second Level Menu Items", "megamenu" ),
|
1662 |
-
'description' => '',
|
1663 |
-
),
|
1664 |
-
'second_level_font' => array(
|
1665 |
-
'priority' => 130,
|
1666 |
-
'title' => __( "Item Font", "megamenu" ),
|
1667 |
-
'description' => __( "Set the font for second level menu items when they're displayed in a Mega Menu.", "megamenu" ),
|
1668 |
-
'settings' => array(
|
1669 |
-
array(
|
1670 |
-
'title' => __( "Color", "megamenu" ),
|
1671 |
-
'type' => 'color',
|
1672 |
-
'key' => 'panel_second_level_font_color'
|
1673 |
-
),
|
1674 |
-
array(
|
1675 |
-
'title' => __( "Size", "megamenu" ),
|
1676 |
-
'type' => 'freetext',
|
1677 |
-
'key' => 'panel_second_level_font_size',
|
1678 |
-
'validation' => 'px'
|
1679 |
-
),
|
1680 |
-
array(
|
1681 |
-
'title' => __( "Family", "megamenu" ),
|
1682 |
-
'type' => 'font',
|
1683 |
-
'key' => 'panel_second_level_font'
|
1684 |
-
),
|
1685 |
-
array(
|
1686 |
-
'title' => __( "Transform", "megamenu" ),
|
1687 |
-
'type' => 'transform',
|
1688 |
-
'key' => 'panel_second_level_text_transform'
|
1689 |
-
),
|
1690 |
-
array(
|
1691 |
-
'title' => __( "Weight", "megamenu" ),
|
1692 |
-
'type' => 'weight',
|
1693 |
-
'key' => 'panel_second_level_font_weight'
|
1694 |
-
),
|
1695 |
-
array(
|
1696 |
-
'title' => __( "Decoration", "megamenu" ),
|
1697 |
-
'type' => 'decoration',
|
1698 |
-
'key' => 'panel_second_level_text_decoration'
|
1699 |
-
),
|
1700 |
-
array(
|
1701 |
-
'title' => __( "Align", "megamenu" ),
|
1702 |
-
'type' => 'align',
|
1703 |
-
'key' => 'panel_second_level_text_align'
|
1704 |
-
),
|
1705 |
-
)
|
1706 |
-
),
|
1707 |
-
'second_level_font_hover' => array(
|
1708 |
-
'priority' => 140,
|
1709 |
-
'title' => __( "Item Font (Hover)", "megamenu" ),
|
1710 |
-
'description' => __( "Set the font style on hover.", "megamenu" ),
|
1711 |
-
'settings' => array(
|
1712 |
-
array(
|
1713 |
-
'title' => __( "Color", "megamenu" ),
|
1714 |
-
'type' => 'color',
|
1715 |
-
'key' => 'panel_second_level_font_color_hover'
|
1716 |
-
),
|
1717 |
-
array(
|
1718 |
-
'title' => __( "Weight", "megamenu" ),
|
1719 |
-
'type' => 'weight',
|
1720 |
-
'key' => 'panel_second_level_font_weight_hover'
|
1721 |
-
),
|
1722 |
-
array(
|
1723 |
-
'title' => __( "Decoration", "megamenu" ),
|
1724 |
-
'type' => 'decoration',
|
1725 |
-
'key' => 'panel_second_level_text_decoration_hover'
|
1726 |
-
),
|
1727 |
-
)
|
1728 |
-
),
|
1729 |
-
'second_level_background_hover' => array(
|
1730 |
-
'priority' => 150,
|
1731 |
-
'title' => __( "Item Background (Hover)", "megamenu" ),
|
1732 |
-
'description' => __( "Set the background hover color for second level menu items.", "megamenu" ),
|
1733 |
-
'settings' => array(
|
1734 |
-
array(
|
1735 |
-
'title' => __( "From", "megamenu" ),
|
1736 |
-
'type' => 'color',
|
1737 |
-
'key' => 'panel_second_level_background_hover_from'
|
1738 |
-
),
|
1739 |
-
array(
|
1740 |
-
'title' => __( "Copy", "megamenu" ),
|
1741 |
-
'type' => 'copy_color',
|
1742 |
-
'key' => 'copy_color'
|
1743 |
-
),
|
1744 |
-
array(
|
1745 |
-
'title' => __( "To", "megamenu" ),
|
1746 |
-
'type' => 'color',
|
1747 |
-
'key' => 'panel_second_level_background_hover_to'
|
1748 |
-
)
|
1749 |
-
)
|
1750 |
-
),
|
1751 |
-
'second_level_padding' => array(
|
1752 |
-
'priority' => 160,
|
1753 |
-
'title' => __( "Item Padding", "megamenu" ),
|
1754 |
-
'description' => __( "Set the padding for the second level menu items.", "megamenu" ),
|
1755 |
-
'settings' => array(
|
1756 |
-
array(
|
1757 |
-
'title' => __( "Top", "megamenu" ),
|
1758 |
-
'type' => 'freetext',
|
1759 |
-
'key' => 'panel_second_level_padding_top',
|
1760 |
-
'validation' => 'px'
|
1761 |
-
),
|
1762 |
-
array(
|
1763 |
-
'title' => __( "Right", "megamenu" ),
|
1764 |
-
'type' => 'freetext',
|
1765 |
-
'key' => 'panel_second_level_padding_right',
|
1766 |
-
'validation' => 'px'
|
1767 |
-
),
|
1768 |
-
array(
|
1769 |
-
'title' => __( "Bottom", "megamenu" ),
|
1770 |
-
'type' => 'freetext',
|
1771 |
-
'key' => 'panel_second_level_padding_bottom',
|
1772 |
-
'validation' => 'px'
|
1773 |
-
),
|
1774 |
-
array(
|
1775 |
-
'title' => __( "Left", "megamenu" ),
|
1776 |
-
'type' => 'freetext',
|
1777 |
-
'key' => 'panel_second_level_padding_left',
|
1778 |
-
'validation' => 'px'
|
1779 |
-
)
|
1780 |
-
)
|
1781 |
-
),
|
1782 |
-
'second_level_margin' => array(
|
1783 |
-
'priority' => 170,
|
1784 |
-
'title' => __( "Item Margin", "megamenu" ),
|
1785 |
-
'description' => __( "Set the margin for the second level menu items.", "megamenu" ),
|
1786 |
-
'settings' => array(
|
1787 |
-
array(
|
1788 |
-
'title' => __( "Top", "megamenu" ),
|
1789 |
-
'type' => 'freetext',
|
1790 |
-
'key' => 'panel_second_level_margin_top',
|
1791 |
-
'validation' => 'px'
|
1792 |
-
),
|
1793 |
-
array(
|
1794 |
-
'title' => __( "Right", "megamenu" ),
|
1795 |
-
'type' => 'freetext',
|
1796 |
-
'key' => 'panel_second_level_margin_right',
|
1797 |
-
'validation' => 'px'
|
1798 |
-
),
|
1799 |
-
array(
|
1800 |
-
'title' => __( "Bottom", "megamenu" ),
|
1801 |
-
'type' => 'freetext',
|
1802 |
-
'key' => 'panel_second_level_margin_bottom',
|
1803 |
-
'validation' => 'px'
|
1804 |
-
),
|
1805 |
-
array(
|
1806 |
-
'title' => __( "Left", "megamenu" ),
|
1807 |
-
'type' => 'freetext',
|
1808 |
-
'key' => 'panel_second_level_margin_left',
|
1809 |
-
'validation' => 'px'
|
1810 |
-
)
|
1811 |
-
)
|
1812 |
-
),
|
1813 |
-
'second_level_border' => array(
|
1814 |
-
'priority' => 180,
|
1815 |
-
'title' => __( "Item Border", "megamenu" ),
|
1816 |
-
'description' => __( "Set the border for the second level menu items.", "megamenu" ),
|
1817 |
-
'settings' => array(
|
1818 |
-
array(
|
1819 |
-
'title' => __( "Color", "megamenu" ),
|
1820 |
-
'type' => 'color',
|
1821 |
-
'key' => 'panel_second_level_border_color'
|
1822 |
-
),
|
1823 |
-
array(
|
1824 |
-
'title' => __( "Color (Hover)", "megamenu" ),
|
1825 |
-
'type' => 'color',
|
1826 |
-
'key' => 'panel_second_level_border_color_hover'
|
1827 |
-
),
|
1828 |
-
array(
|
1829 |
-
'title' => __( "Top", "megamenu" ),
|
1830 |
-
'type' => 'freetext',
|
1831 |
-
'key' => 'panel_second_level_border_top',
|
1832 |
-
'validation' => 'px'
|
1833 |
-
),
|
1834 |
-
array(
|
1835 |
-
'title' => __( "Right", "megamenu" ),
|
1836 |
-
'type' => 'freetext',
|
1837 |
-
'key' => 'panel_second_level_border_right',
|
1838 |
-
'validation' => 'px'
|
1839 |
-
),
|
1840 |
-
array(
|
1841 |
-
'title' => __( "Bottom", "megamenu" ),
|
1842 |
-
'type' => 'freetext',
|
1843 |
-
'key' => 'panel_second_level_border_bottom',
|
1844 |
-
'validation' => 'px'
|
1845 |
-
),
|
1846 |
-
array(
|
1847 |
-
'title' => __( "Left", "megamenu" ),
|
1848 |
-
'type' => 'freetext',
|
1849 |
-
'key' => 'panel_second_level_border_left',
|
1850 |
-
'validation' => 'px'
|
1851 |
-
)
|
1852 |
-
)
|
1853 |
-
),
|
1854 |
-
'third_level_menu_items' => array(
|
1855 |
-
'priority' => 190,
|
1856 |
-
'title' => __( "Third Level Menu Items", "megamenu" ),
|
1857 |
-
'description' => '',
|
1858 |
-
),
|
1859 |
-
'third_level_font' => array(
|
1860 |
-
'priority' => 200,
|
1861 |
-
'title' => __( "Item Font", "megamenu" ),
|
1862 |
-
'description' => __( "Set the font for third level menu items when they're displayed in a Mega Menu.", "megamenu" ),
|
1863 |
-
'settings' => array(
|
1864 |
-
array(
|
1865 |
-
'title' => __( "Color", "megamenu" ),
|
1866 |
-
'type' => 'color',
|
1867 |
-
'key' => 'panel_third_level_font_color'
|
1868 |
-
),
|
1869 |
-
array(
|
1870 |
-
'title' => __( "Size", "megamenu" ),
|
1871 |
-
'type' => 'freetext',
|
1872 |
-
'key' => 'panel_third_level_font_size',
|
1873 |
-
'validation' => 'px'
|
1874 |
-
),
|
1875 |
-
array(
|
1876 |
-
'title' => __( "Family", "megamenu" ),
|
1877 |
-
'type' => 'font',
|
1878 |
-
'key' => 'panel_third_level_font'
|
1879 |
-
),
|
1880 |
-
array(
|
1881 |
-
'title' => __( "Transform", "megamenu" ),
|
1882 |
-
'type' => 'transform',
|
1883 |
-
'key' => 'panel_third_level_text_transform'
|
1884 |
-
),
|
1885 |
-
array(
|
1886 |
-
'title' => __( "Weight", "megamenu" ),
|
1887 |
-
'type' => 'weight',
|
1888 |
-
'key' => 'panel_third_level_font_weight'
|
1889 |
-
),
|
1890 |
-
array(
|
1891 |
-
'title' => __( "Decoration", "megamenu" ),
|
1892 |
-
'type' => 'decoration',
|
1893 |
-
'key' => 'panel_third_level_text_decoration'
|
1894 |
-
),
|
1895 |
-
array(
|
1896 |
-
'title' => __( "Align", "megamenu" ),
|
1897 |
-
'type' => 'align',
|
1898 |
-
'key' => 'panel_third_level_text_align'
|
1899 |
-
),
|
1900 |
-
)
|
1901 |
-
),
|
1902 |
-
'third_level_font_hover' => array(
|
1903 |
-
'priority' => 210,
|
1904 |
-
'title' => __( "Item Font (Hover)", "megamenu" ),
|
1905 |
-
'description' => __( "Set the font style on hover.", "megamenu" ),
|
1906 |
-
'settings' => array(
|
1907 |
-
array(
|
1908 |
-
'title' => __( "Color", "megamenu" ),
|
1909 |
-
'type' => 'color',
|
1910 |
-
'key' => 'panel_third_level_font_color_hover'
|
1911 |
-
),
|
1912 |
-
array(
|
1913 |
-
'title' => __( "Weight", "megamenu" ),
|
1914 |
-
'type' => 'weight',
|
1915 |
-
'key' => 'panel_third_level_font_weight_hover'
|
1916 |
-
),
|
1917 |
-
array(
|
1918 |
-
'title' => __( "Decoration", "megamenu" ),
|
1919 |
-
'type' => 'decoration',
|
1920 |
-
'key' => 'panel_third_level_text_decoration_hover'
|
1921 |
-
),
|
1922 |
-
)
|
1923 |
-
),
|
1924 |
-
'third_level_background_hover' => array(
|
1925 |
-
'priority' => 220,
|
1926 |
-
'title' => __( "Item Background (Hover)", "megamenu" ),
|
1927 |
-
'description' => __( "Set the background hover color for third level menu items.", "megamenu" ),
|
1928 |
-
'settings' => array(
|
1929 |
-
array(
|
1930 |
-
'title' => __( "From", "megamenu" ),
|
1931 |
-
'type' => 'color',
|
1932 |
-
'key' => 'panel_third_level_background_hover_from'
|
1933 |
-
),
|
1934 |
-
array(
|
1935 |
-
'title' => __( "Copy", "megamenu" ),
|
1936 |
-
'type' => 'copy_color',
|
1937 |
-
'key' => 'copy_color'
|
1938 |
-
),
|
1939 |
-
array(
|
1940 |
-
'title' => __( "To", "megamenu" ),
|
1941 |
-
'type' => 'color',
|
1942 |
-
'key' => 'panel_third_level_background_hover_to'
|
1943 |
-
)
|
1944 |
-
)
|
1945 |
-
),
|
1946 |
-
'third_level_padding' => array(
|
1947 |
-
'priority' => 230,
|
1948 |
-
'title' => __( "Item Padding", "megamenu" ),
|
1949 |
-
'description' => __( "Set the padding for the third level menu items.", "megamenu" ),
|
1950 |
-
'settings' => array(
|
1951 |
-
array(
|
1952 |
-
'title' => __( "Top", "megamenu" ),
|
1953 |
-
'type' => 'freetext',
|
1954 |
-
'key' => 'panel_third_level_padding_top',
|
1955 |
-
'validation' => 'px'
|
1956 |
-
),
|
1957 |
-
array(
|
1958 |
-
'title' => __( "Right", "megamenu" ),
|
1959 |
-
'type' => 'freetext',
|
1960 |
-
'key' => 'panel_third_level_padding_right',
|
1961 |
-
'validation' => 'px'
|
1962 |
-
),
|
1963 |
-
array(
|
1964 |
-
'title' => __( "Bottom", "megamenu" ),
|
1965 |
-
'type' => 'freetext',
|
1966 |
-
'key' => 'panel_third_level_padding_bottom',
|
1967 |
-
'validation' => 'px'
|
1968 |
-
),
|
1969 |
-
array(
|
1970 |
-
'title' => __( "Left", "megamenu" ),
|
1971 |
-
'type' => 'freetext',
|
1972 |
-
'key' => 'panel_third_level_padding_left',
|
1973 |
-
'validation' => 'px'
|
1974 |
-
)
|
1975 |
-
)
|
1976 |
-
),
|
1977 |
-
|
1978 |
-
'third_level_margin' => array(
|
1979 |
-
'priority' => 235,
|
1980 |
-
'title' => __( "Item Margin", "megamenu" ),
|
1981 |
-
'description' => __( "Set the margin for the third level menu items.", "megamenu" ),
|
1982 |
-
'settings' => array(
|
1983 |
-
array(
|
1984 |
-
'title' => __( "Top", "megamenu" ),
|
1985 |
-
'type' => 'freetext',
|
1986 |
-
'key' => 'panel_third_level_margin_top',
|
1987 |
-
'validation' => 'px'
|
1988 |
-
),
|
1989 |
-
array(
|
1990 |
-
'title' => __( "Right", "megamenu" ),
|
1991 |
-
'type' => 'freetext',
|
1992 |
-
'key' => 'panel_third_level_margin_right',
|
1993 |
-
'validation' => 'px'
|
1994 |
-
),
|
1995 |
-
array(
|
1996 |
-
'title' => __( "Bottom", "megamenu" ),
|
1997 |
-
'type' => 'freetext',
|
1998 |
-
'key' => 'panel_third_level_margin_bottom',
|
1999 |
-
'validation' => 'px'
|
2000 |
-
),
|
2001 |
-
array(
|
2002 |
-
'title' => __( "Left", "megamenu" ),
|
2003 |
-
'type' => 'freetext',
|
2004 |
-
'key' => 'panel_third_level_margin_left',
|
2005 |
-
'validation' => 'px'
|
2006 |
-
)
|
2007 |
-
)
|
2008 |
-
),
|
2009 |
-
'third_level_border' => array(
|
2010 |
-
'priority' => 237,
|
2011 |
-
'title' => __( "Item Border", "megamenu" ),
|
2012 |
-
'description' => __( "Set the border for the third level menu items.", "megamenu" ),
|
2013 |
-
'settings' => array(
|
2014 |
-
array(
|
2015 |
-
'title' => __( "Color", "megamenu" ),
|
2016 |
-
'type' => 'color',
|
2017 |
-
'key' => 'panel_third_level_border_color'
|
2018 |
-
),
|
2019 |
-
array(
|
2020 |
-
'title' => __( "Color (Hover)", "megamenu" ),
|
2021 |
-
'type' => 'color',
|
2022 |
-
'key' => 'panel_third_level_border_color_hover'
|
2023 |
-
),
|
2024 |
-
array(
|
2025 |
-
'title' => __( "Top", "megamenu" ),
|
2026 |
-
'type' => 'freetext',
|
2027 |
-
'key' => 'panel_third_level_border_top',
|
2028 |
-
'validation' => 'px'
|
2029 |
-
),
|
2030 |
-
array(
|
2031 |
-
'title' => __( "Right", "megamenu" ),
|
2032 |
-
'type' => 'freetext',
|
2033 |
-
'key' => 'panel_third_level_border_right',
|
2034 |
-
'validation' => 'px'
|
2035 |
-
),
|
2036 |
-
array(
|
2037 |
-
'title' => __( "Bottom", "megamenu" ),
|
2038 |
-
'type' => 'freetext',
|
2039 |
-
'key' => 'panel_third_level_border_bottom',
|
2040 |
-
'validation' => 'px'
|
2041 |
-
),
|
2042 |
-
array(
|
2043 |
-
'title' => __( "Left", "megamenu" ),
|
2044 |
-
'type' => 'freetext',
|
2045 |
-
'key' => 'panel_third_level_border_left',
|
2046 |
-
'validation' => 'px'
|
2047 |
-
)
|
2048 |
-
)
|
2049 |
-
),
|
2050 |
-
)
|
2051 |
-
),
|
2052 |
-
'flyout_menus' => array(
|
2053 |
-
'title' => __( "Flyout Menus", "megamenu"),
|
2054 |
-
'settings' => array(
|
2055 |
-
'flyout_menu_background' => array(
|
2056 |
-
'priority' => 10,
|
2057 |
-
'title' => __( "Sub Menu Background", "megamenu" ),
|
2058 |
-
'description' => __( "Set the background color for the flyout menu.", "megamenu" ),
|
2059 |
-
'settings' => array(
|
2060 |
-
array(
|
2061 |
-
'title' => __( "From", "megamenu" ),
|
2062 |
-
'type' => 'color',
|
2063 |
-
'key' => 'flyout_menu_background_from'
|
2064 |
-
),
|
2065 |
-
array(
|
2066 |
-
'title' => __( "Copy", "megamenu" ),
|
2067 |
-
'type' => 'copy_color',
|
2068 |
-
'key' => 'copy_color'
|
2069 |
-
),
|
2070 |
-
array(
|
2071 |
-
'title' => __( "To", "megamenu" ),
|
2072 |
-
'type' => 'color',
|
2073 |
-
'key' => 'flyout_menu_background_to'
|
2074 |
-
)
|
2075 |
-
)
|
2076 |
-
),
|
2077 |
-
'flyout_menu_width' => array(
|
2078 |
-
'priority' => 20,
|
2079 |
-
'title' => __( "Sub Menu Width", "megamenu" ),
|
2080 |
-
'description' => __( "The width of each flyout menu. This must be a fixed pixel value.", "megamenu" ),
|
2081 |
-
'info' => array(
|
2082 |
-
__( "Set this value to the width of your longest menu item title to stop menu items wrapping onto 2 lines.", "megamenu" ),
|
2083 |
-
__( "Experimental: Set this value to 'auto' to use a flexible width.", "megamenu" )
|
2084 |
-
),
|
2085 |
-
'settings' => array(
|
2086 |
-
array(
|
2087 |
-
'title' => "",
|
2088 |
-
'type' => 'freetext',
|
2089 |
-
'key' => 'flyout_width',
|
2090 |
-
'validation' => 'px'
|
2091 |
-
)
|
2092 |
-
)
|
2093 |
-
),
|
2094 |
-
'flyout_menu_padding' => array(
|
2095 |
-
'priority' => 30,
|
2096 |
-
'title' => __( "Sub Menu Padding", "megamenu" ),
|
2097 |
-
'description' => __( "Set the padding for the whole flyout menu.", "megamenu" ),
|
2098 |
-
'info' => array( __( "Only suitable for single level flyout menus. If you're using multi level flyout menus set these values to 0px.", "megamenu" ) ),
|
2099 |
-
'settings' => array(
|
2100 |
-
array(
|
2101 |
-
'title' => __( "Top", "megamenu" ),
|
2102 |
-
'type' => 'freetext',
|
2103 |
-
'key' => 'flyout_padding_top',
|
2104 |
-
'validation' => 'px'
|
2105 |
-
),
|
2106 |
-
array(
|
2107 |
-
'title' => __( "Right", "megamenu" ),
|
2108 |
-
'type' => 'freetext',
|
2109 |
-
'key' => 'flyout_padding_right',
|
2110 |
-
'validation' => 'px'
|
2111 |
-
),
|
2112 |
-
array(
|
2113 |
-
'title' => __( "Bottom", "megamenu" ),
|
2114 |
-
'type' => 'freetext',
|
2115 |
-
'key' => 'flyout_padding_bottom',
|
2116 |
-
'validation' => 'px'
|
2117 |
-
),
|
2118 |
-
array(
|
2119 |
-
'title' => __( "Left", "megamenu" ),
|
2120 |
-
'type' => 'freetext',
|
2121 |
-
'key' => 'flyout_padding_left',
|
2122 |
-
'validation' => 'px'
|
2123 |
-
)
|
2124 |
-
)
|
2125 |
-
),
|
2126 |
-
'flyout_menu_border' => array(
|
2127 |
-
'priority' => 40,
|
2128 |
-
'title' => __( "Sub Menu Border", "megamenu" ),
|
2129 |
-
'description' => __( "Set the border for the flyout menu.", "megamenu" ),
|
2130 |
-
'settings' => array(
|
2131 |
-
array(
|
2132 |
-
'title' => __( "Color", "megamenu" ),
|
2133 |
-
'type' => 'color',
|
2134 |
-
'key' => 'flyout_border_color'
|
2135 |
-
),
|
2136 |
-
array(
|
2137 |
-
'title' => __( "Top", "megamenu" ),
|
2138 |
-
'type' => 'freetext',
|
2139 |
-
'key' => 'flyout_border_top',
|
2140 |
-
'validation' => 'px'
|
2141 |
-
),
|
2142 |
-
array(
|
2143 |
-
'title' => __( "Right", "megamenu" ),
|
2144 |
-
'type' => 'freetext',
|
2145 |
-
'key' => 'flyout_border_right',
|
2146 |
-
'validation' => 'px'
|
2147 |
-
),
|
2148 |
-
array(
|
2149 |
-
'title' => __( "Bottom", "megamenu" ),
|
2150 |
-
'type' => 'freetext',
|
2151 |
-
'key' => 'flyout_border_bottom',
|
2152 |
-
'validation' => 'px'
|
2153 |
-
),
|
2154 |
-
array(
|
2155 |
-
'title' => __( "Left", "megamenu" ),
|
2156 |
-
'type' => 'freetext',
|
2157 |
-
'key' => 'flyout_border_left',
|
2158 |
-
'validation' => 'px'
|
2159 |
-
)
|
2160 |
-
)
|
2161 |
-
),
|
2162 |
-
'flyout_menu_border_radius' => array(
|
2163 |
-
'priority' => 50,
|
2164 |
-
'title' => __( "Sub Menu Border Radius", "megamenu" ),
|
2165 |
-
'description' => __( "Set rounded corners for flyout menus. Rounded corners will be applied to all flyout menu levels.", "megamenu" ),
|
2166 |
-
'settings' => array(
|
2167 |
-
array(
|
2168 |
-
'title' => __( "Top Left", "megamenu" ),
|
2169 |
-
'type' => 'freetext',
|
2170 |
-
'key' => 'flyout_border_radius_top_left',
|
2171 |
-
'validation' => 'px'
|
2172 |
-
),
|
2173 |
-
array(
|
2174 |
-
'title' => __( "Top Right", "megamenu" ),
|
2175 |
-
'type' => 'freetext',
|
2176 |
-
'key' => 'flyout_border_radius_top_right',
|
2177 |
-
'validation' => 'px'
|
2178 |
-
),
|
2179 |
-
array(
|
2180 |
-
'title' => __( "Bottom Right", "megamenu" ),
|
2181 |
-
'type' => 'freetext',
|
2182 |
-
'key' => 'flyout_border_radius_bottom_right',
|
2183 |
-
'validation' => 'px'
|
2184 |
-
),
|
2185 |
-
array(
|
2186 |
-
'title' => __( "Bottom Left", "megamenu" ),
|
2187 |
-
'type' => 'freetext',
|
2188 |
-
'key' => 'flyout_border_radius_bottom_left',
|
2189 |
-
'validation' => 'px'
|
2190 |
-
)
|
2191 |
-
)
|
2192 |
-
),
|
2193 |
-
'flyout_menu_item_background' => array(
|
2194 |
-
'priority' => 60,
|
2195 |
-
'title' => __( "Menu Item Background", "megamenu" ),
|
2196 |
-
'description' => __( "Set the background color for a flyout menu item.", "megamenu" ),
|
2197 |
-
'settings' => array(
|
2198 |
-
array(
|
2199 |
-
'title' => __( "From", "megamenu" ),
|
2200 |
-
'type' => 'color',
|
2201 |
-
'key' => 'flyout_background_from'
|
2202 |
-
),
|
2203 |
-
array(
|
2204 |
-
'title' => __( "Copy", "megamenu" ),
|
2205 |
-
'type' => 'copy_color',
|
2206 |
-
'key' => 'copy_color'
|
2207 |
-
),
|
2208 |
-
array(
|
2209 |
-
'title' => __( "To", "megamenu" ),
|
2210 |
-
'type' => 'color',
|
2211 |
-
'key' => 'flyout_background_to'
|
2212 |
-
)
|
2213 |
-
)
|
2214 |
-
),
|
2215 |
-
'flyout_menu_item_background_hover' => array(
|
2216 |
-
'priority' => 70,
|
2217 |
-
'title' => __( "Menu Item Background (Hover)", "megamenu" ),
|
2218 |
-
'description' => __( "Set the background color for a flyout menu item (on hover).", "megamenu" ),
|
2219 |
-
'settings' => array(
|
2220 |
-
array(
|
2221 |
-
'title' => __( "From", "megamenu" ),
|
2222 |
-
'type' => 'color',
|
2223 |
-
'key' => 'flyout_background_hover_from'
|
2224 |
-
),
|
2225 |
-
array(
|
2226 |
-
'title' => __( "Copy", "megamenu" ),
|
2227 |
-
'type' => 'copy_color',
|
2228 |
-
'key' => 'copy_color'
|
2229 |
-
),
|
2230 |
-
array(
|
2231 |
-
'title' => __( "To", "megamenu" ),
|
2232 |
-
'type' => 'color',
|
2233 |
-
'key' => 'flyout_background_hover_to'
|
2234 |
-
)
|
2235 |
-
)
|
2236 |
-
),
|
2237 |
-
'flyout_menu_item_height' => array(
|
2238 |
-
'priority' => 80,
|
2239 |
-
'title' => __( "Menu Item Height", "megamenu" ),
|
2240 |
-
'description' => __( "The height of each flyout menu item.", "megamenu" ),
|
2241 |
-
'settings' => array(
|
2242 |
-
array(
|
2243 |
-
'title' => "",
|
2244 |
-
'type' => 'freetext',
|
2245 |
-
'key' => 'flyout_link_height',
|
2246 |
-
'validation' => 'px'
|
2247 |
-
)
|
2248 |
-
)
|
2249 |
-
),
|
2250 |
-
'flyout_menu_item_padding' => array(
|
2251 |
-
'priority' => 90,
|
2252 |
-
'title' => __( "Menu Item Padding", "megamenu" ),
|
2253 |
-
'description' => __( "Set the padding for each flyout menu item.", "megamenu" ),
|
2254 |
-
'settings' => array(
|
2255 |
-
array(
|
2256 |
-
'title' => __( "Top", "megamenu" ),
|
2257 |
-
'type' => 'freetext',
|
2258 |
-
'key' => 'flyout_link_padding_top',
|
2259 |
-
'validation' => 'px'
|
2260 |
-
),
|
2261 |
-
array(
|
2262 |
-
'title' => __( "Right", "megamenu" ),
|
2263 |
-
'type' => 'freetext',
|
2264 |
-
'key' => 'flyout_link_padding_right',
|
2265 |
-
'validation' => 'px'
|
2266 |
-
),
|
2267 |
-
array(
|
2268 |
-
'title' => __( "Bottom", "megamenu" ),
|
2269 |
-
'type' => 'freetext',
|
2270 |
-
'key' => 'flyout_link_padding_bottom',
|
2271 |
-
'validation' => 'px'
|
2272 |
-
),
|
2273 |
-
array(
|
2274 |
-
'title' => __( "Left", "megamenu" ),
|
2275 |
-
'type' => 'freetext',
|
2276 |
-
'key' => 'flyout_link_padding_left',
|
2277 |
-
'validation' => 'px'
|
2278 |
-
)
|
2279 |
-
)
|
2280 |
-
),
|
2281 |
-
'flyout_menu_item_font' => array(
|
2282 |
-
'priority' => 100,
|
2283 |
-
'title' => __( "Menu Item Font", "megamenu" ),
|
2284 |
-
'description' => __( "Set the font for the flyout menu items.", "megamenu" ),
|
2285 |
-
'settings' => array(
|
2286 |
-
array(
|
2287 |
-
'title' => __( "Color", "megamenu" ),
|
2288 |
-
'type' => 'color',
|
2289 |
-
'key' => 'flyout_link_color'
|
2290 |
-
),
|
2291 |
-
array(
|
2292 |
-
'title' => __( "Size", "megamenu" ),
|
2293 |
-
'type' => 'freetext',
|
2294 |
-
'key' => 'flyout_link_size',
|
2295 |
-
'validation' => 'px'
|
2296 |
-
),
|
2297 |
-
array(
|
2298 |
-
'title' => __( "Family", "megamenu" ),
|
2299 |
-
'type' => 'font',
|
2300 |
-
'key' => 'flyout_link_family'
|
2301 |
-
),
|
2302 |
-
array(
|
2303 |
-
'title' => __( "Transform", "megamenu" ),
|
2304 |
-
'type' => 'transform',
|
2305 |
-
'key' => 'flyout_link_text_transform'
|
2306 |
-
),
|
2307 |
-
array(
|
2308 |
-
'title' => __( "Weight", "megamenu" ),
|
2309 |
-
'type' => 'weight',
|
2310 |
-
'key' => 'flyout_link_weight'
|
2311 |
-
),
|
2312 |
-
array(
|
2313 |
-
'title' => __( "Decoration", "megamenu" ),
|
2314 |
-
'type' => 'decoration',
|
2315 |
-
'key' => 'flyout_link_text_decoration'
|
2316 |
-
),
|
2317 |
-
)
|
2318 |
-
),
|
2319 |
-
'flyout_menu_item_font_hover' => array(
|
2320 |
-
'priority' => 110,
|
2321 |
-
'title' => __( "Menu Item Font (Hover)", "megamenu" ),
|
2322 |
-
'description' => __( "Set the font for the flyout menu items.", "megamenu" ),
|
2323 |
-
'settings' => array(
|
2324 |
-
array(
|
2325 |
-
'title' => __( "Color", "megamenu" ),
|
2326 |
-
'type' => 'color',
|
2327 |
-
'key' => 'flyout_link_color_hover'
|
2328 |
-
),
|
2329 |
-
array(
|
2330 |
-
'title' => __( "Weight", "megamenu" ),
|
2331 |
-
'type' => 'weight',
|
2332 |
-
'key' => 'flyout_link_weight_hover'
|
2333 |
-
),
|
2334 |
-
array(
|
2335 |
-
'title' => __( "Decoration", "megamenu" ),
|
2336 |
-
'type' => 'decoration',
|
2337 |
-
'key' => 'flyout_link_text_decoration_hover'
|
2338 |
-
),
|
2339 |
-
)
|
2340 |
-
),
|
2341 |
-
'flyout_menu_item_divider' => array(
|
2342 |
-
'priority' => 120,
|
2343 |
-
'title' => __( "Menu Item Divider", "megamenu" ),
|
2344 |
-
'description' => __( "Show a line divider below each menu item.", "megamenu" ),
|
2345 |
-
'settings' => array(
|
2346 |
-
array(
|
2347 |
-
'title' => __( "Enabled", "megamenu" ),
|
2348 |
-
'type' => 'checkbox',
|
2349 |
-
'key' => 'flyout_menu_item_divider'
|
2350 |
-
),
|
2351 |
-
array(
|
2352 |
-
'title' => __( "Color", "megamenu" ),
|
2353 |
-
'type' => 'color',
|
2354 |
-
'key' => 'flyout_menu_item_divider_color'
|
2355 |
-
)
|
2356 |
-
)
|
2357 |
-
),
|
2358 |
-
)
|
2359 |
-
),
|
2360 |
-
'mobile_menu' => array(
|
2361 |
-
'title' => __( "Mobile Menu", "megamenu" ),
|
2362 |
-
'settings' => array(
|
2363 |
-
'mobile_toggle_bar' => array(
|
2364 |
-
'priority' => 5,
|
2365 |
-
'title' => __( "Mobile Toggle Bar", "megamenu" ),
|
2366 |
-
'description' => '',
|
2367 |
-
),
|
2368 |
-
'toggle_bar_background' => array(
|
2369 |
-
'priority' => 20,
|
2370 |
-
'title' => __( "Toggle Bar Background", "megamenu" ),
|
2371 |
-
'description' => __( "Set the background color for the mobile menu toggle bar.", "megamenu" ),
|
2372 |
-
'info' => array(
|
2373 |
-
__("Don't forget to update the Menu toggle block text and icon color in the Toggle Bar Designer above!", "megamenu"),
|
2374 |
-
),
|
2375 |
-
'settings' => array(
|
2376 |
-
array(
|
2377 |
-
'title' => __( "From", "megamenu" ),
|
2378 |
-
'type' => 'color',
|
2379 |
-
'key' => 'toggle_background_from'
|
2380 |
-
),
|
2381 |
-
array(
|
2382 |
-
'title' => __( "Copy", "megamenu" ),
|
2383 |
-
'type' => 'copy_color',
|
2384 |
-
'key' => 'copy_color'
|
2385 |
-
),
|
2386 |
-
array(
|
2387 |
-
'title' => __( "To", "megamenu" ),
|
2388 |
-
'type' => 'color',
|
2389 |
-
'key' => 'toggle_background_to'
|
2390 |
-
)
|
2391 |
-
)
|
2392 |
-
),
|
2393 |
-
'toggle_bar_height' => array(
|
2394 |
-
'priority' => 25,
|
2395 |
-
'title' => __( "Toggle Bar Height", "megamenu" ),
|
2396 |
-
'description' => __( "Set the height of the mobile menu toggle bar.", "megamenu" ),
|
2397 |
-
'settings' => array(
|
2398 |
-
array(
|
2399 |
-
'title' => "",
|
2400 |
-
'type' => 'freetext',
|
2401 |
-
'key' => 'toggle_bar_height'
|
2402 |
-
)
|
2403 |
-
)
|
2404 |
-
),
|
2405 |
-
'toggle_bar_border_radius' => array(
|
2406 |
-
'priority' => 26,
|
2407 |
-
'title' => __( "Toggle Bar Border Radius", "megamenu" ),
|
2408 |
-
'description' => __( "Set a border radius on the mobile toggle bar.", "megamenu" ),
|
2409 |
-
'settings' => array(
|
2410 |
-
array(
|
2411 |
-
'title' => __( "Top Left", "megamenu" ),
|
2412 |
-
'type' => 'freetext',
|
2413 |
-
'key' => 'toggle_bar_border_radius_top_left',
|
2414 |
-
'validation' => 'px'
|
2415 |
-
),
|
2416 |
-
array(
|
2417 |
-
'title' => __( "Top Right", "megamenu" ),
|
2418 |
-
'type' => 'freetext',
|
2419 |
-
'key' => 'toggle_bar_border_radius_top_right',
|
2420 |
-
'validation' => 'px'
|
2421 |
-
),
|
2422 |
-
array(
|
2423 |
-
'title' => __( "Bottom Right", "megamenu" ),
|
2424 |
-
'type' => 'freetext',
|
2425 |
-
'key' => 'toggle_bar_border_radius_bottom_right',
|
2426 |
-
'validation' => 'px'
|
2427 |
-
),
|
2428 |
-
array(
|
2429 |
-
'title' => __( "Bottom Left", "megamenu" ),
|
2430 |
-
'type' => 'freetext',
|
2431 |
-
'key' => 'toggle_bar_border_radius_bottom_left',
|
2432 |
-
'validation' => 'px'
|
2433 |
-
)
|
2434 |
-
)
|
2435 |
-
),
|
2436 |
-
'disable_mobile_toggle' => array(
|
2437 |
-
'priority' => 28,
|
2438 |
-
'title' => __( "Disable Mobile Toggle Bar", "megamenu" ),
|
2439 |
-
'description' => __( "Hide the toggle bar and display the menu in it's open state by default.", "megamenu" ),
|
2440 |
-
'settings' => array(
|
2441 |
-
array(
|
2442 |
-
'title' => "",
|
2443 |
-
'type' => 'checkbox',
|
2444 |
-
'key' => 'disable_mobile_toggle'
|
2445 |
-
)
|
2446 |
-
)
|
2447 |
-
),
|
2448 |
-
'responsive_breakpoint' => array(
|
2449 |
-
'priority' => 3,
|
2450 |
-
'title' => __( "Responsive Breakpoint", "megamenu" ),
|
2451 |
-
'description' => __( "The menu will be converted to a mobile menu when the browser width is below this value.", "megamenu" ),
|
2452 |
-
'settings' => array(
|
2453 |
-
array(
|
2454 |
-
'title' => "",
|
2455 |
-
'type' => 'freetext',
|
2456 |
-
'key' => 'responsive_breakpoint',
|
2457 |
-
'validation' => 'px'
|
2458 |
-
)
|
2459 |
-
),
|
2460 |
-
),
|
2461 |
-
'responsive_breakpoint_disabled' => array(
|
2462 |
-
'priority' => 4,
|
2463 |
-
'title' => __( "The 'Responsive Breakpoint' option has been set to 0px. The desktop version of the menu will be displayed for all browsers (regardless of the browser width), so the following options are disabled.", "megamenu" ),
|
2464 |
-
'description' => '',
|
2465 |
-
),
|
2466 |
-
'mobile_toggle_disabled' => array(
|
2467 |
-
'priority' => 5,
|
2468 |
-
'title' => __( "The 'Disable Mobile Toggle Bar' option has been enabled. The following options are disabled as the mobile toggle bar will not be displayed.", "megamenu" ),
|
2469 |
-
'description' => '',
|
2470 |
-
),
|
2471 |
-
'mobile_top_level_menu_items' => array(
|
2472 |
-
'priority' => 33,
|
2473 |
-
'title' => __( "Mobile Sub Menu", "megamenu" ),
|
2474 |
-
'description' => '',
|
2475 |
-
),
|
2476 |
-
'mobile_menu_overlay' => array(
|
2477 |
-
'priority' => 34,
|
2478 |
-
'title' => __( "Overlay Content", "megamenu" ),
|
2479 |
-
'description' => __( "If enabled, the mobile sub menu will overlay the page content (instead of pushing the page content down)", "megamenu" ),
|
2480 |
-
'settings' => array(
|
2481 |
-
array(
|
2482 |
-
'title' => "",
|
2483 |
-
'type' => 'checkbox',
|
2484 |
-
'key' => 'mobile_menu_overlay'
|
2485 |
-
)
|
2486 |
-
)
|
2487 |
-
),
|
2488 |
-
'mobile_menu_force_width' => array(
|
2489 |
-
'priority' => 35,
|
2490 |
-
'title' => __( "Force Full Width", "megamenu" ),
|
2491 |
-
'description' => __( "If enabled, the mobile sub menu will match the width and position on the given page element (rather than being limited to the width of the toggle bar). For a full width sub menu, leave the 'Selector' value set to 'body'.", "megamenu" ),
|
2492 |
-
'settings' => array(
|
2493 |
-
array(
|
2494 |
-
'title' => "Enabled",
|
2495 |
-
'type' => 'checkbox',
|
2496 |
-
'key' => 'mobile_menu_force_width'
|
2497 |
-
),
|
2498 |
-
array(
|
2499 |
-
'title' => __( "Selector", "megamenu" ),
|
2500 |
-
'type' => 'freetext',
|
2501 |
-
'key' => 'mobile_menu_force_width_selector'
|
2502 |
-
),
|
2503 |
-
)
|
2504 |
-
),
|
2505 |
-
'mobile_menu_off_canvas_width' => array(
|
2506 |
-
'priority' => 36,
|
2507 |
-
'title' => __( "Off Canvas Width", "megamenu" ),
|
2508 |
-
'description' => __( "The width of the sub menu if the Mobile Effect is set to 'Slide Left' or 'Slide Right'. Must be specified in px.", "megamenu" ),
|
2509 |
-
'settings' => array(
|
2510 |
-
array(
|
2511 |
-
'title' => "",
|
2512 |
-
'type' => 'freetext',
|
2513 |
-
'key' => 'mobile_menu_off_canvas_width',
|
2514 |
-
'validation' => 'px'
|
2515 |
-
),
|
2516 |
-
)
|
2517 |
-
),
|
2518 |
-
'mobile_menu_item_height' => array(
|
2519 |
-
'priority' => 38,
|
2520 |
-
'title' => __( "Menu Item Height", "megamenu" ),
|
2521 |
-
'description' => __( "Height of each top level item in the mobile menu.", "megamenu" ),
|
2522 |
-
'settings' => array(
|
2523 |
-
array(
|
2524 |
-
'title' => "",
|
2525 |
-
'type' => 'freetext',
|
2526 |
-
'key' => 'mobile_menu_item_height'
|
2527 |
-
)
|
2528 |
-
)
|
2529 |
-
),
|
2530 |
-
'mobile_menu_padding' => array(
|
2531 |
-
'priority' => 39,
|
2532 |
-
'title' => __( "Menu Padding", "megamenu" ),
|
2533 |
-
'description' => __( "Padding for the mobile sub menu.", "megamenu" ),
|
2534 |
-
'settings' => array(
|
2535 |
-
array(
|
2536 |
-
'title' => __( "Top", "megamenu" ),
|
2537 |
-
'type' => 'freetext',
|
2538 |
-
'key' => 'mobile_menu_padding_top',
|
2539 |
-
'validation' => 'px'
|
2540 |
-
),
|
2541 |
-
array(
|
2542 |
-
'title' => __( "Right", "megamenu" ),
|
2543 |
-
'type' => 'freetext',
|
2544 |
-
'key' => 'mobile_menu_padding_right',
|
2545 |
-
'validation' => 'px'
|
2546 |
-
),
|
2547 |
-
array(
|
2548 |
-
'title' => __( "Bottom", "megamenu" ),
|
2549 |
-
'type' => 'freetext',
|
2550 |
-
'key' => 'mobile_menu_padding_bottom',
|
2551 |
-
'validation' => 'px'
|
2552 |
-
),
|
2553 |
-
array(
|
2554 |
-
'title' => __( "Left", "megamenu" ),
|
2555 |
-
'type' => 'freetext',
|
2556 |
-
'key' => 'mobile_menu_padding_left',
|
2557 |
-
'validation' => 'px'
|
2558 |
-
)
|
2559 |
-
)
|
2560 |
-
),
|
2561 |
-
'mobile_background' => array(
|
2562 |
-
'priority' => 40,
|
2563 |
-
'title' => __( "Menu Background", "megamenu" ),
|
2564 |
-
'description' => __( "The background color for the mobile menu.", "megamenu" ),
|
2565 |
-
'settings' => array(
|
2566 |
-
array(
|
2567 |
-
'title' => __( "From", "megamenu" ),
|
2568 |
-
'type' => 'color',
|
2569 |
-
'key' => 'mobile_background_from'
|
2570 |
-
),
|
2571 |
-
array(
|
2572 |
-
'title' => __( "Copy", "megamenu" ),
|
2573 |
-
'type' => 'copy_color',
|
2574 |
-
'key' => 'copy_color'
|
2575 |
-
),
|
2576 |
-
array(
|
2577 |
-
'title' => __( "To", "megamenu" ),
|
2578 |
-
'type' => 'color',
|
2579 |
-
'key' => 'mobile_background_to'
|
2580 |
-
)
|
2581 |
-
)
|
2582 |
-
),
|
2583 |
-
'mobile_background_hover' => array(
|
2584 |
-
'priority' => 45,
|
2585 |
-
'title' => __( "Menu Item Background (Active)", "megamenu" ),
|
2586 |
-
'description' => __( "The background color for each top level menu item in the mobile menu when the sub menu is open.", "megamenu" ),
|
2587 |
-
'settings' => array(
|
2588 |
-
array(
|
2589 |
-
'title' => __( "From", "megamenu" ),
|
2590 |
-
'type' => 'color',
|
2591 |
-
'key' => 'mobile_menu_item_background_hover_from'
|
2592 |
-
),
|
2593 |
-
array(
|
2594 |
-
'title' => __( "Copy", "megamenu" ),
|
2595 |
-
'type' => 'copy_color',
|
2596 |
-
'key' => 'copy_color'
|
2597 |
-
),
|
2598 |
-
array(
|
2599 |
-
'title' => __( "To", "megamenu" ),
|
2600 |
-
'type' => 'color',
|
2601 |
-
'key' => 'mobile_menu_item_background_hover_to'
|
2602 |
-
)
|
2603 |
-
)
|
2604 |
-
),
|
2605 |
-
'mobile_menu_item_font' => array(
|
2606 |
-
'priority' => 50,
|
2607 |
-
'title' => __( "Font", "megamenu" ),
|
2608 |
-
'description' => __( "The font to use for each top level menu item in the mobile menu.", "megamenu" ),
|
2609 |
-
'settings' => array(
|
2610 |
-
array(
|
2611 |
-
'title' => __( "Color", "megamenu" ),
|
2612 |
-
'type' => 'color',
|
2613 |
-
'key' => 'mobile_menu_item_link_color'
|
2614 |
-
),
|
2615 |
-
array(
|
2616 |
-
'title' => __( "Size", "megamenu" ),
|
2617 |
-
'type' => 'freetext',
|
2618 |
-
'key' => 'mobile_menu_item_link_font_size',
|
2619 |
-
'validation' => 'px'
|
2620 |
-
),
|
2621 |
-
array(
|
2622 |
-
'title' => __( "Align", "megamenu" ),
|
2623 |
-
'type' => 'align',
|
2624 |
-
'key' => 'mobile_menu_item_link_text_align'
|
2625 |
-
),
|
2626 |
-
)
|
2627 |
-
),
|
2628 |
-
'mobile_menu_item_font_hover' => array(
|
2629 |
-
'priority' => 55,
|
2630 |
-
'title' => __( "Font (Active)", "megamenu" ),
|
2631 |
-
'description' => __( "The font color for each top level menu item in the mobile menu when the sub menu is open.", "megamenu" ),
|
2632 |
-
'settings' => array(
|
2633 |
-
array(
|
2634 |
-
'title' => __( "Color", "megamenu" ),
|
2635 |
-
'type' => 'color',
|
2636 |
-
'key' => 'mobile_menu_item_link_color_hover'
|
2637 |
-
)
|
2638 |
-
)
|
2639 |
-
),
|
2640 |
-
'mobile_mega_menus' => array(
|
2641 |
-
'priority' => 60,
|
2642 |
-
'title' => __( "Mega Menus", "megamenu" ),
|
2643 |
-
'description' => '',
|
2644 |
-
),
|
2645 |
-
'mobile_columns' => array(
|
2646 |
-
'priority' => 65,
|
2647 |
-
'title' => __( "Mega Menu Columns", "megamenu" ),
|
2648 |
-
'description' => __( "Collapse mega menu content into this many columns on mobile.", "megamenu" ),
|
2649 |
-
'settings' => array(
|
2650 |
-
array(
|
2651 |
-
'title' => "",
|
2652 |
-
'type' => 'mobile_columns',
|
2653 |
-
'key' => 'mobile_columns'
|
2654 |
-
)
|
2655 |
-
)
|
2656 |
-
)
|
2657 |
-
)
|
2658 |
-
),
|
2659 |
-
'custom_styling' => array(
|
2660 |
-
'title' => __( "Custom Styling", "megamenu"),
|
2661 |
-
'settings' => array(
|
2662 |
-
'custom_styling' => array(
|
2663 |
-
'priority' => 40,
|
2664 |
-
'title' => __( "CSS Editor", "megamenu" ),
|
2665 |
-
'description' => __( "Define any custom CSS you wish to add to menus using this theme. You can use standard CSS or SCSS.", "megamenu"),
|
2666 |
-
'settings' => array(
|
2667 |
-
array(
|
2668 |
-
'title' => "",
|
2669 |
-
'type' => 'textarea',
|
2670 |
-
'key' => 'custom_css'
|
2671 |
-
)
|
2672 |
-
)
|
2673 |
-
)
|
2674 |
-
)
|
2675 |
-
)
|
2676 |
-
) );
|
2677 |
-
|
2678 |
-
echo "<h2 class='nav-tab-wrapper'>";
|
2679 |
-
|
2680 |
-
$is_first = true;
|
2681 |
-
|
2682 |
-
foreach ( $settings as $section_id => $section ) {
|
2683 |
-
|
2684 |
-
if ($is_first) {
|
2685 |
-
$active = 'nav-tab-active ';
|
2686 |
-
$is_first = false;
|
2687 |
-
} else {
|
2688 |
-
$active = '';
|
2689 |
-
}
|
2690 |
-
|
2691 |
-
echo "<a class='mega-tab nav-tab {$active}' data-tab='mega-tab-content-{$section_id}'>".$section['title'] . "</a>";
|
2692 |
-
|
2693 |
-
}
|
2694 |
-
|
2695 |
-
echo "</h2>";
|
2696 |
-
|
2697 |
-
$is_first = true;
|
2698 |
-
|
2699 |
-
foreach ( $settings as $section_id => $section ) {
|
2700 |
-
|
2701 |
-
if ($is_first) {
|
2702 |
-
$display = 'block';
|
2703 |
-
$is_first = false;
|
2704 |
-
} else {
|
2705 |
-
$display = 'none';
|
2706 |
-
}
|
2707 |
-
|
2708 |
-
echo " <div class='mega-tab-content mega-tab-content-{$section_id}' style='display: {$display}'>";
|
2709 |
-
echo " <table class='{$section_id}'>";
|
2710 |
-
|
2711 |
-
// order the fields by priority
|
2712 |
-
uasort( $section['settings'], array( $this, "compare_elems" ) );
|
2713 |
-
|
2714 |
-
foreach ( $section['settings'] as $group_id => $group ) {
|
2715 |
-
|
2716 |
-
echo "<tr class='mega-{$group_id}'>";
|
2717 |
-
|
2718 |
-
if ( isset( $group['settings'] ) ) {
|
2719 |
-
|
2720 |
-
echo "<td class='mega-name'>" . $group['title'] . "<div class='mega-description'>" . $group['description'] . "</div></td>";
|
2721 |
-
echo "<td class='mega-value'>";
|
2722 |
-
|
2723 |
-
foreach ( $group['settings'] as $setting_id => $setting ) {
|
2724 |
-
|
2725 |
-
if ( isset( $setting['validation'] ) ) {
|
2726 |
-
echo "<label class='mega-{$setting['key']}' data-validation='{$setting['validation']}'>";
|
2727 |
-
} else {
|
2728 |
-
echo "<label class='mega-{$setting['key']}'>";
|
2729 |
-
}
|
2730 |
-
echo "<span class='mega-short-desc'>{$setting['title']}</span>";
|
2731 |
-
|
2732 |
-
switch ( $setting['type'] ) {
|
2733 |
-
case "freetext":
|
2734 |
-
$this->print_theme_freetext_option( $setting['key'] );
|
2735 |
-
break;
|
2736 |
-
case "textarea":
|
2737 |
-
$this->print_theme_textarea_option( $setting['key'] );
|
2738 |
-
break;
|
2739 |
-
case "align":
|
2740 |
-
$this->print_theme_align_option( $setting['key'] );
|
2741 |
-
break;
|
2742 |
-
case "checkbox":
|
2743 |
-
$this->print_theme_checkbox_option( $setting['key'] );
|
2744 |
-
break;
|
2745 |
-
case "arrow":
|
2746 |
-
$this->print_theme_arrow_option( $setting['key'] );
|
2747 |
-
break;
|
2748 |
-
case "color":
|
2749 |
-
$this->print_theme_color_option( $setting['key'] );
|
2750 |
-
break;
|
2751 |
-
case "weight":
|
2752 |
-
$this->print_theme_weight_option( $setting['key'] );
|
2753 |
-
break;
|
2754 |
-
case "font":
|
2755 |
-
$this->print_theme_font_option( $setting['key'] );
|
2756 |
-
break;
|
2757 |
-
case "transform":
|
2758 |
-
$this->print_theme_transform_option( $setting['key'] );
|
2759 |
-
break;
|
2760 |
-
case "decoration":
|
2761 |
-
$this->print_theme_text_decoration_option( $setting['key'] );
|
2762 |
-
break;
|
2763 |
-
case "mobile_columns":
|
2764 |
-
$this->print_theme_mobile_columns_option( $setting['key'] );
|
2765 |
-
break;
|
2766 |
-
case "copy_color":
|
2767 |
-
$this->print_theme_copy_color_option( $setting['key'] );
|
2768 |
-
break;
|
2769 |
-
default:
|
2770 |
-
do_action("megamenu_print_theme_option_{$setting['type']}", $setting['key'], $this->id );
|
2771 |
-
break;
|
2772 |
-
}
|
2773 |
-
|
2774 |
-
echo "</label>";
|
2775 |
-
|
2776 |
-
}
|
2777 |
-
|
2778 |
-
if ( isset( $group['info'] ) ) {
|
2779 |
-
foreach ( $group['info'] as $paragraph ) {
|
2780 |
-
echo "<div class='mega-info'>{$paragraph}</div>";
|
2781 |
-
}
|
2782 |
-
}
|
2783 |
-
|
2784 |
-
foreach ( $group['settings'] as $setting_id => $setting ) {
|
2785 |
-
if ( isset( $setting['validation'] ) ) {
|
2786 |
-
|
2787 |
-
echo "<div class='mega-validation-message mega-validation-message-mega-{$setting['key']}'>";
|
2788 |
-
|
2789 |
-
if ( $setting['validation'] == 'int' ) {
|
2790 |
-
$message = __("Enter a whole number (e.g. 1, 5, 100, 999)");
|
2791 |
-
}
|
2792 |
-
|
2793 |
-
if ( $setting['validation'] == 'px' ) {
|
2794 |
-
$message = __("Enter a value including a unit (e.g. 10px, 10rem, 10%)");
|
2795 |
-
}
|
2796 |
-
|
2797 |
-
if ( $setting['validation'] == 'float' ) {
|
2798 |
-
$message = __("Enter a valid number (e.g. 0.1, 1, 10, 999)");
|
2799 |
-
}
|
2800 |
-
|
2801 |
-
if ( strlen( $setting['title'] ) ) {
|
2802 |
-
echo $setting['title'] . ": " . $message;
|
2803 |
-
} else {
|
2804 |
-
echo $message;
|
2805 |
-
}
|
2806 |
-
|
2807 |
-
echo "</div>";
|
2808 |
-
}
|
2809 |
-
}
|
2810 |
-
|
2811 |
-
echo "</td>";
|
2812 |
-
} else {
|
2813 |
-
echo "<td colspan='2'><h5>{$group['title']}</h5></td>";
|
2814 |
-
}
|
2815 |
-
|
2816 |
-
echo "</tr>";
|
2817 |
-
|
2818 |
-
}
|
2819 |
-
|
2820 |
-
echo "</table>";
|
2821 |
-
echo "</div>";
|
2822 |
-
}
|
2823 |
-
|
2824 |
-
?>
|
2825 |
-
|
2826 |
-
|
2827 |
-
<div class='megamenu_submit'>
|
2828 |
-
<div class='mega_left'>
|
2829 |
-
<?php submit_button(); ?>
|
2830 |
-
</div>
|
2831 |
-
<div class='mega_right'>
|
2832 |
-
</div>
|
2833 |
-
</div>
|
2834 |
-
|
2835 |
-
<?php $this->show_cache_warning(); ?>
|
2836 |
-
</form>
|
2837 |
-
</div>
|
2838 |
-
|
2839 |
-
<?php
|
2840 |
-
|
2841 |
-
}
|
2842 |
-
|
2843 |
-
|
2844 |
-
/**
|
2845 |
-
* Check for installed caching/minification/CDN plugins and output a warning if one is found to be
|
2846 |
-
* installed and activated
|
2847 |
-
*/
|
2848 |
-
private function show_cache_warning() {
|
2849 |
-
|
2850 |
-
$active_plugins = max_mega_menu_get_active_caching_plugins();
|
2851 |
-
|
2852 |
-
if ( count( $active_plugins ) ):
|
2853 |
-
|
2854 |
-
?>
|
2855 |
-
|
2856 |
-
<hr />
|
2857 |
-
|
2858 |
-
<div>
|
2859 |
-
|
2860 |
-
<h3><?php _e("Changes not showing up?", "megamenu"); ?></h3>
|
2861 |
-
|
2862 |
-
<p><?php echo _n("We have detected the following plugin that may prevent changes made within the theme editor from being applied to the menu.", "We have detected the following plugins that may prevent changes made within the theme editor from being applied to the menu.", count( $active_plugins), "megamenu"); ?></p>
|
2863 |
-
|
2864 |
-
<ul class='ul-disc'>
|
2865 |
-
<?php
|
2866 |
-
foreach ( $active_plugins as $name ) {
|
2867 |
-
echo "<li>" . $name . "</li>";
|
2868 |
-
}
|
2869 |
-
?>
|
2870 |
-
</ul>
|
2871 |
-
|
2872 |
-
<p><?php echo _n("Try clearing the cache of the above plugin if your changes are not being applied to the menu.", "Try clearing the caches of the above plugins if your changes are not being applied to the menu.", count( $active_plugins), "megamenu"); ?></p>
|
2873 |
-
|
2874 |
-
</div>
|
2875 |
-
|
2876 |
-
<?php
|
2877 |
-
|
2878 |
-
endif;
|
2879 |
-
}
|
2880 |
-
|
2881 |
-
|
2882 |
-
/**
|
2883 |
-
* Compare array values
|
2884 |
-
*
|
2885 |
-
* @param array $elem1
|
2886 |
-
* @param array $elem2
|
2887 |
-
* @return bool
|
2888 |
-
* @since 2.1
|
2889 |
-
*/
|
2890 |
-
private function compare_elems( $elem1, $elem2 ) {
|
2891 |
-
|
2892 |
-
return $elem1['priority'] > $elem2['priority'];
|
2893 |
-
|
2894 |
-
}
|
2895 |
-
|
2896 |
-
|
2897 |
-
/**
|
2898 |
-
* Print a select dropdown with left, center and right options
|
2899 |
-
*
|
2900 |
-
* @since 1.6.1
|
2901 |
-
* @param string $key
|
2902 |
-
* @param string $value
|
2903 |
-
*/
|
2904 |
-
public function print_theme_align_option( $key ) {
|
2905 |
-
|
2906 |
-
$value = $this->active_theme[$key];
|
2907 |
-
|
2908 |
-
?>
|
2909 |
-
|
2910 |
-
<select name='settings[<?php echo $key ?>]'>
|
2911 |
-
<option value='left' <?php selected( $value, 'left' ); ?>><?php _e("Left", "megamenu") ?></option>
|
2912 |
-
<option value='center' <?php selected( $value, 'center' ); ?>><?php _e("Center", "megamenu") ?></option>
|
2913 |
-
<option value='right' <?php selected( $value, 'right' ); ?>><?php _e("Right", "megamenu") ?></option>
|
2914 |
-
</select>
|
2915 |
-
|
2916 |
-
<?php
|
2917 |
-
}
|
2918 |
-
|
2919 |
-
|
2920 |
-
/**
|
2921 |
-
* Print a copy icon
|
2922 |
-
*
|
2923 |
-
* @since 2.2.3
|
2924 |
-
* @param string $key
|
2925 |
-
* @param string $value
|
2926 |
-
*/
|
2927 |
-
public function print_theme_copy_color_option( $key ) {
|
2928 |
-
|
2929 |
-
?>
|
2930 |
-
|
2931 |
-
<span class='dashicons dashicons-arrow-right-alt'></span>
|
2932 |
-
|
2933 |
-
<?php
|
2934 |
-
}
|
2935 |
-
|
2936 |
-
|
2937 |
-
/**
|
2938 |
-
* Print a select dropdown with 1 and 2 options
|
2939 |
-
*
|
2940 |
-
* @since 1.2.0
|
2941 |
-
* @param string $key
|
2942 |
-
* @param string $value
|
2943 |
-
*/
|
2944 |
-
public function print_theme_mobile_columns_option( $key ) {
|
2945 |
-
|
2946 |
-
$value = $this->active_theme[$key];
|
2947 |
-
|
2948 |
-
?>
|
2949 |
-
|
2950 |
-
<select name='settings[<?php echo $key ?>]'>
|
2951 |
-
<option value='1' <?php selected( $value, '1' ); ?>><?php _e("1 Column", "megamenu") ?></option>
|
2952 |
-
<option value='2' <?php selected( $value, '2' ); ?>><?php _e("2 Columns", "megamenu") ?></option>
|
2953 |
-
</select>
|
2954 |
-
|
2955 |
-
<?php
|
2956 |
-
}
|
2957 |
-
|
2958 |
-
|
2959 |
-
/**
|
2960 |
-
* Print a select dropdown with text decoration options
|
2961 |
-
*
|
2962 |
-
* @since 1.6.1
|
2963 |
-
* @param string $key
|
2964 |
-
* @param string $value
|
2965 |
-
*/
|
2966 |
-
public function print_theme_text_decoration_option( $key ) {
|
2967 |
-
|
2968 |
-
$value = $this->active_theme[$key];
|
2969 |
-
|
2970 |
-
?>
|
2971 |
-
|
2972 |
-
<select name='settings[<?php echo $key ?>]'>
|
2973 |
-
<option value='none' <?php selected( $value, 'none' ); ?>><?php _e("None", "megamenu") ?></option>
|
2974 |
-
<option value='underline' <?php selected( $value, 'underline' ); ?>><?php _e("Underline", "megamenu") ?></option>
|
2975 |
-
</select>
|
2976 |
-
|
2977 |
-
<?php
|
2978 |
-
}
|
2979 |
-
|
2980 |
-
|
2981 |
-
/**
|
2982 |
-
* Print a checkbox option
|
2983 |
-
*
|
2984 |
-
* @since 1.6.1
|
2985 |
-
* @param string $key
|
2986 |
-
* @param string $value
|
2987 |
-
*/
|
2988 |
-
public function print_theme_checkbox_option( $key ) {
|
2989 |
-
|
2990 |
-
$value = $this->active_theme[$key];
|
2991 |
-
|
2992 |
-
?>
|
2993 |
-
|
2994 |
-
<input type='hidden' name='checkboxes[<?php echo $key ?>]' />
|
2995 |
-
<input type='checkbox' name='settings[<?php echo $key ?>]' <?php checked( $value, 'on' ); ?> />
|
2996 |
-
|
2997 |
-
<?php
|
2998 |
-
}
|
2999 |
-
|
3000 |
-
|
3001 |
-
/**
|
3002 |
-
* Print an arrow dropdown selection box
|
3003 |
-
*
|
3004 |
-
* @since 1.0
|
3005 |
-
* @param string $key
|
3006 |
-
* @param string $value
|
3007 |
-
*/
|
3008 |
-
public function print_theme_arrow_option( $key ) {
|
3009 |
-
|
3010 |
-
$value = $this->active_theme[$key];
|
3011 |
-
|
3012 |
-
$arrow_icons = $this->arrow_icons();
|
3013 |
-
|
3014 |
-
?>
|
3015 |
-
<select class='icon_dropdown' name='settings[<?php echo $key ?>]'>
|
3016 |
-
<?php
|
3017 |
-
|
3018 |
-
echo "<option value='disabled'>" . __("Disabled", "megamenu") . "</option>";
|
3019 |
-
|
3020 |
-
foreach ($arrow_icons as $code => $class) {
|
3021 |
-
$name = str_replace('dashicons-', '', $class);
|
3022 |
-
$name = ucwords(str_replace(array('-','arrow'), ' ', $name));
|
3023 |
-
echo "<option data-class='{$class}' value='{$code}' " . selected( $value, $code, false ) . ">" . esc_html( $name ) . "</option>";
|
3024 |
-
}
|
3025 |
-
|
3026 |
-
?>
|
3027 |
-
</select>
|
3028 |
-
|
3029 |
-
<?php
|
3030 |
-
}
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
/**
|
3035 |
-
* Print a colorpicker
|
3036 |
-
*
|
3037 |
-
* @since 1.0
|
3038 |
-
* @param string $key
|
3039 |
-
* @param string $value
|
3040 |
-
*/
|
3041 |
-
public function print_theme_color_option( $key ) {
|
3042 |
-
|
3043 |
-
$value = $this->active_theme[$key];
|
3044 |
-
|
3045 |
-
if ( $value == 'transparent' ) {
|
3046 |
-
$value = 'rgba(0,0,0,0)';
|
3047 |
-
}
|
3048 |
-
|
3049 |
-
if ( $value == 'rgba(0,0,0,0)' ) {
|
3050 |
-
$value_text = 'transparent';
|
3051 |
-
} else {
|
3052 |
-
$value_text = $value;
|
3053 |
-
}
|
3054 |
-
|
3055 |
-
echo "<div class='mm-picker-container'>";
|
3056 |
-
echo " <input type='text' class='mm_colorpicker' name='settings[$key]' value='" . esc_attr( $value ) . "' />";
|
3057 |
-
echo " <div class='chosen-color'>" . esc_html( $value_text ) . "</div>";
|
3058 |
-
echo "</div>";
|
3059 |
-
|
3060 |
-
}
|
3061 |
-
|
3062 |
-
|
3063 |
-
/**
|
3064 |
-
* Print a font weight selector
|
3065 |
-
*
|
3066 |
-
* @since 1.0
|
3067 |
-
* @param string $key
|
3068 |
-
* @param string $value
|
3069 |
-
*/
|
3070 |
-
public function print_theme_weight_option( $key ) {
|
3071 |
-
|
3072 |
-
$value = $this->active_theme[$key];
|
3073 |
-
|
3074 |
-
$options = apply_filters( "megamenu_font_weights", array(
|
3075 |
-
'inherit' => __("Theme Default", "megamenu"),
|
3076 |
-
'300' => __("Light (300)", "megamenu"),
|
3077 |
-
'normal' => __("Normal (400)", "megamenu"),
|
3078 |
-
'bold' => __("Bold (700)", "megamenu"),
|
3079 |
-
) );
|
3080 |
-
|
3081 |
-
/**
|
3082 |
-
* '100' => __("Thin (100)", "megamenu"),
|
3083 |
-
* '200' => __("Extra Light (200)", "megamenu"),
|
3084 |
-
* '300' => __("Light (300)", "megamenu"),
|
3085 |
-
* 'normal' => __("Normal (400)", "megamenu"),
|
3086 |
-
* '500' => __("Medium (500)", "megamenu"),
|
3087 |
-
* '600' => __("Semi Bold (600)", "megamenu"),
|
3088 |
-
* 'bold' => __("Bold (700)", "megamenu"),
|
3089 |
-
* '800' => __("Extra Bold (800)", "megamenu"),
|
3090 |
-
* '900' => __("Black (900)", "megamenu")
|
3091 |
-
*/
|
3092 |
-
|
3093 |
-
echo "<select name='settings[$key]'>";
|
3094 |
-
|
3095 |
-
foreach ( $options as $weight => $name ) {
|
3096 |
-
echo "<option value='" . esc_attr( $weight ) . "' " . selected( $value, $weight, false ) . ">" . esc_html( $name ) . "</option>";
|
3097 |
-
}
|
3098 |
-
|
3099 |
-
echo "</select>";
|
3100 |
-
|
3101 |
-
}
|
3102 |
-
|
3103 |
-
|
3104 |
-
/**
|
3105 |
-
* Print a font transform selector
|
3106 |
-
*
|
3107 |
-
* @since 1.0
|
3108 |
-
* @param string $key
|
3109 |
-
* @param string $value
|
3110 |
-
*/
|
3111 |
-
public function print_theme_transform_option( $key ) {
|
3112 |
-
|
3113 |
-
$value = $this->active_theme[$key];
|
3114 |
-
|
3115 |
-
echo "<select name='settings[$key]'>";
|
3116 |
-
echo " <option value='none' " . selected( $value, 'none', false) . ">" . __("Normal", "megamenu") . "</option>";
|
3117 |
-
echo " <option value='capitalize'" . selected( $value, 'capitalize', false) . ">" . __("Capitalize", "megamenu") . "</option>";
|
3118 |
-
echo " <option value='uppercase'" . selected( $value, 'uppercase', false) . ">" . __("UPPERCASE", "megamenu") . "</option>";
|
3119 |
-
echo " <option value='lowercase'" . selected( $value, 'lowercase', false) . ">" . __("lowercase", "megamenu") . "</option>";
|
3120 |
-
echo "</select>";
|
3121 |
-
|
3122 |
-
}
|
3123 |
-
|
3124 |
-
|
3125 |
-
/**
|
3126 |
-
* Print a textarea
|
3127 |
-
*
|
3128 |
-
* @since 1.0
|
3129 |
-
* @param string $key
|
3130 |
-
* @param string $value
|
3131 |
-
*/
|
3132 |
-
public function print_theme_textarea_option( $key ) {
|
3133 |
-
|
3134 |
-
$value = sanitize_textarea_field( $this->active_theme[$key] );
|
3135 |
-
|
3136 |
-
?>
|
3137 |
-
|
3138 |
-
<textarea id='codemirror' name='settings[<?php echo $key ?>]'><?php echo stripslashes( $value ) ?></textarea>
|
3139 |
-
|
3140 |
-
<p><b><?php _e("Custom Styling Tips", "megamenu"); ?></b></p>
|
3141 |
-
<p><?php _e("You can enter standard CSS or <a href='https://sass-lang.com/guide' target='_blank'>SCSS</a> into the custom styling area. If using SCSS there are some variables and mixins you can use:"); ?></p>
|
3142 |
-
<ul class='custom_styling_tips'>
|
3143 |
-
<li><code>#{$wrap}</code> <?php _e("converts to the ID selector of the menu wrapper, e.g. div#mega-menu-wrap-primary", "megamenu"); ?></li>
|
3144 |
-
<li><code>#{$menu}</code> <?php _e("converts to the ID selector of the menu, e.g. ul#mega-menu-primary", "megamenu"); ?></li>
|
3145 |
-
<li><code>@include mobile|desktop { .. }</code> <?php _e("wraps the CSS within a media query based on the configured Responsive Breakpoint (see example CSS)", "megamenu"); ?></li>
|
3146 |
-
<?php
|
3147 |
-
$string = __("Using the %wrap% and %menu% variables makes your theme portable (allowing you to apply the same theme to multiple menu locations)", "megamenu");
|
3148 |
-
$string = str_replace('%wrap%', '<code>#{$wrap}</code>', $string);
|
3149 |
-
$string = str_replace('%menu%', '<code>#{$menu}</code>', $string);
|
3150 |
-
?>
|
3151 |
-
<li><?php echo $string; ?></li>
|
3152 |
-
<li>Example CSS:</li>
|
3153 |
-
<code>/** Add text shadow to top level menu items on desktop AND mobile **/
|
3154 |
-
<br />#{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
|
3155 |
-
<br /> text-shadow: 1px 1px #000000;
|
3156 |
-
<br />}
|
3157 |
-
</code>
|
3158 |
-
<br /><br />
|
3159 |
-
<code>/** Add text shadow to top level menu items on desktop only **/
|
3160 |
-
<br />@include desktop {
|
3161 |
-
<br /> #{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
|
3162 |
-
<br /> text-shadow: 1px 1px #000000;
|
3163 |
-
<br /> }
|
3164 |
-
<br />}
|
3165 |
-
</code></li>
|
3166 |
-
</ul>
|
3167 |
-
|
3168 |
-
<?php
|
3169 |
-
|
3170 |
-
}
|
3171 |
-
|
3172 |
-
|
3173 |
-
/**
|
3174 |
-
* Print a font selector
|
3175 |
-
*
|
3176 |
-
* @since 1.0
|
3177 |
-
* @param string $key
|
3178 |
-
* @param string $value
|
3179 |
-
*/
|
3180 |
-
public function print_theme_font_option( $key ) {
|
3181 |
-
|
3182 |
-
$value = $this->active_theme[$key];
|
3183 |
-
|
3184 |
-
echo "<select name='settings[$key]'>";
|
3185 |
-
|
3186 |
-
echo "<option value='inherit'>" . __("Theme Default", "megamenu") . "</option>";
|
3187 |
-
|
3188 |
-
foreach ( $this->fonts() as $font ) {
|
3189 |
-
$orig_font = $font;
|
3190 |
-
$font = esc_attr( stripslashes( $font ) );
|
3191 |
-
$parts = explode(",", $font);
|
3192 |
-
$font_name = trim($parts[0]);
|
3193 |
-
echo "<option value=\"{$font}\" " . selected( $orig_font, htmlspecialchars_decode( $value ) ) . ">" . esc_html( $font_name ) . "</option>";
|
3194 |
-
}
|
3195 |
-
|
3196 |
-
echo "</select>";
|
3197 |
-
}
|
3198 |
-
|
3199 |
-
|
3200 |
-
/**
|
3201 |
-
* Print a text input
|
3202 |
-
*
|
3203 |
-
* @since 1.0
|
3204 |
-
* @param string $key
|
3205 |
-
* @param string $value
|
3206 |
-
*/
|
3207 |
-
public function print_theme_freetext_option( $key ) {
|
3208 |
-
|
3209 |
-
$value = $this->active_theme[$key];
|
3210 |
-
|
3211 |
-
echo "<input class='mega-setting-{$key}' type='text' name='settings[$key]' value='" . esc_attr( $value ) . "' />";
|
3212 |
-
|
3213 |
-
}
|
3214 |
-
|
3215 |
-
|
3216 |
-
/**
|
3217 |
-
* Returns a list of available fonts.
|
3218 |
-
*
|
3219 |
-
* @since 1.0
|
3220 |
-
*/
|
3221 |
-
public function fonts() {
|
3222 |
-
|
3223 |
-
$fonts = array(
|
3224 |
-
"Georgia, serif",
|
3225 |
-
"Palatino Linotype, Book Antiqua, Palatino, serif",
|
3226 |
-
"Times New Roman, Times, serif",
|
3227 |
-
"Arial, Helvetica, sans-serif",
|
3228 |
-
"Arial Black, Gadget, sans-serif",
|
3229 |
-
"Comic Sans MS, cursive, sans-serif",
|
3230 |
-
"Impact, Charcoal, sans-serif",
|
3231 |
-
"Lucida Sans Unicode, Lucida Grande, sans-serif",
|
3232 |
-
"Tahoma, Geneva, sans-serif",
|
3233 |
-
"Trebuchet MS, Helvetica, sans-serif",
|
3234 |
-
"Verdana, Geneva, sans-serif",
|
3235 |
-
"Courier New, Courier, monospace",
|
3236 |
-
"Lucida Console, Monaco, monospace"
|
3237 |
-
);
|
3238 |
-
|
3239 |
-
$fonts = apply_filters( "megamenu_fonts", $fonts );
|
3240 |
-
|
3241 |
-
return $fonts;
|
3242 |
-
|
3243 |
-
}
|
3244 |
-
|
3245 |
-
|
3246 |
-
/**
|
3247 |
-
* List of all available arrow DashIcon classes.
|
3248 |
-
*
|
3249 |
-
* @since 1.0
|
3250 |
-
* @return array - Sorted list of icon classes
|
3251 |
-
*/
|
3252 |
-
private function arrow_icons() {
|
3253 |
-
|
3254 |
-
$icons = array(
|
3255 |
-
'dash-f142' => 'dashicons-arrow-up',
|
3256 |
-
'dash-f140' => 'dashicons-arrow-down',
|
3257 |
-
'dash-f141' => 'dashicons-arrow-left',
|
3258 |
-
'dash-f139' => 'dashicons-arrow-right',
|
3259 |
-
'dash-f342' => 'dashicons-arrow-up-alt',
|
3260 |
-
'dash-f346' => 'dashicons-arrow-down-alt',
|
3261 |
-
'dash-f340' => 'dashicons-arrow-left-alt',
|
3262 |
-
'dash-f344' => 'dashicons-arrow-right-alt',
|
3263 |
-
'dash-f343' => 'dashicons-arrow-up-alt2',
|
3264 |
-
'dash-f347' => 'dashicons-arrow-down-alt2',
|
3265 |
-
'dash-f341' => 'dashicons-arrow-left-alt2',
|
3266 |
-
'dash-f345' => 'dashicons-arrow-right-alt2',
|
3267 |
-
'dash-f132' => 'dashicons-plus',
|
3268 |
-
'dash-f460' => 'dashicons-minus',
|
3269 |
-
'dash-f158' => 'dashicons-no',
|
3270 |
-
'dash-f335' => 'dashicons-no-alt',
|
3271 |
-
|
3272 |
-
);
|
3273 |
-
|
3274 |
-
$icons = apply_filters( "megamenu_arrow_icons", $icons );
|
3275 |
-
|
3276 |
-
return $icons;
|
3277 |
-
|
3278 |
-
}
|
3279 |
-
|
3280 |
-
}
|
3281 |
-
|
3282 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Themes' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Handles all admin related functionality.
|
11 |
+
*/
|
12 |
+
class Mega_Menu_Themes {
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* All themes (default and custom)
|
17 |
+
*/
|
18 |
+
var $themes = array();
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Active theme
|
23 |
+
*/
|
24 |
+
var $active_theme = array();
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Active theme ID
|
29 |
+
*/
|
30 |
+
var $id = '';
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*
|
36 |
+
* @since 1.0
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
|
40 |
+
add_action( 'wp_ajax_megamenu_save_theme', array( $this, 'ajax_save_theme' ) );
|
41 |
+
add_action( 'admin_post_megamenu_save_theme', array( $this, 'save_theme' ) );
|
42 |
+
add_action( 'admin_post_megamenu_add_theme', array( $this, 'create_theme' ) );
|
43 |
+
add_action( 'admin_post_megamenu_delete_theme', array( $this, 'delete_theme' ) );
|
44 |
+
add_action( 'admin_post_megamenu_revert_theme', array( $this, 'revert_theme' ) );
|
45 |
+
add_action( 'admin_post_megamenu_duplicate_theme', array( $this, 'duplicate_theme' ) );
|
46 |
+
add_action( 'admin_post_megamenu_import_theme', array( $this, 'import_theme' ) );
|
47 |
+
|
48 |
+
add_filter( 'megamenu_menu_tabs', array( $this, 'add_themes_tab' ), 2 );
|
49 |
+
add_action( 'megamenu_page_theme_editor', array( $this, 'theme_editor_page' ) );
|
50 |
+
|
51 |
+
add_filter( 'wp_code_editor_settings', array( $this, 'codemirror_disable_lint' ), 99 );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Divi turns on code linting. This turns it off.
|
56 |
+
*
|
57 |
+
* @since 2.8
|
58 |
+
*/
|
59 |
+
public function codemirror_disable_lint( $settings ) {
|
60 |
+
if ( isset( $_GET['page'] ) && 'maxmegamenu_theme_editor' === $_GET['page'] ) { // @codingStandardsIgnoreLine
|
61 |
+
$settings['codemirror']['lint'] = false;
|
62 |
+
$settings['codemirror']['gutters'] = array();
|
63 |
+
}
|
64 |
+
|
65 |
+
return $settings;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Add the Menu Locations tab to our available tabs
|
70 |
+
*
|
71 |
+
* @param array $tabs
|
72 |
+
* @since 2.8
|
73 |
+
*/
|
74 |
+
public function add_themes_tab( $tabs ) {
|
75 |
+
$tabs['theme_editor'] = __( 'Menu Themes', 'megamenu' );
|
76 |
+
return $tabs;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
*
|
81 |
+
* @since 1.4
|
82 |
+
*/
|
83 |
+
public function init() {
|
84 |
+
if ( class_exists( 'Mega_Menu_Style_Manager' ) ) {
|
85 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
86 |
+
$this->themes = $style_manager->get_themes();
|
87 |
+
|
88 |
+
$last_updated = max_mega_menu_get_last_updated_theme();
|
89 |
+
$preselected_theme = isset( $this->themes[ $last_updated ] ) ? $last_updated : 'default';
|
90 |
+
$theme_id = isset( $_GET['theme'] ) ? sanitize_text_field( $_GET['theme'] ) : $preselected_theme; // @codingStandardsIgnoreLine
|
91 |
+
|
92 |
+
if ( isset( $this->themes[ $theme_id ] ) ) {
|
93 |
+
$this->id = $theme_id;
|
94 |
+
} else {
|
95 |
+
$this->id = $preselected_theme;
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->active_theme = $this->themes[ $this->id ];
|
99 |
+
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns the next available custom theme ID
|
105 |
+
*
|
106 |
+
* @since 1.0
|
107 |
+
*/
|
108 |
+
public function get_next_theme_id() {
|
109 |
+
$last_id = 0;
|
110 |
+
|
111 |
+
if ( $saved_themes = max_mega_menu_get_themes() ) {
|
112 |
+
foreach ( $saved_themes as $key => $value ) {
|
113 |
+
if ( strpos( $key, 'custom_theme' ) !== false ) {
|
114 |
+
$parts = explode( '_', $key );
|
115 |
+
$theme_id = end( $parts );
|
116 |
+
|
117 |
+
if ( $theme_id > $last_id ) {
|
118 |
+
$last_id = $theme_id;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
$next_id = $last_id + 1;
|
125 |
+
|
126 |
+
return $next_id;
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
/**
|
131 |
+
*
|
132 |
+
* @since 2.4.1
|
133 |
+
*/
|
134 |
+
public function ajax_save_theme() {
|
135 |
+
check_ajax_referer( 'megamenu_save_theme' );
|
136 |
+
|
137 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
138 |
+
|
139 |
+
$test = $style_manager->test_theme_compilation( $this->get_prepared_theme_for_saving() );
|
140 |
+
|
141 |
+
if ( is_wp_error( $test ) ) {
|
142 |
+
wp_send_json_error( $test->get_error_message() );
|
143 |
+
} else {
|
144 |
+
$this->save_theme( true );
|
145 |
+
wp_send_json_success( 'Saved' );
|
146 |
+
}
|
147 |
|
148 |
+
wp_die();
|
149 |
+
}
|
150 |
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
/**
|
153 |
+
*
|
154 |
+
* @since 2.4.1
|
155 |
+
*/
|
156 |
+
public function get_prepared_theme_for_saving() {
|
157 |
|
158 |
+
$submitted_settings = $_POST['settings'];
|
|
|
|
|
|
|
159 |
|
160 |
+
if ( isset( $_POST['checkboxes'] ) ) {
|
161 |
+
foreach ( $_POST['checkboxes'] as $checkbox => $value ) {
|
162 |
+
if ( isset( $submitted_settings[ $checkbox ] ) ) {
|
163 |
+
$submitted_settings[ $checkbox ] = 'on';
|
164 |
+
} else {
|
165 |
+
$submitted_settings[ $checkbox ] = 'off';
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
|
170 |
+
if ( is_numeric( $submitted_settings['responsive_breakpoint'] ) ) {
|
171 |
+
$submitted_settings['responsive_breakpoint'] = $submitted_settings['responsive_breakpoint'] . 'px';
|
172 |
+
}
|
|
|
173 |
|
174 |
+
if ( isset( $submitted_settings['toggle_blocks'] ) ) {
|
175 |
+
unset( $submitted_settings['toggle_blocks'] );
|
176 |
+
}
|
177 |
|
178 |
+
if ( isset( $submitted_settings['panel_width'] ) ) {
|
179 |
+
$submitted_settings['panel_width'] = trim( $submitted_settings['panel_width'] );
|
180 |
+
}
|
|
|
|
|
|
|
181 |
|
182 |
+
if ( isset( $submitted_settings['panel_inner_width'] ) ) {
|
183 |
+
$submitted_settings['panel_inner_width'] = trim( $submitted_settings['panel_inner_width'] );
|
184 |
+
}
|
|
|
|
|
|
|
|
|
185 |
|
186 |
+
$theme = array_map( 'esc_attr', $submitted_settings );
|
|
|
187 |
|
188 |
+
return $theme;
|
189 |
+
}
|
190 |
|
191 |
|
192 |
+
/**
|
193 |
+
* Save changes to an exiting theme.
|
194 |
+
*
|
195 |
+
* @since 1.0
|
196 |
+
*/
|
197 |
+
public function save_theme( $is_ajax = false ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
check_admin_referer( 'megamenu_save_theme' );
|
200 |
|
201 |
+
$theme = esc_attr( $_POST['theme_id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
+
$saved_themes = max_mega_menu_get_themes();
|
|
|
|
|
204 |
|
205 |
+
if ( isset( $saved_themes[ $theme ] ) ) {
|
206 |
+
unset( $saved_themes[ $theme ] );
|
207 |
+
}
|
|
|
|
|
208 |
|
209 |
+
$prepared_theme = $this->get_prepared_theme_for_saving();
|
210 |
|
211 |
+
$saved_themes[ $theme ] = $prepared_theme;
|
|
|
212 |
|
213 |
+
max_mega_menu_save_themes( $saved_themes );
|
214 |
+
max_mega_menu_save_last_updated_theme( $theme );
|
215 |
|
216 |
+
do_action( 'megamenu_after_theme_save' );
|
217 |
+
do_action( 'megamenu_delete_cache' );
|
218 |
|
219 |
+
if ( ! $is_ajax ) {
|
220 |
+
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&saved=true" ) );
|
221 |
+
return;
|
222 |
+
}
|
223 |
|
224 |
+
return $prepared_theme;
|
225 |
+
}
|
|
|
|
|
|
|
226 |
|
|
|
227 |
|
228 |
+
/**
|
229 |
+
* Duplicate an existing theme.
|
230 |
+
*
|
231 |
+
* @since 1.0
|
232 |
+
*/
|
233 |
+
public function duplicate_theme() {
|
234 |
|
235 |
+
check_admin_referer( 'megamenu_duplicate_theme' );
|
236 |
|
237 |
+
$this->init();
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
+
$theme = esc_attr( $_GET['theme_id'] );
|
|
|
|
|
|
|
|
|
240 |
|
241 |
+
$copy = $this->themes[ $theme ];
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
+
$saved_themes = max_mega_menu_get_themes();
|
244 |
|
245 |
+
$next_id = $this->get_next_theme_id();
|
|
|
246 |
|
247 |
+
$copy['title'] = $copy['title'] . ' ' . __( 'Copy', 'megamenu' );
|
|
|
|
|
|
|
|
|
248 |
|
249 |
+
$new_theme_id = 'custom_theme_' . $next_id;
|
250 |
|
251 |
+
$saved_themes[ $new_theme_id ] = $copy;
|
252 |
|
253 |
+
max_mega_menu_save_themes( $saved_themes );
|
254 |
|
255 |
+
do_action( 'megamenu_after_theme_duplicate' );
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
+
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$new_theme_id}&duplicated=true" ) );
|
258 |
|
259 |
+
}
|
260 |
|
261 |
|
262 |
+
/**
|
263 |
+
* Delete a theme
|
264 |
+
*
|
265 |
+
* @since 1.0
|
266 |
+
*/
|
267 |
+
public function delete_theme() {
|
268 |
|
269 |
+
check_admin_referer( 'megamenu_delete_theme' );
|
270 |
|
271 |
+
$theme = esc_attr( $_GET['theme_id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
|
273 |
+
if ( $this->theme_is_being_used_by_location( $theme ) ) {
|
|
|
|
|
274 |
|
275 |
+
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&deleted=false" ) );
|
276 |
+
return;
|
277 |
+
}
|
278 |
|
279 |
+
$saved_themes = max_mega_menu_get_themes();
|
|
|
|
|
280 |
|
281 |
+
if ( isset( $saved_themes[ $theme ] ) ) {
|
282 |
+
unset( $saved_themes[ $theme ] );
|
283 |
+
}
|
284 |
|
285 |
+
max_mega_menu_save_themes( $saved_themes );
|
286 |
|
287 |
+
do_action( 'megamenu_after_theme_delete' );
|
288 |
|
289 |
+
do_action( 'megamenu_delete_cache' );
|
290 |
|
291 |
+
$this->redirect( admin_url( 'admin.php?page=maxmegamenu_theme_editor&theme=default&deleted=true' ) );
|
|
|
|
|
|
|
|
|
|
|
292 |
|
293 |
+
}
|
294 |
|
|
|
295 |
|
296 |
+
/**
|
297 |
+
* Revert a theme (only available for default themes, you can't revert a custom theme)
|
298 |
+
*
|
299 |
+
* @since 1.0
|
300 |
+
*/
|
301 |
+
public function revert_theme() {
|
302 |
|
303 |
+
check_admin_referer( 'megamenu_revert_theme' );
|
|
|
|
|
304 |
|
305 |
+
$theme = esc_attr( $_GET['theme_id'] );
|
306 |
|
307 |
+
$saved_themes = max_mega_menu_get_themes();
|
308 |
|
309 |
+
if ( isset( $saved_themes[ $theme ] ) ) {
|
310 |
+
unset( $saved_themes[ $theme ] );
|
311 |
+
}
|
312 |
|
313 |
+
max_mega_menu_save_themes( $saved_themes );
|
|
|
314 |
|
315 |
+
do_action( 'megamenu_after_theme_revert' );
|
|
|
|
|
|
|
316 |
|
317 |
+
do_action( 'megamenu_delete_cache' );
|
318 |
|
319 |
+
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$theme}&reverted=true" ) );
|
320 |
|
321 |
+
}
|
322 |
|
323 |
|
324 |
+
/**
|
325 |
+
* Create a new custom theme
|
326 |
+
*
|
327 |
+
* @since 1.0
|
328 |
+
*/
|
329 |
+
public function create_theme() {
|
330 |
|
331 |
+
check_admin_referer( 'megamenu_create_theme' );
|
332 |
|
333 |
+
$this->init();
|
334 |
|
335 |
+
$saved_themes = max_mega_menu_get_themes();
|
336 |
|
337 |
+
$next_id = $this->get_next_theme_id();
|
338 |
|
339 |
+
$new_theme_id = 'custom_theme_' . $next_id;
|
340 |
|
341 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
342 |
+
$new_theme = $style_manager->get_default_theme();
|
343 |
|
344 |
+
$new_theme['title'] = "Custom {$next_id}";
|
345 |
|
346 |
+
$saved_themes[ $new_theme_id ] = $new_theme;
|
347 |
|
348 |
+
max_mega_menu_save_themes( $saved_themes );
|
349 |
|
350 |
+
do_action( 'megamenu_after_theme_create' );
|
351 |
|
352 |
+
$this->redirect( admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$new_theme_id}&created=true" ) );
|
353 |
|
354 |
+
}
|
355 |
|
356 |
+
/**
|
357 |
+
* Duplicate an existing theme.
|
358 |
+
*
|
359 |
+
* @since 1.8
|
360 |
+
*/
|
361 |
+
public function import_theme() {
|
362 |
+
check_admin_referer( 'megamenu_import_theme' );
|
363 |
|
364 |
+
$import = json_decode( stripslashes( $_POST['data'] ), true );
|
365 |
|
366 |
+
$sanitized = array();
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
+
foreach ( $import as $key => $value ) {
|
369 |
+
if ( $key == 'custom_css' ) {
|
370 |
+
$sanitized[ $key ] = sanitize_textarea_field( $value );
|
371 |
+
} else {
|
372 |
+
$sanitized[ $key ] = sanitize_text_field( $value );
|
373 |
+
}
|
374 |
+
}
|
375 |
|
376 |
+
$import = $sanitized;
|
377 |
|
378 |
+
if ( is_array( $import ) ) {
|
379 |
+
$saved_themes = max_mega_menu_get_themes();
|
380 |
+
$next_id = $this->get_next_theme_id();
|
381 |
+
$import['title'] = $import['title'] . ' ' . __( ' - Imported', 'megamenu' );
|
382 |
+
$new_theme_id = 'custom_theme_' . $next_id;
|
383 |
+
$saved_themes[ $new_theme_id ] = $import;
|
384 |
+
max_mega_menu_save_themes( $saved_themes );
|
385 |
+
do_action( 'megamenu_after_theme_import' );
|
386 |
|
387 |
+
$url = add_query_arg(
|
388 |
+
array(
|
389 |
+
'page' => 'maxmegamenu_theme_editor',
|
390 |
+
'theme' => $new_theme_id,
|
391 |
+
'imported' => 'true',
|
392 |
+
),
|
393 |
+
admin_url( 'admin.php' )
|
394 |
+
);
|
395 |
|
396 |
+
} else {
|
397 |
+
$url = add_query_arg(
|
398 |
+
array(
|
399 |
+
'page' => 'maxmegamenu_theme_editor',
|
400 |
+
'imported' => 'false',
|
401 |
+
),
|
402 |
+
admin_url( 'admin.php' )
|
403 |
+
);
|
404 |
+
}
|
405 |
|
406 |
+
$this->redirect( $url );
|
407 |
+
}
|
|
|
408 |
|
|
|
409 |
|
410 |
+
/**
|
411 |
+
* Redirect and exit
|
412 |
+
*
|
413 |
+
* @since 1.8
|
414 |
+
*/
|
415 |
+
public function redirect( $url ) {
|
416 |
+
wp_redirect( $url );
|
417 |
+
exit;
|
418 |
+
}
|
419 |
+
|
420 |
|
421 |
+
/**
|
422 |
+
* Checks to see if a certain theme is in use.
|
423 |
+
*
|
424 |
+
* @since 1.0
|
425 |
+
* @param string $theme
|
426 |
+
*/
|
427 |
+
public function theme_is_being_used_by_location( $theme ) {
|
428 |
+
$settings = get_option( 'megamenu_settings' );
|
429 |
+
|
430 |
+
if ( ! $settings ) {
|
431 |
+
return false;
|
432 |
+
}
|
433 |
+
|
434 |
+
$locations = get_nav_menu_locations();
|
435 |
+
|
436 |
+
$menus = get_registered_nav_menus();
|
437 |
+
|
438 |
+
$theme_in_use_locations = array();
|
439 |
+
|
440 |
+
if ( count( $locations ) ) {
|
441 |
+
|
442 |
+
foreach ( $locations as $location => $menu_id ) {
|
443 |
|
444 |
+
if ( has_nav_menu( $location ) && max_mega_menu_is_enabled( $location ) && isset( $settings[ $location ]['theme'] ) && $settings[ $location ]['theme'] == $theme ) {
|
445 |
+
$theme_in_use_locations[] = isset( $menus[ $location ] ) ? $menus[ $location ] : $location;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
if ( count( $theme_in_use_locations ) ) {
|
450 |
+
return $theme_in_use_locations;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
return false;
|
455 |
+
}
|
456 |
+
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Display messages to the user
|
460 |
+
*
|
461 |
+
* @since 1.0
|
462 |
+
*/
|
463 |
+
public function print_messages() {
|
464 |
+
|
465 |
+
$this->init();
|
466 |
+
|
467 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
468 |
+
|
469 |
+
$test = $style_manager->test_theme_compilation( $this->active_theme );
|
470 |
+
|
471 |
+
if ( is_wp_error( $test ) ) {
|
472 |
+
?>
|
473 |
+
<div class="notice notice-error is-dismissible">
|
474 |
+
<p><?php echo $test->get_error_message(); ?></p>
|
475 |
+
</div>
|
476 |
+
<?php
|
477 |
+
}
|
478 |
+
|
479 |
+
if ( isset( $_GET['deleted'] ) && $_GET['deleted'] == 'false' ) {
|
480 |
+
?>
|
481 |
+
<div class="notice notice-error is-dismissible">
|
482 |
+
<p><?php _e( 'Failed to delete theme. The theme is in use by a menu.', 'megamenu' ) ?></p>
|
483 |
+
</div>
|
484 |
+
<?php
|
485 |
+
}
|
486 |
|
487 |
+
if ( isset( $_GET['deleted'] ) && $_GET['deleted'] == 'true' ) {
|
488 |
+
?>
|
489 |
+
<div class="notice notice-success is-dismissible">
|
490 |
+
<p><?php _e( 'Theme Deleted', 'megamenu' ) ?></p>
|
491 |
+
</div>
|
492 |
+
<?php
|
493 |
+
}
|
494 |
|
495 |
+
if ( isset( $_GET['duplicated'] ) ) {
|
496 |
+
?>
|
497 |
+
<div class="notice notice-success is-dismissible">
|
498 |
+
<p><?php _e( 'Theme Duplicated', 'megamenu' ) ?></p>
|
499 |
+
</div>
|
500 |
+
<?php
|
501 |
+
}
|
502 |
|
503 |
+
if ( isset( $_GET['reverted'] ) ) {
|
504 |
+
?>
|
505 |
+
<div class="notice notice-success is-dismissible">
|
506 |
+
<p><?php _e( 'Theme Reverted', 'megamenu' ) ?></p>
|
507 |
+
</div>
|
508 |
+
<?php
|
509 |
+
}
|
510 |
+
|
511 |
+
if ( isset( $_GET['created'] ) ) {
|
512 |
+
?>
|
513 |
+
<div class="notice notice-success is-dismissible">
|
514 |
+
<p><?php _e( "New Theme Created. To apply this theme to a menu location, go to <i>Mega Menu > Menu Locations</i> and select this theme from the 'Theme' dropdown.", 'megamenu' ) ?></p>
|
515 |
+
</div>
|
516 |
+
<?php
|
517 |
+
}
|
518 |
+
|
519 |
+
do_action( 'megamenu_print_messages' );
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
|
524 |
+
/**
|
525 |
+
* Lists the available themes
|
526 |
+
*
|
527 |
+
* @since 1.0
|
528 |
+
*/
|
529 |
+
public function theme_selector() {
|
530 |
+
|
531 |
+
$list_items = "<select id='theme_selector'>";
|
532 |
+
|
533 |
+
foreach ( $this->themes as $id => $theme ) {
|
534 |
+
|
535 |
+
$locations = $this->theme_is_being_used_by_location( $id );
|
536 |
+
|
537 |
+
$selected = $id == $this->id ? 'selected=selected' : '';
|
538 |
+
|
539 |
+
$list_items .= "<option {$selected} value='" . admin_url( "admin.php?page=maxmegamenu_theme_editor&theme={$id}" ) . "'>";
|
540 |
+
|
541 |
+
$title = $theme['title'];
|
542 |
+
|
543 |
+
if ( is_array( $locations ) ) {
|
544 |
+
$title .= ' (' . implode( ', ', $locations ) . ')';
|
545 |
+
}
|
546 |
+
|
547 |
+
$list_items .= esc_html( $title );
|
548 |
+
|
549 |
+
$list_items .= '</option>';
|
550 |
+
}
|
551 |
+
|
552 |
+
return $list_items .= '</select>';
|
553 |
+
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Checks to see if a given string contains any of the provided search terms
|
558 |
+
*
|
559 |
+
* @param srgin $key
|
560 |
+
* @param array $needles
|
561 |
+
* @since 1.0
|
562 |
+
*/
|
563 |
+
private function string_contains( $key, $needles ) {
|
564 |
+
|
565 |
+
foreach ( $needles as $needle ) {
|
566 |
+
|
567 |
+
if ( strpos( $key, $needle ) !== false ) {
|
568 |
+
return true;
|
569 |
+
}
|
570 |
+
}
|
571 |
+
|
572 |
+
return false;
|
573 |
+
|
574 |
+
}
|
575 |
+
|
576 |
+
|
577 |
+
/**
|
578 |
+
*
|
579 |
+
* @since 2.9
|
580 |
+
*/
|
581 |
+
public function export_theme() {
|
582 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
583 |
+
$default_theme = $style_manager->get_default_theme();
|
584 |
+
|
585 |
+
$theme_to_export = $this->active_theme;
|
586 |
+
|
587 |
+
$diff = array();
|
588 |
+
|
589 |
+
foreach ( $default_theme as $key => $value ) {
|
590 |
+
if ( isset( $theme_to_export[ $key ] ) && $theme_to_export[ $key ] != $value || $key == 'title' ) {
|
591 |
+
$diff[ $key ] = $theme_to_export[ $key ];
|
592 |
+
}
|
593 |
+
}
|
594 |
+
|
595 |
+
?>
|
596 |
+
|
597 |
+
<div class='menu_settings menu_settings_menu_themes'>
|
598 |
+
<h3 class='first'><?php _e( 'Export Theme', 'megamenu' ); ?></h3>
|
599 |
+
<table>
|
600 |
+
<tr>
|
601 |
+
<td class='mega-name'>
|
602 |
+
<?php _e( 'JSON Format', 'megamenu' ); ?>
|
603 |
+
<div class='mega-description'><?php _e( "Log into the site you wish to import the theme to. Go to Mega Menu > Tools and paste this into the 'Import Theme' text area:", 'megamenu' ); ?></div>
|
604 |
+
</td>
|
605 |
+
<td class='mega-value'>
|
606 |
+
<?php echo "<textarea class='mega-export'>" . sanitize_textarea_field( htmlentities( json_encode( $diff ) ) ) . '</textarea>'; ?>
|
607 |
+
</td>
|
608 |
+
</tr>
|
609 |
+
<tr>
|
610 |
+
<td class='mega-name'>
|
611 |
+
<?php _e( 'PHP Format', 'megamenu' ); ?>
|
612 |
+
<div class='mega-description'><?php _e( 'Paste this code into your themes functions.php file:', 'megamenu' ); ?></div>
|
613 |
+
</td>
|
614 |
+
<td class='mega-value'>
|
615 |
+
<?php
|
616 |
+
$key = strtolower( str_replace( ' ', '_', $theme_to_export['title'] ) );
|
617 |
+
$key .= '_' . time();
|
618 |
+
echo "<textarea class='mega-export'>";
|
619 |
+
echo 'function megamenu_add_theme_' . $key . '($themes) {';
|
620 |
+
echo "\n" . ' $themes["' . $key . '"] = array(';
|
621 |
+
|
622 |
+
foreach ( $diff as $theme_key => $value ) {
|
623 |
+
echo "\n '" . $theme_key . "' => '" . $value . "',";
|
624 |
+
}
|
625 |
+
|
626 |
+
echo "\n" . ' );';
|
627 |
+
echo "\n" . ' return $themes;';
|
628 |
+
echo "\n" . '}';
|
629 |
+
echo "\n" . 'add_filter("megamenu_themes", "megamenu_add_theme_' . $key . '");';
|
630 |
+
echo '</textarea>';
|
631 |
+
?>
|
632 |
+
</td>
|
633 |
+
</tr>
|
634 |
+
</table>
|
635 |
+
</div>
|
636 |
+
|
637 |
+
<?php
|
638 |
+
}
|
639 |
+
|
640 |
+
public function import_theme_page() {
|
641 |
+
|
642 |
+
?>
|
643 |
+
|
644 |
+
<div class='menu_settings menu_settings_menu_themes'>
|
645 |
+
<h3 class='first'><?php _e( 'Import Theme', 'megamenu' ); ?></h3>
|
646 |
+
<table>
|
647 |
+
<tr>
|
648 |
+
<td class='mega-name'>
|
649 |
+
<?php _e( 'Import Theme', 'megamenu' ); ?>
|
650 |
+
<div class='mega-description'><?php _e( 'Import a menu theme in JSON format', 'megamenu' ); ?></div>
|
651 |
+
</td>
|
652 |
+
<td class='mega-value'>
|
653 |
+
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post">
|
654 |
+
<?php wp_nonce_field( 'megamenu_import_theme' ); ?>
|
655 |
+
<input type="hidden" name="action" value="megamenu_import_theme" />
|
656 |
+
<textarea name='data'></textarea>
|
657 |
+
<input type='submit' class='button button-primary' value='<?php _e( 'Import Theme', 'megamenu' ); ?>' />
|
658 |
+
</form>
|
659 |
+
</td>
|
660 |
+
</tr>
|
661 |
+
</table>
|
662 |
+
</div>
|
663 |
+
|
664 |
+
<?php
|
665 |
+
}
|
666 |
+
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Displays the theme editor form.
|
670 |
+
*
|
671 |
+
* @since 1.0
|
672 |
+
*/
|
673 |
+
public function theme_editor_page( $saved_settings ) {
|
674 |
+
|
675 |
+
$this->init();
|
676 |
+
|
677 |
+
if ( isset( $_GET['export'] ) ) {
|
678 |
+
$this->export_theme();
|
679 |
+
return;
|
680 |
+
}
|
681 |
+
|
682 |
+
if ( isset( $_GET['import'] ) ) {
|
683 |
+
$this->import_theme_page();
|
684 |
+
return;
|
685 |
+
}
|
686 |
+
|
687 |
+
$create_url = esc_url(
|
688 |
+
add_query_arg(
|
689 |
+
array(
|
690 |
+
'action' => 'megamenu_add_theme',
|
691 |
+
),
|
692 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_create_theme' )
|
693 |
+
)
|
694 |
+
);
|
695 |
+
|
696 |
+
$duplicate_url = esc_url(
|
697 |
+
add_query_arg(
|
698 |
+
array(
|
699 |
+
'action' => 'megamenu_duplicate_theme',
|
700 |
+
'theme_id' => $this->id,
|
701 |
+
),
|
702 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_duplicate_theme' )
|
703 |
+
)
|
704 |
+
);
|
705 |
+
|
706 |
+
$delete_url = esc_url(
|
707 |
+
add_query_arg(
|
708 |
+
array(
|
709 |
+
'action' => 'megamenu_delete_theme',
|
710 |
+
'theme_id' => $this->id,
|
711 |
+
),
|
712 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_delete_theme' )
|
713 |
+
)
|
714 |
+
);
|
715 |
+
|
716 |
+
$revert_url = esc_url(
|
717 |
+
add_query_arg(
|
718 |
+
array(
|
719 |
+
'action' => 'megamenu_revert_theme',
|
720 |
+
'theme_id' => $this->id,
|
721 |
+
),
|
722 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_revert_theme' )
|
723 |
+
)
|
724 |
+
);
|
725 |
+
|
726 |
+
$export_url = esc_url(
|
727 |
+
add_query_arg(
|
728 |
+
array(
|
729 |
+
'page' => 'maxmegamenu_theme_editor',
|
730 |
+
'theme_id' => $this->id,
|
731 |
+
'export' => 'true',
|
732 |
+
),
|
733 |
+
admin_url( 'admin.php' )
|
734 |
+
)
|
735 |
+
);
|
736 |
+
|
737 |
+
$import_url = esc_url(
|
738 |
+
add_query_arg(
|
739 |
+
array(
|
740 |
+
'page' => 'maxmegamenu_theme_editor',
|
741 |
+
'import' => 'true',
|
742 |
+
),
|
743 |
+
admin_url( 'admin.php' )
|
744 |
+
)
|
745 |
+
);
|
746 |
+
|
747 |
+
?>
|
748 |
+
|
749 |
+
<?php $this->print_messages(); ?>
|
750 |
+
|
751 |
+
<div class='menu_settings menu_settings_menu_themes'>
|
752 |
+
|
753 |
+
<div class='theme_selector'>
|
754 |
+
<?php _e( 'Select theme to edit', 'megamenu' ); ?> <?php echo $this->theme_selector(); ?>
|
755 |
+
</div>
|
756 |
+
|
757 |
+
<div class='mega-ellipsis'>
|
758 |
+
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false">
|
759 |
+
<path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"></path>
|
760 |
+
</svg>
|
761 |
+
<ul class='mega-ellipsis-content'>
|
762 |
+
<li class='mega-create-theme'><a href='<?php echo $create_url; ?>'><span class='dashicons dashicons-welcome-add-page'></span><?php _e( 'Add new theme', 'megamenu' ); ?></a></li>
|
763 |
+
<li class='mega-duplicate-theme'><a href='<?php echo $duplicate_url; ?>'><span class='dashicons dashicons-images-alt2'></span><?php _e( 'Duplicate theme', 'megamenu' ); ?></a></li>
|
764 |
+
<li class='mega-export-theme'><a href='<?php echo $export_url; ?>'><span class='dashicons dashicons-upload'></span><?php _e( 'Export theme', 'megamenu' ); ?></a></li>
|
765 |
+
<li class='mega-import-theme'><a href='<?php echo $import_url; ?>'><span class='dashicons dashicons-download'></span><?php _e( 'Import a theme', 'megamenu' ); ?></a></li>
|
766 |
+
<?php if ( $this->string_contains( $this->id, array( 'custom' ) ) ) : ?>
|
767 |
+
<li class='mega-delete-theme'><a class='delete confirm' href='<?php echo $delete_url; ?>'><span class='dashicons dashicons-trash'></span><?php _e( 'Delete theme', 'megamenu' ); ?></a></li>
|
768 |
+
<?php else : ?>
|
769 |
+
<li class='mega-revert-theme'><a class='confirm' href='<?php echo $revert_url; ?>'><span class='dashicons dashicons-update-alt'></span><?php _e( 'Revert theme', 'megamenu' ); ?></a></li>
|
770 |
+
<?php endif; ?>
|
771 |
+
</ul>
|
772 |
+
</div>
|
773 |
+
|
774 |
+
<h3 class='editing_theme'><?php echo __( 'Editing theme', 'megamenu' ) . ': ' . esc_html( $this->active_theme['title'] ); ?></h3>
|
775 |
+
|
776 |
+
|
777 |
+
|
778 |
+
<?php
|
779 |
+
|
780 |
+
$saved_settings = get_option( 'megamenu_settings' );
|
781 |
+
|
782 |
+
if ( isset( $saved_settings['css'] ) && $saved_settings['css'] == 'disabled' ) {
|
783 |
+
?>
|
784 |
+
<div class='fail'><?php _e( 'CSS Output (under Mega Menu > General Settings) has been disabled. Therefore, changes made within the theme editor will not be applied to your menu.', 'megamenu' ); ?></div>
|
785 |
+
<?php
|
786 |
+
}
|
787 |
+
|
788 |
+
$locations = $this->theme_is_being_used_by_location( $this->id );
|
789 |
+
|
790 |
+
if ( ! $locations && ! isset( $_GET['created'] ) ) {
|
791 |
+
?>
|
792 |
+
<div class='warning'><?php _e( "This menu theme is not currently active as it has not been applied to any menu locations. You may wish to check you are editing the correct menu theme - you can choose a different theme to edit using the 'Select theme to edit' selector above. Alternatively, to apply this theme to a menu go to <i>Appearance > Menus > Max Mega Menu Settings</i> and select this theme from the 'Theme' dropdown.", 'megamenu' ); ?></div>
|
793 |
+
<?php
|
794 |
+
}
|
795 |
+
|
796 |
+
?>
|
797 |
+
|
798 |
+
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post" class="theme_editor">
|
799 |
+
<input type="hidden" name="theme_id" value="<?php echo esc_attr( $this->id ); ?>" />
|
800 |
+
<input type="hidden" name="action" value="megamenu_save_theme" />
|
801 |
+
<?php wp_nonce_field( 'megamenu_save_theme' ); ?>
|
802 |
+
|
803 |
+
<?php
|
804 |
+
|
805 |
+
$settings = apply_filters(
|
806 |
+
'megamenu_theme_editor_settings',
|
807 |
+
array(
|
808 |
+
|
809 |
+
'general' => array(
|
810 |
+
'title' => __( 'General Settings', 'megamenu' ),
|
811 |
+
'settings' => array(
|
812 |
+
'title' => array(
|
813 |
+
'priority' => 10,
|
814 |
+
'title' => __( 'Theme Title', 'megamenu' ),
|
815 |
+
'description' => '',
|
816 |
+
'settings' => array(
|
817 |
+
array(
|
818 |
+
'title' => '',
|
819 |
+
'type' => 'freetext',
|
820 |
+
'key' => 'title',
|
821 |
+
),
|
822 |
+
),
|
823 |
+
),
|
824 |
+
'arrow' => array(
|
825 |
+
'priority' => 20,
|
826 |
+
'title' => __( 'Arrow', 'megamenu' ),
|
827 |
+
'description' => __( 'Select the arrow styles.', 'megamenu' ),
|
828 |
+
'settings' => array(
|
829 |
+
array(
|
830 |
+
'title' => __( 'Up', 'megamenu' ),
|
831 |
+
'type' => 'arrow',
|
832 |
+
'key' => 'arrow_up',
|
833 |
+
),
|
834 |
+
array(
|
835 |
+
'title' => __( 'Down', 'megamenu' ),
|
836 |
+
'type' => 'arrow',
|
837 |
+
'key' => 'arrow_down',
|
838 |
+
),
|
839 |
+
array(
|
840 |
+
'title' => __( 'Left', 'megamenu' ),
|
841 |
+
'type' => 'arrow',
|
842 |
+
'key' => 'arrow_left',
|
843 |
+
),
|
844 |
+
array(
|
845 |
+
'title' => __( 'Right', 'megamenu' ),
|
846 |
+
'type' => 'arrow',
|
847 |
+
'key' => 'arrow_right',
|
848 |
+
),
|
849 |
+
),
|
850 |
+
),
|
851 |
+
'line_height' => array(
|
852 |
+
'priority' => 30,
|
853 |
+
'title' => __( 'Line Height', 'megamenu' ),
|
854 |
+
'description' => __( 'Set the general line height to use in the sub menu contents.', 'megamenu' ),
|
855 |
+
'settings' => array(
|
856 |
+
array(
|
857 |
+
'title' => '',
|
858 |
+
'type' => 'freetext',
|
859 |
+
'key' => 'line_height',
|
860 |
+
),
|
861 |
+
),
|
862 |
+
),
|
863 |
+
'z_index' => array(
|
864 |
+
'priority' => 40,
|
865 |
+
'title' => __( 'Z Index', 'megamenu' ),
|
866 |
+
'description' => __( 'Set the z-index to ensure the sub menus appear ontop of other content.', 'megamenu' ),
|
867 |
+
'settings' => array(
|
868 |
+
array(
|
869 |
+
'title' => '',
|
870 |
+
'type' => 'freetext',
|
871 |
+
'key' => 'z_index',
|
872 |
+
'validation' => 'int',
|
873 |
+
),
|
874 |
+
),
|
875 |
+
),
|
876 |
+
'shadow' => array(
|
877 |
+
'priority' => 50,
|
878 |
+
'title' => __( 'Shadow', 'megamenu' ),
|
879 |
+
'description' => __( 'Apply a shadow to mega and flyout menus.', 'megamenu' ),
|
880 |
+
'settings' => array(
|
881 |
+
array(
|
882 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
883 |
+
'type' => 'checkbox',
|
884 |
+
'key' => 'shadow',
|
885 |
+
),
|
886 |
+
array(
|
887 |
+
'title' => __( 'Horizontal', 'megamenu' ),
|
888 |
+
'type' => 'freetext',
|
889 |
+
'key' => 'shadow_horizontal',
|
890 |
+
'validation' => 'px',
|
891 |
+
),
|
892 |
+
array(
|
893 |
+
'title' => __( 'Vertical', 'megamenu' ),
|
894 |
+
'type' => 'freetext',
|
895 |
+
'key' => 'shadow_vertical',
|
896 |
+
'validation' => 'px',
|
897 |
+
),
|
898 |
+
array(
|
899 |
+
'title' => __( 'Blur', 'megamenu' ),
|
900 |
+
'type' => 'freetext',
|
901 |
+
'key' => 'shadow_blur',
|
902 |
+
'validation' => 'px',
|
903 |
+
),
|
904 |
+
array(
|
905 |
+
'title' => __( 'Spread', 'megamenu' ),
|
906 |
+
'type' => 'freetext',
|
907 |
+
'key' => 'shadow_spread',
|
908 |
+
'validation' => 'px',
|
909 |
+
),
|
910 |
+
array(
|
911 |
+
'title' => __( 'Color', 'megamenu' ),
|
912 |
+
'type' => 'color',
|
913 |
+
'key' => 'shadow_color',
|
914 |
+
),
|
915 |
+
),
|
916 |
+
),
|
917 |
+
'transitions' => array(
|
918 |
+
'priority' => 60,
|
919 |
+
'title' => __( 'Hover Transitions', 'megamenu' ),
|
920 |
+
'description' => __( 'Apply hover transitions to menu items. Note: Transitions will not apply to gradient backgrounds.', 'megamenu' ),
|
921 |
+
'settings' => array(
|
922 |
+
array(
|
923 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
924 |
+
'type' => 'checkbox',
|
925 |
+
'key' => 'transitions',
|
926 |
+
),
|
927 |
+
),
|
928 |
+
),
|
929 |
+
'resets' => array(
|
930 |
+
'priority' => 70,
|
931 |
+
'title' => __( 'Reset Widget Styling', 'megamenu' ),
|
932 |
+
'description' => __( 'Caution: Reset the styling of widgets within the mega menu? This may break the styling of widgets that you have added to your sub menus. Default: Disabled.', 'megamenu' ),
|
933 |
+
'settings' => array(
|
934 |
+
array(
|
935 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
936 |
+
'type' => 'checkbox',
|
937 |
+
'key' => 'resets',
|
938 |
+
),
|
939 |
+
),
|
940 |
+
),
|
941 |
+
),
|
942 |
+
),
|
943 |
+
'menu_bar' => array(
|
944 |
+
'title' => __( 'Menu Bar', 'megamenu' ),
|
945 |
+
'settings' => array(
|
946 |
+
'menu_item_height' => array(
|
947 |
+
'priority' => 05,
|
948 |
+
'title' => __( 'Menu Height', 'megamenu' ),
|
949 |
+
'description' => __( 'Define the height of each top level menu item link. This value plus the Menu Padding (top and bottom) settings define the overall height of the menu bar.', 'megamenu' ),
|
950 |
+
'settings' => array(
|
951 |
+
array(
|
952 |
+
'title' => '',
|
953 |
+
'type' => 'freetext',
|
954 |
+
'key' => 'menu_item_link_height',
|
955 |
+
'validation' => 'px',
|
956 |
+
),
|
957 |
+
),
|
958 |
+
),
|
959 |
+
'menu_background' => array(
|
960 |
+
'priority' => 10,
|
961 |
+
'title' => __( 'Menu Background', 'megamenu' ),
|
962 |
+
'description' => __( "The background color for the main menu bar. Set each value to transparent for a 'button' style menu.", 'megamenu' ),
|
963 |
+
'settings' => array(
|
964 |
+
array(
|
965 |
+
'title' => __( 'From', 'megamenu' ),
|
966 |
+
'type' => 'color',
|
967 |
+
'key' => 'container_background_from',
|
968 |
+
),
|
969 |
+
array(
|
970 |
+
'title' => __( 'Copy', 'megamenu' ),
|
971 |
+
'type' => 'copy_color',
|
972 |
+
'key' => 'copy_color',
|
973 |
+
),
|
974 |
+
array(
|
975 |
+
'title' => __( 'To', 'megamenu' ),
|
976 |
+
'type' => 'color',
|
977 |
+
'key' => 'container_background_to',
|
978 |
+
),
|
979 |
+
),
|
980 |
+
),
|
981 |
+
'menu_padding' => array(
|
982 |
+
'priority' => 20,
|
983 |
+
'title' => __( 'Menu Padding', 'megamenu' ),
|
984 |
+
'description' => __( 'Padding for the main menu bar.', 'megamenu' ),
|
985 |
+
'settings' => array(
|
986 |
+
array(
|
987 |
+
'title' => __( 'Top', 'megamenu' ),
|
988 |
+
'type' => 'freetext',
|
989 |
+
'key' => 'container_padding_top',
|
990 |
+
'validation' => 'px',
|
991 |
+
),
|
992 |
+
array(
|
993 |
+
'title' => __( 'Right', 'megamenu' ),
|
994 |
+
'type' => 'freetext',
|
995 |
+
'key' => 'container_padding_right',
|
996 |
+
'validation' => 'px',
|
997 |
+
),
|
998 |
+
array(
|
999 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1000 |
+
'type' => 'freetext',
|
1001 |
+
'key' => 'container_padding_bottom',
|
1002 |
+
'validation' => 'px',
|
1003 |
+
),
|
1004 |
+
array(
|
1005 |
+
'title' => __( 'Left', 'megamenu' ),
|
1006 |
+
'type' => 'freetext',
|
1007 |
+
'key' => 'container_padding_left',
|
1008 |
+
'validation' => 'px',
|
1009 |
+
),
|
1010 |
+
),
|
1011 |
+
),
|
1012 |
+
'menu_border_radius' => array(
|
1013 |
+
'priority' => 30,
|
1014 |
+
'title' => __( 'Menu Border Radius', 'megamenu' ),
|
1015 |
+
'description' => __( 'Set a border radius on the main menu bar.', 'megamenu' ),
|
1016 |
+
'settings' => array(
|
1017 |
+
array(
|
1018 |
+
'title' => __( 'Top Left', 'megamenu' ),
|
1019 |
+
'type' => 'freetext',
|
1020 |
+
'key' => 'container_border_radius_top_left',
|
1021 |
+
'validation' => 'px',
|
1022 |
+
),
|
1023 |
+
array(
|
1024 |
+
'title' => __( 'Top Right', 'megamenu' ),
|
1025 |
+
'type' => 'freetext',
|
1026 |
+
'key' => 'container_border_radius_top_right',
|
1027 |
+
'validation' => 'px',
|
1028 |
+
),
|
1029 |
+
array(
|
1030 |
+
'title' => __( 'Bottom Right', 'megamenu' ),
|
1031 |
+
'type' => 'freetext',
|
1032 |
+
'key' => 'container_border_radius_bottom_right',
|
1033 |
+
'validation' => 'px',
|
1034 |
+
),
|
1035 |
+
array(
|
1036 |
+
'title' => __( 'Bottom Left', 'megamenu' ),
|
1037 |
+
'type' => 'freetext',
|
1038 |
+
'key' => 'container_border_radius_bottom_left',
|
1039 |
+
'validation' => 'px',
|
1040 |
+
),
|
1041 |
+
),
|
1042 |
+
),
|
1043 |
+
'top_level_menu_items' => array(
|
1044 |
+
'priority' => 50,
|
1045 |
+
'title' => __( 'Top Level Menu Items', 'megamenu' ),
|
1046 |
+
'description' => '',
|
1047 |
+
),
|
1048 |
+
'menu_item_align' => array(
|
1049 |
+
'priority' => 55,
|
1050 |
+
'title' => __( 'Menu Items Align', 'megamenu' ),
|
1051 |
+
'description' => __( 'Align <i>all</i> menu items to the left (default), centrally or to the right.', 'megamenu' ),
|
1052 |
+
'info' => array( __( "This option will apply to all menu items. To align an individual menu item to the right, edit the menu item itself and set 'Menu Item Align' to 'Right'.", 'megamenu' ) ),
|
1053 |
+
'settings' => array(
|
1054 |
+
array(
|
1055 |
+
'title' => '',
|
1056 |
+
'type' => 'align',
|
1057 |
+
'key' => 'menu_item_align',
|
1058 |
+
),
|
1059 |
+
),
|
1060 |
+
),
|
1061 |
+
'menu_item_font' => array(
|
1062 |
+
'priority' => 60,
|
1063 |
+
'title' => __( 'Item Font', 'megamenu' ),
|
1064 |
+
'description' => __( 'The font to use for each top level menu item.', 'megamenu' ),
|
1065 |
+
'settings' => array(
|
1066 |
+
array(
|
1067 |
+
'title' => __( 'Color', 'megamenu' ),
|
1068 |
+
'type' => 'color',
|
1069 |
+
'key' => 'menu_item_link_color',
|
1070 |
+
),
|
1071 |
+
array(
|
1072 |
+
'title' => __( 'Size', 'megamenu' ),
|
1073 |
+
'type' => 'freetext',
|
1074 |
+
'key' => 'menu_item_link_font_size',
|
1075 |
+
'validation' => 'px',
|
1076 |
+
),
|
1077 |
+
array(
|
1078 |
+
'title' => __( 'Family', 'megamenu' ),
|
1079 |
+
'type' => 'font',
|
1080 |
+
'key' => 'menu_item_link_font',
|
1081 |
+
),
|
1082 |
+
array(
|
1083 |
+
'title' => __( 'Transform', 'megamenu' ),
|
1084 |
+
'type' => 'transform',
|
1085 |
+
'key' => 'menu_item_link_text_transform',
|
1086 |
+
),
|
1087 |
+
array(
|
1088 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1089 |
+
'type' => 'weight',
|
1090 |
+
'key' => 'menu_item_link_weight',
|
1091 |
+
),
|
1092 |
+
array(
|
1093 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1094 |
+
'type' => 'decoration',
|
1095 |
+
'key' => 'menu_item_link_text_decoration',
|
1096 |
+
),
|
1097 |
+
array(
|
1098 |
+
'title' => __( 'Align', 'megamenu' ),
|
1099 |
+
'type' => 'align',
|
1100 |
+
'key' => 'menu_item_link_text_align',
|
1101 |
+
),
|
1102 |
+
),
|
1103 |
+
),
|
1104 |
+
'menu_item_font_hover' => array(
|
1105 |
+
'priority' => 65,
|
1106 |
+
'title' => __( 'Item Font (Hover)', 'megamenu' ),
|
1107 |
+
'description' => __( 'Set the font to use for each top level menu item (on hover).', 'megamenu' ),
|
1108 |
+
'settings' => array(
|
1109 |
+
array(
|
1110 |
+
'title' => __( 'Color', 'megamenu' ),
|
1111 |
+
'type' => 'color',
|
1112 |
+
'key' => 'menu_item_link_color_hover',
|
1113 |
+
),
|
1114 |
+
array(
|
1115 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1116 |
+
'type' => 'weight',
|
1117 |
+
'key' => 'menu_item_link_weight_hover',
|
1118 |
+
),
|
1119 |
+
array(
|
1120 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1121 |
+
'type' => 'decoration',
|
1122 |
+
'key' => 'menu_item_link_text_decoration_hover',
|
1123 |
+
),
|
1124 |
+
),
|
1125 |
+
),
|
1126 |
+
'menu_item_background' => array(
|
1127 |
+
'priority' => 70,
|
1128 |
+
'title' => __( 'Item Background', 'megamenu' ),
|
1129 |
+
'description' => __( "The background color for each top level menu item. Tip: Set these values to transparent if you've already set a background color on the menu bar.", 'megamenu' ),
|
1130 |
+
'settings' => array(
|
1131 |
+
array(
|
1132 |
+
'title' => __( 'From', 'megamenu' ),
|
1133 |
+
'type' => 'color',
|
1134 |
+
'key' => 'menu_item_background_from',
|
1135 |
+
),
|
1136 |
+
array(
|
1137 |
+
'title' => __( 'Copy', 'megamenu' ),
|
1138 |
+
'type' => 'copy_color',
|
1139 |
+
'key' => 'copy_color',
|
1140 |
+
),
|
1141 |
+
array(
|
1142 |
+
'title' => __( 'To', 'megamenu' ),
|
1143 |
+
'type' => 'color',
|
1144 |
+
'key' => 'menu_item_background_to',
|
1145 |
+
),
|
1146 |
+
),
|
1147 |
+
),
|
1148 |
+
'menu_item_background_hover' => array(
|
1149 |
+
'priority' => 75,
|
1150 |
+
'title' => __( 'Item Background (Hover)', 'megamenu' ),
|
1151 |
+
'description' => __( 'The background color for a top level menu item (on hover).', 'megamenu' ),
|
1152 |
+
'settings' => array(
|
1153 |
+
array(
|
1154 |
+
'title' => __( 'From', 'megamenu' ),
|
1155 |
+
'type' => 'color',
|
1156 |
+
'key' => 'menu_item_background_hover_from',
|
1157 |
+
),
|
1158 |
+
array(
|
1159 |
+
'title' => __( 'Copy', 'megamenu' ),
|
1160 |
+
'type' => 'copy_color',
|
1161 |
+
'key' => 'copy_color',
|
1162 |
+
),
|
1163 |
+
array(
|
1164 |
+
'title' => __( 'To', 'megamenu' ),
|
1165 |
+
'type' => 'color',
|
1166 |
+
'key' => 'menu_item_background_hover_to',
|
1167 |
+
),
|
1168 |
+
),
|
1169 |
+
),
|
1170 |
+
'menu_item_spacing' => array(
|
1171 |
+
'priority' => 80,
|
1172 |
+
'title' => __( 'Item Spacing', 'megamenu' ),
|
1173 |
+
'description' => __( 'Define the size of the gap between each top level menu item.', 'megamenu' ),
|
1174 |
+
'settings' => array(
|
1175 |
+
array(
|
1176 |
+
'title' => '',
|
1177 |
+
'type' => 'freetext',
|
1178 |
+
'key' => 'menu_item_spacing',
|
1179 |
+
'validation' => 'px',
|
1180 |
+
),
|
1181 |
+
),
|
1182 |
+
),
|
1183 |
+
|
1184 |
+
'menu_item_padding' => array(
|
1185 |
+
'priority' => 85,
|
1186 |
+
'title' => __( 'Item Padding', 'megamenu' ),
|
1187 |
+
'description' => __( 'Set the padding for each top level menu item.', 'megamenu' ),
|
1188 |
+
'info' => array( __( "Generally we advise against using the Top and Bottom options here. Use the 'Menu Height' setting to determine the height of your top level menu items.", 'megamenu' ) ),
|
1189 |
+
'settings' => array(
|
1190 |
+
array(
|
1191 |
+
'title' => __( 'Top', 'megamenu' ),
|
1192 |
+
'type' => 'freetext',
|
1193 |
+
'key' => 'menu_item_link_padding_top',
|
1194 |
+
'validation' => 'px',
|
1195 |
+
),
|
1196 |
+
array(
|
1197 |
+
'title' => __( 'Right', 'megamenu' ),
|
1198 |
+
'type' => 'freetext',
|
1199 |
+
'key' => 'menu_item_link_padding_right',
|
1200 |
+
'validation' => 'px',
|
1201 |
+
),
|
1202 |
+
array(
|
1203 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1204 |
+
'type' => 'freetext',
|
1205 |
+
'key' => 'menu_item_link_padding_bottom',
|
1206 |
+
'validation' => 'px',
|
1207 |
+
),
|
1208 |
+
array(
|
1209 |
+
'title' => __( 'Left', 'megamenu' ),
|
1210 |
+
'type' => 'freetext',
|
1211 |
+
'key' => 'menu_item_link_padding_left',
|
1212 |
+
'validation' => 'px',
|
1213 |
+
),
|
1214 |
+
),
|
1215 |
+
),
|
1216 |
+
'menu_item_border' => array(
|
1217 |
+
'priority' => 90,
|
1218 |
+
'title' => __( 'Item Border', 'megamenu' ),
|
1219 |
+
'description' => __( 'Set the border to display on each top level menu item.', 'megamenu' ),
|
1220 |
+
'settings' => array(
|
1221 |
+
array(
|
1222 |
+
'title' => __( 'Color', 'megamenu' ),
|
1223 |
+
'type' => 'color',
|
1224 |
+
'key' => 'menu_item_border_color',
|
1225 |
+
),
|
1226 |
+
array(
|
1227 |
+
'title' => __( 'Color (Hover)', 'megamenu' ),
|
1228 |
+
'type' => 'color',
|
1229 |
+
'key' => 'menu_item_border_color_hover',
|
1230 |
+
),
|
1231 |
+
array(
|
1232 |
+
'title' => __( 'Top', 'megamenu' ),
|
1233 |
+
'type' => 'freetext',
|
1234 |
+
'key' => 'menu_item_border_top',
|
1235 |
+
'validation' => 'px',
|
1236 |
+
),
|
1237 |
+
array(
|
1238 |
+
'title' => __( 'Right', 'megamenu' ),
|
1239 |
+
'type' => 'freetext',
|
1240 |
+
'key' => 'menu_item_border_right',
|
1241 |
+
'validation' => 'px',
|
1242 |
+
),
|
1243 |
+
array(
|
1244 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1245 |
+
'type' => 'freetext',
|
1246 |
+
'key' => 'menu_item_border_bottom',
|
1247 |
+
'validation' => 'px',
|
1248 |
+
),
|
1249 |
+
array(
|
1250 |
+
'title' => __( 'Left', 'megamenu' ),
|
1251 |
+
'type' => 'freetext',
|
1252 |
+
'key' => 'menu_item_border_left',
|
1253 |
+
'validation' => 'px',
|
1254 |
+
),
|
1255 |
+
),
|
1256 |
+
),
|
1257 |
+
'menu_item_border_radius' => array(
|
1258 |
+
'priority' => 95,
|
1259 |
+
'title' => __( 'Item Border Radius', 'megamenu' ),
|
1260 |
+
'description' => __( 'Set rounded corners for each top level menu item.', 'megamenu' ),
|
1261 |
+
'settings' => array(
|
1262 |
+
array(
|
1263 |
+
'title' => __( 'Top Left', 'megamenu' ),
|
1264 |
+
'type' => 'freetext',
|
1265 |
+
'key' => 'menu_item_link_border_radius_top_left',
|
1266 |
+
'validation' => 'px',
|
1267 |
+
),
|
1268 |
+
array(
|
1269 |
+
'title' => __( 'Top Right', 'megamenu' ),
|
1270 |
+
'type' => 'freetext',
|
1271 |
+
'key' => 'menu_item_link_border_radius_top_right',
|
1272 |
+
'validation' => 'px',
|
1273 |
+
),
|
1274 |
+
array(
|
1275 |
+
'title' => __( 'Bottom Right', 'megamenu' ),
|
1276 |
+
'type' => 'freetext',
|
1277 |
+
'key' => 'menu_item_link_border_radius_bottom_right',
|
1278 |
+
'validation' => 'px',
|
1279 |
+
),
|
1280 |
+
array(
|
1281 |
+
'title' => __( 'Bottom Left', 'megamenu' ),
|
1282 |
+
'type' => 'freetext',
|
1283 |
+
'key' => 'menu_item_link_border_radius_bottom_left',
|
1284 |
+
'validation' => 'px',
|
1285 |
+
),
|
1286 |
+
),
|
1287 |
+
),
|
1288 |
+
'menu_item_divider' => array(
|
1289 |
+
'priority' => 160,
|
1290 |
+
'title' => __( 'Item Divider', 'megamenu' ),
|
1291 |
+
'description' => __( 'Show a small divider bar between each menu item.', 'megamenu' ),
|
1292 |
+
'settings' => array(
|
1293 |
+
array(
|
1294 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
1295 |
+
'type' => 'checkbox',
|
1296 |
+
'key' => 'menu_item_divider',
|
1297 |
+
),
|
1298 |
+
array(
|
1299 |
+
'title' => __( 'Color', 'megamenu' ),
|
1300 |
+
'type' => 'color',
|
1301 |
+
'key' => 'menu_item_divider_color',
|
1302 |
+
),
|
1303 |
+
array(
|
1304 |
+
'title' => __( 'Glow Opacity', 'megamenu' ),
|
1305 |
+
'type' => 'freetext',
|
1306 |
+
'key' => 'menu_item_divider_glow_opacity',
|
1307 |
+
'validation' => 'float',
|
1308 |
+
),
|
1309 |
+
),
|
1310 |
+
),
|
1311 |
+
'menu_item_highlight' => array(
|
1312 |
+
'priority' => 170,
|
1313 |
+
'title' => __( 'Highlight Current Item', 'megamenu' ),
|
1314 |
+
'description' => __( "Apply the 'hover' styling to current menu items. Applies to top level menu items only.", 'megamenu' ),
|
1315 |
+
'settings' => array(
|
1316 |
+
array(
|
1317 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
1318 |
+
'type' => 'checkbox',
|
1319 |
+
'key' => 'menu_item_highlight_current',
|
1320 |
+
),
|
1321 |
+
),
|
1322 |
+
'info' => array(
|
1323 |
+
"<a href='https://www.megamenu.com/documentation/highlight-active-menu-items/' target='blank'>" . __( 'Documentation: Highlighting Menu Items', 'megamenu' ) . '</a>',
|
1324 |
+
),
|
1325 |
+
),
|
1326 |
+
),
|
1327 |
+
),
|
1328 |
+
'mega_panels' => array(
|
1329 |
+
'title' => __( 'Mega Menus', 'megamenu' ),
|
1330 |
+
'settings' => array(
|
1331 |
+
'panel_background' => array(
|
1332 |
+
'priority' => 10,
|
1333 |
+
'title' => __( 'Panel Background', 'megamenu' ),
|
1334 |
+
'description' => __( 'Set a background color for a whole sub menu.', 'megamenu' ),
|
1335 |
+
'settings' => array(
|
1336 |
+
array(
|
1337 |
+
'title' => __( 'From', 'megamenu' ),
|
1338 |
+
'type' => 'color',
|
1339 |
+
'key' => 'panel_background_from',
|
1340 |
+
),
|
1341 |
+
array(
|
1342 |
+
'title' => __( 'Copy', 'megamenu' ),
|
1343 |
+
'type' => 'copy_color',
|
1344 |
+
'key' => 'copy_color',
|
1345 |
+
),
|
1346 |
+
array(
|
1347 |
+
'title' => __( 'To', 'megamenu' ),
|
1348 |
+
'type' => 'color',
|
1349 |
+
'key' => 'panel_background_to',
|
1350 |
+
),
|
1351 |
+
),
|
1352 |
+
),
|
1353 |
+
'panel_width' => array(
|
1354 |
+
'priority' => 20,
|
1355 |
+
'title' => __( 'Panel Width', 'megamenu' ),
|
1356 |
+
'description' => __( 'Mega Panel width.', 'megamenu' ),
|
1357 |
+
'info' => array(
|
1358 |
+
__( 'A 100% wide panel will only ever be as wide as the menu itself. For a fixed sub menu width set this to a pixel value.', 'megamenu' ),
|
1359 |
+
__( 'Advanced: Enter a jQuery selector to synchronize the width and position of the sub menu with existing page element (e.g. body, #container, .page).', 'megamenu' ),
|
1360 |
+
"<a href='https://www.megamenu.com/documentation/adjust-sub-menu-width/' target='blank'>" . __( 'Documentation: Configuring the sub menu width', 'megamenu' ) . '</a>',
|
1361 |
+
),
|
1362 |
+
'settings' => array(
|
1363 |
+
array(
|
1364 |
+
'title' => __( 'Outer Width', 'megamenu' ),
|
1365 |
+
'type' => 'freetext',
|
1366 |
+
'key' => 'panel_width',
|
1367 |
+
),
|
1368 |
+
array(
|
1369 |
+
'title' => __( 'Inner Width', 'megamenu' ),
|
1370 |
+
'type' => 'freetext',
|
1371 |
+
'key' => 'panel_inner_width',
|
1372 |
+
),
|
1373 |
+
),
|
1374 |
+
),
|
1375 |
+
'panel_padding' => array(
|
1376 |
+
'priority' => 30,
|
1377 |
+
'title' => __( 'Panel Padding', 'megamenu' ),
|
1378 |
+
'description' => __( 'Set the padding for the whole sub menu. Set these values 0px if you wish your sub menu content to go edge-to-edge.', 'megamenu' ),
|
1379 |
+
'settings' => array(
|
1380 |
+
array(
|
1381 |
+
'title' => __( 'Top', 'megamenu' ),
|
1382 |
+
'type' => 'freetext',
|
1383 |
+
'key' => 'panel_padding_top',
|
1384 |
+
'validation' => 'px',
|
1385 |
+
),
|
1386 |
+
array(
|
1387 |
+
'title' => __( 'Right', 'megamenu' ),
|
1388 |
+
'type' => 'freetext',
|
1389 |
+
'key' => 'panel_padding_right',
|
1390 |
+
'validation' => 'px',
|
1391 |
+
),
|
1392 |
+
array(
|
1393 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1394 |
+
'type' => 'freetext',
|
1395 |
+
'key' => 'panel_padding_bottom',
|
1396 |
+
'validation' => 'px',
|
1397 |
+
),
|
1398 |
+
array(
|
1399 |
+
'title' => __( 'Left', 'megamenu' ),
|
1400 |
+
'type' => 'freetext',
|
1401 |
+
'key' => 'panel_padding_left',
|
1402 |
+
'validation' => 'px',
|
1403 |
+
),
|
1404 |
+
),
|
1405 |
+
),
|
1406 |
+
'panel_border' => array(
|
1407 |
+
'priority' => 40,
|
1408 |
+
'title' => __( 'Panel Border', 'megamenu' ),
|
1409 |
+
'description' => __( 'Set the border to display on the sub menu.', 'megamenu' ),
|
1410 |
+
'settings' => array(
|
1411 |
+
array(
|
1412 |
+
'title' => __( 'Color', 'megamenu' ),
|
1413 |
+
'type' => 'color',
|
1414 |
+
'key' => 'panel_border_color',
|
1415 |
+
),
|
1416 |
+
array(
|
1417 |
+
'title' => __( 'Top', 'megamenu' ),
|
1418 |
+
'type' => 'freetext',
|
1419 |
+
'key' => 'panel_border_top',
|
1420 |
+
'validation' => 'px',
|
1421 |
+
),
|
1422 |
+
array(
|
1423 |
+
'title' => __( 'Right', 'megamenu' ),
|
1424 |
+
'type' => 'freetext',
|
1425 |
+
'key' => 'panel_border_right',
|
1426 |
+
'validation' => 'px',
|
1427 |
+
),
|
1428 |
+
array(
|
1429 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1430 |
+
'type' => 'freetext',
|
1431 |
+
'key' => 'panel_border_bottom',
|
1432 |
+
'validation' => 'px',
|
1433 |
+
),
|
1434 |
+
array(
|
1435 |
+
'title' => __( 'Left', 'megamenu' ),
|
1436 |
+
'type' => 'freetext',
|
1437 |
+
'key' => 'panel_border_left',
|
1438 |
+
'validation' => 'px',
|
1439 |
+
),
|
1440 |
+
),
|
1441 |
+
),
|
1442 |
+
'panel_border_radius' => array(
|
1443 |
+
'priority' => 50,
|
1444 |
+
'title' => __( 'Panel Border Radius', 'megamenu' ),
|
1445 |
+
'description' => __( 'Set rounded corners for the sub menu.', 'megamenu' ),
|
1446 |
+
'settings' => array(
|
1447 |
+
array(
|
1448 |
+
'title' => __( 'Top Left', 'megamenu' ),
|
1449 |
+
'type' => 'freetext',
|
1450 |
+
'key' => 'panel_border_radius_top_left',
|
1451 |
+
'validation' => 'px',
|
1452 |
+
),
|
1453 |
+
array(
|
1454 |
+
'title' => __( 'Top Right', 'megamenu' ),
|
1455 |
+
'type' => 'freetext',
|
1456 |
+
'key' => 'panel_border_radius_top_right',
|
1457 |
+
'validation' => 'px',
|
1458 |
+
),
|
1459 |
+
array(
|
1460 |
+
'title' => __( 'Bottom Right', 'megamenu' ),
|
1461 |
+
'type' => 'freetext',
|
1462 |
+
'key' => 'panel_border_radius_bottom_right',
|
1463 |
+
'validation' => 'px',
|
1464 |
+
),
|
1465 |
+
array(
|
1466 |
+
'title' => __( 'Bottom Left', 'megamenu' ),
|
1467 |
+
'type' => 'freetext',
|
1468 |
+
'key' => 'panel_border_radius_bottom_left',
|
1469 |
+
'validation' => 'px',
|
1470 |
+
),
|
1471 |
+
),
|
1472 |
+
),
|
1473 |
+
'widget_padding' => array(
|
1474 |
+
'priority' => 60,
|
1475 |
+
'title' => __( 'Column Padding', 'megamenu' ),
|
1476 |
+
'description' => __( 'Use this to define the amount of space around each widget / set of menu items within the sub menu.', 'megamenu' ),
|
1477 |
+
'settings' => array(
|
1478 |
+
array(
|
1479 |
+
'title' => __( 'Top', 'megamenu' ),
|
1480 |
+
'type' => 'freetext',
|
1481 |
+
'key' => 'panel_widget_padding_top',
|
1482 |
+
'validation' => 'px',
|
1483 |
+
),
|
1484 |
+
array(
|
1485 |
+
'title' => __( 'Right', 'megamenu' ),
|
1486 |
+
'type' => 'freetext',
|
1487 |
+
'key' => 'panel_widget_padding_right',
|
1488 |
+
'validation' => 'px',
|
1489 |
+
),
|
1490 |
+
array(
|
1491 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1492 |
+
'type' => 'freetext',
|
1493 |
+
'key' => 'panel_widget_padding_bottom',
|
1494 |
+
'validation' => 'px',
|
1495 |
+
),
|
1496 |
+
array(
|
1497 |
+
'title' => __( 'Left', 'megamenu' ),
|
1498 |
+
'type' => 'freetext',
|
1499 |
+
'key' => 'panel_widget_padding_left',
|
1500 |
+
'validation' => 'px',
|
1501 |
+
),
|
1502 |
+
),
|
1503 |
+
),
|
1504 |
+
'mega_menu_widgets' => array(
|
1505 |
+
'priority' => 65,
|
1506 |
+
'title' => __( 'Widgets', 'megamenu' ),
|
1507 |
+
'description' => '',
|
1508 |
+
),
|
1509 |
+
'widget_heading_font' => array(
|
1510 |
+
'priority' => 70,
|
1511 |
+
'title' => __( 'Title Font', 'megamenu' ),
|
1512 |
+
'description' => __( 'Set the font to use Widget headers in the mega menu. Tip: set this to the same style as the Second Level Menu Item Font to keep your styling consistent.', 'megamenu' ),
|
1513 |
+
'settings' => array(
|
1514 |
+
array(
|
1515 |
+
'title' => __( 'Color', 'megamenu' ),
|
1516 |
+
'type' => 'color',
|
1517 |
+
'key' => 'panel_header_color',
|
1518 |
+
),
|
1519 |
+
array(
|
1520 |
+
'title' => __( 'Size', 'megamenu' ),
|
1521 |
+
'type' => 'freetext',
|
1522 |
+
'key' => 'panel_header_font_size',
|
1523 |
+
'validation' => 'px',
|
1524 |
+
),
|
1525 |
+
array(
|
1526 |
+
'title' => __( 'Family', 'megamenu' ),
|
1527 |
+
'type' => 'font',
|
1528 |
+
'key' => 'panel_header_font',
|
1529 |
+
),
|
1530 |
+
array(
|
1531 |
+
'title' => __( 'Transform', 'megamenu' ),
|
1532 |
+
'type' => 'transform',
|
1533 |
+
'key' => 'panel_header_text_transform',
|
1534 |
+
),
|
1535 |
+
array(
|
1536 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1537 |
+
'type' => 'weight',
|
1538 |
+
'key' => 'panel_header_font_weight',
|
1539 |
+
),
|
1540 |
+
array(
|
1541 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1542 |
+
'type' => 'decoration',
|
1543 |
+
'key' => 'panel_header_text_decoration',
|
1544 |
+
),
|
1545 |
+
array(
|
1546 |
+
'title' => __( 'Align', 'megamenu' ),
|
1547 |
+
'type' => 'align',
|
1548 |
+
'key' => 'panel_header_text_align',
|
1549 |
+
),
|
1550 |
+
),
|
1551 |
+
),
|
1552 |
+
'widget_heading_padding' => array(
|
1553 |
+
'priority' => 90,
|
1554 |
+
'title' => __( 'Title Padding', 'megamenu' ),
|
1555 |
+
'description' => __( 'Set the padding for the widget headings.', 'megamenu' ),
|
1556 |
+
'settings' => array(
|
1557 |
+
array(
|
1558 |
+
'title' => __( 'Top', 'megamenu' ),
|
1559 |
+
'type' => 'freetext',
|
1560 |
+
'key' => 'panel_header_padding_top',
|
1561 |
+
'validation' => 'px',
|
1562 |
+
),
|
1563 |
+
array(
|
1564 |
+
'title' => __( 'Right', 'megamenu' ),
|
1565 |
+
'type' => 'freetext',
|
1566 |
+
'key' => 'panel_header_padding_right',
|
1567 |
+
'validation' => 'px',
|
1568 |
+
),
|
1569 |
+
array(
|
1570 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1571 |
+
'type' => 'freetext',
|
1572 |
+
'key' => 'panel_header_padding_bottom',
|
1573 |
+
'validation' => 'px',
|
1574 |
+
),
|
1575 |
+
array(
|
1576 |
+
'title' => __( 'Left', 'megamenu' ),
|
1577 |
+
'type' => 'freetext',
|
1578 |
+
'key' => 'panel_header_padding_left',
|
1579 |
+
'validation' => 'px',
|
1580 |
+
),
|
1581 |
+
),
|
1582 |
+
),
|
1583 |
+
'widget_heading_margin' => array(
|
1584 |
+
'priority' => 100,
|
1585 |
+
'title' => __( 'Title Margin', 'megamenu' ),
|
1586 |
+
'description' => __( 'Set the margin for the widget headings.', 'megamenu' ),
|
1587 |
+
'settings' => array(
|
1588 |
+
array(
|
1589 |
+
'title' => __( 'Top', 'megamenu' ),
|
1590 |
+
'type' => 'freetext',
|
1591 |
+
'key' => 'panel_header_margin_top',
|
1592 |
+
'validation' => 'px',
|
1593 |
+
),
|
1594 |
+
array(
|
1595 |
+
'title' => __( 'Right', 'megamenu' ),
|
1596 |
+
'type' => 'freetext',
|
1597 |
+
'key' => 'panel_header_margin_right',
|
1598 |
+
'validation' => 'px',
|
1599 |
+
),
|
1600 |
+
array(
|
1601 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1602 |
+
'type' => 'freetext',
|
1603 |
+
'key' => 'panel_header_margin_bottom',
|
1604 |
+
'validation' => 'px',
|
1605 |
+
),
|
1606 |
+
array(
|
1607 |
+
'title' => __( 'Left', 'megamenu' ),
|
1608 |
+
'type' => 'freetext',
|
1609 |
+
'key' => 'panel_header_margin_left',
|
1610 |
+
'validation' => 'px',
|
1611 |
+
),
|
1612 |
+
),
|
1613 |
+
),
|
1614 |
+
'widget_header_border' => array(
|
1615 |
+
'priority' => 110,
|
1616 |
+
'title' => __( 'Title Border', 'megamenu' ),
|
1617 |
+
'description' => __( 'Set the border for the widget headings.', 'megamenu' ),
|
1618 |
+
'settings' => array(
|
1619 |
+
array(
|
1620 |
+
'title' => __( 'Color', 'megamenu' ),
|
1621 |
+
'type' => 'color',
|
1622 |
+
'key' => 'panel_header_border_color',
|
1623 |
+
),
|
1624 |
+
array(
|
1625 |
+
'title' => __( 'Color (Hover)', 'megamenu' ),
|
1626 |
+
'type' => 'color',
|
1627 |
+
'key' => 'panel_header_border_color_hover',
|
1628 |
+
),
|
1629 |
+
array(
|
1630 |
+
'title' => __( 'Top', 'megamenu' ),
|
1631 |
+
'type' => 'freetext',
|
1632 |
+
'key' => 'panel_header_border_top',
|
1633 |
+
'validation' => 'px',
|
1634 |
+
),
|
1635 |
+
array(
|
1636 |
+
'title' => __( 'Right', 'megamenu' ),
|
1637 |
+
'type' => 'freetext',
|
1638 |
+
'key' => 'panel_header_border_right',
|
1639 |
+
'validation' => 'px',
|
1640 |
+
),
|
1641 |
+
array(
|
1642 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1643 |
+
'type' => 'freetext',
|
1644 |
+
'key' => 'panel_header_border_bottom',
|
1645 |
+
'validation' => 'px',
|
1646 |
+
),
|
1647 |
+
array(
|
1648 |
+
'title' => __( 'Left', 'megamenu' ),
|
1649 |
+
'type' => 'freetext',
|
1650 |
+
'key' => 'panel_header_border_left',
|
1651 |
+
'validation' => 'px',
|
1652 |
+
),
|
1653 |
+
),
|
1654 |
+
),
|
1655 |
+
'widget_content_font' => array(
|
1656 |
+
'priority' => 115,
|
1657 |
+
'title' => __( 'Content Font', 'megamenu' ),
|
1658 |
+
'description' => __( 'Set the font to use for panel contents.', 'megamenu' ),
|
1659 |
+
'settings' => array(
|
1660 |
+
array(
|
1661 |
+
'title' => __( 'Color', 'megamenu' ),
|
1662 |
+
'type' => 'color',
|
1663 |
+
'key' => 'panel_font_color',
|
1664 |
+
),
|
1665 |
+
array(
|
1666 |
+
'title' => __( 'Size', 'megamenu' ),
|
1667 |
+
'type' => 'freetext',
|
1668 |
+
'key' => 'panel_font_size',
|
1669 |
+
'validation' => 'px',
|
1670 |
+
),
|
1671 |
+
array(
|
1672 |
+
'title' => __( 'Family', 'megamenu' ),
|
1673 |
+
'type' => 'font',
|
1674 |
+
'key' => 'panel_font_family',
|
1675 |
+
),
|
1676 |
+
),
|
1677 |
+
),
|
1678 |
+
'second_level_menu_items' => array(
|
1679 |
+
'priority' => 120,
|
1680 |
+
'title' => __( 'Second Level Menu Items', 'megamenu' ),
|
1681 |
+
'description' => '',
|
1682 |
+
),
|
1683 |
+
'second_level_font' => array(
|
1684 |
+
'priority' => 130,
|
1685 |
+
'title' => __( 'Item Font', 'megamenu' ),
|
1686 |
+
'description' => __( "Set the font for second level menu items when they're displayed in a Mega Menu.", 'megamenu' ),
|
1687 |
+
'settings' => array(
|
1688 |
+
array(
|
1689 |
+
'title' => __( 'Color', 'megamenu' ),
|
1690 |
+
'type' => 'color',
|
1691 |
+
'key' => 'panel_second_level_font_color',
|
1692 |
+
),
|
1693 |
+
array(
|
1694 |
+
'title' => __( 'Size', 'megamenu' ),
|
1695 |
+
'type' => 'freetext',
|
1696 |
+
'key' => 'panel_second_level_font_size',
|
1697 |
+
'validation' => 'px',
|
1698 |
+
),
|
1699 |
+
array(
|
1700 |
+
'title' => __( 'Family', 'megamenu' ),
|
1701 |
+
'type' => 'font',
|
1702 |
+
'key' => 'panel_second_level_font',
|
1703 |
+
),
|
1704 |
+
array(
|
1705 |
+
'title' => __( 'Transform', 'megamenu' ),
|
1706 |
+
'type' => 'transform',
|
1707 |
+
'key' => 'panel_second_level_text_transform',
|
1708 |
+
),
|
1709 |
+
array(
|
1710 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1711 |
+
'type' => 'weight',
|
1712 |
+
'key' => 'panel_second_level_font_weight',
|
1713 |
+
),
|
1714 |
+
array(
|
1715 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1716 |
+
'type' => 'decoration',
|
1717 |
+
'key' => 'panel_second_level_text_decoration',
|
1718 |
+
),
|
1719 |
+
array(
|
1720 |
+
'title' => __( 'Align', 'megamenu' ),
|
1721 |
+
'type' => 'align',
|
1722 |
+
'key' => 'panel_second_level_text_align',
|
1723 |
+
),
|
1724 |
+
),
|
1725 |
+
),
|
1726 |
+
'second_level_font_hover' => array(
|
1727 |
+
'priority' => 140,
|
1728 |
+
'title' => __( 'Item Font (Hover)', 'megamenu' ),
|
1729 |
+
'description' => __( 'Set the font style on hover.', 'megamenu' ),
|
1730 |
+
'settings' => array(
|
1731 |
+
array(
|
1732 |
+
'title' => __( 'Color', 'megamenu' ),
|
1733 |
+
'type' => 'color',
|
1734 |
+
'key' => 'panel_second_level_font_color_hover',
|
1735 |
+
),
|
1736 |
+
array(
|
1737 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1738 |
+
'type' => 'weight',
|
1739 |
+
'key' => 'panel_second_level_font_weight_hover',
|
1740 |
+
),
|
1741 |
+
array(
|
1742 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1743 |
+
'type' => 'decoration',
|
1744 |
+
'key' => 'panel_second_level_text_decoration_hover',
|
1745 |
+
),
|
1746 |
+
),
|
1747 |
+
),
|
1748 |
+
'second_level_background_hover' => array(
|
1749 |
+
'priority' => 150,
|
1750 |
+
'title' => __( 'Item Background (Hover)', 'megamenu' ),
|
1751 |
+
'description' => __( 'Set the background hover color for second level menu items.', 'megamenu' ),
|
1752 |
+
'settings' => array(
|
1753 |
+
array(
|
1754 |
+
'title' => __( 'From', 'megamenu' ),
|
1755 |
+
'type' => 'color',
|
1756 |
+
'key' => 'panel_second_level_background_hover_from',
|
1757 |
+
),
|
1758 |
+
array(
|
1759 |
+
'title' => __( 'Copy', 'megamenu' ),
|
1760 |
+
'type' => 'copy_color',
|
1761 |
+
'key' => 'copy_color',
|
1762 |
+
),
|
1763 |
+
array(
|
1764 |
+
'title' => __( 'To', 'megamenu' ),
|
1765 |
+
'type' => 'color',
|
1766 |
+
'key' => 'panel_second_level_background_hover_to',
|
1767 |
+
),
|
1768 |
+
),
|
1769 |
+
),
|
1770 |
+
'second_level_padding' => array(
|
1771 |
+
'priority' => 160,
|
1772 |
+
'title' => __( 'Item Padding', 'megamenu' ),
|
1773 |
+
'description' => __( 'Set the padding for the second level menu items.', 'megamenu' ),
|
1774 |
+
'settings' => array(
|
1775 |
+
array(
|
1776 |
+
'title' => __( 'Top', 'megamenu' ),
|
1777 |
+
'type' => 'freetext',
|
1778 |
+
'key' => 'panel_second_level_padding_top',
|
1779 |
+
'validation' => 'px',
|
1780 |
+
),
|
1781 |
+
array(
|
1782 |
+
'title' => __( 'Right', 'megamenu' ),
|
1783 |
+
'type' => 'freetext',
|
1784 |
+
'key' => 'panel_second_level_padding_right',
|
1785 |
+
'validation' => 'px',
|
1786 |
+
),
|
1787 |
+
array(
|
1788 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1789 |
+
'type' => 'freetext',
|
1790 |
+
'key' => 'panel_second_level_padding_bottom',
|
1791 |
+
'validation' => 'px',
|
1792 |
+
),
|
1793 |
+
array(
|
1794 |
+
'title' => __( 'Left', 'megamenu' ),
|
1795 |
+
'type' => 'freetext',
|
1796 |
+
'key' => 'panel_second_level_padding_left',
|
1797 |
+
'validation' => 'px',
|
1798 |
+
),
|
1799 |
+
),
|
1800 |
+
),
|
1801 |
+
'second_level_margin' => array(
|
1802 |
+
'priority' => 170,
|
1803 |
+
'title' => __( 'Item Margin', 'megamenu' ),
|
1804 |
+
'description' => __( 'Set the margin for the second level menu items.', 'megamenu' ),
|
1805 |
+
'settings' => array(
|
1806 |
+
array(
|
1807 |
+
'title' => __( 'Top', 'megamenu' ),
|
1808 |
+
'type' => 'freetext',
|
1809 |
+
'key' => 'panel_second_level_margin_top',
|
1810 |
+
'validation' => 'px',
|
1811 |
+
),
|
1812 |
+
array(
|
1813 |
+
'title' => __( 'Right', 'megamenu' ),
|
1814 |
+
'type' => 'freetext',
|
1815 |
+
'key' => 'panel_second_level_margin_right',
|
1816 |
+
'validation' => 'px',
|
1817 |
+
),
|
1818 |
+
array(
|
1819 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1820 |
+
'type' => 'freetext',
|
1821 |
+
'key' => 'panel_second_level_margin_bottom',
|
1822 |
+
'validation' => 'px',
|
1823 |
+
),
|
1824 |
+
array(
|
1825 |
+
'title' => __( 'Left', 'megamenu' ),
|
1826 |
+
'type' => 'freetext',
|
1827 |
+
'key' => 'panel_second_level_margin_left',
|
1828 |
+
'validation' => 'px',
|
1829 |
+
),
|
1830 |
+
),
|
1831 |
+
),
|
1832 |
+
'second_level_border' => array(
|
1833 |
+
'priority' => 180,
|
1834 |
+
'title' => __( 'Item Border', 'megamenu' ),
|
1835 |
+
'description' => __( 'Set the border for the second level menu items.', 'megamenu' ),
|
1836 |
+
'settings' => array(
|
1837 |
+
array(
|
1838 |
+
'title' => __( 'Color', 'megamenu' ),
|
1839 |
+
'type' => 'color',
|
1840 |
+
'key' => 'panel_second_level_border_color',
|
1841 |
+
),
|
1842 |
+
array(
|
1843 |
+
'title' => __( 'Color (Hover)', 'megamenu' ),
|
1844 |
+
'type' => 'color',
|
1845 |
+
'key' => 'panel_second_level_border_color_hover',
|
1846 |
+
),
|
1847 |
+
array(
|
1848 |
+
'title' => __( 'Top', 'megamenu' ),
|
1849 |
+
'type' => 'freetext',
|
1850 |
+
'key' => 'panel_second_level_border_top',
|
1851 |
+
'validation' => 'px',
|
1852 |
+
),
|
1853 |
+
array(
|
1854 |
+
'title' => __( 'Right', 'megamenu' ),
|
1855 |
+
'type' => 'freetext',
|
1856 |
+
'key' => 'panel_second_level_border_right',
|
1857 |
+
'validation' => 'px',
|
1858 |
+
),
|
1859 |
+
array(
|
1860 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1861 |
+
'type' => 'freetext',
|
1862 |
+
'key' => 'panel_second_level_border_bottom',
|
1863 |
+
'validation' => 'px',
|
1864 |
+
),
|
1865 |
+
array(
|
1866 |
+
'title' => __( 'Left', 'megamenu' ),
|
1867 |
+
'type' => 'freetext',
|
1868 |
+
'key' => 'panel_second_level_border_left',
|
1869 |
+
'validation' => 'px',
|
1870 |
+
),
|
1871 |
+
),
|
1872 |
+
),
|
1873 |
+
'third_level_menu_items' => array(
|
1874 |
+
'priority' => 190,
|
1875 |
+
'title' => __( 'Third Level Menu Items', 'megamenu' ),
|
1876 |
+
'description' => '',
|
1877 |
+
),
|
1878 |
+
'third_level_font' => array(
|
1879 |
+
'priority' => 200,
|
1880 |
+
'title' => __( 'Item Font', 'megamenu' ),
|
1881 |
+
'description' => __( "Set the font for third level menu items when they're displayed in a Mega Menu.", 'megamenu' ),
|
1882 |
+
'settings' => array(
|
1883 |
+
array(
|
1884 |
+
'title' => __( 'Color', 'megamenu' ),
|
1885 |
+
'type' => 'color',
|
1886 |
+
'key' => 'panel_third_level_font_color',
|
1887 |
+
),
|
1888 |
+
array(
|
1889 |
+
'title' => __( 'Size', 'megamenu' ),
|
1890 |
+
'type' => 'freetext',
|
1891 |
+
'key' => 'panel_third_level_font_size',
|
1892 |
+
'validation' => 'px',
|
1893 |
+
),
|
1894 |
+
array(
|
1895 |
+
'title' => __( 'Family', 'megamenu' ),
|
1896 |
+
'type' => 'font',
|
1897 |
+
'key' => 'panel_third_level_font',
|
1898 |
+
),
|
1899 |
+
array(
|
1900 |
+
'title' => __( 'Transform', 'megamenu' ),
|
1901 |
+
'type' => 'transform',
|
1902 |
+
'key' => 'panel_third_level_text_transform',
|
1903 |
+
),
|
1904 |
+
array(
|
1905 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1906 |
+
'type' => 'weight',
|
1907 |
+
'key' => 'panel_third_level_font_weight',
|
1908 |
+
),
|
1909 |
+
array(
|
1910 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1911 |
+
'type' => 'decoration',
|
1912 |
+
'key' => 'panel_third_level_text_decoration',
|
1913 |
+
),
|
1914 |
+
array(
|
1915 |
+
'title' => __( 'Align', 'megamenu' ),
|
1916 |
+
'type' => 'align',
|
1917 |
+
'key' => 'panel_third_level_text_align',
|
1918 |
+
),
|
1919 |
+
),
|
1920 |
+
),
|
1921 |
+
'third_level_font_hover' => array(
|
1922 |
+
'priority' => 210,
|
1923 |
+
'title' => __( 'Item Font (Hover)', 'megamenu' ),
|
1924 |
+
'description' => __( 'Set the font style on hover.', 'megamenu' ),
|
1925 |
+
'settings' => array(
|
1926 |
+
array(
|
1927 |
+
'title' => __( 'Color', 'megamenu' ),
|
1928 |
+
'type' => 'color',
|
1929 |
+
'key' => 'panel_third_level_font_color_hover',
|
1930 |
+
),
|
1931 |
+
array(
|
1932 |
+
'title' => __( 'Weight', 'megamenu' ),
|
1933 |
+
'type' => 'weight',
|
1934 |
+
'key' => 'panel_third_level_font_weight_hover',
|
1935 |
+
),
|
1936 |
+
array(
|
1937 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
1938 |
+
'type' => 'decoration',
|
1939 |
+
'key' => 'panel_third_level_text_decoration_hover',
|
1940 |
+
),
|
1941 |
+
),
|
1942 |
+
),
|
1943 |
+
'third_level_background_hover' => array(
|
1944 |
+
'priority' => 220,
|
1945 |
+
'title' => __( 'Item Background (Hover)', 'megamenu' ),
|
1946 |
+
'description' => __( 'Set the background hover color for third level menu items.', 'megamenu' ),
|
1947 |
+
'settings' => array(
|
1948 |
+
array(
|
1949 |
+
'title' => __( 'From', 'megamenu' ),
|
1950 |
+
'type' => 'color',
|
1951 |
+
'key' => 'panel_third_level_background_hover_from',
|
1952 |
+
),
|
1953 |
+
array(
|
1954 |
+
'title' => __( 'Copy', 'megamenu' ),
|
1955 |
+
'type' => 'copy_color',
|
1956 |
+
'key' => 'copy_color',
|
1957 |
+
),
|
1958 |
+
array(
|
1959 |
+
'title' => __( 'To', 'megamenu' ),
|
1960 |
+
'type' => 'color',
|
1961 |
+
'key' => 'panel_third_level_background_hover_to',
|
1962 |
+
),
|
1963 |
+
),
|
1964 |
+
),
|
1965 |
+
'third_level_padding' => array(
|
1966 |
+
'priority' => 230,
|
1967 |
+
'title' => __( 'Item Padding', 'megamenu' ),
|
1968 |
+
'description' => __( 'Set the padding for the third level menu items.', 'megamenu' ),
|
1969 |
+
'settings' => array(
|
1970 |
+
array(
|
1971 |
+
'title' => __( 'Top', 'megamenu' ),
|
1972 |
+
'type' => 'freetext',
|
1973 |
+
'key' => 'panel_third_level_padding_top',
|
1974 |
+
'validation' => 'px',
|
1975 |
+
),
|
1976 |
+
array(
|
1977 |
+
'title' => __( 'Right', 'megamenu' ),
|
1978 |
+
'type' => 'freetext',
|
1979 |
+
'key' => 'panel_third_level_padding_right',
|
1980 |
+
'validation' => 'px',
|
1981 |
+
),
|
1982 |
+
array(
|
1983 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
1984 |
+
'type' => 'freetext',
|
1985 |
+
'key' => 'panel_third_level_padding_bottom',
|
1986 |
+
'validation' => 'px',
|
1987 |
+
),
|
1988 |
+
array(
|
1989 |
+
'title' => __( 'Left', 'megamenu' ),
|
1990 |
+
'type' => 'freetext',
|
1991 |
+
'key' => 'panel_third_level_padding_left',
|
1992 |
+
'validation' => 'px',
|
1993 |
+
),
|
1994 |
+
),
|
1995 |
+
),
|
1996 |
+
|
1997 |
+
'third_level_margin' => array(
|
1998 |
+
'priority' => 235,
|
1999 |
+
'title' => __( 'Item Margin', 'megamenu' ),
|
2000 |
+
'description' => __( 'Set the margin for the third level menu items.', 'megamenu' ),
|
2001 |
+
'settings' => array(
|
2002 |
+
array(
|
2003 |
+
'title' => __( 'Top', 'megamenu' ),
|
2004 |
+
'type' => 'freetext',
|
2005 |
+
'key' => 'panel_third_level_margin_top',
|
2006 |
+
'validation' => 'px',
|
2007 |
+
),
|
2008 |
+
array(
|
2009 |
+
'title' => __( 'Right', 'megamenu' ),
|
2010 |
+
'type' => 'freetext',
|
2011 |
+
'key' => 'panel_third_level_margin_right',
|
2012 |
+
'validation' => 'px',
|
2013 |
+
),
|
2014 |
+
array(
|
2015 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2016 |
+
'type' => 'freetext',
|
2017 |
+
'key' => 'panel_third_level_margin_bottom',
|
2018 |
+
'validation' => 'px',
|
2019 |
+
),
|
2020 |
+
array(
|
2021 |
+
'title' => __( 'Left', 'megamenu' ),
|
2022 |
+
'type' => 'freetext',
|
2023 |
+
'key' => 'panel_third_level_margin_left',
|
2024 |
+
'validation' => 'px',
|
2025 |
+
),
|
2026 |
+
),
|
2027 |
+
),
|
2028 |
+
'third_level_border' => array(
|
2029 |
+
'priority' => 237,
|
2030 |
+
'title' => __( 'Item Border', 'megamenu' ),
|
2031 |
+
'description' => __( 'Set the border for the third level menu items.', 'megamenu' ),
|
2032 |
+
'settings' => array(
|
2033 |
+
array(
|
2034 |
+
'title' => __( 'Color', 'megamenu' ),
|
2035 |
+
'type' => 'color',
|
2036 |
+
'key' => 'panel_third_level_border_color',
|
2037 |
+
),
|
2038 |
+
array(
|
2039 |
+
'title' => __( 'Color (Hover)', 'megamenu' ),
|
2040 |
+
'type' => 'color',
|
2041 |
+
'key' => 'panel_third_level_border_color_hover',
|
2042 |
+
),
|
2043 |
+
array(
|
2044 |
+
'title' => __( 'Top', 'megamenu' ),
|
2045 |
+
'type' => 'freetext',
|
2046 |
+
'key' => 'panel_third_level_border_top',
|
2047 |
+
'validation' => 'px',
|
2048 |
+
),
|
2049 |
+
array(
|
2050 |
+
'title' => __( 'Right', 'megamenu' ),
|
2051 |
+
'type' => 'freetext',
|
2052 |
+
'key' => 'panel_third_level_border_right',
|
2053 |
+
'validation' => 'px',
|
2054 |
+
),
|
2055 |
+
array(
|
2056 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2057 |
+
'type' => 'freetext',
|
2058 |
+
'key' => 'panel_third_level_border_bottom',
|
2059 |
+
'validation' => 'px',
|
2060 |
+
),
|
2061 |
+
array(
|
2062 |
+
'title' => __( 'Left', 'megamenu' ),
|
2063 |
+
'type' => 'freetext',
|
2064 |
+
'key' => 'panel_third_level_border_left',
|
2065 |
+
'validation' => 'px',
|
2066 |
+
),
|
2067 |
+
),
|
2068 |
+
),
|
2069 |
+
),
|
2070 |
+
),
|
2071 |
+
'flyout_menus' => array(
|
2072 |
+
'title' => __( 'Flyout Menus', 'megamenu' ),
|
2073 |
+
'settings' => array(
|
2074 |
+
'flyout_menu_background' => array(
|
2075 |
+
'priority' => 10,
|
2076 |
+
'title' => __( 'Sub Menu Background', 'megamenu' ),
|
2077 |
+
'description' => __( 'Set the background color for the flyout menu.', 'megamenu' ),
|
2078 |
+
'settings' => array(
|
2079 |
+
array(
|
2080 |
+
'title' => __( 'From', 'megamenu' ),
|
2081 |
+
'type' => 'color',
|
2082 |
+
'key' => 'flyout_menu_background_from',
|
2083 |
+
),
|
2084 |
+
array(
|
2085 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2086 |
+
'type' => 'copy_color',
|
2087 |
+
'key' => 'copy_color',
|
2088 |
+
),
|
2089 |
+
array(
|
2090 |
+
'title' => __( 'To', 'megamenu' ),
|
2091 |
+
'type' => 'color',
|
2092 |
+
'key' => 'flyout_menu_background_to',
|
2093 |
+
),
|
2094 |
+
),
|
2095 |
+
),
|
2096 |
+
'flyout_menu_width' => array(
|
2097 |
+
'priority' => 20,
|
2098 |
+
'title' => __( 'Sub Menu Width', 'megamenu' ),
|
2099 |
+
'description' => __( 'The width of each flyout menu. This must be a fixed pixel value.', 'megamenu' ),
|
2100 |
+
'info' => array(
|
2101 |
+
__( 'Set this value to the width of your longest menu item title to stop menu items wrapping onto 2 lines.', 'megamenu' ),
|
2102 |
+
__( "Experimental: Set this value to 'auto' to use a flexible width.", 'megamenu' ),
|
2103 |
+
),
|
2104 |
+
'settings' => array(
|
2105 |
+
array(
|
2106 |
+
'title' => '',
|
2107 |
+
'type' => 'freetext',
|
2108 |
+
'key' => 'flyout_width',
|
2109 |
+
'validation' => 'px',
|
2110 |
+
),
|
2111 |
+
),
|
2112 |
+
),
|
2113 |
+
'flyout_menu_padding' => array(
|
2114 |
+
'priority' => 30,
|
2115 |
+
'title' => __( 'Sub Menu Padding', 'megamenu' ),
|
2116 |
+
'description' => __( 'Set the padding for the whole flyout menu.', 'megamenu' ),
|
2117 |
+
'info' => array( __( "Only suitable for single level flyout menus. If you're using multi level flyout menus set these values to 0px.", 'megamenu' ) ),
|
2118 |
+
'settings' => array(
|
2119 |
+
array(
|
2120 |
+
'title' => __( 'Top', 'megamenu' ),
|
2121 |
+
'type' => 'freetext',
|
2122 |
+
'key' => 'flyout_padding_top',
|
2123 |
+
'validation' => 'px',
|
2124 |
+
),
|
2125 |
+
array(
|
2126 |
+
'title' => __( 'Right', 'megamenu' ),
|
2127 |
+
'type' => 'freetext',
|
2128 |
+
'key' => 'flyout_padding_right',
|
2129 |
+
'validation' => 'px',
|
2130 |
+
),
|
2131 |
+
array(
|
2132 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2133 |
+
'type' => 'freetext',
|
2134 |
+
'key' => 'flyout_padding_bottom',
|
2135 |
+
'validation' => 'px',
|
2136 |
+
),
|
2137 |
+
array(
|
2138 |
+
'title' => __( 'Left', 'megamenu' ),
|
2139 |
+
'type' => 'freetext',
|
2140 |
+
'key' => 'flyout_padding_left',
|
2141 |
+
'validation' => 'px',
|
2142 |
+
),
|
2143 |
+
),
|
2144 |
+
),
|
2145 |
+
'flyout_menu_border' => array(
|
2146 |
+
'priority' => 40,
|
2147 |
+
'title' => __( 'Sub Menu Border', 'megamenu' ),
|
2148 |
+
'description' => __( 'Set the border for the flyout menu.', 'megamenu' ),
|
2149 |
+
'settings' => array(
|
2150 |
+
array(
|
2151 |
+
'title' => __( 'Color', 'megamenu' ),
|
2152 |
+
'type' => 'color',
|
2153 |
+
'key' => 'flyout_border_color',
|
2154 |
+
),
|
2155 |
+
array(
|
2156 |
+
'title' => __( 'Top', 'megamenu' ),
|
2157 |
+
'type' => 'freetext',
|
2158 |
+
'key' => 'flyout_border_top',
|
2159 |
+
'validation' => 'px',
|
2160 |
+
),
|
2161 |
+
array(
|
2162 |
+
'title' => __( 'Right', 'megamenu' ),
|
2163 |
+
'type' => 'freetext',
|
2164 |
+
'key' => 'flyout_border_right',
|
2165 |
+
'validation' => 'px',
|
2166 |
+
),
|
2167 |
+
array(
|
2168 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2169 |
+
'type' => 'freetext',
|
2170 |
+
'key' => 'flyout_border_bottom',
|
2171 |
+
'validation' => 'px',
|
2172 |
+
),
|
2173 |
+
array(
|
2174 |
+
'title' => __( 'Left', 'megamenu' ),
|
2175 |
+
'type' => 'freetext',
|
2176 |
+
'key' => 'flyout_border_left',
|
2177 |
+
'validation' => 'px',
|
2178 |
+
),
|
2179 |
+
),
|
2180 |
+
),
|
2181 |
+
'flyout_menu_border_radius' => array(
|
2182 |
+
'priority' => 50,
|
2183 |
+
'title' => __( 'Sub Menu Border Radius', 'megamenu' ),
|
2184 |
+
'description' => __( 'Set rounded corners for flyout menus. Rounded corners will be applied to all flyout menu levels.', 'megamenu' ),
|
2185 |
+
'settings' => array(
|
2186 |
+
array(
|
2187 |
+
'title' => __( 'Top Left', 'megamenu' ),
|
2188 |
+
'type' => 'freetext',
|
2189 |
+
'key' => 'flyout_border_radius_top_left',
|
2190 |
+
'validation' => 'px',
|
2191 |
+
),
|
2192 |
+
array(
|
2193 |
+
'title' => __( 'Top Right', 'megamenu' ),
|
2194 |
+
'type' => 'freetext',
|
2195 |
+
'key' => 'flyout_border_radius_top_right',
|
2196 |
+
'validation' => 'px',
|
2197 |
+
),
|
2198 |
+
array(
|
2199 |
+
'title' => __( 'Bottom Right', 'megamenu' ),
|
2200 |
+
'type' => 'freetext',
|
2201 |
+
'key' => 'flyout_border_radius_bottom_right',
|
2202 |
+
'validation' => 'px',
|
2203 |
+
),
|
2204 |
+
array(
|
2205 |
+
'title' => __( 'Bottom Left', 'megamenu' ),
|
2206 |
+
'type' => 'freetext',
|
2207 |
+
'key' => 'flyout_border_radius_bottom_left',
|
2208 |
+
'validation' => 'px',
|
2209 |
+
),
|
2210 |
+
),
|
2211 |
+
),
|
2212 |
+
'flyout_menu_item_background' => array(
|
2213 |
+
'priority' => 60,
|
2214 |
+
'title' => __( 'Menu Item Background', 'megamenu' ),
|
2215 |
+
'description' => __( 'Set the background color for a flyout menu item.', 'megamenu' ),
|
2216 |
+
'settings' => array(
|
2217 |
+
array(
|
2218 |
+
'title' => __( 'From', 'megamenu' ),
|
2219 |
+
'type' => 'color',
|
2220 |
+
'key' => 'flyout_background_from',
|
2221 |
+
),
|
2222 |
+
array(
|
2223 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2224 |
+
'type' => 'copy_color',
|
2225 |
+
'key' => 'copy_color',
|
2226 |
+
),
|
2227 |
+
array(
|
2228 |
+
'title' => __( 'To', 'megamenu' ),
|
2229 |
+
'type' => 'color',
|
2230 |
+
'key' => 'flyout_background_to',
|
2231 |
+
),
|
2232 |
+
),
|
2233 |
+
),
|
2234 |
+
'flyout_menu_item_background_hover' => array(
|
2235 |
+
'priority' => 70,
|
2236 |
+
'title' => __( 'Menu Item Background (Hover)', 'megamenu' ),
|
2237 |
+
'description' => __( 'Set the background color for a flyout menu item (on hover).', 'megamenu' ),
|
2238 |
+
'settings' => array(
|
2239 |
+
array(
|
2240 |
+
'title' => __( 'From', 'megamenu' ),
|
2241 |
+
'type' => 'color',
|
2242 |
+
'key' => 'flyout_background_hover_from',
|
2243 |
+
),
|
2244 |
+
array(
|
2245 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2246 |
+
'type' => 'copy_color',
|
2247 |
+
'key' => 'copy_color',
|
2248 |
+
),
|
2249 |
+
array(
|
2250 |
+
'title' => __( 'To', 'megamenu' ),
|
2251 |
+
'type' => 'color',
|
2252 |
+
'key' => 'flyout_background_hover_to',
|
2253 |
+
),
|
2254 |
+
),
|
2255 |
+
),
|
2256 |
+
'flyout_menu_item_height' => array(
|
2257 |
+
'priority' => 80,
|
2258 |
+
'title' => __( 'Menu Item Height', 'megamenu' ),
|
2259 |
+
'description' => __( 'The height of each flyout menu item.', 'megamenu' ),
|
2260 |
+
'settings' => array(
|
2261 |
+
array(
|
2262 |
+
'title' => '',
|
2263 |
+
'type' => 'freetext',
|
2264 |
+
'key' => 'flyout_link_height',
|
2265 |
+
'validation' => 'px',
|
2266 |
+
),
|
2267 |
+
),
|
2268 |
+
),
|
2269 |
+
'flyout_menu_item_padding' => array(
|
2270 |
+
'priority' => 90,
|
2271 |
+
'title' => __( 'Menu Item Padding', 'megamenu' ),
|
2272 |
+
'description' => __( 'Set the padding for each flyout menu item.', 'megamenu' ),
|
2273 |
+
'settings' => array(
|
2274 |
+
array(
|
2275 |
+
'title' => __( 'Top', 'megamenu' ),
|
2276 |
+
'type' => 'freetext',
|
2277 |
+
'key' => 'flyout_link_padding_top',
|
2278 |
+
'validation' => 'px',
|
2279 |
+
),
|
2280 |
+
array(
|
2281 |
+
'title' => __( 'Right', 'megamenu' ),
|
2282 |
+
'type' => 'freetext',
|
2283 |
+
'key' => 'flyout_link_padding_right',
|
2284 |
+
'validation' => 'px',
|
2285 |
+
),
|
2286 |
+
array(
|
2287 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2288 |
+
'type' => 'freetext',
|
2289 |
+
'key' => 'flyout_link_padding_bottom',
|
2290 |
+
'validation' => 'px',
|
2291 |
+
),
|
2292 |
+
array(
|
2293 |
+
'title' => __( 'Left', 'megamenu' ),
|
2294 |
+
'type' => 'freetext',
|
2295 |
+
'key' => 'flyout_link_padding_left',
|
2296 |
+
'validation' => 'px',
|
2297 |
+
),
|
2298 |
+
),
|
2299 |
+
),
|
2300 |
+
'flyout_menu_item_font' => array(
|
2301 |
+
'priority' => 100,
|
2302 |
+
'title' => __( 'Menu Item Font', 'megamenu' ),
|
2303 |
+
'description' => __( 'Set the font for the flyout menu items.', 'megamenu' ),
|
2304 |
+
'settings' => array(
|
2305 |
+
array(
|
2306 |
+
'title' => __( 'Color', 'megamenu' ),
|
2307 |
+
'type' => 'color',
|
2308 |
+
'key' => 'flyout_link_color',
|
2309 |
+
),
|
2310 |
+
array(
|
2311 |
+
'title' => __( 'Size', 'megamenu' ),
|
2312 |
+
'type' => 'freetext',
|
2313 |
+
'key' => 'flyout_link_size',
|
2314 |
+
'validation' => 'px',
|
2315 |
+
),
|
2316 |
+
array(
|
2317 |
+
'title' => __( 'Family', 'megamenu' ),
|
2318 |
+
'type' => 'font',
|
2319 |
+
'key' => 'flyout_link_family',
|
2320 |
+
),
|
2321 |
+
array(
|
2322 |
+
'title' => __( 'Transform', 'megamenu' ),
|
2323 |
+
'type' => 'transform',
|
2324 |
+
'key' => 'flyout_link_text_transform',
|
2325 |
+
),
|
2326 |
+
array(
|
2327 |
+
'title' => __( 'Weight', 'megamenu' ),
|
2328 |
+
'type' => 'weight',
|
2329 |
+
'key' => 'flyout_link_weight',
|
2330 |
+
),
|
2331 |
+
array(
|
2332 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
2333 |
+
'type' => 'decoration',
|
2334 |
+
'key' => 'flyout_link_text_decoration',
|
2335 |
+
),
|
2336 |
+
),
|
2337 |
+
),
|
2338 |
+
'flyout_menu_item_font_hover' => array(
|
2339 |
+
'priority' => 110,
|
2340 |
+
'title' => __( 'Menu Item Font (Hover)', 'megamenu' ),
|
2341 |
+
'description' => __( 'Set the font for the flyout menu items.', 'megamenu' ),
|
2342 |
+
'settings' => array(
|
2343 |
+
array(
|
2344 |
+
'title' => __( 'Color', 'megamenu' ),
|
2345 |
+
'type' => 'color',
|
2346 |
+
'key' => 'flyout_link_color_hover',
|
2347 |
+
),
|
2348 |
+
array(
|
2349 |
+
'title' => __( 'Weight', 'megamenu' ),
|
2350 |
+
'type' => 'weight',
|
2351 |
+
'key' => 'flyout_link_weight_hover',
|
2352 |
+
),
|
2353 |
+
array(
|
2354 |
+
'title' => __( 'Decoration', 'megamenu' ),
|
2355 |
+
'type' => 'decoration',
|
2356 |
+
'key' => 'flyout_link_text_decoration_hover',
|
2357 |
+
),
|
2358 |
+
),
|
2359 |
+
),
|
2360 |
+
'flyout_menu_item_divider' => array(
|
2361 |
+
'priority' => 120,
|
2362 |
+
'title' => __( 'Menu Item Divider', 'megamenu' ),
|
2363 |
+
'description' => __( 'Show a line divider below each menu item.', 'megamenu' ),
|
2364 |
+
'settings' => array(
|
2365 |
+
array(
|
2366 |
+
'title' => __( 'Enabled', 'megamenu' ),
|
2367 |
+
'type' => 'checkbox',
|
2368 |
+
'key' => 'flyout_menu_item_divider',
|
2369 |
+
),
|
2370 |
+
array(
|
2371 |
+
'title' => __( 'Color', 'megamenu' ),
|
2372 |
+
'type' => 'color',
|
2373 |
+
'key' => 'flyout_menu_item_divider_color',
|
2374 |
+
),
|
2375 |
+
),
|
2376 |
+
),
|
2377 |
+
),
|
2378 |
+
),
|
2379 |
+
'mobile_menu' => array(
|
2380 |
+
'title' => __( 'Mobile Menu', 'megamenu' ),
|
2381 |
+
'settings' => array(
|
2382 |
+
'mobile_toggle_bar' => array(
|
2383 |
+
'priority' => 5,
|
2384 |
+
'title' => __( 'Mobile Toggle Bar', 'megamenu' ),
|
2385 |
+
'description' => '',
|
2386 |
+
),
|
2387 |
+
'toggle_bar_background' => array(
|
2388 |
+
'priority' => 20,
|
2389 |
+
'title' => __( 'Toggle Bar Background', 'megamenu' ),
|
2390 |
+
'description' => __( 'Set the background color for the mobile menu toggle bar.', 'megamenu' ),
|
2391 |
+
'info' => array(
|
2392 |
+
__( "Don't forget to update the Menu toggle block text and icon color in the Toggle Bar Designer above!", 'megamenu' ),
|
2393 |
+
),
|
2394 |
+
'settings' => array(
|
2395 |
+
array(
|
2396 |
+
'title' => __( 'From', 'megamenu' ),
|
2397 |
+
'type' => 'color',
|
2398 |
+
'key' => 'toggle_background_from',
|
2399 |
+
),
|
2400 |
+
array(
|
2401 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2402 |
+
'type' => 'copy_color',
|
2403 |
+
'key' => 'copy_color',
|
2404 |
+
),
|
2405 |
+
array(
|
2406 |
+
'title' => __( 'To', 'megamenu' ),
|
2407 |
+
'type' => 'color',
|
2408 |
+
'key' => 'toggle_background_to',
|
2409 |
+
),
|
2410 |
+
),
|
2411 |
+
),
|
2412 |
+
'toggle_bar_height' => array(
|
2413 |
+
'priority' => 25,
|
2414 |
+
'title' => __( 'Toggle Bar Height', 'megamenu' ),
|
2415 |
+
'description' => __( 'Set the height of the mobile menu toggle bar.', 'megamenu' ),
|
2416 |
+
'settings' => array(
|
2417 |
+
array(
|
2418 |
+
'title' => '',
|
2419 |
+
'type' => 'freetext',
|
2420 |
+
'key' => 'toggle_bar_height',
|
2421 |
+
),
|
2422 |
+
),
|
2423 |
+
),
|
2424 |
+
'toggle_bar_border_radius' => array(
|
2425 |
+
'priority' => 26,
|
2426 |
+
'title' => __( 'Toggle Bar Border Radius', 'megamenu' ),
|
2427 |
+
'description' => __( 'Set a border radius on the mobile toggle bar.', 'megamenu' ),
|
2428 |
+
'settings' => array(
|
2429 |
+
array(
|
2430 |
+
'title' => __( 'Top Left', 'megamenu' ),
|
2431 |
+
'type' => 'freetext',
|
2432 |
+
'key' => 'toggle_bar_border_radius_top_left',
|
2433 |
+
'validation' => 'px',
|
2434 |
+
),
|
2435 |
+
array(
|
2436 |
+
'title' => __( 'Top Right', 'megamenu' ),
|
2437 |
+
'type' => 'freetext',
|
2438 |
+
'key' => 'toggle_bar_border_radius_top_right',
|
2439 |
+
'validation' => 'px',
|
2440 |
+
),
|
2441 |
+
array(
|
2442 |
+
'title' => __( 'Bottom Right', 'megamenu' ),
|
2443 |
+
'type' => 'freetext',
|
2444 |
+
'key' => 'toggle_bar_border_radius_bottom_right',
|
2445 |
+
'validation' => 'px',
|
2446 |
+
),
|
2447 |
+
array(
|
2448 |
+
'title' => __( 'Bottom Left', 'megamenu' ),
|
2449 |
+
'type' => 'freetext',
|
2450 |
+
'key' => 'toggle_bar_border_radius_bottom_left',
|
2451 |
+
'validation' => 'px',
|
2452 |
+
),
|
2453 |
+
),
|
2454 |
+
),
|
2455 |
+
'disable_mobile_toggle' => array(
|
2456 |
+
'priority' => 28,
|
2457 |
+
'title' => __( 'Disable Mobile Toggle Bar', 'megamenu' ),
|
2458 |
+
'description' => __( "Hide the toggle bar and display the menu in it's open state by default.", 'megamenu' ),
|
2459 |
+
'settings' => array(
|
2460 |
+
array(
|
2461 |
+
'title' => '',
|
2462 |
+
'type' => 'checkbox',
|
2463 |
+
'key' => 'disable_mobile_toggle',
|
2464 |
+
),
|
2465 |
+
),
|
2466 |
+
),
|
2467 |
+
'responsive_breakpoint' => array(
|
2468 |
+
'priority' => 3,
|
2469 |
+
'title' => __( 'Responsive Breakpoint', 'megamenu' ),
|
2470 |
+
'description' => __( 'The menu will be converted to a mobile menu when the browser width is below this value.', 'megamenu' ),
|
2471 |
+
'settings' => array(
|
2472 |
+
array(
|
2473 |
+
'title' => '',
|
2474 |
+
'type' => 'freetext',
|
2475 |
+
'key' => 'responsive_breakpoint',
|
2476 |
+
'validation' => 'px',
|
2477 |
+
),
|
2478 |
+
),
|
2479 |
+
),
|
2480 |
+
'responsive_breakpoint_disabled' => array(
|
2481 |
+
'priority' => 4,
|
2482 |
+
'title' => __( "The 'Responsive Breakpoint' option has been set to 0px. The desktop version of the menu will be displayed for all browsers (regardless of the browser width), so the following options are disabled.", 'megamenu' ),
|
2483 |
+
'description' => '',
|
2484 |
+
),
|
2485 |
+
'mobile_toggle_disabled' => array(
|
2486 |
+
'priority' => 5,
|
2487 |
+
'title' => __( "The 'Disable Mobile Toggle Bar' option has been enabled. The following options are disabled as the mobile toggle bar will not be displayed.", 'megamenu' ),
|
2488 |
+
'description' => '',
|
2489 |
+
),
|
2490 |
+
'mobile_top_level_menu_items' => array(
|
2491 |
+
'priority' => 33,
|
2492 |
+
'title' => __( 'Mobile Sub Menu', 'megamenu' ),
|
2493 |
+
'description' => '',
|
2494 |
+
),
|
2495 |
+
'mobile_menu_overlay' => array(
|
2496 |
+
'priority' => 34,
|
2497 |
+
'title' => __( 'Overlay Content', 'megamenu' ),
|
2498 |
+
'description' => __( 'If enabled, the mobile sub menu will overlay the page content (instead of pushing the page content down)', 'megamenu' ),
|
2499 |
+
'settings' => array(
|
2500 |
+
array(
|
2501 |
+
'title' => '',
|
2502 |
+
'type' => 'checkbox',
|
2503 |
+
'key' => 'mobile_menu_overlay',
|
2504 |
+
),
|
2505 |
+
),
|
2506 |
+
),
|
2507 |
+
'mobile_menu_force_width' => array(
|
2508 |
+
'priority' => 35,
|
2509 |
+
'title' => __( 'Force Full Width', 'megamenu' ),
|
2510 |
+
'description' => __( "If enabled, the mobile sub menu will match the width and position on the given page element (rather than being limited to the width of the toggle bar). For a full width sub menu, leave the 'Selector' value set to 'body'.", 'megamenu' ),
|
2511 |
+
'settings' => array(
|
2512 |
+
array(
|
2513 |
+
'title' => 'Enabled',
|
2514 |
+
'type' => 'checkbox',
|
2515 |
+
'key' => 'mobile_menu_force_width',
|
2516 |
+
),
|
2517 |
+
array(
|
2518 |
+
'title' => __( 'Selector', 'megamenu' ),
|
2519 |
+
'type' => 'freetext',
|
2520 |
+
'key' => 'mobile_menu_force_width_selector',
|
2521 |
+
),
|
2522 |
+
),
|
2523 |
+
),
|
2524 |
+
'mobile_menu_off_canvas_width' => array(
|
2525 |
+
'priority' => 36,
|
2526 |
+
'title' => __( 'Off Canvas Width', 'megamenu' ),
|
2527 |
+
'description' => __( "The width of the sub menu if the Mobile Effect is set to 'Slide Left' or 'Slide Right'. Must be specified in px.", 'megamenu' ),
|
2528 |
+
'settings' => array(
|
2529 |
+
array(
|
2530 |
+
'title' => '',
|
2531 |
+
'type' => 'freetext',
|
2532 |
+
'key' => 'mobile_menu_off_canvas_width',
|
2533 |
+
'validation' => 'px',
|
2534 |
+
),
|
2535 |
+
),
|
2536 |
+
),
|
2537 |
+
'mobile_menu_item_height' => array(
|
2538 |
+
'priority' => 38,
|
2539 |
+
'title' => __( 'Menu Item Height', 'megamenu' ),
|
2540 |
+
'description' => __( 'Height of each top level item in the mobile menu.', 'megamenu' ),
|
2541 |
+
'settings' => array(
|
2542 |
+
array(
|
2543 |
+
'title' => '',
|
2544 |
+
'type' => 'freetext',
|
2545 |
+
'key' => 'mobile_menu_item_height',
|
2546 |
+
),
|
2547 |
+
),
|
2548 |
+
),
|
2549 |
+
'mobile_menu_padding' => array(
|
2550 |
+
'priority' => 39,
|
2551 |
+
'title' => __( 'Menu Padding', 'megamenu' ),
|
2552 |
+
'description' => __( 'Padding for the mobile sub menu.', 'megamenu' ),
|
2553 |
+
'settings' => array(
|
2554 |
+
array(
|
2555 |
+
'title' => __( 'Top', 'megamenu' ),
|
2556 |
+
'type' => 'freetext',
|
2557 |
+
'key' => 'mobile_menu_padding_top',
|
2558 |
+
'validation' => 'px',
|
2559 |
+
),
|
2560 |
+
array(
|
2561 |
+
'title' => __( 'Right', 'megamenu' ),
|
2562 |
+
'type' => 'freetext',
|
2563 |
+
'key' => 'mobile_menu_padding_right',
|
2564 |
+
'validation' => 'px',
|
2565 |
+
),
|
2566 |
+
array(
|
2567 |
+
'title' => __( 'Bottom', 'megamenu' ),
|
2568 |
+
'type' => 'freetext',
|
2569 |
+
'key' => 'mobile_menu_padding_bottom',
|
2570 |
+
'validation' => 'px',
|
2571 |
+
),
|
2572 |
+
array(
|
2573 |
+
'title' => __( 'Left', 'megamenu' ),
|
2574 |
+
'type' => 'freetext',
|
2575 |
+
'key' => 'mobile_menu_padding_left',
|
2576 |
+
'validation' => 'px',
|
2577 |
+
),
|
2578 |
+
),
|
2579 |
+
),
|
2580 |
+
'mobile_background' => array(
|
2581 |
+
'priority' => 40,
|
2582 |
+
'title' => __( 'Menu Background', 'megamenu' ),
|
2583 |
+
'description' => __( 'The background color for the mobile menu.', 'megamenu' ),
|
2584 |
+
'settings' => array(
|
2585 |
+
array(
|
2586 |
+
'title' => __( 'From', 'megamenu' ),
|
2587 |
+
'type' => 'color',
|
2588 |
+
'key' => 'mobile_background_from',
|
2589 |
+
),
|
2590 |
+
array(
|
2591 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2592 |
+
'type' => 'copy_color',
|
2593 |
+
'key' => 'copy_color',
|
2594 |
+
),
|
2595 |
+
array(
|
2596 |
+
'title' => __( 'To', 'megamenu' ),
|
2597 |
+
'type' => 'color',
|
2598 |
+
'key' => 'mobile_background_to',
|
2599 |
+
),
|
2600 |
+
),
|
2601 |
+
),
|
2602 |
+
'mobile_background_hover' => array(
|
2603 |
+
'priority' => 45,
|
2604 |
+
'title' => __( 'Menu Item Background (Active)', 'megamenu' ),
|
2605 |
+
'description' => __( 'The background color for each top level menu item in the mobile menu when the sub menu is open.', 'megamenu' ),
|
2606 |
+
'settings' => array(
|
2607 |
+
array(
|
2608 |
+
'title' => __( 'From', 'megamenu' ),
|
2609 |
+
'type' => 'color',
|
2610 |
+
'key' => 'mobile_menu_item_background_hover_from',
|
2611 |
+
),
|
2612 |
+
array(
|
2613 |
+
'title' => __( 'Copy', 'megamenu' ),
|
2614 |
+
'type' => 'copy_color',
|
2615 |
+
'key' => 'copy_color',
|
2616 |
+
),
|
2617 |
+
array(
|
2618 |
+
'title' => __( 'To', 'megamenu' ),
|
2619 |
+
'type' => 'color',
|
2620 |
+
'key' => 'mobile_menu_item_background_hover_to',
|
2621 |
+
),
|
2622 |
+
),
|
2623 |
+
),
|
2624 |
+
'mobile_menu_item_font' => array(
|
2625 |
+
'priority' => 50,
|
2626 |
+
'title' => __( 'Font', 'megamenu' ),
|
2627 |
+
'description' => __( 'The font to use for each top level menu item in the mobile menu.', 'megamenu' ),
|
2628 |
+
'settings' => array(
|
2629 |
+
array(
|
2630 |
+
'title' => __( 'Color', 'megamenu' ),
|
2631 |
+
'type' => 'color',
|
2632 |
+
'key' => 'mobile_menu_item_link_color',
|
2633 |
+
),
|
2634 |
+
array(
|
2635 |
+
'title' => __( 'Size', 'megamenu' ),
|
2636 |
+
'type' => 'freetext',
|
2637 |
+
'key' => 'mobile_menu_item_link_font_size',
|
2638 |
+
'validation' => 'px',
|
2639 |
+
),
|
2640 |
+
array(
|
2641 |
+
'title' => __( 'Align', 'megamenu' ),
|
2642 |
+
'type' => 'align',
|
2643 |
+
'key' => 'mobile_menu_item_link_text_align',
|
2644 |
+
),
|
2645 |
+
),
|
2646 |
+
),
|
2647 |
+
'mobile_menu_item_font_hover' => array(
|
2648 |
+
'priority' => 55,
|
2649 |
+
'title' => __( 'Font (Active)', 'megamenu' ),
|
2650 |
+
'description' => __( 'The font color for each top level menu item in the mobile menu when the sub menu is open.', 'megamenu' ),
|
2651 |
+
'settings' => array(
|
2652 |
+
array(
|
2653 |
+
'title' => __( 'Color', 'megamenu' ),
|
2654 |
+
'type' => 'color',
|
2655 |
+
'key' => 'mobile_menu_item_link_color_hover',
|
2656 |
+
),
|
2657 |
+
),
|
2658 |
+
),
|
2659 |
+
'mobile_mega_menus' => array(
|
2660 |
+
'priority' => 60,
|
2661 |
+
'title' => __( 'Mega Menus', 'megamenu' ),
|
2662 |
+
'description' => '',
|
2663 |
+
),
|
2664 |
+
'mobile_columns' => array(
|
2665 |
+
'priority' => 65,
|
2666 |
+
'title' => __( 'Mega Menu Columns', 'megamenu' ),
|
2667 |
+
'description' => __( 'Collapse mega menu content into this many columns on mobile.', 'megamenu' ),
|
2668 |
+
'settings' => array(
|
2669 |
+
array(
|
2670 |
+
'title' => '',
|
2671 |
+
'type' => 'mobile_columns',
|
2672 |
+
'key' => 'mobile_columns',
|
2673 |
+
),
|
2674 |
+
),
|
2675 |
+
),
|
2676 |
+
),
|
2677 |
+
),
|
2678 |
+
'custom_styling' => array(
|
2679 |
+
'title' => __( 'Custom Styling', 'megamenu' ),
|
2680 |
+
'settings' => array(
|
2681 |
+
'custom_styling' => array(
|
2682 |
+
'priority' => 40,
|
2683 |
+
'title' => __( 'CSS Editor', 'megamenu' ),
|
2684 |
+
'description' => __( 'Define any custom CSS you wish to add to menus using this theme. You can use standard CSS or SCSS.', 'megamenu' ),
|
2685 |
+
'settings' => array(
|
2686 |
+
array(
|
2687 |
+
'title' => '',
|
2688 |
+
'type' => 'textarea',
|
2689 |
+
'key' => 'custom_css',
|
2690 |
+
),
|
2691 |
+
),
|
2692 |
+
),
|
2693 |
+
),
|
2694 |
+
),
|
2695 |
+
)
|
2696 |
+
);
|
2697 |
+
|
2698 |
+
echo "<h2 class='nav-tab-wrapper'>";
|
2699 |
+
|
2700 |
+
$is_first = true;
|
2701 |
+
|
2702 |
+
foreach ( $settings as $section_id => $section ) {
|
2703 |
+
|
2704 |
+
if ( $is_first ) {
|
2705 |
+
$active = 'nav-tab-active ';
|
2706 |
+
$is_first = false;
|
2707 |
+
} else {
|
2708 |
+
$active = '';
|
2709 |
+
}
|
2710 |
+
|
2711 |
+
echo "<a class='mega-tab nav-tab {$active}' data-tab='mega-tab-content-{$section_id}'>" . $section['title'] . '</a>';
|
2712 |
+
|
2713 |
+
}
|
2714 |
+
|
2715 |
+
echo '</h2>';
|
2716 |
+
|
2717 |
+
$is_first = true;
|
2718 |
+
|
2719 |
+
foreach ( $settings as $section_id => $section ) {
|
2720 |
+
|
2721 |
+
if ( $is_first ) {
|
2722 |
+
$display = 'block';
|
2723 |
+
$is_first = false;
|
2724 |
+
} else {
|
2725 |
+
$display = 'none';
|
2726 |
+
}
|
2727 |
+
|
2728 |
+
echo " <div class='mega-tab-content mega-tab-content-{$section_id}' style='display: {$display}'>";
|
2729 |
+
echo " <table class='{$section_id}'>";
|
2730 |
+
|
2731 |
+
// order the fields by priority
|
2732 |
+
uasort( $section['settings'], array( $this, 'compare_elems' ) );
|
2733 |
+
|
2734 |
+
foreach ( $section['settings'] as $group_id => $group ) {
|
2735 |
+
|
2736 |
+
echo "<tr class='mega-{$group_id}'>";
|
2737 |
+
|
2738 |
+
if ( isset( $group['settings'] ) ) {
|
2739 |
+
|
2740 |
+
echo "<td class='mega-name'>" . $group['title'] . "<div class='mega-description'>" . $group['description'] . '</div></td>';
|
2741 |
+
echo "<td class='mega-value'>";
|
2742 |
+
|
2743 |
+
foreach ( $group['settings'] as $setting_id => $setting ) {
|
2744 |
+
|
2745 |
+
if ( isset( $setting['validation'] ) ) {
|
2746 |
+
echo "<label class='mega-{$setting['key']}' data-validation='{$setting['validation']}'>";
|
2747 |
+
} else {
|
2748 |
+
echo "<label class='mega-{$setting['key']}'>";
|
2749 |
+
}
|
2750 |
+
echo "<span class='mega-short-desc'>{$setting['title']}</span>";
|
2751 |
+
|
2752 |
+
switch ( $setting['type'] ) {
|
2753 |
+
case 'freetext':
|
2754 |
+
$this->print_theme_freetext_option( $setting['key'] );
|
2755 |
+
break;
|
2756 |
+
case 'textarea':
|
2757 |
+
$this->print_theme_textarea_option( $setting['key'] );
|
2758 |
+
break;
|
2759 |
+
case 'align':
|
2760 |
+
$this->print_theme_align_option( $setting['key'] );
|
2761 |
+
break;
|
2762 |
+
case 'checkbox':
|
2763 |
+
$this->print_theme_checkbox_option( $setting['key'] );
|
2764 |
+
break;
|
2765 |
+
case 'arrow':
|
2766 |
+
$this->print_theme_arrow_option( $setting['key'] );
|
2767 |
+
break;
|
2768 |
+
case 'color':
|
2769 |
+
$this->print_theme_color_option( $setting['key'] );
|
2770 |
+
break;
|
2771 |
+
case 'weight':
|
2772 |
+
$this->print_theme_weight_option( $setting['key'] );
|
2773 |
+
break;
|
2774 |
+
case 'font':
|
2775 |
+
$this->print_theme_font_option( $setting['key'] );
|
2776 |
+
break;
|
2777 |
+
case 'transform':
|
2778 |
+
$this->print_theme_transform_option( $setting['key'] );
|
2779 |
+
break;
|
2780 |
+
case 'decoration':
|
2781 |
+
$this->print_theme_text_decoration_option( $setting['key'] );
|
2782 |
+
break;
|
2783 |
+
case 'mobile_columns':
|
2784 |
+
$this->print_theme_mobile_columns_option( $setting['key'] );
|
2785 |
+
break;
|
2786 |
+
case 'copy_color':
|
2787 |
+
$this->print_theme_copy_color_option( $setting['key'] );
|
2788 |
+
break;
|
2789 |
+
default:
|
2790 |
+
do_action( "megamenu_print_theme_option_{$setting['type']}", $setting['key'], $this->id );
|
2791 |
+
break;
|
2792 |
+
}
|
2793 |
|
2794 |
+
echo '</label>';
|
2795 |
|
2796 |
+
}
|
2797 |
|
2798 |
+
if ( isset( $group['info'] ) ) {
|
2799 |
+
foreach ( $group['info'] as $paragraph ) {
|
2800 |
+
echo "<div class='mega-info'>{$paragraph}</div>";
|
2801 |
+
}
|
2802 |
+
}
|
2803 |
|
2804 |
+
foreach ( $group['settings'] as $setting_id => $setting ) {
|
2805 |
+
if ( isset( $setting['validation'] ) ) {
|
|
|
2806 |
|
2807 |
+
echo "<div class='mega-validation-message mega-validation-message-mega-{$setting['key']}'>";
|
2808 |
|
2809 |
+
if ( $setting['validation'] == 'int' ) {
|
2810 |
+
$message = __( 'Enter a whole number (e.g. 1, 5, 100, 999)' );
|
2811 |
+
}
|
2812 |
|
2813 |
+
if ( $setting['validation'] == 'px' ) {
|
2814 |
+
$message = __( 'Enter a value including a unit (e.g. 10px, 10rem, 10%)' );
|
2815 |
+
}
|
2816 |
|
2817 |
+
if ( $setting['validation'] == 'float' ) {
|
2818 |
+
$message = __( 'Enter a valid number (e.g. 0.1, 1, 10, 999)' );
|
2819 |
+
}
|
2820 |
+
|
2821 |
+
if ( strlen( $setting['title'] ) ) {
|
2822 |
+
echo $setting['title'] . ': ' . $message;
|
2823 |
+
} else {
|
2824 |
+
echo $message;
|
2825 |
+
}
|
2826 |
|
2827 |
+
echo '</div>';
|
2828 |
+
}
|
2829 |
+
}
|
2830 |
|
2831 |
+
echo '</td>';
|
2832 |
+
} else {
|
2833 |
+
echo "<td colspan='2'><h5>{$group['title']}</h5></td>";
|
2834 |
+
}
|
2835 |
+
|
2836 |
+
echo '</tr>';
|
2837 |
|
2838 |
+
}
|
2839 |
+
|
2840 |
+
echo '</table>';
|
2841 |
+
echo '</div>';
|
2842 |
+
}
|
2843 |
+
|
2844 |
+
?>
|
2845 |
+
|
2846 |
+
|
2847 |
+
<div class='megamenu_submit'>
|
2848 |
+
<div class='mega_left'>
|
2849 |
+
<?php submit_button(); ?>
|
2850 |
+
</div>
|
2851 |
+
<div class='mega_right'>
|
2852 |
+
</div>
|
2853 |
+
</div>
|
2854 |
|
2855 |
+
<?php $this->show_cache_warning(); ?>
|
2856 |
+
</form>
|
2857 |
+
</div>
|
2858 |
|
2859 |
+
<?php
|
2860 |
|
2861 |
+
}
|
2862 |
|
|
|
2863 |
|
2864 |
+
/**
|
2865 |
+
* Check for installed caching/minification/CDN plugins and output a warning if one is found to be
|
2866 |
+
* installed and activated
|
2867 |
+
*/
|
2868 |
+
public function show_cache_warning() {
|
2869 |
|
2870 |
+
$active_plugins = max_mega_menu_get_active_caching_plugins();
|
|
|
2871 |
|
2872 |
+
if ( count( $active_plugins ) ) :
|
2873 |
|
2874 |
+
?>
|
2875 |
|
2876 |
+
<div>
|
2877 |
|
2878 |
+
<h3><?php _e( 'Changes not showing up?', 'megamenu' ); ?></h3>
|
2879 |
|
2880 |
+
<p><?php echo _n( 'We have detected the following plugin that may prevent changes made within the theme editor from being applied to the menu.', 'We have detected the following plugins that may prevent changes made within the theme editor from being applied to the menu.', count( $active_plugins ), 'megamenu' ); ?></p>
|
2881 |
|
2882 |
+
<ul class='ul-disc'>
|
2883 |
+
<?php
|
2884 |
+
foreach ( $active_plugins as $name ) {
|
2885 |
+
echo '<li>' . $name . '</li>';
|
2886 |
+
}
|
2887 |
+
?>
|
2888 |
+
</ul>
|
2889 |
|
2890 |
+
<p><?php echo _n( 'Try clearing the cache of the above plugin if your changes are not being applied to the menu.', 'Try clearing the caches of the above plugins if your changes are not being applied to the menu.', count( $active_plugins ), 'megamenu' ); ?></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
2891 |
|
2892 |
+
</div>
|
2893 |
|
2894 |
+
<?php
|
2895 |
|
2896 |
+
endif;
|
2897 |
+
}
|
|
|
|
|
|
|
|
|
|
|
2898 |
|
|
|
2899 |
|
2900 |
+
/**
|
2901 |
+
* Compare array values
|
2902 |
+
*
|
2903 |
+
* @param array $elem1
|
2904 |
+
* @param array $elem2
|
2905 |
+
* @return bool
|
2906 |
+
* @since 2.1
|
2907 |
+
*/
|
2908 |
+
private function compare_elems( $elem1, $elem2 ) {
|
2909 |
|
2910 |
+
return $elem1['priority'] > $elem2['priority'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2911 |
|
2912 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2913 |
|
|
|
2914 |
|
2915 |
+
/**
|
2916 |
+
* Print a select dropdown with left, center and right options
|
2917 |
+
*
|
2918 |
+
* @since 1.6.1
|
2919 |
+
* @param string $key
|
2920 |
+
* @param string $value
|
2921 |
+
*/
|
2922 |
+
public function print_theme_align_option( $key ) {
|
2923 |
|
2924 |
+
$value = $this->active_theme[ $key ];
|
2925 |
|
2926 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
2927 |
|
2928 |
+
<select name='settings[<?php echo $key; ?>]'>
|
2929 |
+
<option value='left' <?php selected( $value, 'left' ); ?>><?php _e( 'Left', 'megamenu' ); ?></option>
|
2930 |
+
<option value='center' <?php selected( $value, 'center' ); ?>><?php _e( 'Center', 'megamenu' ); ?></option>
|
2931 |
+
<option value='right' <?php selected( $value, 'right' ); ?>><?php _e( 'Right', 'megamenu' ); ?></option>
|
2932 |
+
</select>
|
2933 |
|
2934 |
+
<?php
|
2935 |
+
}
|
2936 |
|
2937 |
|
2938 |
+
/**
|
2939 |
+
* Print a copy icon
|
2940 |
+
*
|
2941 |
+
* @since 2.2.3
|
2942 |
+
* @param string $key
|
2943 |
+
* @param string $value
|
2944 |
+
*/
|
2945 |
+
public function print_theme_copy_color_option( $key ) {
|
2946 |
|
2947 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2948 |
|
2949 |
+
<span class='dashicons dashicons-arrow-right-alt'></span>
|
|
|
|
|
2950 |
|
2951 |
+
<?php
|
2952 |
+
}
|
2953 |
|
|
|
2954 |
|
2955 |
+
/**
|
2956 |
+
* Print a select dropdown with 1 and 2 options
|
2957 |
+
*
|
2958 |
+
* @since 1.2.0
|
2959 |
+
* @param string $key
|
2960 |
+
* @param string $value
|
2961 |
+
*/
|
2962 |
+
public function print_theme_mobile_columns_option( $key ) {
|
2963 |
|
2964 |
+
$value = $this->active_theme[ $key ];
|
2965 |
|
2966 |
+
?>
|
2967 |
|
2968 |
+
<select name='settings[<?php echo $key; ?>]'>
|
2969 |
+
<option value='1' <?php selected( $value, '1' ); ?>><?php _e( '1 Column', 'megamenu' ); ?></option>
|
2970 |
+
<option value='2' <?php selected( $value, '2' ); ?>><?php _e( '2 Columns', 'megamenu' ); ?></option>
|
2971 |
+
</select>
|
2972 |
|
2973 |
+
<?php
|
2974 |
+
}
|
2975 |
|
|
|
|
|
|
|
2976 |
|
2977 |
+
/**
|
2978 |
+
* Print a select dropdown with text decoration options
|
2979 |
+
*
|
2980 |
+
* @since 1.6.1
|
2981 |
+
* @param string $key
|
2982 |
+
* @param string $value
|
2983 |
+
*/
|
2984 |
+
public function print_theme_text_decoration_option( $key ) {
|
2985 |
|
2986 |
+
$value = $this->active_theme[ $key ];
|
|
|
2987 |
|
2988 |
+
?>
|
2989 |
|
2990 |
+
<select name='settings[<?php echo $key; ?>]'>
|
2991 |
+
<option value='none' <?php selected( $value, 'none' ); ?>><?php _e( 'None', 'megamenu' ); ?></option>
|
2992 |
+
<option value='underline' <?php selected( $value, 'underline' ); ?>><?php _e( 'Underline', 'megamenu' ); ?></option>
|
2993 |
+
</select>
|
|
|
|
|
2994 |
|
2995 |
+
<?php
|
2996 |
+
}
|
2997 |
|
|
|
2998 |
|
2999 |
+
/**
|
3000 |
+
* Print a checkbox option
|
3001 |
+
*
|
3002 |
+
* @since 1.6.1
|
3003 |
+
* @param string $key
|
3004 |
+
* @param string $value
|
3005 |
+
*/
|
3006 |
+
public function print_theme_checkbox_option( $key ) {
|
3007 |
|
3008 |
+
$value = $this->active_theme[ $key ];
|
|
|
|
|
3009 |
|
3010 |
+
?>
|
|
|
|
|
3011 |
|
3012 |
+
<input type='hidden' name='checkboxes[<?php echo $key; ?>]' />
|
3013 |
+
<input type='checkbox' name='settings[<?php echo $key; ?>]' <?php checked( $value, 'on' ); ?> />
|
|
|
3014 |
|
3015 |
+
<?php
|
3016 |
+
}
|
|
|
3017 |
|
|
|
|
|
|
|
3018 |
|
3019 |
+
/**
|
3020 |
+
* Print an arrow dropdown selection box
|
3021 |
+
*
|
3022 |
+
* @since 1.0
|
3023 |
+
* @param string $key
|
3024 |
+
* @param string $value
|
3025 |
+
*/
|
3026 |
+
public function print_theme_arrow_option( $key ) {
|
3027 |
|
3028 |
+
$value = $this->active_theme[ $key ];
|
3029 |
|
3030 |
+
$arrow_icons = $this->arrow_icons();
|
3031 |
|
3032 |
+
?>
|
3033 |
+
<select class='icon_dropdown' name='settings[<?php echo $key; ?>]'>
|
3034 |
+
<?php
|
3035 |
|
3036 |
+
echo "<option value='disabled'>" . __( 'Disabled', 'megamenu' ) . '</option>';
|
|
|
|
|
|
|
|
|
|
|
3037 |
|
3038 |
+
foreach ( $arrow_icons as $code => $class ) {
|
3039 |
+
$name = str_replace( 'dashicons-', '', $class );
|
3040 |
+
$name = ucwords( str_replace( array( '-', 'arrow' ), ' ', $name ) );
|
3041 |
+
echo "<option data-class='{$class}' value='{$code}' " . selected( $value, $code, false ) . '>' . esc_html( $name ) . '</option>';
|
3042 |
+
}
|
3043 |
|
3044 |
+
?>
|
3045 |
+
</select>
|
3046 |
|
3047 |
+
<?php
|
3048 |
+
}
|
3049 |
|
|
|
3050 |
|
|
|
3051 |
|
3052 |
+
/**
|
3053 |
+
* Print a colorpicker
|
3054 |
+
*
|
3055 |
+
* @since 1.0
|
3056 |
+
* @param string $key
|
3057 |
+
* @param string $value
|
3058 |
+
*/
|
3059 |
+
public function print_theme_color_option( $key ) {
|
3060 |
|
3061 |
+
$value = $this->active_theme[ $key ];
|
|
|
|
|
3062 |
|
3063 |
+
if ( $value == 'transparent' ) {
|
3064 |
+
$value = 'rgba(0,0,0,0)';
|
3065 |
+
}
|
3066 |
|
3067 |
+
if ( $value == 'rgba(0,0,0,0)' ) {
|
3068 |
+
$value_text = 'transparent';
|
3069 |
+
} else {
|
3070 |
+
$value_text = $value;
|
3071 |
+
}
|
3072 |
|
3073 |
+
echo "<div class='mm-picker-container'>";
|
3074 |
+
echo " <input type='text' class='mm_colorpicker' name='settings[$key]' value='" . esc_attr( $value ) . "' />";
|
3075 |
+
echo " <div class='chosen-color'>" . esc_html( $value_text ) . '</div>';
|
3076 |
+
echo '</div>';
|
3077 |
+
|
3078 |
+
}
|
3079 |
+
|
3080 |
+
|
3081 |
+
/**
|
3082 |
+
* Print a font weight selector
|
3083 |
+
*
|
3084 |
+
* @since 1.0
|
3085 |
+
* @param string $key
|
3086 |
+
* @param string $value
|
3087 |
+
*/
|
3088 |
+
public function print_theme_weight_option( $key ) {
|
3089 |
+
|
3090 |
+
$value = $this->active_theme[ $key ];
|
3091 |
+
|
3092 |
+
$options = apply_filters(
|
3093 |
+
'megamenu_font_weights',
|
3094 |
+
array(
|
3095 |
+
'inherit' => __( 'Theme Default', 'megamenu' ),
|
3096 |
+
'300' => __( 'Light (300)', 'megamenu' ),
|
3097 |
+
'normal' => __( 'Normal (400)', 'megamenu' ),
|
3098 |
+
'bold' => __( 'Bold (700)', 'megamenu' ),
|
3099 |
+
)
|
3100 |
+
);
|
3101 |
+
|
3102 |
+
/**
|
3103 |
+
* '100' => __("Thin (100)", "megamenu"),
|
3104 |
+
* '200' => __("Extra Light (200)", "megamenu"),
|
3105 |
+
* '300' => __("Light (300)", "megamenu"),
|
3106 |
+
* 'normal' => __("Normal (400)", "megamenu"),
|
3107 |
+
* '500' => __("Medium (500)", "megamenu"),
|
3108 |
+
* '600' => __("Semi Bold (600)", "megamenu"),
|
3109 |
+
* 'bold' => __("Bold (700)", "megamenu"),
|
3110 |
+
* '800' => __("Extra Bold (800)", "megamenu"),
|
3111 |
+
* '900' => __("Black (900)", "megamenu")
|
3112 |
+
*/
|
3113 |
+
|
3114 |
+
echo "<select name='settings[$key]'>";
|
3115 |
+
|
3116 |
+
foreach ( $options as $weight => $name ) {
|
3117 |
+
echo "<option value='" . esc_attr( $weight ) . "' " . selected( $value, $weight, false ) . '>' . esc_html( $name ) . '</option>';
|
3118 |
+
}
|
3119 |
+
|
3120 |
+
echo '</select>';
|
3121 |
+
|
3122 |
+
}
|
3123 |
+
|
3124 |
+
|
3125 |
+
/**
|
3126 |
+
* Print a font transform selector
|
3127 |
+
*
|
3128 |
+
* @since 1.0
|
3129 |
+
* @param string $key
|
3130 |
+
* @param string $value
|
3131 |
+
*/
|
3132 |
+
public function print_theme_transform_option( $key ) {
|
3133 |
+
|
3134 |
+
$value = $this->active_theme[ $key ];
|
3135 |
+
|
3136 |
+
echo "<select name='settings[$key]'>";
|
3137 |
+
echo " <option value='none' " . selected( $value, 'none', false ) . '>' . __( 'Normal', 'megamenu' ) . '</option>';
|
3138 |
+
echo " <option value='capitalize'" . selected( $value, 'capitalize', false ) . '>' . __( 'Capitalize', 'megamenu' ) . '</option>';
|
3139 |
+
echo " <option value='uppercase'" . selected( $value, 'uppercase', false ) . '>' . __( 'UPPERCASE', 'megamenu' ) . '</option>';
|
3140 |
+
echo " <option value='lowercase'" . selected( $value, 'lowercase', false ) . '>' . __( 'lowercase', 'megamenu' ) . '</option>';
|
3141 |
+
echo '</select>';
|
3142 |
+
|
3143 |
+
}
|
3144 |
+
|
3145 |
+
|
3146 |
+
/**
|
3147 |
+
* Print a textarea
|
3148 |
+
*
|
3149 |
+
* @since 1.0
|
3150 |
+
* @param string $key
|
3151 |
+
* @param string $value
|
3152 |
+
*/
|
3153 |
+
public function print_theme_textarea_option( $key ) {
|
3154 |
+
|
3155 |
+
$value = sanitize_textarea_field( $this->active_theme[ $key ] );
|
3156 |
+
|
3157 |
+
?>
|
3158 |
+
|
3159 |
+
<textarea id='codemirror' name='settings[<?php echo $key; ?>]'><?php echo stripslashes( $value ); ?></textarea>
|
3160 |
+
|
3161 |
+
<p><b><?php _e( 'Custom Styling Tips', 'megamenu' ); ?></b></p>
|
3162 |
+
<p><?php _e( "You can enter standard CSS or <a href='https://sass-lang.com/guide' target='_blank'>SCSS</a> into the custom styling area. If using SCSS there are some variables and mixins you can use:" ); ?></p>
|
3163 |
+
<ul class='custom_styling_tips'>
|
3164 |
+
<li><code>#{$wrap}</code> <?php _e( 'converts to the ID selector of the menu wrapper, e.g. div#mega-menu-wrap-primary', 'megamenu' ); ?></li>
|
3165 |
+
<li><code>#{$menu}</code> <?php _e( 'converts to the ID selector of the menu, e.g. ul#mega-menu-primary', 'megamenu' ); ?></li>
|
3166 |
+
<li><code>@include mobile|desktop { .. }</code> <?php _e( 'wraps the CSS within a media query based on the configured Responsive Breakpoint (see example CSS)', 'megamenu' ); ?></li>
|
3167 |
+
<?php
|
3168 |
+
$string = __( 'Using the %wrap% and %menu% variables makes your theme portable (allowing you to apply the same theme to multiple menu locations)', 'megamenu' );
|
3169 |
+
$string = str_replace( '%wrap%', '<code>#{$wrap}</code>', $string );
|
3170 |
+
$string = str_replace( '%menu%', '<code>#{$menu}</code>', $string );
|
3171 |
+
?>
|
3172 |
+
<li><?php echo $string; ?></li>
|
3173 |
+
<li>Example CSS:</li>
|
3174 |
+
<code>/** Add text shadow to top level menu items on desktop AND mobile **/
|
3175 |
+
<br />#{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
|
3176 |
+
<br /> text-shadow: 1px 1px #000000;
|
3177 |
+
<br />}
|
3178 |
+
</code>
|
3179 |
+
<br /><br />
|
3180 |
+
<code>/** Add text shadow to top level menu items on desktop only **/
|
3181 |
+
<br />@include desktop {
|
3182 |
+
<br /> #{$wrap} #{$menu} > li.mega-menu-item > a.mega-menu-link {
|
3183 |
+
<br /> text-shadow: 1px 1px #000000;
|
3184 |
+
<br /> }
|
3185 |
+
<br />}
|
3186 |
+
</code></li>
|
3187 |
+
</ul>
|
3188 |
+
|
3189 |
+
<?php
|
3190 |
+
|
3191 |
+
}
|
3192 |
+
|
3193 |
+
|
3194 |
+
/**
|
3195 |
+
* Print a font selector
|
3196 |
+
*
|
3197 |
+
* @since 1.0
|
3198 |
+
* @param string $key
|
3199 |
+
* @param string $value
|
3200 |
+
*/
|
3201 |
+
public function print_theme_font_option( $key ) {
|
3202 |
+
|
3203 |
+
$value = $this->active_theme[ $key ];
|
3204 |
+
|
3205 |
+
echo "<select name='settings[$key]'>";
|
3206 |
+
|
3207 |
+
echo "<option value='inherit'>" . __( 'Theme Default', 'megamenu' ) . '</option>';
|
3208 |
+
|
3209 |
+
foreach ( $this->fonts() as $font ) {
|
3210 |
+
$orig_font = $font;
|
3211 |
+
$font = esc_attr( stripslashes( $font ) );
|
3212 |
+
$parts = explode( ',', $font );
|
3213 |
+
$font_name = trim( $parts[0] );
|
3214 |
+
echo "<option value=\"{$font}\" " . selected( $orig_font, htmlspecialchars_decode( $value ) ) . '>' . esc_html( $font_name ) . '</option>';
|
3215 |
+
}
|
3216 |
+
|
3217 |
+
echo '</select>';
|
3218 |
+
}
|
3219 |
+
|
3220 |
+
|
3221 |
+
/**
|
3222 |
+
* Print a text input
|
3223 |
+
*
|
3224 |
+
* @since 1.0
|
3225 |
+
* @param string $key
|
3226 |
+
* @param string $value
|
3227 |
+
*/
|
3228 |
+
public function print_theme_freetext_option( $key ) {
|
3229 |
+
|
3230 |
+
$value = $this->active_theme[ $key ];
|
3231 |
+
|
3232 |
+
echo "<input class='mega-setting-{$key}' type='text' name='settings[$key]' value='" . esc_attr( $value ) . "' />";
|
3233 |
+
|
3234 |
+
}
|
3235 |
+
|
3236 |
+
|
3237 |
+
/**
|
3238 |
+
* Returns a list of available fonts.
|
3239 |
+
*
|
3240 |
+
* @since 1.0
|
3241 |
+
*/
|
3242 |
+
public function fonts() {
|
3243 |
+
|
3244 |
+
$fonts = array(
|
3245 |
+
'Georgia, serif',
|
3246 |
+
'Palatino Linotype, Book Antiqua, Palatino, serif',
|
3247 |
+
'Times New Roman, Times, serif',
|
3248 |
+
'Arial, Helvetica, sans-serif',
|
3249 |
+
'Arial Black, Gadget, sans-serif',
|
3250 |
+
'Comic Sans MS, cursive, sans-serif',
|
3251 |
+
'Impact, Charcoal, sans-serif',
|
3252 |
+
'Lucida Sans Unicode, Lucida Grande, sans-serif',
|
3253 |
+
'Tahoma, Geneva, sans-serif',
|
3254 |
+
'Trebuchet MS, Helvetica, sans-serif',
|
3255 |
+
'Verdana, Geneva, sans-serif',
|
3256 |
+
'Courier New, Courier, monospace',
|
3257 |
+
'Lucida Console, Monaco, monospace',
|
3258 |
+
);
|
3259 |
+
|
3260 |
+
$fonts = apply_filters( 'megamenu_fonts', $fonts );
|
3261 |
+
|
3262 |
+
return $fonts;
|
3263 |
+
|
3264 |
+
}
|
3265 |
+
|
3266 |
+
|
3267 |
+
/**
|
3268 |
+
* List of all available arrow DashIcon classes.
|
3269 |
+
*
|
3270 |
+
* @since 1.0
|
3271 |
+
* @return array - Sorted list of icon classes
|
3272 |
+
*/
|
3273 |
+
private function arrow_icons() {
|
3274 |
+
|
3275 |
+
$icons = array(
|
3276 |
+
'dash-f142' => 'dashicons-arrow-up',
|
3277 |
+
'dash-f140' => 'dashicons-arrow-down',
|
3278 |
+
'dash-f141' => 'dashicons-arrow-left',
|
3279 |
+
'dash-f139' => 'dashicons-arrow-right',
|
3280 |
+
'dash-f342' => 'dashicons-arrow-up-alt',
|
3281 |
+
'dash-f346' => 'dashicons-arrow-down-alt',
|
3282 |
+
'dash-f340' => 'dashicons-arrow-left-alt',
|
3283 |
+
'dash-f344' => 'dashicons-arrow-right-alt',
|
3284 |
+
'dash-f343' => 'dashicons-arrow-up-alt2',
|
3285 |
+
'dash-f347' => 'dashicons-arrow-down-alt2',
|
3286 |
+
'dash-f341' => 'dashicons-arrow-left-alt2',
|
3287 |
+
'dash-f345' => 'dashicons-arrow-right-alt2',
|
3288 |
+
'dash-f132' => 'dashicons-plus',
|
3289 |
+
'dash-f460' => 'dashicons-minus',
|
3290 |
+
'dash-f158' => 'dashicons-no',
|
3291 |
+
'dash-f335' => 'dashicons-no-alt',
|
3292 |
+
|
3293 |
+
);
|
3294 |
+
|
3295 |
+
$icons = apply_filters( 'megamenu_arrow_icons', $icons );
|
3296 |
+
|
3297 |
+
return $icons;
|
3298 |
+
|
3299 |
+
}
|
3300 |
+
|
3301 |
+
}
|
3302 |
|
3303 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pages/tools.php
CHANGED
@@ -1,184 +1,187 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Tools' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_Tools {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Tools' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Handles all admin related functionality.
|
11 |
+
*/
|
12 |
+
class Mega_Menu_Tools {
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
add_action( 'admin_post_megamenu_clear_css_cache', array( $this, 'tools_clear_css_cache' ) );
|
22 |
+
add_action( 'admin_post_megamenu_delete_data', array( $this, 'delete_data' ) );
|
23 |
+
|
24 |
+
add_filter( 'megamenu_menu_tabs', array( $this, 'add_tools_tab' ), 4 );
|
25 |
+
add_action( 'megamenu_page_tools', array( $this, 'tools_page' ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add the Menu Locations tab to our available tabs
|
30 |
+
*
|
31 |
+
* @param array $tabs
|
32 |
+
* @since 2.8
|
33 |
+
*/
|
34 |
+
public function add_tools_tab( $tabs ) {
|
35 |
+
$tabs['tools'] = __( 'Tools', 'megamenu' );
|
36 |
+
return $tabs;
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Clear the CSS cache.
|
42 |
+
*
|
43 |
+
* @since 1.5
|
44 |
+
*/
|
45 |
+
public function tools_clear_css_cache() {
|
46 |
+
check_admin_referer( 'megamenu_clear_css_cache' );
|
47 |
+
do_action( 'megamenu_delete_cache' );
|
48 |
+
$this->redirect( admin_url( 'admin.php?page=maxmegamenu_tools&clear_css_cache=true' ) );
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Deletes all Max Mega Menu data from the database
|
54 |
+
*
|
55 |
+
* @since 1.5
|
56 |
+
*/
|
57 |
+
public function delete_data() {
|
58 |
+
|
59 |
+
check_admin_referer( 'megamenu_delete_data' );
|
60 |
+
|
61 |
+
do_action( 'megamenu_delete_cache' );
|
62 |
+
|
63 |
+
// delete options
|
64 |
+
delete_option( 'megamenu_settings' );
|
65 |
+
delete_option( 'megamenu_locations' );
|
66 |
+
delete_option( 'megamenu_toggle_blocks' );
|
67 |
+
delete_option( 'megamenu_version' );
|
68 |
+
delete_option( 'megamenu_initial_version' );
|
69 |
+
delete_option( 'megamenu_themes_last_updated' );
|
70 |
+
delete_option( 'megamenu_multisite_share_themes' );
|
71 |
+
|
72 |
+
// delete all widgets assigned to menus
|
73 |
+
$widget_manager = new Mega_Menu_Widget_Manager();
|
74 |
+
|
75 |
+
if ( $mega_menu_widgets = $widget_manager->get_mega_menu_sidebar_widgets() ) {
|
76 |
+
foreach ( $mega_menu_widgets as $widget_id ) {
|
77 |
+
$widget_manager->delete_widget( $widget_id );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
// delete all mega menu metadata stored against menu items
|
82 |
+
delete_metadata( 'post', 0, '_megamenu', '', true );
|
83 |
+
|
84 |
+
// clear cache
|
85 |
+
delete_transient( 'megamenu_css' );
|
86 |
+
|
87 |
+
// delete custom themes
|
88 |
+
max_mega_menu_delete_themes();
|
89 |
+
|
90 |
+
$this->redirect( admin_url( 'admin.php?page=maxmegamenu_tools&delete_data=true' ) );
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Redirect and exit
|
96 |
+
*
|
97 |
+
* @since 1.8
|
98 |
+
*/
|
99 |
+
public function redirect( $url ) {
|
100 |
+
wp_redirect( $url );
|
101 |
+
exit;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Content for 'Tools' tab
|
107 |
+
*
|
108 |
+
* @since 1.4
|
109 |
+
*/
|
110 |
+
public function tools_page( $saved_settings ) {
|
111 |
+
$this->print_messages();
|
112 |
+
|
113 |
+
?>
|
114 |
+
|
115 |
+
<div class='menu_settings menu_settings_tools'>
|
116 |
+
<h3 class='first'><?php _e( 'Tools', 'megamenu' ); ?></h3>
|
117 |
+
<table>
|
118 |
+
<tr>
|
119 |
+
<td class='mega-name'>
|
120 |
+
<?php _e( 'Cache', 'megamenu' ); ?>
|
121 |
+
<div class='mega-description'><?php _e( 'The CSS for your menu is updated each time a menu or a menu theme is changed. You can force the menu CSS to be updated using this tool.', 'megamenu' ); ?></div>
|
122 |
+
</td>
|
123 |
+
<td class='mega-value'>
|
124 |
+
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post">
|
125 |
+
<?php wp_nonce_field( 'megamenu_clear_css_cache' ); ?>
|
126 |
+
<input type="hidden" name="action" value="megamenu_clear_css_cache" />
|
127 |
+
|
128 |
+
<input type='submit' class='button button-primary' value='<?php _e( 'Clear CSS Cache', 'megamenu' ); ?>' />
|
129 |
+
|
130 |
+
<?php if ( get_transient( 'megamenu_css_last_updated' ) ) : ?>
|
131 |
+
<p><em><small><?php echo sprintf( __( 'The menu CSS was last updated on %s', 'megamenu' ), date( 'l jS F Y H:i:s', get_transient( 'megamenu_css_last_updated' ) ) ); ?><small><em></p>
|
132 |
+
<?php endif; ?>
|
133 |
+
</form>
|
134 |
+
</td>
|
135 |
+
</tr>
|
136 |
+
<tr>
|
137 |
+
<td class='mega-name'>
|
138 |
+
<?php _e( 'Plugin Data', 'megamenu' ); ?>
|
139 |
+
<div class='mega-description'><?php _e( 'Delete all saved Max Mega Menu plugin data from the database. Use with caution!', 'megamenu' ); ?></div>
|
140 |
+
</td>
|
141 |
+
<td class='mega-value'>
|
142 |
+
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post">
|
143 |
+
<?php wp_nonce_field( 'megamenu_delete_data' ); ?>
|
144 |
+
<input type="hidden" name="action" value="megamenu_delete_data" />
|
145 |
+
|
146 |
+
<input type='submit' class='button button-secondary confirm' value='<?php _e( 'Delete Data', 'megamenu' ); ?>' />
|
147 |
+
</form>
|
148 |
+
</td>
|
149 |
+
</tr>
|
150 |
+
</table>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
<?php
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Display messages to the user
|
159 |
+
*
|
160 |
+
* @since 1.0
|
161 |
+
*/
|
162 |
+
public function print_messages() {
|
163 |
+
if ( isset( $_GET['clear_css_cache'] ) && $_GET['clear_css_cache'] == 'true' ) {
|
164 |
+
?>
|
165 |
+
<div class="notice notice-success is-dismissible">
|
166 |
+
<p><?php esc_html_e( 'The cache has been cleared and the menu CSS has been regenerated.', 'megamenu' ) ?></p>
|
167 |
+
|
168 |
+
<?php
|
169 |
+
$theme_class = new Mega_Menu_Themes();
|
170 |
+
|
171 |
+
$theme_class->show_cache_warning();
|
172 |
+
?>
|
173 |
+
</div>
|
174 |
+
<?php
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( isset( $_GET['delete_data'] ) && $_GET['delete_data'] == 'true' ) {
|
178 |
+
?>
|
179 |
+
<div class="notice notice-success is-dismissible">
|
180 |
+
<p><?php _e( 'All plugin data removed', 'megamenu' ) ?></p>
|
181 |
+
</div>
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
endif;
|
classes/style-manager.class.php
CHANGED
@@ -1,1173 +1,1177 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Style_Manager' ) ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
final class Mega_Menu_Style_Manager {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
|
|
318 |
#{$wrap} {
|
319 |
clear: both;
|
320 |
-
}'
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
-
$themes['default'] = $this->get_default_theme();
|
332 |
-
|
333 |
-
return apply_filters( "megamenu_themes", $themes );
|
334 |
-
}
|
335 |
-
|
336 |
-
/**
|
337 |
-
* Merge the saved themes (from options table) into array of complete themes
|
338 |
-
*
|
339 |
-
* @since 2.1
|
340 |
-
*/
|
341 |
-
private function merge_in_saved_themes( $all_themes ) {
|
342 |
-
|
343 |
-
if ( $saved_themes = max_mega_menu_get_themes() ) {
|
344 |
-
foreach ( $saved_themes as $key => $settings ) {
|
345 |
-
if ( isset( $all_themes[ $key ] ) ) {
|
346 |
-
// merge modifications to default themes
|
347 |
-
$all_themes[ $key ] = array_merge( $all_themes[ $key ], $saved_themes[ $key ] );
|
348 |
-
} else {
|
349 |
-
// add in new themes
|
350 |
-
$all_themes[ $key ] = $settings;
|
351 |
-
}
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
return $all_themes;
|
356 |
-
}
|
357 |
-
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Populate all themes with all keys from the default theme
|
361 |
-
*
|
362 |
-
* @since 2.1
|
363 |
-
*/
|
364 |
-
private function ensure_all_themes_have_all_default_theme_settings( $all_themes ) {
|
365 |
-
|
366 |
-
$default_theme = $this->get_default_theme();
|
367 |
-
|
368 |
-
$themes = array();
|
369 |
-
|
370 |
-
foreach ( $all_themes as $theme_id => $theme ) {
|
371 |
-
$themes[ $theme_id ] = array_merge( $default_theme, $theme );
|
372 |
-
}
|
373 |
-
|
374 |
-
return $themes;
|
375 |
-
}
|
376 |
-
|
377 |
-
|
378 |
-
/**
|
379 |
-
* For backwards compatibility, copy old settings into new values
|
380 |
-
*
|
381 |
-
* @since 2.1
|
382 |
-
*/
|
383 |
-
private function process_theme_replacements( $all_themes ) {
|
384 |
-
|
385 |
-
foreach ( $all_themes as $key => $settings ) {
|
386 |
-
// process replacements
|
387 |
-
foreach ( $settings as $var => $val ) {
|
388 |
-
if ( ! is_array( $val ) && isset( $all_themes[$key][$val] ) ) {
|
389 |
-
$all_themes[$key][$var] = $all_themes[$key][$val];
|
390 |
-
}
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
return $all_themes;
|
395 |
-
}
|
396 |
-
|
397 |
-
|
398 |
-
/**
|
399 |
-
* Return a filtered list of themes
|
400 |
-
*
|
401 |
-
* @since 1.0
|
402 |
-
* @return array
|
403 |
-
*/
|
404 |
-
public function get_themes() {
|
405 |
-
|
406 |
-
$default_themes = $this->default_themes();
|
407 |
-
|
408 |
-
$all_themes = $this->merge_in_saved_themes( $default_themes );
|
409 |
-
$all_themes = $this->ensure_all_themes_have_all_default_theme_settings( $all_themes );
|
410 |
-
$all_themes = $this->process_theme_replacements( $all_themes );
|
411 |
-
|
412 |
-
uasort( $all_themes, array( $this, 'sort_by_title' ) );
|
413 |
-
|
414 |
-
return $all_themes;
|
415 |
-
}
|
416 |
-
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Sorts a 2d array by the 'title' key
|
420 |
-
*
|
421 |
-
* @since 1.0
|
422 |
-
* @param array $a
|
423 |
-
* @param array $b
|
424 |
-
*/
|
425 |
-
private function sort_by_title( $a, $b ) {
|
426 |
-
return strcmp( $a['title'], $b['title'] );
|
427 |
-
}
|
428 |
-
|
429 |
-
|
430 |
-
/**
|
431 |
-
*
|
432 |
-
*
|
433 |
-
* @since 1.3.1
|
434 |
-
* @return bool
|
435 |
-
*/
|
436 |
-
private function is_debug_mode() {
|
437 |
-
return ( defined( 'MEGAMENU_DEBUG' ) && MEGAMENU_DEBUG === true );
|
438 |
-
}
|
439 |
-
|
440 |
-
|
441 |
-
/**
|
442 |
-
* Return the menu CSS for use in inline CSS block. Use the cache if possible.
|
443 |
-
*
|
444 |
-
* @since 1.3.1
|
445 |
-
*/
|
446 |
-
public function get_css() {
|
447 |
-
|
448 |
-
if ( ( $css = $this->get_cached_css() ) && ! $this->is_debug_mode() ) {
|
449 |
-
return $css;
|
450 |
-
} else {
|
451 |
-
return $this->generate_css();
|
452 |
-
}
|
453 |
-
}
|
454 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
* @since 1.0
|
461 |
-
* @return string
|
462 |
-
* @param boolean $debug_mode (prints error messages to the CSS when enabled)
|
463 |
-
*/
|
464 |
-
public function generate_css() {
|
465 |
-
|
466 |
-
if ( function_exists('wp_raise_memory_limit') ) {
|
467 |
-
wp_raise_memory_limit(); // attempt to raise memory limit to 256MB
|
468 |
-
}
|
469 |
-
|
470 |
-
// the settings may have changed since the class was instantiated,
|
471 |
-
// reset them here
|
472 |
-
$this->settings = get_option( "megamenu_settings" );
|
473 |
-
|
474 |
-
if ( ! $this->settings ) {
|
475 |
-
return "/** CSS Generation Failed. No menu settings found **/";
|
476 |
-
}
|
477 |
-
|
478 |
-
$css = "";
|
479 |
-
|
480 |
-
foreach ( $this->settings as $location => $settings ) {
|
481 |
-
if ( isset( $settings['enabled'] ) && has_nav_menu( $location ) ) {
|
482 |
-
$theme = $this->get_theme_settings_for_location( $location );
|
483 |
-
$menu_id = $this->get_menu_id_for_location( $location );
|
484 |
-
$compiled_css = $this->generate_css_for_location( $location, $theme, $menu_id );
|
485 |
-
|
486 |
-
if ( ! is_wp_error( $compiled_css ) ) {
|
487 |
-
$css .= $compiled_css;
|
488 |
-
}
|
489 |
-
}
|
490 |
-
}
|
491 |
-
|
492 |
-
if ( strlen( $css ) ) {
|
493 |
-
$scss_location = 'core';
|
494 |
-
|
495 |
-
foreach ( $this->get_possible_scss_file_locations() as $path ) {
|
496 |
-
if ( file_exists($path) && $path !== $this->get_default_scss_file_location() ) {
|
497 |
-
$scss_location = 'custom';
|
498 |
-
}
|
499 |
-
}
|
500 |
-
|
501 |
-
$css = "/** " . date('l jS F Y H:i:s e') . " ({$scss_location}) **/\n/** THIS FILE IS AUTOMATICALLY GENERATED - DO NOT MAKE MANUAL EDITS! **/\n/** Custom CSS should be added to Mega Menu > Menu Themes > Custom Styling **/\n\n.mega-menu-last-modified-" . time() . " { content: '" . date('l jS F Y H:i:s e') . "'; }\n\n" . $css;
|
502 |
-
|
503 |
-
$css = apply_filters( "megamenu_compiled_css", $css );
|
504 |
-
|
505 |
-
$this->set_cached_css( $css );
|
506 |
-
|
507 |
-
if ( $this->get_css_output_method() == 'fs' ) {
|
508 |
-
$this->save_to_filesystem( $css );
|
509 |
-
}
|
510 |
-
|
511 |
-
}
|
512 |
-
|
513 |
-
return $css;
|
514 |
-
}
|
515 |
-
|
516 |
-
|
517 |
-
/**
|
518 |
-
* Saves the generated CSS to the uploads folder
|
519 |
-
*
|
520 |
-
* @since 1.6.1
|
521 |
-
*/
|
522 |
-
private function save_to_filesystem( $css ) {
|
523 |
-
global $wp_filesystem;
|
524 |
-
|
525 |
-
if ( ! $wp_filesystem ) {
|
526 |
-
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
527 |
-
}
|
528 |
-
|
529 |
-
$upload_dir = wp_upload_dir();
|
530 |
-
$filename = $this->get_css_filename();
|
531 |
-
|
532 |
-
$dir = trailingslashit( $upload_dir['basedir'] ) . 'maxmegamenu/';
|
533 |
-
|
534 |
-
WP_Filesystem( false, $upload_dir['basedir'], true );
|
535 |
-
|
536 |
-
if( ! $wp_filesystem->is_dir( $dir ) ) {
|
537 |
-
$wp_filesystem->mkdir( $dir );
|
538 |
-
}
|
539 |
-
|
540 |
-
if ( ! $wp_filesystem->put_contents( $dir . $filename, $css ) ) {
|
541 |
-
// File write failed.
|
542 |
-
// Update CSS output option to 'head' to stop us from attempting to regenerate the CSS on every request.
|
543 |
-
$settings = get_option( 'megamenu_settings' );
|
544 |
-
$settings['css'] = 'head';
|
545 |
-
update_option( 'megamenu_settings', $settings );
|
546 |
-
$this->settings = get_option( "megamenu_settings" );
|
547 |
-
|
548 |
-
// set a far expiration date to prevent transient from being autoloaded
|
549 |
-
$hundred_years_in_seconds = 3153600000;
|
550 |
-
set_transient( 'megamenu_failed_to_write_css_to_filesystem', 'true', $hundred_years_in_seconds );
|
551 |
-
}
|
552 |
-
|
553 |
-
}
|
554 |
-
|
555 |
-
|
556 |
-
/**
|
557 |
-
* Return an array of all the possible file path locations for the SCSS file
|
558 |
-
* @since 2.2.3
|
559 |
-
* @return array
|
560 |
-
*/
|
561 |
-
private function get_possible_scss_file_locations() {
|
562 |
-
return apply_filters( "megamenu_scss_locations", array(
|
563 |
-
trailingslashit( get_stylesheet_directory() ) . trailingslashit("megamenu") . 'megamenu.scss', // child theme
|
564 |
-
trailingslashit( get_template_directory() ) . trailingslashit("megamenu") . 'megamenu.scss', // parent theme
|
565 |
-
$this->get_default_scss_file_location()
|
566 |
-
));
|
567 |
-
}
|
568 |
-
|
569 |
-
|
570 |
-
/**
|
571 |
-
* Return the default SCSS file path
|
572 |
-
*
|
573 |
-
* @since 2.2.3
|
574 |
-
* @return string
|
575 |
-
*/
|
576 |
-
private function get_default_scss_file_location() {
|
577 |
-
return MEGAMENU_PATH . trailingslashit('css') . 'megamenu.scss';
|
578 |
-
}
|
579 |
-
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Return the path to the megamenu.scss file, look for custom files before
|
583 |
-
* loading the core version.
|
584 |
-
*
|
585 |
-
* @since 1.0
|
586 |
-
* @return string
|
587 |
-
*/
|
588 |
-
private function load_scss_file() {
|
589 |
-
|
590 |
-
/**
|
591 |
-
* *** IMPORTANT NOTICE ***
|
592 |
-
*
|
593 |
-
* Allowing users to create their own versions of megamenu.scss was a poor design decision.
|
594 |
-
*
|
595 |
-
* The bundled SCSS file and the plugin code work in perfect harmony.
|
596 |
-
*
|
597 |
-
* When a user (or theme developer) creates their own copy of megamenu.scss it
|
598 |
-
* _will_ become outdated as the plugin is updated and the menu HTML changes.
|
599 |
-
*
|
600 |
-
* Instead of using a custom SCSS file, override only the absolute minimum CSS in the
|
601 |
-
* Mega Menu > Menu Themes > Custom Styling section.
|
602 |
-
*/
|
603 |
-
$scss = file_get_contents( MEGAMENU_PATH . trailingslashit('css') . 'mixin.scss' );
|
604 |
-
$scss .= file_get_contents( MEGAMENU_PATH . trailingslashit('css') . 'reset.scss' );
|
605 |
-
|
606 |
-
$locations = $this->get_possible_scss_file_locations();
|
607 |
-
|
608 |
-
foreach ( $locations as $path ) {
|
609 |
-
|
610 |
-
if ( file_exists( $path ) ) {
|
611 |
-
|
612 |
-
$scss .= file_get_contents( $path );
|
613 |
-
//break;
|
614 |
-
//
|
615 |
-
// @todo: add a break here. This is a known bug but some users may be relying on it.
|
616 |
-
// Add warning message to plugin to alert users about not using custom megamenu.scss files
|
617 |
-
// then fix the bug in a later release.
|
618 |
-
}
|
619 |
-
|
620 |
-
}
|
621 |
-
|
622 |
-
$scss .= file_get_contents( MEGAMENU_PATH . trailingslashit('css') . 'compatibility.scss' );
|
623 |
-
|
624 |
-
return apply_filters( "megamenu_load_scss_file_contents", $scss);
|
625 |
-
|
626 |
-
}
|
627 |
-
|
628 |
-
/**
|
629 |
-
* Before a theme is saved, attempt to generate the CSS to ensure it passes as valid SCSS
|
630 |
-
*
|
631 |
-
* @param array $theme
|
632 |
-
*/
|
633 |
-
public function test_theme_compilation( $theme ) {
|
634 |
-
$menu_id = 0;
|
635 |
-
|
636 |
-
$menus = get_registered_nav_menus();
|
637 |
-
|
638 |
-
if ( count( $menus ) ) {
|
639 |
-
$locations = get_nav_menu_locations();
|
640 |
-
|
641 |
-
foreach ($menus as $location => $description ) {
|
642 |
-
if ( isset( $locations[ $location ] ) ) {
|
643 |
-
$menu_id = $locations[ $location ];
|
644 |
-
continue;
|
645 |
-
}
|
646 |
-
}
|
647 |
-
}
|
648 |
-
|
649 |
-
return $this->generate_css_for_location( 'test', $theme, $menu_id );
|
650 |
-
|
651 |
-
}
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Compiles raw SCSS into CSS for a particular menu location.
|
656 |
-
*
|
657 |
-
* @since 1.3
|
658 |
-
* @return mixed
|
659 |
-
* @param array $settings
|
660 |
-
* @param string $location
|
661 |
-
*/
|
662 |
-
public function generate_css_for_location( $location, $theme, $menu_id ) {
|
663 |
-
|
664 |
-
$scssc = new scssc();
|
665 |
-
$scssc->setFormatter( 'scss_formatter' );
|
666 |
-
|
667 |
-
$import_paths = apply_filters('megamenu_scss_import_paths', array(
|
668 |
-
trailingslashit( get_stylesheet_directory() ) . trailingslashit("megamenu"),
|
669 |
-
trailingslashit( get_stylesheet_directory() ),
|
670 |
-
trailingslashit( get_template_directory() ) . trailingslashit("megamenu"),
|
671 |
-
trailingslashit( get_template_directory() ),
|
672 |
-
trailingslashit( WP_PLUGIN_DIR )
|
673 |
-
));
|
674 |
|
675 |
-
|
676 |
-
|
677 |
-
}
|
678 |
|
679 |
-
|
680 |
-
return $scssc->compile( $this->get_complete_scss_for_location( $location, $theme, $menu_id ) );
|
681 |
-
}
|
682 |
-
catch ( Exception $e ) {
|
683 |
-
$message = __("Warning: CSS compilation failed. Please check your changes or revert the theme.", "megamenu");
|
684 |
|
685 |
-
return new WP_Error( 'scss_compile_fail', $message . "<br /><br />" . $e->getMessage() );
|
686 |
-
}
|
687 |
|
688 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
689 |
|
|
|
690 |
|
691 |
-
|
692 |
-
|
693 |
-
* for a particular menu location.
|
694 |
-
*
|
695 |
-
* @since 1.3
|
696 |
-
* @return string
|
697 |
-
* @param string $theme
|
698 |
-
* @param string $location
|
699 |
-
* @param int $menu_id
|
700 |
-
*/
|
701 |
-
private function get_complete_scss_for_location( $location, $theme, $menu_id ) {
|
702 |
|
703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
|
705 |
-
|
706 |
-
|
707 |
|
708 |
-
|
709 |
-
$vars['menu'] = "'$menu_selector'";
|
710 |
-
$vars['location'] = "'$sanitized_location'";
|
711 |
-
$vars['menu_id'] = "'$menu_id'";
|
712 |
-
$vars['elementor_pro_active'] = 'false';
|
713 |
-
$vars['arrow_font'] = 'dashicons';
|
714 |
-
$vars['arrow_font_weight'] = 'normal';
|
715 |
|
716 |
-
|
717 |
-
|
|
|
718 |
|
719 |
-
|
|
|
|
|
720 |
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
|
725 |
-
|
726 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
727 |
-
}
|
728 |
|
729 |
-
|
730 |
-
|
731 |
-
|
|
|
|
|
732 |
|
733 |
-
|
734 |
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
|
741 |
-
|
742 |
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
|
749 |
-
|
750 |
|
751 |
-
|
752 |
-
$effect_mobile = $settings['effect_mobile'];
|
753 |
-
} else {
|
754 |
-
$effect_mobile = 'disabled';
|
755 |
-
}
|
756 |
|
757 |
-
|
758 |
|
|
|
|
|
759 |
|
760 |
-
|
761 |
|
|
|
762 |
|
763 |
-
|
|
|
764 |
|
765 |
-
|
766 |
-
$code = end( $parts );
|
767 |
|
768 |
-
|
769 |
|
770 |
-
|
|
|
771 |
|
772 |
-
|
773 |
-
}
|
774 |
|
775 |
-
|
|
|
|
|
|
|
|
|
776 |
|
777 |
-
|
|
|
778 |
|
779 |
-
|
780 |
-
|
|
|
|
|
|
|
|
|
781 |
|
782 |
-
|
|
|
|
|
|
|
783 |
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
}
|
789 |
|
790 |
-
|
791 |
-
}
|
792 |
|
793 |
-
|
794 |
-
if ( preg_match('/^\d/', $value) !== 1 ) { // doesn't start with number (jQuery selector)
|
795 |
-
$vars[$name] = '100%';
|
796 |
-
continue;
|
797 |
-
}
|
798 |
-
}
|
799 |
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
|
804 |
-
|
805 |
|
806 |
-
|
807 |
-
if ( isset( $vars['title'] ) ) {
|
808 |
-
unset( $vars['title'] );
|
809 |
-
}
|
810 |
|
811 |
-
|
812 |
|
813 |
-
|
814 |
|
815 |
-
foreach ($vars as $name => $value) {
|
816 |
-
$scss .= "$" . $name . ": " . $value . ";\n";
|
817 |
-
}
|
818 |
|
819 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
820 |
|
821 |
-
|
|
|
822 |
|
823 |
-
return apply_filters( "megamenu_scss", $scss, $location, $theme, $menu_id );
|
824 |
|
825 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
826 |
|
|
|
|
|
827 |
|
828 |
-
/**
|
829 |
-
* Returns the menu ID for a specified menu location, defaults to 0
|
830 |
-
*
|
831 |
-
* @since 1.3
|
832 |
-
*/
|
833 |
-
private function get_menu_id_for_location( $location ) {
|
834 |
-
$locations = get_nav_menu_locations();
|
835 |
-
$menu_id = isset( $locations[ $location ] ) ? $locations[ $location ] : 0;
|
836 |
|
837 |
-
|
838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
|
|
|
|
|
840 |
|
841 |
-
/**
|
842 |
-
* Returns the theme ID for a specified menu location, defaults to 'default'
|
843 |
-
*
|
844 |
-
* @since 2.1
|
845 |
-
*/
|
846 |
-
private function get_theme_id_for_location( $location ) {
|
847 |
-
$settings = $this->settings;
|
848 |
-
$theme_id = isset( $settings[ $location ]['theme'] ) ? $settings[ $location ]['theme'] : 'default';
|
849 |
|
850 |
-
|
851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
|
854 |
-
|
855 |
-
* Returns the theme settings for a specified location. Defaults to the default theme.
|
856 |
-
*
|
857 |
-
* @since 1.3
|
858 |
-
*/
|
859 |
-
private function get_theme_settings_for_location( $location ) {
|
860 |
-
$theme_id = $this->get_theme_id_for_location( $location );
|
861 |
-
$all_themes = $this->get_themes();
|
862 |
-
$theme_settings = isset( $all_themes[ $theme_id ] ) ? $all_themes[ $theme_id ] : $all_themes[ 'default' ];
|
863 |
|
864 |
-
|
865 |
-
}
|
866 |
|
|
|
867 |
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
$settings = $this->settings;
|
875 |
-
$location_settings = isset( $settings[ $location ] ) ? $settings[ $location ] : array();
|
876 |
-
return $location_settings;
|
877 |
-
}
|
878 |
|
879 |
-
|
880 |
-
* Enqueue public CSS and JS files required by Mega Menu
|
881 |
-
*
|
882 |
-
* @since 1.0
|
883 |
-
*/
|
884 |
-
public function enqueue_styles() {
|
885 |
-
if ( $this->get_css_output_method() == 'fs' ) {
|
886 |
-
$this->enqueue_fs_style();
|
887 |
-
}
|
888 |
|
889 |
-
|
890 |
|
891 |
-
|
892 |
|
893 |
-
|
894 |
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
* @since 1.0
|
899 |
-
*/
|
900 |
-
public function enqueue_scripts() {
|
901 |
|
902 |
-
|
|
|
|
|
|
|
|
|
|
|
903 |
|
904 |
-
|
905 |
|
906 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
907 |
|
908 |
-
|
|
|
909 |
|
910 |
-
if ( defined( 'MEGAMENU_SCRIPTS_IN_FOOTER' ) ) {
|
911 |
-
$scripts_in_footer = MEGAMENU_SCRIPTS_IN_FOOTER;
|
912 |
-
}
|
913 |
|
914 |
-
///** change the script handle to prevent conflict with theme files */
|
915 |
-
//function megamenu_script_handle() {
|
916 |
-
// return "maxmegamenu";
|
917 |
-
//}
|
918 |
-
//add_filter("megamenu_javascript_handle", "megamenu_script_handle");*/
|
919 |
-
$handle = apply_filters("megamenu_javascript_handle", "megamenu");
|
920 |
|
921 |
-
|
|
|
|
|
|
|
|
|
|
|
922 |
|
923 |
-
|
924 |
-
// cached versions of maxmegamenu.js
|
925 |
-
$params = apply_filters("megamenu_javascript_localisation",
|
926 |
-
array(
|
927 |
-
"timeout" => 300,
|
928 |
-
"interval" => 100
|
929 |
-
)
|
930 |
-
);
|
931 |
|
932 |
-
|
933 |
-
}
|
934 |
|
|
|
935 |
|
|
|
|
|
|
|
936 |
|
937 |
-
|
938 |
-
* Enqueue the stylesheet held on the filesystem.
|
939 |
-
*
|
940 |
-
* @since 1.6.1
|
941 |
-
*/
|
942 |
-
private function enqueue_fs_style() {
|
943 |
|
944 |
-
|
|
|
945 |
|
946 |
-
|
947 |
|
948 |
-
|
949 |
|
950 |
-
|
951 |
-
|
952 |
-
$this->generate_css();
|
953 |
|
954 |
-
|
955 |
|
956 |
-
|
957 |
-
if ( is_file( $filepath ) ) {
|
958 |
|
959 |
-
|
960 |
|
961 |
-
$protocol = is_ssl() ? 'https://' : 'http://';
|
962 |
|
963 |
-
|
964 |
-
|
|
|
|
|
|
|
|
|
|
|
965 |
|
966 |
-
|
|
|
|
|
|
|
967 |
|
968 |
-
}
|
969 |
|
970 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
|
972 |
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
|
|
980 |
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
}
|
985 |
|
|
|
|
|
|
|
986 |
|
987 |
-
|
988 |
-
|
989 |
-
*
|
990 |
-
* @since 1.9
|
991 |
-
* @return mixed
|
992 |
-
*/
|
993 |
-
private function get_cached_css() {
|
994 |
-
return get_transient( $this->get_transient_key() );
|
995 |
-
}
|
996 |
|
|
|
997 |
|
998 |
-
|
999 |
-
* Delete the cached CSS
|
1000 |
-
*
|
1001 |
-
* @since 1.9
|
1002 |
-
* @return mixed
|
1003 |
-
*/
|
1004 |
-
public function delete_cache() {
|
1005 |
-
global $wp_filesystem;
|
1006 |
|
1007 |
-
|
1008 |
-
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
1009 |
-
}
|
1010 |
|
1011 |
-
|
1012 |
-
$filename = $this->get_css_filename();
|
1013 |
-
$dir = trailingslashit( $upload_dir['basedir'] ) . 'maxmegamenu/';
|
1014 |
|
1015 |
-
|
1016 |
-
$wp_filesystem->rmdir( $dir, true );
|
1017 |
|
1018 |
-
delete_transient( $this->get_transient_key() );
|
1019 |
|
1020 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
|
1022 |
-
do_action( "megamenu_after_delete_cache" );
|
1023 |
|
1024 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
|
1026 |
-
}
|
1027 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1028 |
|
1029 |
-
/**
|
1030 |
-
* Return the key to use for the CSS transient
|
1031 |
-
*
|
1032 |
-
* @since 1.9
|
1033 |
-
* @return string
|
1034 |
-
*/
|
1035 |
-
private function get_transient_key() {
|
1036 |
-
return apply_filters( 'megamenu_css_transient_key', 'megamenu_css' );
|
1037 |
-
}
|
1038 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
-
|
1041 |
-
* Return the filename to use for the stylesheet, ensuring the filename is unique
|
1042 |
-
* for multi site setups
|
1043 |
-
*
|
1044 |
-
* @since 1.6.1
|
1045 |
-
*/
|
1046 |
-
private function get_css_filename() {
|
1047 |
-
return apply_filters( "megamenu_css_filename", 'style' ) . '.css';
|
1048 |
-
}
|
1049 |
|
|
|
|
|
|
|
|
|
1050 |
|
1051 |
-
|
1052 |
-
* Return the CSS output method, default to filesystem
|
1053 |
-
*
|
1054 |
-
* @return string
|
1055 |
-
*/
|
1056 |
-
private function get_css_output_method() {
|
1057 |
-
return isset( $this->settings['css'] ) ? $this->settings['css'] : 'fs';
|
1058 |
-
}
|
1059 |
|
|
|
1060 |
|
1061 |
-
|
1062 |
-
* Print CSS to <head>
|
1063 |
-
*
|
1064 |
-
* @since 1.3.1
|
1065 |
-
*/
|
1066 |
-
public function head_css() {
|
1067 |
|
1068 |
-
$method = $this->get_css_output_method();
|
1069 |
-
|
1070 |
-
if ( in_array( $method, array( 'disabled', 'fs' ) ) ) {
|
1071 |
-
echo "<style type=\"text/css\">/** Mega Menu CSS: {$method} **/</style>\n";
|
1072 |
-
return;
|
1073 |
-
}
|
1074 |
-
|
1075 |
-
$css = $this->get_css();
|
1076 |
|
1077 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1078 |
|
1079 |
-
|
|
|
|
|
|
|
1080 |
|
1081 |
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
|
1090 |
-
|
1091 |
-
delete_transient( 'megamenu_css_' . $term->locale );
|
1092 |
-
}
|
1093 |
-
}
|
1094 |
|
|
|
|
|
|
|
1095 |
|
1096 |
-
|
1097 |
-
|
1098 |
-
*
|
1099 |
-
* @since 1.9
|
1100 |
-
* @return string
|
1101 |
-
*/
|
1102 |
-
public function polylang_transient_key( $key ) {
|
1103 |
|
1104 |
-
$locale = strtolower( pll_current_language('locale') );
|
1105 |
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
|
|
|
|
|
|
|
|
1109 |
|
1110 |
-
|
1111 |
-
}
|
1112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
|
1114 |
-
/**
|
1115 |
-
* Modify the CSS filename to make it unique to the current language
|
1116 |
-
*
|
1117 |
-
* @since 1.9
|
1118 |
-
* @return string
|
1119 |
-
*/
|
1120 |
-
public function polylang_css_filename( $filename ) {
|
1121 |
|
1122 |
-
|
|
|
|
|
|
|
|
|
|
|
1123 |
|
1124 |
-
|
1125 |
-
$filename .= "_" . $locale;
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
return $filename;
|
1129 |
-
}
|
1130 |
-
|
1131 |
-
|
1132 |
-
/**
|
1133 |
-
* Delete language specific transients created when WPML is installed
|
1134 |
-
*
|
1135 |
-
* @since 1.9
|
1136 |
-
*/
|
1137 |
-
public function wpml_delete_cache() {
|
1138 |
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
}
|
1144 |
-
}
|
1145 |
|
1146 |
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
|
1156 |
-
|
1157 |
-
|
1158 |
|
1159 |
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
|
1169 |
-
|
1170 |
-
|
1171 |
-
}
|
1172 |
|
1173 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
if ( ! class_exists( 'Mega_Menu_Style_Manager' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
final class Mega_Menu_Style_Manager {
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
var $settings = array();
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructor
|
22 |
+
*
|
23 |
+
* @since 1.0
|
24 |
+
*/
|
25 |
+
public function __construct() {
|
26 |
+
$this->settings = get_option( 'megamenu_settings' );
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Setup actions
|
32 |
+
*
|
33 |
+
* @since 1.0
|
34 |
+
*/
|
35 |
+
public function setup_actions() {
|
36 |
+
add_action( 'megamenu_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
37 |
+
add_action( 'megamenu_enqueue_styles', array( $this, 'enqueue_styles' ) );
|
38 |
+
|
39 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
40 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 999 );
|
41 |
+
add_action( 'wp_head', array( $this, 'head_css' ), 9999 );
|
42 |
+
add_action( 'megamenu_delete_cache', array( $this, 'delete_cache' ) );
|
43 |
+
add_action( 'megamenu_delete_cache', array( $this, 'clear_external_caches' ) );
|
44 |
+
add_action( 'after_switch_theme', array( $this, 'delete_cache' ) );
|
45 |
+
|
46 |
+
add_action( 'megamenu_head_css', array( $this, 'head_css' ), 999 );
|
47 |
+
|
48 |
+
// PolyLang
|
49 |
+
if ( function_exists( 'pll_current_language' ) ) {
|
50 |
+
add_filter( 'megamenu_css_transient_key', array( $this, 'polylang_transient_key' ) );
|
51 |
+
add_filter( 'megamenu_css_filename', array( $this, 'polylang_css_filename' ) );
|
52 |
+
add_action( 'megamenu_after_delete_cache', array( $this, 'polylang_delete_cache' ) );
|
53 |
+
} elseif ( defined( 'ICL_LANGUAGE_CODE' ) ) { // WPML
|
54 |
+
add_filter( 'megamenu_css_transient_key', array( $this, 'wpml_transient_key' ) );
|
55 |
+
add_filter( 'megamenu_css_filename', array( $this, 'wpml_css_filename' ) );
|
56 |
+
add_action( 'megamenu_after_delete_cache', array( $this, 'wpml_delete_cache' ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
add_filter( 'megamenu_scripts_in_footer', array( $this, 'scripts_in_footer' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Determines whether to load JavaScript in footer or not, based on the configured option.
|
65 |
+
*
|
66 |
+
* @since 2.9
|
67 |
+
* @return bool
|
68 |
+
*/
|
69 |
+
function scripts_in_footer() {
|
70 |
+
if ( isset( $this->settings['js'] ) && $this->settings['js'] == 'head' ) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Clear plugin caches when CSS is updated or menu settings are changed
|
80 |
+
*/
|
81 |
+
public function clear_external_caches() {
|
82 |
+
// Breeze: https://wordpress.org/plugins/breeze/
|
83 |
+
do_action( 'breeze_clear_all_cache' );
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Return the default menu theme
|
89 |
+
*/
|
90 |
+
public function get_default_theme() {
|
91 |
+
return apply_filters(
|
92 |
+
'megamenu_default_theme',
|
93 |
+
array(
|
94 |
+
'title' => __( 'Default', 'megamenu' ),
|
95 |
+
'container_background_from' => '#222',
|
96 |
+
'container_background_to' => '#222',
|
97 |
+
'container_padding_left' => '0px',
|
98 |
+
'container_padding_right' => '0px',
|
99 |
+
'container_padding_top' => '0px',
|
100 |
+
'container_padding_bottom' => '0px',
|
101 |
+
'container_border_radius_top_left' => '0px',
|
102 |
+
'container_border_radius_top_right' => '0px',
|
103 |
+
'container_border_radius_bottom_left' => '0px',
|
104 |
+
'container_border_radius_bottom_right' => '0px',
|
105 |
+
'arrow_up' => 'dash-f142',
|
106 |
+
'arrow_down' => 'dash-f140',
|
107 |
+
'arrow_left' => 'dash-f141',
|
108 |
+
'arrow_right' => 'dash-f139',
|
109 |
+
'font_size' => '14px', // deprecated
|
110 |
+
'font_color' => '#666', // deprecated
|
111 |
+
'font_family' => 'inherit', // deprecated
|
112 |
+
'menu_item_align' => 'left',
|
113 |
+
'menu_item_background_from' => 'rgba(0,0,0,0)',
|
114 |
+
'menu_item_background_to' => 'rgba(0,0,0,0)',
|
115 |
+
'menu_item_background_hover_from' => '#333',
|
116 |
+
'menu_item_background_hover_to' => '#333',
|
117 |
+
'menu_item_spacing' => '0px',
|
118 |
+
'menu_item_link_font' => 'inherit',
|
119 |
+
'menu_item_link_font_size' => '14px',
|
120 |
+
'menu_item_link_height' => '40px',
|
121 |
+
'menu_item_link_color' => '#ffffff',
|
122 |
+
'menu_item_link_weight' => 'normal',
|
123 |
+
'menu_item_link_text_transform' => 'none',
|
124 |
+
'menu_item_link_text_decoration' => 'none',
|
125 |
+
'menu_item_link_text_align' => 'left',
|
126 |
+
'menu_item_link_color_hover' => '#ffffff',
|
127 |
+
'menu_item_link_weight_hover' => 'normal',
|
128 |
+
'menu_item_link_text_decoration_hover' => 'none',
|
129 |
+
'menu_item_link_padding_left' => '10px',
|
130 |
+
'menu_item_link_padding_right' => '10px',
|
131 |
+
'menu_item_link_padding_top' => '0px',
|
132 |
+
'menu_item_link_padding_bottom' => '0px',
|
133 |
+
'menu_item_link_border_radius_top_left' => '0px',
|
134 |
+
'menu_item_link_border_radius_top_right' => '0px',
|
135 |
+
'menu_item_link_border_radius_bottom_left' => '0px',
|
136 |
+
'menu_item_link_border_radius_bottom_right' => '0px',
|
137 |
+
'menu_item_border_color' => '#fff',
|
138 |
+
'menu_item_border_left' => '0px',
|
139 |
+
'menu_item_border_right' => '0px',
|
140 |
+
'menu_item_border_top' => '0px',
|
141 |
+
'menu_item_border_bottom' => '0px',
|
142 |
+
'menu_item_border_color_hover' => '#fff',
|
143 |
+
'menu_item_highlight_current' => 'on',
|
144 |
+
'menu_item_divider' => 'off',
|
145 |
+
'menu_item_divider_color' => 'rgba(255, 255, 255, 0.1)',
|
146 |
+
'menu_item_divider_glow_opacity' => '0.1',
|
147 |
+
'panel_background_from' => '#f1f1f1',
|
148 |
+
'panel_background_to' => '#f1f1f1',
|
149 |
+
'panel_width' => '100%',
|
150 |
+
'panel_inner_width' => '100%',
|
151 |
+
'panel_border_color' => '#fff',
|
152 |
+
'panel_border_left' => '0px',
|
153 |
+
'panel_border_right' => '0px',
|
154 |
+
'panel_border_top' => '0px',
|
155 |
+
'panel_border_bottom' => '0px',
|
156 |
+
'panel_border_radius_top_left' => '0px',
|
157 |
+
'panel_border_radius_top_right' => '0px',
|
158 |
+
'panel_border_radius_bottom_left' => '0px',
|
159 |
+
'panel_border_radius_bottom_right' => '0px',
|
160 |
+
'panel_header_color' => '#555',
|
161 |
+
'panel_header_text_transform' => 'uppercase',
|
162 |
+
'panel_header_text_align' => 'left',
|
163 |
+
'panel_header_font' => 'inherit',
|
164 |
+
'panel_header_font_size' => '16px',
|
165 |
+
'panel_header_font_weight' => 'bold',
|
166 |
+
'panel_header_text_decoration' => 'none',
|
167 |
+
'panel_header_padding_top' => '0px',
|
168 |
+
'panel_header_padding_right' => '0px',
|
169 |
+
'panel_header_padding_bottom' => '5px',
|
170 |
+
'panel_header_padding_left' => '0px',
|
171 |
+
'panel_header_margin_top' => '0px',
|
172 |
+
'panel_header_margin_right' => '0px',
|
173 |
+
'panel_header_margin_bottom' => '0px',
|
174 |
+
'panel_header_margin_left' => '0px',
|
175 |
+
'panel_header_border_color' => 'rgba(0,0,0,0)',
|
176 |
+
'panel_header_border_color_hover' => 'rgba(0,0,0,0)',
|
177 |
+
'panel_header_border_left' => '0px',
|
178 |
+
'panel_header_border_right' => '0px',
|
179 |
+
'panel_header_border_top' => '0px',
|
180 |
+
'panel_header_border_bottom' => '0px',
|
181 |
+
'panel_padding_left' => '0px',
|
182 |
+
'panel_padding_right' => '0px',
|
183 |
+
'panel_padding_top' => '0px',
|
184 |
+
'panel_padding_bottom' => '0px',
|
185 |
+
'panel_widget_padding_left' => '15px',
|
186 |
+
'panel_widget_padding_right' => '15px',
|
187 |
+
'panel_widget_padding_top' => '15px',
|
188 |
+
'panel_widget_padding_bottom' => '15px',
|
189 |
+
'panel_font_size' => 'font_size',
|
190 |
+
'panel_font_color' => 'font_color',
|
191 |
+
'panel_font_family' => 'font_family',
|
192 |
+
'panel_second_level_font_color' => 'panel_header_color',
|
193 |
+
'panel_second_level_font_color_hover' => 'panel_header_color',
|
194 |
+
'panel_second_level_text_transform' => 'panel_header_text_transform',
|
195 |
+
'panel_second_level_text_align' => 'left',
|
196 |
+
'panel_second_level_font' => 'panel_header_font',
|
197 |
+
'panel_second_level_font_size' => 'panel_header_font_size',
|
198 |
+
'panel_second_level_font_weight' => 'panel_header_font_weight',
|
199 |
+
'panel_second_level_font_weight_hover' => 'panel_header_font_weight',
|
200 |
+
'panel_second_level_text_decoration' => 'panel_header_text_decoration',
|
201 |
+
'panel_second_level_text_decoration_hover' => 'panel_header_text_decoration',
|
202 |
+
'panel_second_level_background_hover_from' => 'rgba(0,0,0,0)',
|
203 |
+
'panel_second_level_background_hover_to' => 'rgba(0,0,0,0)',
|
204 |
+
'panel_second_level_padding_left' => '0px',
|
205 |
+
'panel_second_level_padding_right' => '0px',
|
206 |
+
'panel_second_level_padding_top' => '0px',
|
207 |
+
'panel_second_level_padding_bottom' => '0px',
|
208 |
+
'panel_second_level_margin_left' => '0px',
|
209 |
+
'panel_second_level_margin_right' => '0px',
|
210 |
+
'panel_second_level_margin_top' => '0px',
|
211 |
+
'panel_second_level_margin_bottom' => '0px',
|
212 |
+
'panel_second_level_border_color' => 'rgba(0,0,0,0)',
|
213 |
+
'panel_second_level_border_color_hover' => 'rgba(0,0,0,0)',
|
214 |
+
'panel_second_level_border_left' => '0px',
|
215 |
+
'panel_second_level_border_right' => '0px',
|
216 |
+
'panel_second_level_border_top' => '0px',
|
217 |
+
'panel_second_level_border_bottom' => '0px',
|
218 |
+
'panel_third_level_font_color' => 'panel_font_color',
|
219 |
+
'panel_third_level_font_color_hover' => 'panel_font_color',
|
220 |
+
'panel_third_level_text_transform' => 'none',
|
221 |
+
'panel_third_level_text_align' => 'left',
|
222 |
+
'panel_third_level_font' => 'panel_font_family',
|
223 |
+
'panel_third_level_font_size' => 'panel_font_size',
|
224 |
+
'panel_third_level_font_weight' => 'normal',
|
225 |
+
'panel_third_level_font_weight_hover' => 'normal',
|
226 |
+
'panel_third_level_text_decoration' => 'none',
|
227 |
+
'panel_third_level_text_decoration_hover' => 'none',
|
228 |
+
'panel_third_level_background_hover_from' => 'rgba(0,0,0,0)',
|
229 |
+
'panel_third_level_background_hover_to' => 'rgba(0,0,0,0)',
|
230 |
+
'panel_third_level_padding_left' => '0px',
|
231 |
+
'panel_third_level_padding_right' => '0px',
|
232 |
+
'panel_third_level_padding_top' => '0px',
|
233 |
+
'panel_third_level_padding_bottom' => '0px',
|
234 |
+
'panel_third_level_margin_left' => '0px',
|
235 |
+
'panel_third_level_margin_right' => '0px',
|
236 |
+
'panel_third_level_margin_top' => '0px',
|
237 |
+
'panel_third_level_margin_bottom' => '0px',
|
238 |
+
'panel_third_level_border_color' => 'rgba(0,0,0,0)',
|
239 |
+
'panel_third_level_border_color_hover' => 'rgba(0,0,0,0)',
|
240 |
+
'panel_third_level_border_left' => '0px',
|
241 |
+
'panel_third_level_border_right' => '0px',
|
242 |
+
'panel_third_level_border_top' => '0px',
|
243 |
+
'panel_third_level_border_bottom' => '0px',
|
244 |
+
'flyout_width' => '250px',
|
245 |
+
'flyout_menu_background_from' => '#f1f1f1',
|
246 |
+
'flyout_menu_background_to' => '#f1f1f1',
|
247 |
+
'flyout_border_color' => '#ffffff',
|
248 |
+
'flyout_border_left' => '0px',
|
249 |
+
'flyout_border_right' => '0px',
|
250 |
+
'flyout_border_top' => '0px',
|
251 |
+
'flyout_border_bottom' => '0px',
|
252 |
+
'flyout_border_radius_top_left' => '0px',
|
253 |
+
'flyout_border_radius_top_right' => '0px',
|
254 |
+
'flyout_border_radius_bottom_left' => '0px',
|
255 |
+
'flyout_border_radius_bottom_right' => '0px',
|
256 |
+
'flyout_menu_item_divider' => 'off',
|
257 |
+
'flyout_menu_item_divider_color' => 'rgba(255, 255, 255, 0.1)',
|
258 |
+
'flyout_padding_top' => '0px',
|
259 |
+
'flyout_padding_right' => '0px',
|
260 |
+
'flyout_padding_bottom' => '0px',
|
261 |
+
'flyout_padding_left' => '0px',
|
262 |
+
'flyout_link_padding_left' => '10px',
|
263 |
+
'flyout_link_padding_right' => '10px',
|
264 |
+
'flyout_link_padding_top' => '0px',
|
265 |
+
'flyout_link_padding_bottom' => '0px',
|
266 |
+
'flyout_link_weight' => 'normal',
|
267 |
+
'flyout_link_weight_hover' => 'normal',
|
268 |
+
'flyout_link_height' => '35px',
|
269 |
+
'flyout_link_text_decoration' => 'none',
|
270 |
+
'flyout_link_text_decoration_hover' => 'none',
|
271 |
+
'flyout_background_from' => '#f1f1f1',
|
272 |
+
'flyout_background_to' => '#f1f1f1',
|
273 |
+
'flyout_background_hover_from' => '#dddddd',
|
274 |
+
'flyout_background_hover_to' => '#dddddd',
|
275 |
+
'flyout_link_size' => 'font_size',
|
276 |
+
'flyout_link_color' => 'font_color',
|
277 |
+
'flyout_link_color_hover' => 'font_color',
|
278 |
+
'flyout_link_family' => 'font_family',
|
279 |
+
'flyout_link_text_transform' => 'none',
|
280 |
+
'responsive_breakpoint' => '768px',
|
281 |
+
'responsive_text' => 'MENU', // deprecated
|
282 |
+
'line_height' => '1.7',
|
283 |
+
'z_index' => '999',
|
284 |
+
'shadow' => 'off',
|
285 |
+
'shadow_horizontal' => '0px',
|
286 |
+
'shadow_vertical' => '0px',
|
287 |
+
'shadow_blur' => '5px',
|
288 |
+
'shadow_spread' => '0px',
|
289 |
+
'shadow_color' => 'rgba(0, 0, 0, 0.1)',
|
290 |
+
'transitions' => 'off',
|
291 |
+
'resets' => 'off',
|
292 |
+
'mobile_columns' => '1',
|
293 |
+
'toggle_background_from' => 'container_background_from',
|
294 |
+
'toggle_background_to' => 'container_background_to',
|
295 |
+
'toggle_font_color' => 'rgb(221, 221, 221)', // deprecated
|
296 |
+
'toggle_bar_height' => '40px',
|
297 |
+
'toggle_bar_border_radius_top_left' => '2px',
|
298 |
+
'toggle_bar_border_radius_top_right' => '2px',
|
299 |
+
'toggle_bar_border_radius_bottom_left' => '2px',
|
300 |
+
'toggle_bar_border_radius_bottom_right' => '2px',
|
301 |
+
'mobile_menu_padding_left' => '0px',
|
302 |
+
'mobile_menu_padding_right' => '0px',
|
303 |
+
'mobile_menu_padding_top' => '0px',
|
304 |
+
'mobile_menu_padding_bottom' => '0px',
|
305 |
+
'mobile_menu_item_height' => '40px',
|
306 |
+
'mobile_menu_overlay' => 'off',
|
307 |
+
'mobile_menu_force_width' => 'off',
|
308 |
+
'mobile_menu_force_width_selector' => 'body',
|
309 |
+
'mobile_background_from' => 'container_background_from',
|
310 |
+
'mobile_background_to' => 'container_background_to',
|
311 |
+
'mobile_menu_item_link_font_size' => 'menu_item_link_font_size',
|
312 |
+
'mobile_menu_item_link_color' => 'menu_item_link_color',
|
313 |
+
'mobile_menu_item_link_text_align' => 'menu_item_link_text_align',
|
314 |
+
'mobile_menu_item_link_color_hover' => 'menu_item_link_color_hover',
|
315 |
+
'mobile_menu_item_background_hover_from' => 'menu_item_background_hover_from',
|
316 |
+
'mobile_menu_item_background_hover_to' => 'menu_item_background_hover_to',
|
317 |
+
'mobile_menu_off_canvas_width' => '300px',
|
318 |
+
'disable_mobile_toggle' => 'off',
|
319 |
+
'custom_css' => '/** Push menu onto new line **/
|
320 |
#{$wrap} {
|
321 |
clear: both;
|
322 |
+
}',
|
323 |
+
)
|
324 |
+
);
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* @since 1.0
|
331 |
+
*/
|
332 |
+
public function default_themes() {
|
333 |
+
|
334 |
+
$themes['default'] = $this->get_default_theme();
|
335 |
+
|
336 |
+
return apply_filters( 'megamenu_themes', $themes );
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Merge the saved themes (from options table) into array of complete themes
|
341 |
+
*
|
342 |
+
* @since 2.1
|
343 |
+
*/
|
344 |
+
private function merge_in_saved_themes( $all_themes ) {
|
345 |
+
|
346 |
+
if ( $saved_themes = max_mega_menu_get_themes() ) {
|
347 |
+
foreach ( $saved_themes as $key => $settings ) {
|
348 |
+
if ( isset( $all_themes[ $key ] ) ) {
|
349 |
+
// merge modifications to default themes
|
350 |
+
$all_themes[ $key ] = array_merge( $all_themes[ $key ], $saved_themes[ $key ] );
|
351 |
+
} else {
|
352 |
+
// add in new themes
|
353 |
+
$all_themes[ $key ] = $settings;
|
354 |
+
}
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
return $all_themes;
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Populate all themes with all keys from the default theme
|
364 |
+
*
|
365 |
+
* @since 2.1
|
366 |
+
*/
|
367 |
+
private function ensure_all_themes_have_all_default_theme_settings( $all_themes ) {
|
368 |
+
|
369 |
+
$default_theme = $this->get_default_theme();
|
370 |
+
|
371 |
+
$themes = array();
|
372 |
+
|
373 |
+
foreach ( $all_themes as $theme_id => $theme ) {
|
374 |
+
$themes[ $theme_id ] = array_merge( $default_theme, $theme );
|
375 |
+
}
|
376 |
+
|
377 |
+
return $themes;
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
/**
|
382 |
+
* For backwards compatibility, copy old settings into new values
|
383 |
+
*
|
384 |
+
* @since 2.1
|
385 |
+
*/
|
386 |
+
private function process_theme_replacements( $all_themes ) {
|
387 |
+
|
388 |
+
foreach ( $all_themes as $key => $settings ) {
|
389 |
+
// process replacements
|
390 |
+
foreach ( $settings as $var => $val ) {
|
391 |
+
if ( ! is_array( $val ) && isset( $all_themes[ $key ][ $val ] ) ) {
|
392 |
+
$all_themes[ $key ][ $var ] = $all_themes[ $key ][ $val ];
|
393 |
+
}
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
return $all_themes;
|
398 |
+
}
|
399 |
+
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Return a filtered list of themes
|
403 |
+
*
|
404 |
+
* @since 1.0
|
405 |
+
* @return array
|
406 |
+
*/
|
407 |
+
public function get_themes() {
|
408 |
+
|
409 |
+
$default_themes = $this->default_themes();
|
410 |
+
|
411 |
+
$all_themes = $this->merge_in_saved_themes( $default_themes );
|
412 |
+
$all_themes = $this->ensure_all_themes_have_all_default_theme_settings( $all_themes );
|
413 |
+
$all_themes = $this->process_theme_replacements( $all_themes );
|
414 |
+
|
415 |
+
uasort( $all_themes, array( $this, 'sort_by_title' ) );
|
416 |
+
|
417 |
+
return $all_themes;
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Sorts a 2d array by the 'title' key
|
423 |
+
*
|
424 |
+
* @since 1.0
|
425 |
+
* @param array $a
|
426 |
+
* @param array $b
|
427 |
+
*/
|
428 |
+
private function sort_by_title( $a, $b ) {
|
429 |
+
return strcmp( $a['title'], $b['title'] );
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
/**
|
434 |
+
*
|
435 |
+
*
|
436 |
+
* @since 1.3.1
|
437 |
+
* @return bool
|
438 |
+
*/
|
439 |
+
private function is_debug_mode() {
|
440 |
+
return ( defined( 'MEGAMENU_DEBUG' ) && MEGAMENU_DEBUG === true );
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Return the menu CSS for use in inline CSS block. Use the cache if possible.
|
446 |
+
*
|
447 |
+
* @since 1.3.1
|
448 |
+
*/
|
449 |
+
public function get_css() {
|
450 |
+
|
451 |
+
if ( ( $css = $this->get_cached_css() ) && ! $this->is_debug_mode() ) {
|
452 |
+
return $css;
|
453 |
+
} else {
|
454 |
+
return $this->generate_css();
|
455 |
+
}
|
456 |
+
}
|
457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
|
459 |
+
/**
|
460 |
+
* Generate and cache the CSS for our menus.
|
461 |
+
* The CSS is compiled by scssphp using the file located in /css/megamenu.scss
|
462 |
+
*
|
463 |
+
* @since 1.0
|
464 |
+
* @return string
|
465 |
+
* @param boolean $debug_mode (prints error messages to the CSS when enabled)
|
466 |
+
*/
|
467 |
+
public function generate_css() {
|
468 |
+
|
469 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
470 |
+
wp_raise_memory_limit(); // attempt to raise memory limit to 256MB
|
471 |
+
}
|
472 |
+
|
473 |
+
// the settings may have changed since the class was instantiated,
|
474 |
+
// reset them here
|
475 |
+
$this->settings = get_option( 'megamenu_settings' );
|
476 |
+
|
477 |
+
if ( ! $this->settings ) {
|
478 |
+
return '/** CSS Generation Failed. No menu settings found **/';
|
479 |
+
}
|
480 |
+
|
481 |
+
$css = '';
|
482 |
+
|
483 |
+
foreach ( $this->settings as $location => $settings ) {
|
484 |
+
if ( isset( $settings['enabled'] ) && has_nav_menu( $location ) ) {
|
485 |
+
$theme = $this->get_theme_settings_for_location( $location );
|
486 |
+
$menu_id = $this->get_menu_id_for_location( $location );
|
487 |
+
$compiled_css = $this->generate_css_for_location( $location, $theme, $menu_id );
|
488 |
+
|
489 |
+
if ( ! is_wp_error( $compiled_css ) ) {
|
490 |
+
$css .= $compiled_css;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
if ( strlen( $css ) ) {
|
496 |
+
$scss_location = 'core';
|
497 |
+
|
498 |
+
foreach ( $this->get_possible_scss_file_locations() as $path ) {
|
499 |
+
if ( file_exists( $path ) && $path !== $this->get_default_scss_file_location() ) {
|
500 |
+
$scss_location = 'custom';
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
$css = '/** ' . date( 'l jS F Y H:i:s e' ) . " ({$scss_location}) **/\n/** THIS FILE IS AUTOMATICALLY GENERATED - DO NOT MAKE MANUAL EDITS! **/\n/** Custom CSS should be added to Mega Menu > Menu Themes > Custom Styling **/\n\n.mega-menu-last-modified-" . time() . " { content: '" . date( 'l jS F Y H:i:s e' ) . "'; }\n\n" . $css;
|
505 |
+
|
506 |
+
$css = apply_filters( 'megamenu_compiled_css', $css );
|
507 |
+
|
508 |
+
$this->set_cached_css( $css );
|
509 |
+
|
510 |
+
if ( $this->get_css_output_method() == 'fs' ) {
|
511 |
+
$this->save_to_filesystem( $css );
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
return $css;
|
516 |
+
}
|
517 |
+
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Saves the generated CSS to the uploads folder
|
521 |
+
*
|
522 |
+
* @since 1.6.1
|
523 |
+
*/
|
524 |
+
private function save_to_filesystem( $css ) {
|
525 |
+
global $wp_filesystem;
|
526 |
+
|
527 |
+
if ( ! $wp_filesystem ) {
|
528 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
529 |
+
}
|
530 |
+
|
531 |
+
$upload_dir = wp_upload_dir();
|
532 |
+
$filename = $this->get_css_filename();
|
533 |
+
|
534 |
+
$dir = trailingslashit( $upload_dir['basedir'] ) . 'maxmegamenu/';
|
535 |
+
|
536 |
+
WP_Filesystem( false, $upload_dir['basedir'], true );
|
537 |
+
|
538 |
+
if ( ! $wp_filesystem->is_dir( $dir ) ) {
|
539 |
+
$wp_filesystem->mkdir( $dir );
|
540 |
+
}
|
541 |
+
|
542 |
+
if ( ! $wp_filesystem->put_contents( $dir . $filename, $css ) ) {
|
543 |
+
// File write failed.
|
544 |
+
// Update CSS output option to 'head' to stop us from attempting to regenerate the CSS on every request.
|
545 |
+
$settings = get_option( 'megamenu_settings' );
|
546 |
+
$settings['css'] = 'head';
|
547 |
+
update_option( 'megamenu_settings', $settings );
|
548 |
+
$this->settings = get_option( 'megamenu_settings' );
|
549 |
+
|
550 |
+
// set a far expiration date to prevent transient from being autoloaded
|
551 |
+
$hundred_years_in_seconds = 3153600000;
|
552 |
+
set_transient( 'megamenu_failed_to_write_css_to_filesystem', 'true', $hundred_years_in_seconds );
|
553 |
+
}
|
554 |
+
|
555 |
+
}
|
556 |
+
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Return an array of all the possible file path locations for the SCSS file
|
560 |
+
* @since 2.2.3
|
561 |
+
* @return array
|
562 |
+
*/
|
563 |
+
private function get_possible_scss_file_locations() {
|
564 |
+
return apply_filters(
|
565 |
+
'megamenu_scss_locations',
|
566 |
+
array(
|
567 |
+
trailingslashit( get_stylesheet_directory() ) . trailingslashit( 'megamenu' ) . 'megamenu.scss', // child theme
|
568 |
+
trailingslashit( get_template_directory() ) . trailingslashit( 'megamenu' ) . 'megamenu.scss', // parent theme
|
569 |
+
$this->get_default_scss_file_location(),
|
570 |
+
)
|
571 |
+
);
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Return the default SCSS file path
|
577 |
+
*
|
578 |
+
* @since 2.2.3
|
579 |
+
* @return string
|
580 |
+
*/
|
581 |
+
private function get_default_scss_file_location() {
|
582 |
+
return MEGAMENU_PATH . trailingslashit( 'css' ) . 'megamenu.scss';
|
583 |
+
}
|
584 |
+
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Return the path to the megamenu.scss file, look for custom files before
|
588 |
+
* loading the core version.
|
589 |
+
*
|
590 |
+
* @since 1.0
|
591 |
+
* @return string
|
592 |
+
*/
|
593 |
+
private function load_scss_file() {
|
594 |
+
|
595 |
+
/**
|
596 |
+
* *** IMPORTANT NOTICE ***
|
597 |
+
*
|
598 |
+
* Allowing users to create their own versions of megamenu.scss was a poor design decision.
|
599 |
+
*
|
600 |
+
* The bundled SCSS file and the plugin code work in perfect harmony.
|
601 |
+
*
|
602 |
+
* When a user (or theme developer) creates their own copy of megamenu.scss it
|
603 |
+
* _will_ become outdated as the plugin is updated and the menu HTML changes.
|
604 |
+
*
|
605 |
+
* Instead of using a custom SCSS file, override only the absolute minimum CSS in the
|
606 |
+
* Mega Menu > Menu Themes > Custom Styling section.
|
607 |
+
*/
|
608 |
+
$scss = file_get_contents( MEGAMENU_PATH . trailingslashit( 'css' ) . 'mixin.scss' );
|
609 |
+
$scss .= file_get_contents( MEGAMENU_PATH . trailingslashit( 'css' ) . 'reset.scss' );
|
610 |
+
|
611 |
+
$locations = $this->get_possible_scss_file_locations();
|
612 |
+
|
613 |
+
foreach ( $locations as $path ) {
|
614 |
+
|
615 |
+
if ( file_exists( $path ) ) {
|
616 |
+
|
617 |
+
$scss .= file_get_contents( $path );
|
618 |
+
//break;
|
619 |
+
//
|
620 |
+
// @todo: add a break here. This is a known bug but some users may be relying on it.
|
621 |
+
// Add warning message to plugin to alert users about not using custom megamenu.scss files
|
622 |
+
// then fix the bug in a later release.
|
623 |
+
}
|
624 |
+
}
|
625 |
+
|
626 |
+
$scss .= file_get_contents( MEGAMENU_PATH . trailingslashit( 'css' ) . 'compatibility.scss' );
|
627 |
+
|
628 |
+
return apply_filters( 'megamenu_load_scss_file_contents', $scss );
|
629 |
+
|
630 |
+
}
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Before a theme is saved, attempt to generate the CSS to ensure it passes as valid SCSS
|
634 |
+
*
|
635 |
+
* @param array $theme
|
636 |
+
*/
|
637 |
+
public function test_theme_compilation( $theme ) {
|
638 |
+
$menu_id = 0;
|
639 |
+
|
640 |
+
$menus = get_registered_nav_menus();
|
641 |
+
|
642 |
+
if ( count( $menus ) ) {
|
643 |
+
$locations = get_nav_menu_locations();
|
644 |
+
|
645 |
+
foreach ( $menus as $location => $description ) {
|
646 |
+
if ( isset( $locations[ $location ] ) ) {
|
647 |
+
$menu_id = $locations[ $location ];
|
648 |
+
continue;
|
649 |
+
}
|
650 |
+
}
|
651 |
+
}
|
652 |
+
|
653 |
+
return $this->generate_css_for_location( 'test', $theme, $menu_id );
|
654 |
+
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Compiles raw SCSS into CSS for a particular menu location.
|
660 |
+
*
|
661 |
+
* @since 1.3
|
662 |
+
* @return mixed
|
663 |
+
* @param array $settings
|
664 |
+
* @param string $location
|
665 |
+
*/
|
666 |
+
public function generate_css_for_location( $location, $theme, $menu_id ) {
|
667 |
+
|
668 |
+
$scssc = new scssc();
|
669 |
+
$scssc->setFormatter( 'scss_formatter' );
|
670 |
+
|
671 |
+
$import_paths = apply_filters(
|
672 |
+
'megamenu_scss_import_paths',
|
673 |
+
array(
|
674 |
+
trailingslashit( get_stylesheet_directory() ) . trailingslashit( 'megamenu' ),
|
675 |
+
trailingslashit( get_stylesheet_directory() ),
|
676 |
+
trailingslashit( get_template_directory() ) . trailingslashit( 'megamenu' ),
|
677 |
+
trailingslashit( get_template_directory() ),
|
678 |
+
trailingslashit( WP_PLUGIN_DIR ),
|
679 |
+
)
|
680 |
+
);
|
681 |
+
|
682 |
+
foreach ( $import_paths as $path ) {
|
683 |
+
$scssc->addImportPath( $path );
|
684 |
+
}
|
685 |
|
686 |
+
try {
|
687 |
+
return $scssc->compile( $this->get_complete_scss_for_location( $location, $theme, $menu_id ) );
|
688 |
+
} catch ( Exception $e ) {
|
689 |
+
$message = __( 'Warning: CSS compilation failed. Please check your changes or revert the theme.', 'megamenu' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
|
691 |
+
return new WP_Error( 'scss_compile_fail', $message . '<br /><br />' . $e->getMessage() );
|
692 |
+
}
|
|
|
693 |
|
694 |
+
}
|
|
|
|
|
|
|
|
|
695 |
|
|
|
|
|
696 |
|
697 |
+
/**
|
698 |
+
* Generates a SCSS string which includes the variables for a menu theme,
|
699 |
+
* for a particular menu location.
|
700 |
+
*
|
701 |
+
* @since 1.3
|
702 |
+
* @return string
|
703 |
+
* @param string $theme
|
704 |
+
* @param string $location
|
705 |
+
* @param int $menu_id
|
706 |
+
*/
|
707 |
+
private function get_complete_scss_for_location( $location, $theme, $menu_id ) {
|
708 |
|
709 |
+
$sanitized_location = str_replace( apply_filters( 'megamenu_location_replacements', array( '-', ' ' ) ), '-', $location );
|
710 |
|
711 |
+
$wrap_selector = apply_filters( 'megamenu_scss_wrap_selector', "#mega-menu-wrap-{$sanitized_location}", $menu_id, $location );
|
712 |
+
$menu_selector = apply_filters( 'megamenu_scss_menu_selector', "#mega-menu-{$sanitized_location}", $menu_id, $location );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
|
714 |
+
$vars['wrap'] = "'$wrap_selector'";
|
715 |
+
$vars['menu'] = "'$menu_selector'";
|
716 |
+
$vars['location'] = "'$sanitized_location'";
|
717 |
+
$vars['menu_id'] = "'$menu_id'";
|
718 |
+
$vars['elementor_pro_active'] = 'false';
|
719 |
+
$vars['arrow_font'] = 'dashicons';
|
720 |
+
$vars['arrow_font_weight'] = 'normal';
|
721 |
|
722 |
+
$current_theme = wp_get_theme();
|
723 |
+
$theme_id = $current_theme->template;
|
724 |
|
725 |
+
$vars['wp_theme'] = strtolower( str_replace( array( '.', ' ' ), '_', $theme_id ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
726 |
|
727 |
+
if ( empty( $vars['wp_theme'] ) ) {
|
728 |
+
$vars['wp_theme'] = 'unknown';
|
729 |
+
}
|
730 |
|
731 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
732 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
733 |
+
}
|
734 |
|
735 |
+
if ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'elementor-pro/elementor-pro.php' ) ) {
|
736 |
+
$vars['elementor_pro_active'] = 'true';
|
737 |
+
}
|
738 |
|
739 |
+
$settings = $this->get_menu_settings_for_location( $location );
|
|
|
|
|
740 |
|
741 |
+
if ( isset( $settings['effect_speed'] ) && absint( $settings['effect_speed'] ) > 0 ) {
|
742 |
+
$effect_speed = absint( $settings['effect_speed'] ) . 'ms';
|
743 |
+
} else {
|
744 |
+
$effect_speed = '200ms';
|
745 |
+
}
|
746 |
|
747 |
+
$vars['effect_speed'] = $effect_speed;
|
748 |
|
749 |
+
if ( isset( $settings['effect_speed_mobile'] ) && absint( $settings['effect_speed_mobile'] ) > 0 ) {
|
750 |
+
$effect_speed_mobile = absint( $settings['effect_speed_mobile'] ) . 'ms';
|
751 |
+
} else {
|
752 |
+
$effect_speed_mobile = '200ms';
|
753 |
+
}
|
754 |
|
755 |
+
$vars['effect_speed_mobile'] = $effect_speed_mobile;
|
756 |
|
757 |
+
if ( isset( $settings['effect_mobile'] ) ) {
|
758 |
+
$effect_mobile = $settings['effect_mobile'];
|
759 |
+
} else {
|
760 |
+
$effect_mobile = 'disabled';
|
761 |
+
}
|
762 |
|
763 |
+
$vars['effect_mobile'] = $effect_mobile;
|
764 |
|
765 |
+
foreach ( $theme as $name => $value ) {
|
|
|
|
|
|
|
|
|
766 |
|
767 |
+
if ( in_array( $name, array( 'arrow_up', 'arrow_down', 'arrow_left', 'arrow_right' ) ) ) {
|
768 |
|
769 |
+
$parts = explode( '-', $value );
|
770 |
+
$code = end( $parts );
|
771 |
|
772 |
+
$arrow_icon = $code == 'disabled' ? "''" : "'\\" . $code . "'";
|
773 |
|
774 |
+
$vars[ $name ] = $arrow_icon;
|
775 |
|
776 |
+
continue;
|
777 |
+
}
|
778 |
|
779 |
+
if ( in_array( $name, array( 'menu_item_link_font', 'panel_font_family', 'panel_header_font', 'panel_second_level_font', 'panel_third_level_font', 'panel_third_level_font', 'flyout_link_family', 'tabbed_link_family' ) ) ) {
|
|
|
780 |
|
781 |
+
$vars[ $name ] = "'" . stripslashes( htmlspecialchars_decode( $value ) ) . "'";
|
782 |
|
783 |
+
continue;
|
784 |
+
}
|
785 |
|
786 |
+
if ( in_array( $name, array( 'responsive_text' ) ) ) {
|
|
|
787 |
|
788 |
+
if ( strlen( $value ) ) {
|
789 |
+
$vars[ $name ] = "'" . do_shortcode( $value ) . "'";
|
790 |
+
} else {
|
791 |
+
$vars[ $name ] = "''";
|
792 |
+
}
|
793 |
|
794 |
+
continue;
|
795 |
+
}
|
796 |
|
797 |
+
if ( in_array( $name, array( 'panel_width', 'panel_inner_width', 'mobile_menu_force_width_selector' ) ) ) {
|
798 |
+
if ( preg_match( '/^\d/', $value ) !== 1 ) { // doesn't start with number (jQuery selector)
|
799 |
+
$vars[ $name ] = '100%';
|
800 |
+
continue;
|
801 |
+
}
|
802 |
+
}
|
803 |
|
804 |
+
if ( $name != 'custom_css' ) {
|
805 |
+
$vars[ $name ] = $value;
|
806 |
+
}
|
807 |
+
}
|
808 |
|
809 |
+
// Non-standard characters in the title will break CSS compilation, unset it here as it's not needed.
|
810 |
+
if ( isset( $vars['title'] ) ) {
|
811 |
+
unset( $vars['title'] );
|
812 |
+
}
|
|
|
813 |
|
814 |
+
$vars = apply_filters( 'megamenu_scss_variables', $vars, $location, $theme, $menu_id, $this->get_theme_id_for_location( $location ) );
|
|
|
815 |
|
816 |
+
$scss = '';
|
|
|
|
|
|
|
|
|
|
|
817 |
|
818 |
+
foreach ( $vars as $name => $value ) {
|
819 |
+
$scss .= '$' . $name . ': ' . $value . ";\n";
|
820 |
+
}
|
821 |
|
822 |
+
$scss .= $this->load_scss_file();
|
823 |
|
824 |
+
$scss .= stripslashes( html_entity_decode( $theme['custom_css'], ENT_QUOTES ) );
|
|
|
|
|
|
|
825 |
|
826 |
+
return apply_filters( 'megamenu_scss', $scss, $location, $theme, $menu_id );
|
827 |
|
828 |
+
}
|
829 |
|
|
|
|
|
|
|
830 |
|
831 |
+
/**
|
832 |
+
* Returns the menu ID for a specified menu location, defaults to 0
|
833 |
+
*
|
834 |
+
* @since 1.3
|
835 |
+
*/
|
836 |
+
private function get_menu_id_for_location( $location ) {
|
837 |
+
$locations = get_nav_menu_locations();
|
838 |
+
$menu_id = isset( $locations[ $location ] ) ? $locations[ $location ] : 0;
|
839 |
|
840 |
+
return $menu_id;
|
841 |
+
}
|
842 |
|
|
|
843 |
|
844 |
+
/**
|
845 |
+
* Returns the theme ID for a specified menu location, defaults to 'default'
|
846 |
+
*
|
847 |
+
* @since 2.1
|
848 |
+
*/
|
849 |
+
private function get_theme_id_for_location( $location ) {
|
850 |
+
$settings = $this->settings;
|
851 |
+
$theme_id = isset( $settings[ $location ]['theme'] ) ? $settings[ $location ]['theme'] : 'default';
|
852 |
|
853 |
+
return $theme_id;
|
854 |
+
}
|
855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
856 |
|
857 |
+
/**
|
858 |
+
* Returns the theme settings for a specified location. Defaults to the default theme.
|
859 |
+
*
|
860 |
+
* @since 1.3
|
861 |
+
*/
|
862 |
+
private function get_theme_settings_for_location( $location ) {
|
863 |
+
$theme_id = $this->get_theme_id_for_location( $location );
|
864 |
+
$all_themes = $this->get_themes();
|
865 |
+
$theme_settings = isset( $all_themes[ $theme_id ] ) ? $all_themes[ $theme_id ] : $all_themes['default'];
|
866 |
|
867 |
+
return $theme_settings;
|
868 |
+
}
|
869 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
870 |
|
871 |
+
/**
|
872 |
+
* Returns the menu settings for a specified location.
|
873 |
+
*
|
874 |
+
* @since 2.2
|
875 |
+
*/
|
876 |
+
private function get_menu_settings_for_location( $location ) {
|
877 |
+
$settings = $this->settings;
|
878 |
+
$location_settings = isset( $settings[ $location ] ) ? $settings[ $location ] : array();
|
879 |
+
return $location_settings;
|
880 |
+
}
|
881 |
|
882 |
+
/**
|
883 |
+
* Enqueue public CSS and JS files required by Mega Menu
|
884 |
+
*
|
885 |
+
* @since 1.0
|
886 |
+
*/
|
887 |
+
public function enqueue_styles() {
|
888 |
+
if ( 'fs' === $this->get_css_output_method() ) {
|
889 |
+
$this->enqueue_fs_style();
|
890 |
+
}
|
891 |
|
892 |
+
wp_enqueue_style( 'dashicons' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
893 |
|
894 |
+
do_action( 'megamenu_enqueue_public_scripts' );
|
|
|
895 |
|
896 |
+
}
|
897 |
|
898 |
+
/**
|
899 |
+
* Enqueue public CSS and JS files required by Mega Menu
|
900 |
+
*
|
901 |
+
* @since 1.0
|
902 |
+
*/
|
903 |
+
public function enqueue_scripts() {
|
|
|
|
|
|
|
|
|
904 |
|
905 |
+
wp_enqueue_script( 'hoverIntent' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
906 |
|
907 |
+
$js_path = MEGAMENU_BASE_URL . 'js/maxmegamenu.js';
|
908 |
|
909 |
+
$dependencies = apply_filters( 'megamenu_javascript_dependencies', array( 'jquery', 'hoverIntent' ) );
|
910 |
|
911 |
+
$scripts_in_footer = apply_filters( 'megamenu_scripts_in_footer', true );
|
912 |
|
913 |
+
if ( defined( 'MEGAMENU_SCRIPTS_IN_FOOTER' ) ) {
|
914 |
+
$scripts_in_footer = MEGAMENU_SCRIPTS_IN_FOOTER;
|
915 |
+
}
|
|
|
|
|
|
|
916 |
|
917 |
+
///** change the script handle to prevent conflict with theme files */
|
918 |
+
//function megamenu_script_handle() {
|
919 |
+
// return "maxmegamenu";
|
920 |
+
//}
|
921 |
+
//add_filter("megamenu_javascript_handle", "megamenu_script_handle");*/
|
922 |
+
$handle = apply_filters( 'megamenu_javascript_handle', 'megamenu' );
|
923 |
|
924 |
+
wp_enqueue_script( $handle, $js_path, $dependencies, MEGAMENU_VERSION, $scripts_in_footer );
|
925 |
|
926 |
+
// @todo: remove the following code in future update. Only here to prevent JS errors for users with
|
927 |
+
// cached versions of maxmegamenu.js
|
928 |
+
$params = apply_filters(
|
929 |
+
'megamenu_javascript_localisation',
|
930 |
+
array(
|
931 |
+
'timeout' => 300,
|
932 |
+
'interval' => 100,
|
933 |
+
)
|
934 |
+
);
|
935 |
|
936 |
+
wp_localize_script( $handle, 'megamenu', $params );
|
937 |
+
}
|
938 |
|
|
|
|
|
|
|
939 |
|
|
|
|
|
|
|
|
|
|
|
|
|
940 |
|
941 |
+
/**
|
942 |
+
* Enqueue the stylesheet held on the filesystem.
|
943 |
+
*
|
944 |
+
* @since 1.6.1
|
945 |
+
*/
|
946 |
+
private function enqueue_fs_style() {
|
947 |
|
948 |
+
$upload_dir = wp_upload_dir();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
949 |
|
950 |
+
$filename = $this->get_css_filename();
|
|
|
951 |
|
952 |
+
$filepath = trailingslashit( $upload_dir['basedir'] ) . 'maxmegamenu/' . $filename;
|
953 |
|
954 |
+
if ( ! is_file( $filepath ) || $this->is_debug_mode() ) {
|
955 |
+
// regenerate the CSS and save to filesystem.
|
956 |
+
$this->generate_css();
|
957 |
|
958 |
+
}
|
|
|
|
|
|
|
|
|
|
|
959 |
|
960 |
+
// file should now exist.
|
961 |
+
if ( is_file( $filepath ) ) {
|
962 |
|
963 |
+
$css_url = trailingslashit( $upload_dir['baseurl'] ) . 'maxmegamenu/' . $filename;
|
964 |
|
965 |
+
$protocol = is_ssl() ? 'https://' : 'http://';
|
966 |
|
967 |
+
// ensure we're using the correct protocol.
|
968 |
+
$css_url = str_replace( array( 'http://', 'https://' ), $protocol, $css_url );
|
|
|
969 |
|
970 |
+
wp_enqueue_style( 'megamenu', $css_url, false, substr( md5( filemtime( $filepath ) ), 0, 6 ) );
|
971 |
|
972 |
+
}
|
|
|
973 |
|
974 |
+
}
|
975 |
|
|
|
976 |
|
977 |
+
/**
|
978 |
+
*
|
979 |
+
* @since 1.6.1
|
980 |
+
*/
|
981 |
+
private function set_cached_css( $css ) {
|
982 |
+
// set a far expiration date to prevent transient from being autoloaded.
|
983 |
+
$hundred_years_in_seconds = 3153600000;
|
984 |
|
985 |
+
set_transient( $this->get_transient_key(), $css, $hundred_years_in_seconds );
|
986 |
+
set_transient( 'megamenu_css_version', MEGAMENU_VERSION, $hundred_years_in_seconds );
|
987 |
+
set_transient( 'megamenu_css_last_updated', time(), $hundred_years_in_seconds );
|
988 |
+
}
|
989 |
|
|
|
990 |
|
991 |
+
/**
|
992 |
+
* Return the cached css if it exists
|
993 |
+
*
|
994 |
+
* @since 1.9
|
995 |
+
* @return mixed
|
996 |
+
*/
|
997 |
+
private function get_cached_css() {
|
998 |
+
return get_transient( $this->get_transient_key() );
|
999 |
+
}
|
1000 |
|
1001 |
|
1002 |
+
/**
|
1003 |
+
* Delete the cached CSS
|
1004 |
+
*
|
1005 |
+
* @since 1.9
|
1006 |
+
* @return mixed
|
1007 |
+
*/
|
1008 |
+
public function delete_cache() {
|
1009 |
+
global $wp_filesystem;
|
1010 |
|
1011 |
+
if ( ! $wp_filesystem ) {
|
1012 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
1013 |
+
}
|
|
|
1014 |
|
1015 |
+
$upload_dir = wp_upload_dir();
|
1016 |
+
$filename = $this->get_css_filename();
|
1017 |
+
$dir = trailingslashit( $upload_dir['basedir'] ) . 'maxmegamenu/';
|
1018 |
|
1019 |
+
WP_Filesystem( false, $upload_dir['basedir'], true );
|
1020 |
+
$wp_filesystem->rmdir( $dir, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
|
1022 |
+
delete_transient( $this->get_transient_key() );
|
1023 |
|
1024 |
+
$this->generate_css();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
|
1026 |
+
do_action( 'megamenu_after_delete_cache' );
|
|
|
|
|
1027 |
|
1028 |
+
return true;
|
|
|
|
|
1029 |
|
1030 |
+
}
|
|
|
1031 |
|
|
|
1032 |
|
1033 |
+
/**
|
1034 |
+
* Return the key to use for the CSS transient
|
1035 |
+
*
|
1036 |
+
* @since 1.9
|
1037 |
+
* @return string
|
1038 |
+
*/
|
1039 |
+
private function get_transient_key() {
|
1040 |
+
return apply_filters( 'megamenu_css_transient_key', 'megamenu_css' );
|
1041 |
+
}
|
1042 |
|
|
|
1043 |
|
1044 |
+
/**
|
1045 |
+
* Return the filename to use for the stylesheet, ensuring the filename is unique
|
1046 |
+
* for multi site setups
|
1047 |
+
*
|
1048 |
+
* @since 1.6.1
|
1049 |
+
*/
|
1050 |
+
private function get_css_filename() {
|
1051 |
+
return apply_filters( 'megamenu_css_filename', 'style' ) . '.css';
|
1052 |
+
}
|
1053 |
|
|
|
1054 |
|
1055 |
+
/**
|
1056 |
+
* Return the CSS output method, default to filesystem
|
1057 |
+
*
|
1058 |
+
* @return string
|
1059 |
+
*/
|
1060 |
+
private function get_css_output_method() {
|
1061 |
+
return isset( $this->settings['css'] ) ? $this->settings['css'] : 'fs';
|
1062 |
+
}
|
1063 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1064 |
|
1065 |
+
/**
|
1066 |
+
* Print CSS to <head>
|
1067 |
+
*
|
1068 |
+
* @since 1.3.1
|
1069 |
+
*/
|
1070 |
+
public function head_css() {
|
1071 |
|
1072 |
+
$method = $this->get_css_output_method();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1073 |
|
1074 |
+
if ( in_array( $method, array( 'disabled', 'fs' ) ) ) {
|
1075 |
+
echo "<style type=\"text/css\">/** Mega Menu CSS: {$method} **/</style>\n";
|
1076 |
+
return;
|
1077 |
+
}
|
1078 |
|
1079 |
+
$css = $this->get_css();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1080 |
|
1081 |
+
echo '<style type="text/css">' . str_replace( array( ' ', "\n" ), '', $css ) . "</style>\n";
|
1082 |
|
1083 |
+
}
|
|
|
|
|
|
|
|
|
|
|
1084 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1085 |
|
1086 |
+
/**
|
1087 |
+
* Delete language specific transients created when PolyLang is installed
|
1088 |
+
*
|
1089 |
+
* @since 1.9
|
1090 |
+
*/
|
1091 |
+
public function polylang_delete_cache() {
|
1092 |
+
global $polylang;
|
1093 |
|
1094 |
+
foreach ( $polylang->model->get_languages_list() as $term ) {
|
1095 |
+
delete_transient( 'megamenu_css_' . $term->locale );
|
1096 |
+
}
|
1097 |
+
}
|
1098 |
|
1099 |
|
1100 |
+
/**
|
1101 |
+
* Modify the CSS transient key to make it unique to the current language
|
1102 |
+
*
|
1103 |
+
* @since 1.9
|
1104 |
+
* @return string
|
1105 |
+
*/
|
1106 |
+
public function polylang_transient_key( $key ) {
|
1107 |
|
1108 |
+
$locale = strtolower( pll_current_language( 'locale' ) );
|
|
|
|
|
|
|
1109 |
|
1110 |
+
if ( strlen( $locale ) ) {
|
1111 |
+
$key = $key . '_' . $locale;
|
1112 |
+
}
|
1113 |
|
1114 |
+
return $key;
|
1115 |
+
}
|
|
|
|
|
|
|
|
|
|
|
1116 |
|
|
|
1117 |
|
1118 |
+
/**
|
1119 |
+
* Modify the CSS filename to make it unique to the current language
|
1120 |
+
*
|
1121 |
+
* @since 1.9
|
1122 |
+
* @return string
|
1123 |
+
*/
|
1124 |
+
public function polylang_css_filename( $filename ) {
|
1125 |
|
1126 |
+
$locale = strtolower( pll_current_language( 'locale' ) );
|
|
|
1127 |
|
1128 |
+
if ( strlen( $locale ) ) {
|
1129 |
+
$filename .= '_' . $locale;
|
1130 |
+
}
|
1131 |
+
|
1132 |
+
return $filename;
|
1133 |
+
}
|
1134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1135 |
|
1136 |
+
/**
|
1137 |
+
* Delete language specific transients created when WPML is installed
|
1138 |
+
*
|
1139 |
+
* @since 1.9
|
1140 |
+
*/
|
1141 |
+
public function wpml_delete_cache() {
|
1142 |
|
1143 |
+
$languages = icl_get_languages( 'skip_missing=N' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1144 |
|
1145 |
+
foreach ( $languages as $language ) {
|
1146 |
+
delete_transient( 'megamenu_css_' . $language['language_code'] );
|
1147 |
+
}
|
1148 |
+
}
|
|
|
|
|
1149 |
|
1150 |
|
1151 |
+
/**
|
1152 |
+
* Modify the CSS transient key to make it unique to the current language
|
1153 |
+
*
|
1154 |
+
* @since 1.9
|
1155 |
+
* @return string
|
1156 |
+
*/
|
1157 |
+
public function wpml_transient_key( $key ) {
|
1158 |
+
$key .= '_' . ICL_LANGUAGE_CODE;
|
1159 |
|
1160 |
+
return $key;
|
1161 |
+
}
|
1162 |
|
1163 |
|
1164 |
+
/**
|
1165 |
+
* Modify the CSS filename to make it unique to the current language
|
1166 |
+
*
|
1167 |
+
* @since 1.9
|
1168 |
+
* @return string
|
1169 |
+
*/
|
1170 |
+
public function wpml_css_filename( $filename ) {
|
1171 |
+
$filename .= '_' . ICL_LANGUAGE_CODE;
|
1172 |
|
1173 |
+
return $filename;
|
1174 |
+
}
|
1175 |
+
}
|
1176 |
|
1177 |
+
endif;
|
classes/toggle-blocks.class.php
CHANGED
@@ -1,1021 +1,1031 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Toggle_Blocks') ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
class Mega_Menu_Toggle_Blocks {
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
add_filter( 'megamenu_load_scss_file_contents', array( $this, 'append_scss'), 10 );
|
26 |
-
add_filter( 'megamenu_toggle_bar_content', array( $this, 'output_public_toggle_blocks' ), 10, 4 );
|
27 |
-
|
28 |
-
add_action( 'wp_ajax_mm_get_toggle_block_menu_toggle', array( $this, 'output_menu_toggle_block_html' ) );
|
29 |
-
add_action( 'megamenu_output_admin_toggle_block_menu_toggle', array( $this, 'output_menu_toggle_block_html'), 10, 2 );
|
30 |
-
add_action( 'megamenu_output_public_toggle_block_menu_toggle', array( $this, 'output_menu_public_toggle_block_html'), 10, 2 );
|
31 |
-
|
32 |
-
add_action( 'wp_ajax_mm_get_toggle_block_menu_toggle_animated', array( $this, 'output_menu_toggle_block_animated_html' ) );
|
33 |
-
add_action( 'megamenu_output_admin_toggle_block_menu_toggle_animated', array( $this, 'output_menu_toggle_block_animated_html'), 10, 2 );
|
34 |
-
add_action( 'megamenu_output_public_toggle_block_menu_toggle_animated', array( $this, 'output_menu_public_toggle_block_animated_html'), 10, 2 );
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
add_action( 'megamenu_after_theme_revert', array($this, 'revert_toggle_blocks') );
|
40 |
-
add_action( 'megamenu_after_theme_save', array( $this, 'save_toggle_blocks' ) );
|
41 |
-
|
42 |
-
add_action( 'megamenu_admin_scripts', array( $this, 'enqueue_scripts' ) );
|
43 |
-
add_action( 'megamenu_print_theme_option_toggle_blocks', array( $this, 'print_theme_toggle_bar_designer_option'), 10, 2);
|
44 |
-
|
45 |
-
add_filter( 'megamenu_theme_editor_settings', array( $this, 'add_toggle_designer_to_theme_editor'), 10 );
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Output the menu toggle block (front end)
|
52 |
-
*
|
53 |
-
* @since 2.4.1
|
54 |
-
* @param string $html
|
55 |
-
* @param array $settings
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
public function output_menu_public_toggle_block_html( $html, $settings ) {
|
59 |
-
|
60 |
-
$css_version = get_transient("megamenu_css_version");
|
61 |
-
|
62 |
-
// only use HTML version of toggle block if CSS version is above 2.4.0.2
|
63 |
-
// if transient is missing, assume the latest version of the CSS is present and use Flex layout
|
64 |
-
if ( ! $css_version || version_compare($css_version, '2.4.0.2') >= 0 ) {
|
65 |
-
$closed_text = isset( $settings['closed_text'] ) ? do_shortcode( stripslashes( $settings['closed_text'] ) ) : "MENU";
|
66 |
-
$open_text = isset( $settings['open_text'] ) ? do_shortcode( stripslashes( $settings['open_text'] ) ) : "MENU";
|
67 |
-
|
68 |
-
$html = "<span class='mega-toggle-label' role='button' aria-expanded='false'><span class='mega-toggle-label-closed'>{$closed_text}</span><span class='mega-toggle-label-open'>{$open_text}</span></span>";
|
69 |
-
} else {
|
70 |
-
$html = "";
|
71 |
-
}
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Return the saved toggle blocks for a specified theme
|
79 |
-
*
|
80 |
-
* @param string $theme_id
|
81 |
-
* @since 2.1
|
82 |
-
* @return array
|
83 |
-
*/
|
84 |
-
private function get_toggle_blocks_for_theme( $theme_id ) {
|
85 |
-
|
86 |
-
$blocks = max_mega_menu_get_toggle_blocks();
|
87 |
-
|
88 |
-
if ( isset( $blocks[ $theme_id ] ) ) {
|
89 |
-
return $blocks[ $theme_id ];
|
90 |
-
}
|
91 |
-
|
92 |
-
$defaults[] = array(
|
93 |
-
'type' => 'menu_toggle_animated',
|
94 |
-
'align' => 'right',
|
95 |
-
'icon_scale' => isset($settings['icon_scale']) && strlen($settings['icon_scale']) ? $settings['icon_scale'] : "0.8",
|
96 |
-
'icon_color' => isset($settings['icon_color']) ? $settings['icon_color'] : 'rgb(221, 221, 221)'
|
97 |
-
);
|
98 |
-
|
99 |
-
return $defaults;
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Return default menu toggle block settings
|
106 |
-
*
|
107 |
-
* @since 2.1
|
108 |
-
* @return array
|
109 |
-
*/
|
110 |
-
private function get_default_menu_toggle_block( $theme_id = 'default' ) {
|
111 |
-
|
112 |
-
$style_manager = new Mega_Menu_Style_Manager();
|
113 |
-
|
114 |
-
$themes = $style_manager->get_themes();
|
115 |
-
|
116 |
-
$menu_theme = isset( $themes[ $theme_id ] ) ? $themes[ $theme_id ] : $themes['default'];
|
117 |
-
|
118 |
-
$defaults = array(
|
119 |
-
'type' => 'menu_toggle',
|
120 |
-
'align' => 'right',
|
121 |
-
'closed_text' => isset($menu_theme['responsive_text']) ? $menu_theme['responsive_text'] : "MENU",
|
122 |
-
'open_text' => isset($menu_theme['responsive_text']) ? $menu_theme['responsive_text'] : "MENU",
|
123 |
-
'closed_icon' => 'dash-f333',
|
124 |
-
'open_icon' => 'dash-f153',
|
125 |
-
'icon_position' => 'after',
|
126 |
-
'text_color' => isset($menu_theme['toggle_font_color']) ? $menu_theme['toggle_font_color'] : 'rgb(221, 221, 221)',
|
127 |
-
'icon_color' => isset($menu_theme['toggle_font_color']) ? $menu_theme['toggle_font_color'] : 'rgb(221, 221, 221)',
|
128 |
-
'text_size' => '14px',
|
129 |
-
'icon_size' => '24px'
|
130 |
-
);
|
131 |
-
|
132 |
-
return $defaults;
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Get the HTML output for the toggle blocks
|
138 |
-
*
|
139 |
-
* @since 2.1
|
140 |
-
* @param string $content
|
141 |
-
* @param string $nav_menu
|
142 |
-
* @param array $args
|
143 |
-
* @param string $theme_id
|
144 |
-
* @return string
|
145 |
-
*/
|
146 |
-
public function output_public_toggle_blocks( $content, $nav_menu, $args, $theme_id ) {
|
147 |
-
|
148 |
-
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
149 |
-
|
150 |
-
$blocks_html = "";
|
151 |
-
|
152 |
-
if ( is_array( $toggle_blocks ) ) {
|
153 |
-
|
154 |
-
$css_version = get_transient("megamenu_css_version");
|
155 |
-
|
156 |
-
// only use Flex layout version of toggle blocks if CSS version is above 2.4.0.2
|
157 |
-
// if transient is missing, assume the latest version of the CSS is present and use Flex layout
|
158 |
-
if ( ! $css_version || version_compare($css_version, '2.4.0.2') >= 0 ) {
|
159 |
-
$blocks_html = $this->get_flex_blocks_html($toggle_blocks, $content, $nav_menu, $args, $theme_id);
|
160 |
-
} else {
|
161 |
-
$blocks_html = $this->get_backwards_compatibility_blocks_html($toggle_blocks, $content, $nav_menu, $args, $theme_id);
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
$content .= $blocks_html;
|
166 |
-
|
167 |
-
return $content;
|
168 |
|
169 |
-
|
|
|
|
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
* @param array $toggle_blocks
|
175 |
-
* @since 2.4.1
|
176 |
-
* @return string html
|
177 |
-
*/
|
178 |
-
private function get_flex_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id ) {
|
179 |
-
|
180 |
-
$sorted_blocks = array();
|
181 |
-
|
182 |
-
/** Sort blocks into left, center, right array **/
|
183 |
-
foreach ( $toggle_blocks as $block_id => $block ) {
|
184 |
-
if ( isset( $block['align'] ) ) {
|
185 |
-
$sorted_blocks[$block['align']][$block_id] = $block;
|
186 |
-
} else {
|
187 |
-
$sorted_blocks['left'][$block_id] = $block;
|
188 |
-
}
|
189 |
-
}
|
190 |
-
|
191 |
-
$blocks_html = '<div class="mega-toggle-blocks-left">';
|
192 |
-
|
193 |
-
if ( isset( $sorted_blocks['left'] ) ) {
|
194 |
-
foreach ( $sorted_blocks['left'] as $block_id => $block ) {
|
195 |
-
$blocks_html .= $this->get_toggle_block_html($block_id, $block, $content, $nav_menu, $args, $theme_id);
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
$blocks_html .= "</div>";
|
200 |
-
|
201 |
-
$blocks_html .= '<div class="mega-toggle-blocks-center">';
|
202 |
-
|
203 |
-
if ( isset( $sorted_blocks['center'] ) ) {
|
204 |
-
foreach ( $sorted_blocks['center'] as $block_id => $block ) {
|
205 |
-
$blocks_html .= $this->get_toggle_block_html($block_id, $block, $content, $nav_menu, $args, $theme_id);
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
$blocks_html .= "</div>";
|
210 |
-
|
211 |
-
$blocks_html .= '<div class="mega-toggle-blocks-right">';
|
212 |
-
|
213 |
-
if ( isset( $sorted_blocks['right'] ) ) {
|
214 |
-
foreach ( $sorted_blocks['right'] as $block_id => $block ) {
|
215 |
-
$blocks_html .= $this->get_toggle_block_html($block_id, $block, $content, $nav_menu, $args, $theme_id);
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
$blocks_html .= "</div>";
|
220 |
-
|
221 |
-
return $blocks_html;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Generate the HTML for a single toggle block
|
226 |
-
*
|
227 |
-
* @since 2.4.1
|
228 |
-
* @param string block_id
|
229 |
-
* @param array $block
|
230 |
-
* @return string
|
231 |
-
*/
|
232 |
-
private function get_toggle_block_html($block_id, $block, $content, $nav_menu, $args, $theme_id) {
|
233 |
-
$block_html = "";
|
234 |
-
|
235 |
-
if ( isset( $block['type'] ) ) {
|
236 |
-
$class = "mega-" . str_replace("_", "-", $block['type']) . "-block";
|
237 |
-
} else {
|
238 |
-
$class = "";
|
239 |
-
}
|
240 |
-
|
241 |
-
$id = apply_filters('megamenu_toggle_block_id', 'mega-toggle-block-' . $block_id);
|
242 |
-
|
243 |
-
$atts = array(
|
244 |
-
"class" => "mega-toggle-block {$class} mega-toggle-block-{$block_id}",
|
245 |
-
"id" => "mega-toggle-block-{$block_id}",
|
246 |
-
);
|
247 |
|
248 |
-
|
249 |
-
|
250 |
-
}
|
251 |
|
252 |
-
|
|
|
253 |
|
254 |
-
|
|
|
|
|
255 |
|
256 |
-
foreach ( $attributes as $attribute => $val ) {
|
257 |
-
$block_html .= " " . $attribute . "='" . esc_attr( $val ) . "'";
|
258 |
-
}
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
-
|
265 |
-
}
|
266 |
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
* @since 2.4.1
|
273 |
-
* @return string html
|
274 |
-
*/
|
275 |
-
private function get_backwards_compatibility_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id ) {
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
foreach ( $toggle_blocks as $block_id => $block ) {
|
280 |
|
281 |
-
|
282 |
-
$class = "mega-" . str_replace("_", "-", $block['type']) . "-block";
|
283 |
-
} else {
|
284 |
-
$class = "";
|
285 |
-
}
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
292 |
|
293 |
-
|
294 |
-
$id = apply_filters('megamenu_toggle_block_id', 'mega-toggle-block-' . $block_id);
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
), $block, $content, $nav_menu, $args, $theme_id);
|
300 |
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
* return $attributes;
|
308 |
-
* }
|
309 |
-
* add_filter('megamenu_toggle_block_attributes', 'remove_ids_from_toggle_blocks', 10, 6);
|
310 |
-
*
|
311 |
-
*/
|
312 |
|
313 |
-
|
314 |
|
315 |
-
|
316 |
-
$blocks_html .= " " . $attribute . "='" . esc_attr( $val ) . "'";
|
317 |
-
}
|
318 |
|
319 |
-
$blocks_html .= ">";
|
320 |
-
$blocks_html .= apply_filters("megamenu_output_public_toggle_block_{$block['type']}", "", $block);
|
321 |
-
$blocks_html .= "</div>";
|
322 |
-
}
|
323 |
-
|
324 |
-
return $blocks_html;
|
325 |
-
}
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
-
|
329 |
-
* Save the toggle blocks when the theme is saved
|
330 |
-
*
|
331 |
-
* @since 2.1
|
332 |
-
*/
|
333 |
-
public function save_toggle_blocks() {
|
334 |
|
335 |
-
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
-
|
|
|
344 |
|
345 |
-
$saved_blocks[ $theme ] = $submitted_settings;
|
346 |
|
347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
349 |
-
|
350 |
|
|
|
351 |
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
|
|
|
|
|
|
|
|
358 |
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Add the toggle bar designer to the theme editor
|
373 |
-
*
|
374 |
-
* @since 2.1
|
375 |
-
* @return array
|
376 |
-
*/
|
377 |
-
public function add_toggle_designer_to_theme_editor( $settings ) {
|
378 |
-
|
379 |
-
$settings['mobile_menu']['settings']['toggle_blocks'] = array(
|
380 |
-
'priority' => 6,
|
381 |
-
'title' => __( "Toggle Bar Designer", "megamenu" ),
|
382 |
-
'description' => __( "Configure the contents of the mobile toggle bar", "megamenu" ),
|
383 |
-
'settings' => array(
|
384 |
-
array(
|
385 |
-
'title' => "",
|
386 |
-
'type' => 'toggle_blocks',
|
387 |
-
'key' => 'toggle_blocks'
|
388 |
-
)
|
389 |
-
),
|
390 |
-
);
|
391 |
-
|
392 |
-
return $settings;
|
393 |
-
}
|
394 |
-
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Enqueue nav-menus.php scripts
|
398 |
-
*
|
399 |
-
* @since 2.1
|
400 |
-
*/
|
401 |
-
public function enqueue_scripts() {
|
402 |
-
|
403 |
-
wp_enqueue_script( 'mega-menu-toggle-bar-designer', MEGAMENU_BASE_URL . 'js/toggledesigner.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), MEGAMENU_VERSION );
|
404 |
|
405 |
-
wp_localize_script( 'mega-menu-toggle-bar-designer', 'megamenu',
|
406 |
-
array(
|
407 |
-
'nonce' => wp_create_nonce('megamenu_edit')
|
408 |
-
)
|
409 |
-
);
|
410 |
|
411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
|
|
|
413 |
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
* @param string
|
420 |
-
*/
|
421 |
-
public function append_scss( $scss ) {
|
422 |
|
423 |
-
|
|
|
|
|
|
|
|
|
424 |
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
|
429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
|
445 |
-
|
446 |
|
447 |
-
|
|
|
|
|
448 |
|
449 |
-
|
|
|
|
|
450 |
|
451 |
-
|
452 |
-
|
453 |
-
if ( isset( $settings['type'] ) && $settings['type'] == 'menu_toggle' ) {
|
454 |
-
|
455 |
-
if ( isset( $settings['closed_icon'] ) ) {
|
456 |
-
$closed_icon_parts = explode( '-', $settings['closed_icon'] );
|
457 |
-
$closed_icon = end( $closed_icon_parts );
|
458 |
-
} else {
|
459 |
-
$closed_icon = 'disabled';
|
460 |
-
}
|
461 |
-
|
462 |
-
if ( isset( $settings['open_icon'] ) ) {
|
463 |
-
$open_icon_parts = explode( '-', $settings['open_icon'] );
|
464 |
-
$open_icon = end( $open_icon_parts );
|
465 |
-
} else {
|
466 |
-
$open_icon = 'disabled';
|
467 |
-
}
|
468 |
-
|
469 |
-
$styles = array(
|
470 |
-
'id' => $index,
|
471 |
-
'align' => isset($settings['align']) ? "'" . $settings['align'] . "'" : "'right'",
|
472 |
-
'closed_text' => "''", // deprecated
|
473 |
-
'open_text' => "''", // deprecated
|
474 |
-
'closed_icon' => $closed_icon != 'disabled' ? "'\\" . $closed_icon . "'" : "''",
|
475 |
-
'open_icon' => $open_icon != 'disabled' ? "'\\" . $open_icon . "'" : "''",
|
476 |
-
'text_color' => isset($settings['text_color']) ? $settings['text_color'] : '#fff',
|
477 |
-
'icon_color' => isset($settings['icon_color']) ? $settings['icon_color'] : '#fff',
|
478 |
-
'icon_position' => isset($settings['icon_position']) ? "'" . $settings['icon_position'] . "'" : 'after',
|
479 |
-
'text_size' => isset($settings['text_size']) && strlen($settings['text_size']) ? $settings['text_size'] : '14px',
|
480 |
-
'icon_size' => isset($settings['icon_size']) && strlen($settings['icon_size']) ? $settings['icon_size'] : '24px'
|
481 |
-
);
|
482 |
|
483 |
-
|
484 |
-
}
|
485 |
|
486 |
-
|
487 |
-
}
|
488 |
|
489 |
-
|
490 |
-
// (123, red, 150px),
|
491 |
-
// (456, green, null),
|
492 |
-
// (789, blue, 90%),());
|
493 |
-
if ( count( $menu_toggle_blocks ) ) {
|
494 |
|
495 |
-
|
|
|
496 |
|
497 |
-
|
498 |
-
|
499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
501 |
-
|
502 |
-
// Lists with a single item are not treated the same way by SASS
|
503 |
-
$list .= "());";
|
504 |
|
505 |
-
|
506 |
|
507 |
-
|
508 |
|
509 |
-
|
510 |
|
511 |
-
|
512 |
|
513 |
-
|
514 |
-
|
|
|
|
|
|
|
515 |
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
* @param string $location
|
521 |
-
* @param string $theme
|
522 |
-
* @param int $menu_id
|
523 |
-
* @param string $theme_id
|
524 |
-
* @return array - all custom SCSS vars
|
525 |
-
* @since 2.1
|
526 |
-
*/
|
527 |
-
public function add_spacer_block_vars_to_scss( $vars, $location, $theme, $menu_id, $theme_id ) {
|
528 |
|
529 |
-
|
|
|
|
|
|
|
|
|
530 |
|
531 |
-
|
532 |
|
533 |
-
|
|
|
|
|
534 |
|
535 |
-
|
|
|
|
|
536 |
|
537 |
-
|
538 |
|
539 |
-
|
540 |
-
'id' => $index,
|
541 |
-
'align' => isset($settings['align']) ? "'" . $settings['align'] . "'" : "'right'",
|
542 |
-
'width' => isset($settings['width']) ? $settings['width'] : '0px',
|
543 |
-
);
|
544 |
|
545 |
-
|
546 |
-
}
|
547 |
|
548 |
-
|
549 |
-
}
|
550 |
|
551 |
-
|
552 |
-
// (123, red, 150px),
|
553 |
-
// (456, green, null),
|
554 |
-
// (789, blue, 90%),());
|
555 |
-
if ( count( $spacer_blocks ) ) {
|
556 |
|
557 |
-
|
558 |
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
-
|
564 |
-
// Lists with a single item are not treated the same way by SASS
|
565 |
-
$list .= "());";
|
566 |
|
567 |
-
|
568 |
|
569 |
-
|
570 |
|
571 |
-
|
572 |
|
573 |
-
|
574 |
|
575 |
-
|
|
|
|
|
|
|
|
|
576 |
|
577 |
-
|
|
|
|
|
|
|
578 |
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
|
|
|
|
|
|
591 |
|
592 |
-
|
593 |
|
594 |
-
|
595 |
|
596 |
-
|
597 |
|
598 |
-
|
599 |
|
600 |
-
|
601 |
|
602 |
-
|
603 |
-
'id' => $index,
|
604 |
-
'icon_scale' => isset($settings['icon_scale']) && strlen($settings['icon_scale']) ? $settings['icon_scale'] : "0.8",
|
605 |
-
'icon_color' => isset($settings['icon_color']) ? $settings['icon_color'] : 'rgb(221, 221, 221)',
|
606 |
-
);
|
607 |
|
608 |
-
$menu_toggle_animated_blocks[ $index ] = $styles;
|
609 |
-
}
|
610 |
|
611 |
-
|
612 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
613 |
|
614 |
-
|
615 |
-
// (123, red, 150px),
|
616 |
-
// (456, green, null),
|
617 |
-
// (789, blue, 90%),());
|
618 |
-
if ( count( $menu_toggle_animated_blocks ) ) {
|
619 |
|
620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
|
622 |
-
|
623 |
-
|
624 |
-
}
|
625 |
|
626 |
-
|
627 |
-
|
628 |
-
$list .= "());";
|
629 |
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
<?php _e("Text Size", "megamenu") ?><input type='text' class='text_size' name='toggle_blocks[<?php echo $block_id; ?>][text_size]' value='<?php echo stripslashes( esc_attr( $settings['text_size'] ) ) ?>' />
|
830 |
-
</label>
|
831 |
-
<label>
|
832 |
-
<?php _e("Icon Color", "megamenu") ?>
|
833 |
-
<?php $this->print_toggle_color_option( 'icon_color', $block_id, $settings['icon_color'] ); ?>
|
834 |
-
</label>
|
835 |
-
<label>
|
836 |
-
<?php _e("Icon Size", "megamenu") ?><input type='text' class='icon_size' name='toggle_blocks[<?php echo $block_id; ?>][icon_size]' value='<?php echo stripslashes( esc_attr( $settings['icon_size'] ) ) ?>' />
|
837 |
-
</label>
|
838 |
-
<label>
|
839 |
-
<?php _e("Icon Position", "megamenu") ?><select name='toggle_blocks[<?php echo $block_id; ?>][icon_position]'>
|
840 |
-
<option value='before' <?php selected( $settings['icon_position'], "before" ) ?> ><?php _e("Before", "megamenu") ?></option>
|
841 |
-
<option value='after' <?php selected( $settings['icon_position'], "after" ) ?> ><?php _e("After", "megamenu") ?></option>
|
842 |
-
</select>
|
843 |
-
</label>
|
844 |
-
<a class='mega-delete'><?php _e("Delete", "megamenu"); ?></a>
|
845 |
-
</div>
|
846 |
-
</div>
|
847 |
-
|
848 |
-
<?php
|
849 |
-
}
|
850 |
-
|
851 |
-
|
852 |
-
/**
|
853 |
-
* Output the menu toggle block (front end)
|
854 |
-
*
|
855 |
-
* @since 2.5.3
|
856 |
-
* @param string $html
|
857 |
-
* @param array $settings
|
858 |
-
* @return string
|
859 |
-
*/
|
860 |
-
public function output_menu_public_toggle_block_animated_html( $html, $settings ) {
|
861 |
-
$style = isset( $settings['style'] ) ? $settings['style'] : "slider";
|
862 |
-
$label = isset( $settings['aria_label'] ) ? do_shortcode( stripslashes( $settings['aria_label'] ) ) : "Toggle Menu";
|
863 |
-
|
864 |
-
$html = '<button aria-label="'. esc_attr($label) .'" class="mega-toggle-animated mega-toggle-animated-' . esc_attr($style) . '" type="button" aria-expanded="false">
|
865 |
<span class="mega-toggle-animated-box">
|
866 |
<span class="mega-toggle-animated-inner"></span>
|
867 |
</span>
|
868 |
</button>';
|
869 |
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
}
|
1020 |
-
|
1021 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Toggle_Blocks' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Mobile Toggle Blocks
|
11 |
+
*/
|
12 |
+
class Mega_Menu_Toggle_Blocks {
|
13 |
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
+
*
|
17 |
+
* @since 2.1
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
|
21 |
+
add_filter( 'megamenu_scss_variables', array( $this, 'add_menu_toggle_block_vars_to_scss' ), 10, 5 );
|
22 |
+
add_filter( 'megamenu_scss_variables', array( $this, 'add_spacer_block_vars_to_scss' ), 10, 5 );
|
23 |
+
add_filter( 'megamenu_scss_variables', array( $this, 'add_menu_toggle_animated_block_vars_to_scss' ), 10, 5 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
add_filter( 'megamenu_load_scss_file_contents', array( $this, 'append_scss' ), 10 );
|
26 |
+
add_filter( 'megamenu_toggle_bar_content', array( $this, 'output_public_toggle_blocks' ), 10, 4 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
add_action( 'wp_ajax_mm_get_toggle_block_menu_toggle', array( $this, 'output_menu_toggle_block_html' ) );
|
29 |
+
add_action( 'megamenu_output_admin_toggle_block_menu_toggle', array( $this, 'output_menu_toggle_block_html' ), 10, 2 );
|
30 |
+
add_action( 'megamenu_output_public_toggle_block_menu_toggle', array( $this, 'output_menu_public_toggle_block_html' ), 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
add_action( 'wp_ajax_mm_get_toggle_block_menu_toggle_animated', array( $this, 'output_menu_toggle_block_animated_html' ) );
|
33 |
+
add_action( 'megamenu_output_admin_toggle_block_menu_toggle_animated', array( $this, 'output_menu_toggle_block_animated_html' ), 10, 2 );
|
34 |
+
add_action( 'megamenu_output_public_toggle_block_menu_toggle_animated', array( $this, 'output_menu_public_toggle_block_animated_html' ), 10, 2 );
|
35 |
|
36 |
+
add_action( 'wp_ajax_mm_get_toggle_block_spacer', array( $this, 'output_spacer_block_html' ) );
|
37 |
+
add_action( 'megamenu_output_admin_toggle_block_spacer', array( $this, 'output_spacer_block_html' ), 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
add_action( 'megamenu_after_theme_revert', array( $this, 'revert_toggle_blocks' ) );
|
40 |
+
add_action( 'megamenu_after_theme_save', array( $this, 'save_toggle_blocks' ) );
|
|
|
41 |
|
42 |
+
add_action( 'megamenu_admin_scripts', array( $this, 'enqueue_scripts' ) );
|
43 |
+
add_action( 'megamenu_print_theme_option_toggle_blocks', array( $this, 'print_theme_toggle_bar_designer_option' ), 10, 2 );
|
44 |
|
45 |
+
add_filter( 'megamenu_theme_editor_settings', array( $this, 'add_toggle_designer_to_theme_editor' ), 10 );
|
46 |
+
|
47 |
+
}
|
48 |
|
|
|
|
|
|
|
49 |
|
50 |
+
/**
|
51 |
+
* Output the menu toggle block (front end)
|
52 |
+
*
|
53 |
+
* @since 2.4.1
|
54 |
+
* @param string $html
|
55 |
+
* @param array $settings
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function output_menu_public_toggle_block_html( $html, $settings ) {
|
59 |
|
60 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
|
|
61 |
|
62 |
+
// only use HTML version of toggle block if CSS version is above 2.4.0.2
|
63 |
+
// if transient is missing, assume the latest version of the CSS is present and use Flex layout
|
64 |
+
if ( ! $css_version || version_compare( $css_version, '2.4.0.2' ) >= 0 ) {
|
65 |
+
$closed_text = isset( $settings['closed_text'] ) ? do_shortcode( stripslashes( $settings['closed_text'] ) ) : 'MENU';
|
66 |
+
$open_text = isset( $settings['open_text'] ) ? do_shortcode( stripslashes( $settings['open_text'] ) ) : 'MENU';
|
67 |
|
68 |
+
$html = "<span class='mega-toggle-label' role='button' aria-expanded='false'><span class='mega-toggle-label-closed'>{$closed_text}</span><span class='mega-toggle-label-open'>{$open_text}</span></span>";
|
69 |
+
} else {
|
70 |
+
$html = '';
|
71 |
+
}
|
|
|
|
|
|
|
|
|
72 |
|
73 |
+
return apply_filters( 'megamenu_toggle_menu_toggle_html', $html );
|
|
|
|
|
74 |
|
75 |
+
}
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
/**
|
78 |
+
* Return the saved toggle blocks for a specified theme
|
79 |
+
*
|
80 |
+
* @param string $theme_id
|
81 |
+
* @since 2.1
|
82 |
+
* @return array
|
83 |
+
*/
|
84 |
+
private function get_toggle_blocks_for_theme( $theme_id ) {
|
85 |
|
86 |
+
$blocks = max_mega_menu_get_toggle_blocks();
|
|
|
87 |
|
88 |
+
if ( isset( $blocks[ $theme_id ] ) ) {
|
89 |
+
return $blocks[ $theme_id ];
|
90 |
+
}
|
|
|
91 |
|
92 |
+
$defaults[] = array(
|
93 |
+
'type' => 'menu_toggle_animated',
|
94 |
+
'align' => 'right',
|
95 |
+
'icon_scale' => isset( $settings['icon_scale'] ) && strlen( $settings['icon_scale'] ) ? $settings['icon_scale'] : '0.8',
|
96 |
+
'icon_color' => isset( $settings['icon_color'] ) ? $settings['icon_color'] : 'rgb(221, 221, 221)',
|
97 |
+
);
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
+
return $defaults;
|
100 |
|
101 |
+
}
|
|
|
|
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
/**
|
105 |
+
* Return default menu toggle block settings
|
106 |
+
*
|
107 |
+
* @since 2.1
|
108 |
+
* @return array
|
109 |
+
*/
|
110 |
+
private function get_default_menu_toggle_block( $theme_id = 'default' ) {
|
111 |
|
112 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
$themes = $style_manager->get_themes();
|
115 |
|
116 |
+
$menu_theme = isset( $themes[ $theme_id ] ) ? $themes[ $theme_id ] : $themes['default'];
|
117 |
|
118 |
+
$defaults = array(
|
119 |
+
'type' => 'menu_toggle',
|
120 |
+
'align' => 'right',
|
121 |
+
'closed_text' => isset( $menu_theme['responsive_text'] ) ? $menu_theme['responsive_text'] : 'MENU',
|
122 |
+
'open_text' => isset( $menu_theme['responsive_text'] ) ? $menu_theme['responsive_text'] : 'MENU',
|
123 |
+
'closed_icon' => 'dash-f333',
|
124 |
+
'open_icon' => 'dash-f153',
|
125 |
+
'icon_position' => 'after',
|
126 |
+
'text_color' => isset( $menu_theme['toggle_font_color'] ) ? $menu_theme['toggle_font_color'] : 'rgb(221, 221, 221)',
|
127 |
+
'icon_color' => isset( $menu_theme['toggle_font_color'] ) ? $menu_theme['toggle_font_color'] : 'rgb(221, 221, 221)',
|
128 |
+
'text_size' => '14px',
|
129 |
+
'icon_size' => '24px',
|
130 |
+
);
|
131 |
|
132 |
+
return $defaults;
|
133 |
+
}
|
134 |
|
|
|
135 |
|
136 |
+
/**
|
137 |
+
* Get the HTML output for the toggle blocks
|
138 |
+
*
|
139 |
+
* @since 2.1
|
140 |
+
* @param string $content
|
141 |
+
* @param string $nav_menu
|
142 |
+
* @param array $args
|
143 |
+
* @param string $theme_id
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function output_public_toggle_blocks( $content, $nav_menu, $args, $theme_id ) {
|
147 |
+
|
148 |
+
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
149 |
+
|
150 |
+
$blocks_html = '';
|
151 |
+
|
152 |
+
if ( is_array( $toggle_blocks ) ) {
|
153 |
+
|
154 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
155 |
+
|
156 |
+
// only use Flex layout version of toggle blocks if CSS version is above 2.4.0.2
|
157 |
+
// if transient is missing, assume the latest version of the CSS is present and use Flex layout
|
158 |
+
if ( ! $css_version || version_compare( $css_version, '2.4.0.2' ) >= 0 ) {
|
159 |
+
$blocks_html = $this->get_flex_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id );
|
160 |
+
} else {
|
161 |
+
$blocks_html = $this->get_backwards_compatibility_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id );
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
$content .= $blocks_html;
|
166 |
|
167 |
+
return $content;
|
168 |
|
169 |
+
}
|
170 |
|
171 |
+
/**
|
172 |
+
* Sort the toggle blocks into 3 divs (left, center, right) to be aligned using flex CSS.
|
173 |
+
*
|
174 |
+
* @param array $toggle_blocks
|
175 |
+
* @since 2.4.1
|
176 |
+
* @return string html
|
177 |
+
*/
|
178 |
+
private function get_flex_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id ) {
|
179 |
+
|
180 |
+
$sorted_blocks = array();
|
181 |
|
182 |
+
/** Sort blocks into left, center, right array **/
|
183 |
+
foreach ( $toggle_blocks as $block_id => $block ) {
|
184 |
+
if ( isset( $block['align'] ) ) {
|
185 |
+
$sorted_blocks[ $block['align'] ][ $block_id ] = $block;
|
186 |
+
} else {
|
187 |
+
$sorted_blocks['left'][ $block_id ] = $block;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
$blocks_html = '<div class="mega-toggle-blocks-left">';
|
192 |
+
|
193 |
+
if ( isset( $sorted_blocks['left'] ) ) {
|
194 |
+
foreach ( $sorted_blocks['left'] as $block_id => $block ) {
|
195 |
+
$blocks_html .= $this->get_toggle_block_html( $block_id, $block, $content, $nav_menu, $args, $theme_id );
|
196 |
+
}
|
197 |
+
}
|
198 |
|
199 |
+
$blocks_html .= '</div>';
|
200 |
+
|
201 |
+
$blocks_html .= '<div class="mega-toggle-blocks-center">';
|
202 |
+
|
203 |
+
if ( isset( $sorted_blocks['center'] ) ) {
|
204 |
+
foreach ( $sorted_blocks['center'] as $block_id => $block ) {
|
205 |
+
$blocks_html .= $this->get_toggle_block_html( $block_id, $block, $content, $nav_menu, $args, $theme_id );
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
$blocks_html .= '</div>';
|
210 |
+
|
211 |
+
$blocks_html .= '<div class="mega-toggle-blocks-right">';
|
212 |
+
|
213 |
+
if ( isset( $sorted_blocks['right'] ) ) {
|
214 |
+
foreach ( $sorted_blocks['right'] as $block_id => $block ) {
|
215 |
+
$blocks_html .= $this->get_toggle_block_html( $block_id, $block, $content, $nav_menu, $args, $theme_id );
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
$blocks_html .= '</div>';
|
220 |
+
|
221 |
+
return $blocks_html;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Generate the HTML for a single toggle block
|
226 |
+
*
|
227 |
+
* @since 2.4.1
|
228 |
+
* @param string block_id
|
229 |
+
* @param array $block
|
230 |
+
* @return string
|
231 |
+
*/
|
232 |
+
private function get_toggle_block_html( $block_id, $block, $content, $nav_menu, $args, $theme_id ) {
|
233 |
+
$block_html = '';
|
234 |
+
|
235 |
+
if ( isset( $block['type'] ) ) {
|
236 |
+
$class = 'mega-' . str_replace( '_', '-', $block['type'] ) . '-block';
|
237 |
+
} else {
|
238 |
+
$class = '';
|
239 |
+
}
|
240 |
+
|
241 |
+
$id = apply_filters( 'megamenu_toggle_block_id', 'mega-toggle-block-' . $block_id );
|
242 |
+
|
243 |
+
$atts = array(
|
244 |
+
'class' => "mega-toggle-block {$class} mega-toggle-block-{$block_id}",
|
245 |
+
'id' => "mega-toggle-block-{$block_id}",
|
246 |
+
);
|
247 |
+
|
248 |
+
if ( isset( $block['type'] ) && $block['type'] == 'menu_toggle' ) {
|
249 |
+
$atts['tabindex'] = '0';
|
250 |
+
}
|
251 |
+
|
252 |
+
$attributes = apply_filters( 'megamenu_toggle_block_attributes', $atts, $block, $content, $nav_menu, $args, $theme_id );
|
253 |
+
|
254 |
+
$block_html .= '<div';
|
255 |
+
|
256 |
+
foreach ( $attributes as $attribute => $val ) {
|
257 |
+
$block_html .= ' ' . $attribute . "='" . esc_attr( $val ) . "'";
|
258 |
+
}
|
259 |
|
260 |
+
$block_html .= '>';
|
261 |
+
$block_html .= apply_filters( "megamenu_output_public_toggle_block_{$block['type']}", '', $block );
|
262 |
+
$block_html .= '</div>';
|
263 |
|
264 |
+
return $block_html;
|
265 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
+
/**
|
269 |
+
* Return a flat HTML list of menu toggle blocks. Only used when CSS version has not been updated to 2.4.1+
|
270 |
+
*
|
271 |
+
* @param array $toggle_blocks
|
272 |
+
* @since 2.4.1
|
273 |
+
* @return string html
|
274 |
+
*/
|
275 |
+
private function get_backwards_compatibility_blocks_html( $toggle_blocks, $content, $nav_menu, $args, $theme_id ) {
|
276 |
+
|
277 |
+
$blocks_html = '';
|
278 |
|
279 |
+
foreach ( $toggle_blocks as $block_id => $block ) {
|
280 |
|
281 |
+
if ( isset( $block['type'] ) ) {
|
282 |
+
$class = 'mega-' . str_replace( '_', '-', $block['type'] ) . '-block';
|
283 |
+
} else {
|
284 |
+
$class = '';
|
285 |
+
}
|
|
|
|
|
|
|
286 |
|
287 |
+
if ( isset( $block['align'] ) ) {
|
288 |
+
$align = 'mega-toggle-block-' . $block['align'];
|
289 |
+
} else {
|
290 |
+
$align = 'mega-toggle-block-left';
|
291 |
+
}
|
292 |
|
293 |
+
// @todo remove ID once MMM Pro has been updated to use classes
|
294 |
+
$id = apply_filters( 'megamenu_toggle_block_id', 'mega-toggle-block-' . $block_id );
|
295 |
+
|
296 |
+
$attributes = apply_filters(
|
297 |
+
'megamenu_toggle_block_attributes',
|
298 |
+
array(
|
299 |
+
'class' => "mega-toggle-block {$class} {$align} mega-toggle-block-{$block_id}",
|
300 |
+
'id' => "mega-toggle-block-{$block_id}",
|
301 |
+
),
|
302 |
+
$block,
|
303 |
+
$content,
|
304 |
+
$nav_menu,
|
305 |
+
$args,
|
306 |
+
$theme_id
|
307 |
+
);
|
308 |
+
|
309 |
+
/**
|
310 |
+
*
|
311 |
+
* function remove_ids_from_toggle_blocks($attributes, $block, $content, $nav_menu, $args, $theme_id) {
|
312 |
+
* if (isset($attributes['id'])) {
|
313 |
+
* unset($attributes['id']);
|
314 |
+
* }
|
315 |
+
* return $attributes;
|
316 |
+
* }
|
317 |
+
* add_filter('megamenu_toggle_block_attributes', 'remove_ids_from_toggle_blocks', 10, 6);
|
318 |
+
*
|
319 |
+
*/
|
320 |
+
|
321 |
+
$blocks_html .= '<div';
|
322 |
+
|
323 |
+
foreach ( $attributes as $attribute => $val ) {
|
324 |
+
$blocks_html .= ' ' . $attribute . "='" . esc_attr( $val ) . "'";
|
325 |
+
}
|
326 |
+
|
327 |
+
$blocks_html .= '>';
|
328 |
+
$blocks_html .= apply_filters( "megamenu_output_public_toggle_block_{$block['type']}", '', $block );
|
329 |
+
$blocks_html .= '</div>';
|
330 |
+
}
|
331 |
+
|
332 |
+
return $blocks_html;
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Save the toggle blocks when the theme is saved
|
338 |
+
*
|
339 |
+
* @since 2.1
|
340 |
+
*/
|
341 |
+
public function save_toggle_blocks() {
|
342 |
|
343 |
+
$theme = esc_attr( $_POST['theme_id'] );
|
344 |
+
|
345 |
+
$saved_blocks = max_mega_menu_get_toggle_blocks();
|
346 |
+
|
347 |
+
if ( isset( $saved_blocks[ $theme ] ) ) {
|
348 |
+
unset( $saved_blocks[ $theme ] );
|
349 |
+
}
|
350 |
+
|
351 |
+
$submitted_settings = $_POST['toggle_blocks'];
|
352 |
+
|
353 |
+
$saved_blocks[ $theme ] = $submitted_settings;
|
354 |
+
|
355 |
+
max_mega_menu_save_toggle_blocks( $saved_blocks );
|
356 |
+
|
357 |
+
}
|
358 |
+
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Revert the toggle blocks when a theme is reverted
|
362 |
+
*
|
363 |
+
* @since 2.1
|
364 |
+
*/
|
365 |
+
public function revert_toggle_blocks() {
|
366 |
+
|
367 |
+
$theme = esc_attr( $_GET['theme_id'] );
|
368 |
+
|
369 |
+
$saved_toggle_blocks = max_mega_menu_get_toggle_blocks();
|
370 |
+
|
371 |
+
if ( isset( $saved_toggle_blocks[ $theme ] ) ) {
|
372 |
+
unset( $saved_toggle_blocks[ $theme ] );
|
373 |
+
}
|
374 |
+
|
375 |
+
max_mega_menu_save_toggle_blocks( $saved_toggle_blocks );
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Add the toggle bar designer to the theme editor
|
381 |
+
*
|
382 |
+
* @since 2.1
|
383 |
+
* @return array
|
384 |
+
*/
|
385 |
+
public function add_toggle_designer_to_theme_editor( $settings ) {
|
386 |
+
|
387 |
+
$settings['mobile_menu']['settings']['toggle_blocks'] = array(
|
388 |
+
'priority' => 6,
|
389 |
+
'title' => __( 'Toggle Bar Designer', 'megamenu' ),
|
390 |
+
'description' => __( 'Configure the contents of the mobile toggle bar', 'megamenu' ),
|
391 |
+
'settings' => array(
|
392 |
+
array(
|
393 |
+
'title' => '',
|
394 |
+
'type' => 'toggle_blocks',
|
395 |
+
'key' => 'toggle_blocks',
|
396 |
+
),
|
397 |
+
),
|
398 |
+
);
|
399 |
+
|
400 |
+
return $settings;
|
401 |
+
}
|
402 |
+
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Enqueue nav-menus.php scripts
|
406 |
+
*
|
407 |
+
* @since 2.1
|
408 |
+
*/
|
409 |
+
public function enqueue_scripts() {
|
410 |
+
if ( isset( $_GET['page'] ) && 'maxmegamenu_theme_editor' === $_GET['page'] ) { // @codingStandardsIgnoreLine
|
411 |
+
wp_enqueue_script( 'mega-menu-toggle-bar-designer', MEGAMENU_BASE_URL . 'js/toggledesigner.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), MEGAMENU_VERSION );
|
412 |
+
|
413 |
+
wp_localize_script(
|
414 |
+
'mega-menu-toggle-bar-designer',
|
415 |
+
'megamenu',
|
416 |
+
array(
|
417 |
+
'nonce' => wp_create_nonce( 'megamenu_edit' ),
|
418 |
+
)
|
419 |
+
);
|
420 |
+
}
|
421 |
+
}
|
422 |
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Append the logo SCSS to the main SCSS file
|
426 |
+
*
|
427 |
+
* @since 2.1
|
428 |
+
* @param string $scss
|
429 |
+
* @param string
|
430 |
+
*/
|
431 |
+
public function append_scss( $scss ) {
|
432 |
+
|
433 |
+
$path = MEGAMENU_PATH . 'css/toggle-blocks.scss';
|
434 |
+
|
435 |
+
$contents = file_get_contents( $path );
|
436 |
+
|
437 |
+
return $scss . $contents;
|
438 |
+
|
439 |
+
}
|
440 |
|
441 |
|
442 |
+
/**
|
443 |
+
* Create a new variable containing the toggle blocks to be used by the SCSS file
|
444 |
+
*
|
445 |
+
* @param array $vars
|
446 |
+
* @param string $location
|
447 |
+
* @param string $theme
|
448 |
+
* @param int $menu_id
|
449 |
+
* @param string $theme_id
|
450 |
+
* @return array - all custom SCSS vars
|
451 |
+
* @since 2.1
|
452 |
+
*/
|
453 |
+
public function add_menu_toggle_block_vars_to_scss( $vars, $location, $theme, $menu_id, $theme_id ) {
|
454 |
+
|
455 |
+
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
456 |
+
|
457 |
+
$menu_toggle_blocks = array();
|
458 |
+
|
459 |
+
if ( is_array( $toggle_blocks ) ) {
|
460 |
+
|
461 |
+
foreach ( $toggle_blocks as $index => $settings ) {
|
462 |
+
|
463 |
+
if ( isset( $settings['type'] ) && $settings['type'] == 'menu_toggle' ) {
|
464 |
+
|
465 |
+
if ( isset( $settings['closed_icon'] ) ) {
|
466 |
+
$closed_icon_parts = explode( '-', $settings['closed_icon'] );
|
467 |
+
$closed_icon = end( $closed_icon_parts );
|
468 |
+
} else {
|
469 |
+
$closed_icon = 'disabled';
|
470 |
+
}
|
471 |
+
|
472 |
+
if ( isset( $settings['open_icon'] ) ) {
|
473 |
+
$open_icon_parts = explode( '-', $settings['open_icon'] );
|
474 |
+
$open_icon = end( $open_icon_parts );
|
475 |
+
} else {
|
476 |
+
$open_icon = 'disabled';
|
477 |
+
}
|
478 |
+
|
479 |
+
$styles = array(
|
480 |
+
'id' => $index,
|
481 |
+
'align' => isset( $settings['align'] ) ? "'" . $settings['align'] . "'" : "'right'",
|
482 |
+
'closed_text' => "''", // deprecated
|
483 |
+
'open_text' => "''", // deprecated
|
484 |
+
'closed_icon' => $closed_icon != 'disabled' ? "'\\" . $closed_icon . "'" : "''",
|
485 |
+
'open_icon' => $open_icon != 'disabled' ? "'\\" . $open_icon . "'" : "''",
|
486 |
+
'text_color' => isset( $settings['text_color'] ) ? $settings['text_color'] : '#fff',
|
487 |
+
'icon_color' => isset( $settings['icon_color'] ) ? $settings['icon_color'] : '#fff',
|
488 |
+
'icon_position' => isset( $settings['icon_position'] ) ? "'" . $settings['icon_position'] . "'" : 'after',
|
489 |
+
'text_size' => isset( $settings['text_size'] ) && strlen( $settings['text_size'] ) ? $settings['text_size'] : '14px',
|
490 |
+
'icon_size' => isset( $settings['icon_size'] ) && strlen( $settings['icon_size'] ) ? $settings['icon_size'] : '24px',
|
491 |
+
);
|
492 |
+
|
493 |
+
$menu_toggle_blocks[ $index ] = $styles;
|
494 |
+
}
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
//$menu_toggle_blocks(
|
499 |
+
// (123, red, 150px),
|
500 |
+
// (456, green, null),
|
501 |
+
// (789, blue, 90%),());
|
502 |
+
if ( count( $menu_toggle_blocks ) ) {
|
503 |
|
504 |
+
$list = '(';
|
505 |
|
506 |
+
foreach ( $menu_toggle_blocks as $id => $vals ) {
|
507 |
+
$list .= '(' . implode( ',', $vals ) . '),';
|
508 |
+
}
|
509 |
|
510 |
+
// Always add an empty list item to meke sure there are always at least 2 items in the list
|
511 |
+
// Lists with a single item are not treated the same way by SASS
|
512 |
+
$list .= '());';
|
513 |
|
514 |
+
$vars['menu_toggle_blocks'] = $list;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
|
516 |
+
} else {
|
|
|
517 |
|
518 |
+
$vars['menu_toggle_blocks'] = '()';
|
|
|
519 |
|
520 |
+
}
|
|
|
|
|
|
|
|
|
521 |
|
522 |
+
return $vars;
|
523 |
+
}
|
524 |
|
525 |
+
/**
|
526 |
+
* Create a new variable containing the spacer blocks to be used by the SCSS file
|
527 |
+
*
|
528 |
+
* @param array $vars
|
529 |
+
* @param string $location
|
530 |
+
* @param string $theme
|
531 |
+
* @param int $menu_id
|
532 |
+
* @param string $theme_id
|
533 |
+
* @return array - all custom SCSS vars
|
534 |
+
* @since 2.1
|
535 |
+
*/
|
536 |
+
public function add_spacer_block_vars_to_scss( $vars, $location, $theme, $menu_id, $theme_id ) {
|
537 |
|
538 |
+
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
|
|
|
|
539 |
|
540 |
+
$spacer_blocks = array();
|
541 |
|
542 |
+
if ( is_array( $toggle_blocks ) ) {
|
543 |
|
544 |
+
foreach ( $toggle_blocks as $index => $settings ) {
|
545 |
|
546 |
+
if ( isset( $settings['type'] ) && $settings['type'] == 'spacer' ) {
|
547 |
|
548 |
+
$styles = array(
|
549 |
+
'id' => $index,
|
550 |
+
'align' => isset( $settings['align'] ) ? "'" . $settings['align'] . "'" : "'right'",
|
551 |
+
'width' => isset( $settings['width'] ) ? $settings['width'] : '0px',
|
552 |
+
);
|
553 |
|
554 |
+
$spacer_blocks[ $index ] = $styles;
|
555 |
+
}
|
556 |
+
}
|
557 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
|
559 |
+
//$menu_toggle_blocks(
|
560 |
+
// (123, red, 150px),
|
561 |
+
// (456, green, null),
|
562 |
+
// (789, blue, 90%),());
|
563 |
+
if ( count( $spacer_blocks ) ) {
|
564 |
|
565 |
+
$list = '(';
|
566 |
|
567 |
+
foreach ( $spacer_blocks as $id => $vals ) {
|
568 |
+
$list .= '(' . implode( ',', $vals ) . '),';
|
569 |
+
}
|
570 |
|
571 |
+
// Always add an empty list item to meke sure there are always at least 2 items in the list
|
572 |
+
// Lists with a single item are not treated the same way by SASS
|
573 |
+
$list .= '());';
|
574 |
|
575 |
+
$vars['spacer_toggle_blocks'] = $list;
|
576 |
|
577 |
+
} else {
|
|
|
|
|
|
|
|
|
578 |
|
579 |
+
$vars['spacer_toggle_blocks'] = '()';
|
|
|
580 |
|
581 |
+
}
|
|
|
582 |
|
583 |
+
return $vars;
|
|
|
|
|
|
|
|
|
584 |
|
585 |
+
}
|
586 |
|
587 |
+
/**
|
588 |
+
* Create a new variable containing the animated menu toggle blocks to be used by the SCSS file
|
589 |
+
*
|
590 |
+
* @param array $vars
|
591 |
+
* @param string $location
|
592 |
+
* @param string $theme
|
593 |
+
* @param int $menu_id
|
594 |
+
* @param string $theme_id
|
595 |
+
* @return array - all custom SCSS vars
|
596 |
+
* @since 2.5.3
|
597 |
+
*/
|
598 |
+
public function add_menu_toggle_animated_block_vars_to_scss( $vars, $location, $theme, $menu_id, $theme_id ) {
|
599 |
|
600 |
+
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
|
|
|
|
601 |
|
602 |
+
$menu_toggle_animated_blocks = array();
|
603 |
|
604 |
+
if ( is_array( $toggle_blocks ) ) {
|
605 |
|
606 |
+
foreach ( $toggle_blocks as $index => $settings ) {
|
607 |
|
608 |
+
if ( isset( $settings['type'] ) && $settings['type'] == 'menu_toggle_animated' ) {
|
609 |
|
610 |
+
$styles = array(
|
611 |
+
'id' => $index,
|
612 |
+
'icon_scale' => isset( $settings['icon_scale'] ) && strlen( $settings['icon_scale'] ) ? $settings['icon_scale'] : '0.8',
|
613 |
+
'icon_color' => isset( $settings['icon_color'] ) ? $settings['icon_color'] : 'rgb(221, 221, 221)',
|
614 |
+
);
|
615 |
|
616 |
+
$menu_toggle_animated_blocks[ $index ] = $styles;
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
|
621 |
+
//$menu_toggle_blocks(
|
622 |
+
// (123, red, 150px),
|
623 |
+
// (456, green, null),
|
624 |
+
// (789, blue, 90%),());
|
625 |
+
if ( count( $menu_toggle_animated_blocks ) ) {
|
626 |
+
|
627 |
+
$list = '(';
|
628 |
+
|
629 |
+
foreach ( $menu_toggle_animated_blocks as $id => $vals ) {
|
630 |
+
$list .= '(' . implode( ',', $vals ) . '),';
|
631 |
+
}
|
632 |
+
|
633 |
+
// Always add an empty list item to meke sure there are always at least 2 items in the list
|
634 |
+
// Lists with a single item are not treated the same way by SASS
|
635 |
+
$list .= '());';
|
636 |
|
637 |
+
$vars['menu_toggle_animated_blocks'] = $list;
|
638 |
|
639 |
+
} else {
|
640 |
|
641 |
+
$vars['menu_toggle_animated_blocks'] = '()';
|
642 |
|
643 |
+
}
|
644 |
|
645 |
+
return $vars;
|
646 |
|
647 |
+
}
|
|
|
|
|
|
|
|
|
648 |
|
|
|
|
|
649 |
|
650 |
+
/**
|
651 |
+
* Print the toggle bar designer option
|
652 |
+
*
|
653 |
+
* @since 2.1
|
654 |
+
* @param string $key
|
655 |
+
* @param string $theme_id
|
656 |
+
*/
|
657 |
+
public function print_theme_toggle_bar_designer_option( $key, $theme_id ) {
|
658 |
|
659 |
+
$toggle_blocks = $this->get_toggle_blocks_for_theme( $theme_id );
|
|
|
|
|
|
|
|
|
660 |
|
661 |
+
$block_types = apply_filters(
|
662 |
+
'megamenu_registered_toggle_blocks',
|
663 |
+
array(
|
664 |
+
'menu_toggle_animated' => __( 'Menu Toggle (Animated)', 'megamenu' ),
|
665 |
+
'menu_toggle' => __( 'Menu Toggle (Standard)', 'megamenu' ),
|
666 |
+
'spacer' => __( 'Spacer', 'megamenu' ),
|
667 |
+
)
|
668 |
+
);
|
669 |
|
670 |
+
ksort( $block_types );
|
671 |
+
?>
|
|
|
672 |
|
673 |
+
<select id='toggle-block-selector'>
|
674 |
+
<option value='title'><?php echo __( 'Add block to toggle bar', 'megamenu' ); ?></option>
|
|
|
675 |
|
676 |
+
<?php foreach ( $block_types as $block_id => $block_name ) : ?>
|
677 |
+
<option value='<?php echo $block_id; ?>'><?php echo $block_name; ?></option>
|
678 |
+
<?php endforeach; ?>
|
679 |
+
|
680 |
+
<?php if ( ! is_plugin_active( 'megamenu-pro/megamenu-pro.php' ) ) : ?>
|
681 |
+
<option disabled="disabled">Menu Toggle (Custom) (Pro)</option>
|
682 |
+
<option disabled="disabled">Search (Pro)</option>
|
683 |
+
<option disabled="disabled">Logo (Pro)</option>
|
684 |
+
<option disabled="disabled">Icon (Pro)</option>
|
685 |
+
<option disabled="disabled">HTML (Pro)</option>
|
686 |
+
<?php endif; ?>
|
687 |
+
</select>
|
688 |
+
|
689 |
+
<div class='toggle-bar-designer'>
|
690 |
+
<div class='mega-blocks'>
|
691 |
+
<div class='mega-left'>
|
692 |
+
<?php
|
693 |
+
|
694 |
+
if ( is_array( $toggle_blocks ) ) {
|
695 |
+
foreach ( $toggle_blocks as $block_id => $settings ) {
|
696 |
+
if ( is_int( $block_id ) && is_array( $settings ) && isset( $settings['align'] ) && $settings['align'] == 'left' || ! isset( $settings['align'] ) ) {
|
697 |
+
if ( isset( $settings['type'] ) ) {
|
698 |
+
do_action( "megamenu_output_admin_toggle_block_{$settings['type']}", $block_id, $settings );
|
699 |
+
}
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
|
704 |
+
?>
|
705 |
+
</div>
|
706 |
+
<div class='mega-center'>
|
707 |
+
<?php
|
708 |
+
|
709 |
+
if ( is_array( $toggle_blocks ) ) {
|
710 |
+
foreach ( $toggle_blocks as $block_id => $settings ) {
|
711 |
+
if ( is_int( $block_id ) && is_array( $settings ) && isset( $settings['align'] ) && $settings['align'] == 'center' ) {
|
712 |
+
if ( isset( $settings['type'] ) ) {
|
713 |
+
do_action( "megamenu_output_admin_toggle_block_{$settings['type']}", $block_id, $settings );
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
?>
|
720 |
+
</div>
|
721 |
+
<div class='mega-right'>
|
722 |
+
<?php
|
723 |
+
|
724 |
+
if ( is_array( $toggle_blocks ) ) {
|
725 |
+
foreach ( $toggle_blocks as $block_id => $settings ) {
|
726 |
+
if ( is_int( $block_id ) && is_array( $settings ) && isset( $settings['align'] ) && $settings['align'] == 'right' ) {
|
727 |
+
if ( isset( $settings['type'] ) ) {
|
728 |
+
do_action( "megamenu_output_admin_toggle_block_{$settings['type']}", $block_id, $settings );
|
729 |
+
}
|
730 |
+
}
|
731 |
+
}
|
732 |
+
}
|
733 |
+
|
734 |
+
?>
|
735 |
+
</div>
|
736 |
+
|
737 |
+
</div>
|
738 |
+
|
739 |
+
|
740 |
+
</div>
|
741 |
+
|
742 |
+
<p class='mega-info'><?php _e( 'Click on a block to edit it, or drag and drop it to resposition the block within the toggle bar', 'megamenu' ); ?></p>
|
743 |
+
|
744 |
+
|
745 |
+
<?php
|
746 |
+
}
|
747 |
+
|
748 |
+
|
749 |
+
/**
|
750 |
+
* Output the HTML for the "Spacer" toggle block settings
|
751 |
+
*
|
752 |
+
* @since 2.1
|
753 |
+
* @param int $block_id
|
754 |
+
* @param array $settings
|
755 |
+
*/
|
756 |
+
public function output_spacer_block_html( $block_id, $settings = array() ) {
|
757 |
+
|
758 |
+
if ( empty( $settings ) ) {
|
759 |
+
$block_id = '0';
|
760 |
+
}
|
761 |
+
|
762 |
+
$defaults = array(
|
763 |
+
'align' => 'right',
|
764 |
+
'width' => '0px',
|
765 |
+
);
|
766 |
+
|
767 |
+
$settings = array_merge( $defaults, $settings );
|
768 |
+
|
769 |
+
?>
|
770 |
+
|
771 |
+
<div class='block'>
|
772 |
+
<div class='block-title'><span title='<?php _e( 'Spacer', 'megamenu' ); ?>' class="dashicons dashicons-leftright"></span></div>
|
773 |
+
<div class='block-settings'>
|
774 |
+
<h3><?php _e( 'Spacer Settings', 'megamenu' ); ?></h3>
|
775 |
+
<input type='hidden' class='type' name='toggle_blocks[<?php echo $block_id; ?>][type]' value='spacer' />
|
776 |
+
<input type='hidden' class='align' name='toggle_blocks[<?php echo $block_id; ?>][align]' value='<?php echo $settings['align']; ?>'>
|
777 |
+
<label>
|
778 |
+
<?php _e( 'Width', 'megamenu' ); ?><input type='text' class='closed_text' name='toggle_blocks[<?php echo $block_id; ?>][width]' value='<?php echo $settings['width']; ?>' />
|
779 |
+
</label>
|
780 |
+
<a class='mega-delete'><?php _e( 'Delete', 'megamenu' ); ?></a>
|
781 |
+
</div>
|
782 |
+
</div>
|
783 |
+
|
784 |
+
<?php
|
785 |
+
}
|
786 |
+
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Output the HTML for the "Menu Toggle" block settings
|
790 |
+
*
|
791 |
+
* @since 2.1
|
792 |
+
* @param int $block_id
|
793 |
+
* @param array $settings
|
794 |
+
*/
|
795 |
+
public function output_menu_toggle_block_html( $block_id, $settings = array() ) {
|
796 |
+
|
797 |
+
if ( empty( $settings ) ) {
|
798 |
+
$block_id = '0';
|
799 |
+
}
|
800 |
+
|
801 |
+
$theme_id = 'default';
|
802 |
+
|
803 |
+
if ( isset( $_GET['theme'] ) ) {
|
804 |
+
$theme_id = esc_attr( $_GET['theme'] );
|
805 |
+
|
806 |
+
}
|
807 |
+
|
808 |
+
$defaults = $this->get_default_menu_toggle_block( $theme_id );
|
809 |
+
|
810 |
+
$settings = array_merge( $defaults, $settings );
|
811 |
+
|
812 |
+
?>
|
813 |
+
|
814 |
+
<div class='block'>
|
815 |
+
<div class='block-title'><?php _e( 'TOGGLE', 'megamenu' ); ?> <span title='<?php _e( 'Menu Toggle', 'megamenu' ); ?>' class="dashicons dashicons-menu"></span></div>
|
816 |
+
<div class='block-settings'>
|
817 |
+
<h3><?php _e( 'Menu Toggle Settings', 'megamenu' ); ?></h3>
|
818 |
+
<input type='hidden' class='type' name='toggle_blocks[<?php echo $block_id; ?>][type]' value='menu_toggle' />
|
819 |
+
<input type='hidden' class='align' name='toggle_blocks[<?php echo $block_id; ?>][align]' value='<?php echo $settings['align']; ?>'>
|
820 |
+
<label>
|
821 |
+
<?php _e( 'Closed Text', 'megamenu' ); ?><input type='text' class='closed_text' name='toggle_blocks[<?php echo $block_id; ?>][closed_text]' value='<?php echo stripslashes( esc_attr( $settings['closed_text'] ) ); ?>' />
|
822 |
+
</label>
|
823 |
+
<label>
|
824 |
+
<?php _e( 'Open Text', 'megamenu' ); ?><input type='text' class='open_text' name='toggle_blocks[<?php echo $block_id; ?>][open_text]' value='<?php echo stripslashes( esc_attr( $settings['open_text'] ) ); ?>' />
|
825 |
+
</label>
|
826 |
+
<label>
|
827 |
+
<?php _e( 'Closed Icon', 'megamenu' ); ?>
|
828 |
+
<?php $this->print_icon_option( 'closed_icon', $block_id, $settings['closed_icon'], $this->toggle_icons() ); ?>
|
829 |
+
</label>
|
830 |
+
<label>
|
831 |
+
<?php _e( 'Open Icon', 'megamenu' ); ?>
|
832 |
+
<?php $this->print_icon_option( 'open_icon', $block_id, $settings['open_icon'], $this->toggle_icons() ); ?>
|
833 |
+
</label>
|
834 |
+
<label>
|
835 |
+
<?php _e( 'Text Color', 'megamenu' ); ?>
|
836 |
+
<?php $this->print_toggle_color_option( 'text_color', $block_id, $settings['text_color'] ); ?>
|
837 |
+
</label>
|
838 |
+
<label>
|
839 |
+
<?php _e( 'Text Size', 'megamenu' ); ?><input type='text' class='text_size' name='toggle_blocks[<?php echo $block_id; ?>][text_size]' value='<?php echo stripslashes( esc_attr( $settings['text_size'] ) ); ?>' />
|
840 |
+
</label>
|
841 |
+
<label>
|
842 |
+
<?php _e( 'Icon Color', 'megamenu' ); ?>
|
843 |
+
<?php $this->print_toggle_color_option( 'icon_color', $block_id, $settings['icon_color'] ); ?>
|
844 |
+
</label>
|
845 |
+
<label>
|
846 |
+
<?php _e( 'Icon Size', 'megamenu' ); ?><input type='text' class='icon_size' name='toggle_blocks[<?php echo $block_id; ?>][icon_size]' value='<?php echo stripslashes( esc_attr( $settings['icon_size'] ) ); ?>' />
|
847 |
+
</label>
|
848 |
+
<label>
|
849 |
+
<?php _e( 'Icon Position', 'megamenu' ); ?><select name='toggle_blocks[<?php echo $block_id; ?>][icon_position]'>
|
850 |
+
<option value='before' <?php selected( $settings['icon_position'], 'before' ); ?> ><?php _e( 'Before', 'megamenu' ); ?></option>
|
851 |
+
<option value='after' <?php selected( $settings['icon_position'], 'after' ); ?> ><?php _e( 'After', 'megamenu' ); ?></option>
|
852 |
+
</select>
|
853 |
+
</label>
|
854 |
+
<a class='mega-delete'><?php _e( 'Delete', 'megamenu' ); ?></a>
|
855 |
+
</div>
|
856 |
+
</div>
|
857 |
+
|
858 |
+
<?php
|
859 |
+
}
|
860 |
+
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Output the menu toggle block (front end)
|
864 |
+
*
|
865 |
+
* @since 2.5.3
|
866 |
+
* @param string $html
|
867 |
+
* @param array $settings
|
868 |
+
* @return string
|
869 |
+
*/
|
870 |
+
public function output_menu_public_toggle_block_animated_html( $html, $settings ) {
|
871 |
+
$style = isset( $settings['style'] ) ? $settings['style'] : 'slider';
|
872 |
+
$label = isset( $settings['aria_label'] ) ? do_shortcode( stripslashes( $settings['aria_label'] ) ) : 'Toggle Menu';
|
873 |
+
|
874 |
+
$html = '<button aria-label="' . esc_attr( $label ) . '" class="mega-toggle-animated mega-toggle-animated-' . esc_attr( $style ) . '" type="button" aria-expanded="false">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
875 |
<span class="mega-toggle-animated-box">
|
876 |
<span class="mega-toggle-animated-inner"></span>
|
877 |
</span>
|
878 |
</button>';
|
879 |
|
880 |
+
return apply_filters( 'megamenu_toggle_menu_toggle_animated_html', $html );
|
881 |
+
|
882 |
+
}
|
883 |
+
|
884 |
+
/**
|
885 |
+
* Output the HTML for the "Menu Toggle (Animated)" block settings
|
886 |
+
*
|
887 |
+
* @since 2.5.3
|
888 |
+
* @param int $block_id
|
889 |
+
* @param array $settings
|
890 |
+
*/
|
891 |
+
public function output_menu_toggle_block_animated_html( $block_id, $settings = array() ) {
|
892 |
+
|
893 |
+
if ( empty( $settings ) ) {
|
894 |
+
$block_id = '0';
|
895 |
+
}
|
896 |
+
|
897 |
+
$defaults = array(
|
898 |
+
'icon_scale' => '0.8',
|
899 |
+
'icon_color' => 'rgb(221, 221, 221)',
|
900 |
+
'aria_label' => 'Toggle Menu',
|
901 |
+
);
|
902 |
+
|
903 |
+
$settings = array_merge( $defaults, $settings );
|
904 |
+
|
905 |
+
?>
|
906 |
+
|
907 |
+
<div class='block'>
|
908 |
+
<div class='block-title'><?php _e( 'TOGGLE', 'megamenu' ); ?> <span title='<?php _e( 'Menu Toggle', 'megamenu' ); ?>' class="dashicons dashicons-menu"></span></div>
|
909 |
+
<div class='block-settings'>
|
910 |
+
<h3><?php _e( 'Animated Menu Toggle Settings', 'megamenu' ); ?></h3>
|
911 |
+
<input type='hidden' class='type' name='toggle_blocks[<?php echo $block_id; ?>][type]' value='menu_toggle_animated' />
|
912 |
+
<input type='hidden' class='align' name='toggle_blocks[<?php echo $block_id; ?>][align]' value='<?php echo $settings['align']; ?>'>
|
913 |
+
<input type='hidden' class='style' name='toggle_blocks[<?php echo $block_id; ?>][style]' value='slider'>
|
914 |
+
|
915 |
+
<label>
|
916 |
+
<?php _e( 'Color', 'megamenu' ); ?>
|
917 |
+
<?php $this->print_toggle_color_option( 'icon_color', $block_id, $settings['icon_color'] ); ?>
|
918 |
+
</label>
|
919 |
+
<label>
|
920 |
+
<?php _e( 'Size', 'megamenu' ); ?><select name='toggle_blocks[<?php echo $block_id; ?>][icon_scale]'>
|
921 |
+
<option value='0.6' <?php selected( $settings['icon_scale'], '0.6' ); ?> ><?php _e( 'Small', 'megamenu' ); ?></option>
|
922 |
+
<option value='0.8' <?php selected( $settings['icon_scale'], '0.8' ); ?> ><?php _e( 'Medium', 'megamenu' ); ?></option>
|
923 |
+
<option value='1.0' <?php selected( $settings['icon_scale'], '1.0' ); ?> ><?php _e( 'Large', 'megamenu' ); ?></option>
|
924 |
+
<option value='1.2' <?php selected( $settings['icon_scale'], '1.2' ); ?> ><?php _e( 'X Large', 'megamenu' ); ?></option>
|
925 |
+
</select>
|
926 |
+
</label>
|
927 |
+
<label>
|
928 |
+
<?php _e( 'Label', 'megamenu' ); ?><input type='text' class='aria_label' name='toggle_blocks[<?php echo $block_id; ?>][aria_label]' value='<?php echo stripslashes( esc_attr( $settings['aria_label'] ) ); ?>' />
|
929 |
+
</label>
|
930 |
+
<a class='mega-delete'><?php _e( 'Delete', 'megamenu' ); ?></a>
|
931 |
+
</div>
|
932 |
+
</div>
|
933 |
+
|
934 |
+
<?php
|
935 |
+
}
|
936 |
+
|
937 |
+
|
938 |
+
/**
|
939 |
+
* Print an icon selection box
|
940 |
+
*
|
941 |
+
* @since 2.1
|
942 |
+
* @param string $key
|
943 |
+
* @param int $block_id
|
944 |
+
* @param string $value
|
945 |
+
*/
|
946 |
+
public function print_icon_option( $key, $block_id, $value, $icons ) {
|
947 |
+
|
948 |
+
?>
|
949 |
+
<select class='icon_dropdown' name='toggle_blocks[<?php echo $block_id; ?>][<?php echo $key; ?>]'>
|
950 |
+
<?php
|
951 |
+
|
952 |
+
echo "<option value='disabled'>" . __( 'Disabled', 'megamenu' ) . '</option>';
|
953 |
+
|
954 |
+
foreach ( $icons as $code => $class ) {
|
955 |
+
$name = str_replace( 'dashicons-', '', $class );
|
956 |
+
$name = ucwords( str_replace( array( '-', 'arrow' ), ' ', $name ) );
|
957 |
+
echo "<option data-class='{$class}' value='{$code}'" . selected( $value, $code, false ) . '>' . $name . '</option>';
|
958 |
+
}
|
959 |
+
|
960 |
+
?>
|
961 |
+
</select>
|
962 |
+
|
963 |
+
<?php
|
964 |
+
}
|
965 |
+
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Print a color picker
|
969 |
+
*
|
970 |
+
* @since 2.1
|
971 |
+
* @param string $key
|
972 |
+
* @param int $block_id
|
973 |
+
* @param string $value
|
974 |
+
*/
|
975 |
+
public function print_toggle_color_option( $key, $block_id, $value ) {
|
976 |
+
|
977 |
+
if ( $value == 'transparent' ) {
|
978 |
+
$value = 'rgba(0,0,0,0)';
|
979 |
+
}
|
980 |
+
|
981 |
+
if ( $value == 'rgba(0,0,0,0)' ) {
|
982 |
+
$value_text = 'transparent';
|
983 |
+
} else {
|
984 |
+
$value_text = $value;
|
985 |
+
}
|
986 |
+
|
987 |
+
echo "<div class='mm-picker-container'>";
|
988 |
+
echo " <input type='text' class='mm_colorpicker' name='toggle_blocks[{$block_id}][{$key}]' value='{$value}' />";
|
989 |
+
echo " <div class='chosen-color'>{$value_text}</div>";
|
990 |
+
echo '</div>';
|
991 |
+
|
992 |
+
}
|
993 |
+
|
994 |
+
|
995 |
+
/**
|
996 |
+
* List of all available toggle DashIcon classes.
|
997 |
+
*
|
998 |
+
* @since 2.1
|
999 |
+
* @return array - Sorted list of toggle classes
|
1000 |
+
*/
|
1001 |
+
public function toggle_icons() {
|
1002 |
+
|
1003 |
+
$icons = array(
|
1004 |
+
'dash-f333' => 'dashicons-menu',
|
1005 |
+
'dash-f228' => 'dashicons-menu-alt',
|
1006 |
+
'dash-f329' => 'dashicons-menu-alt2',
|
1007 |
+
'dash-f349' => 'dashicons-menu-alt3',
|
1008 |
+
'dash-f214' => 'dashicons-editor-justify',
|
1009 |
+
'dash-f158' => 'dashicons-no',
|
1010 |
+
'dash-f335' => 'dashicons-no-alt',
|
1011 |
+
'dash-f132' => 'dashicons-plus',
|
1012 |
+
'dash-f502' => 'dashicons-plus-alt',
|
1013 |
+
'dash-f460' => 'dashicons-minus',
|
1014 |
+
'dash-f153' => 'dashicons-dismiss',
|
1015 |
+
'dash-f142' => 'dashicons-arrow-up',
|
1016 |
+
'dash-f140' => 'dashicons-arrow-down',
|
1017 |
+
'dash-f342' => 'dashicons-arrow-up-alt',
|
1018 |
+
'dash-f346' => 'dashicons-arrow-down-alt',
|
1019 |
+
'dash-f343' => 'dashicons-arrow-up-alt2',
|
1020 |
+
'dash-f347' => 'dashicons-arrow-down-alt2',
|
1021 |
+
);
|
1022 |
+
|
1023 |
+
$icons = apply_filters( 'megamenu_toggle_icons', $icons );
|
1024 |
+
|
1025 |
+
return $icons;
|
1026 |
+
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
endif;
|
classes/walker.class.php
CHANGED
@@ -1,218 +1,220 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if( ! class_exists( 'Mega_Menu_Walker' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* @package WordPress
|
11 |
-
* @since 1.0.0
|
12 |
-
* @uses Walker
|
13 |
-
*/
|
14 |
-
class Mega_Menu_Walker extends Walker_Nav_Menu {
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
*
|
19 |
-
* @
|
20 |
-
*
|
21 |
-
* @since 1.0
|
22 |
-
*
|
23 |
-
* @param string $output Passed by reference. Used to append additional content.
|
24 |
-
* @param int $depth Depth of menu item. Used for padding.
|
25 |
-
* @param array $args An array of arguments. @see wp_nav_menu()
|
26 |
*/
|
27 |
-
|
28 |
-
|
29 |
-
$indent = str_repeat("\t", $depth);
|
30 |
-
|
31 |
-
$output .= "\n$indent<ul class=\"mega-sub-menu\">\n";
|
32 |
-
}
|
33 |
|
34 |
-
/**
|
35 |
-
* Ends the list of after the elements are added.
|
36 |
-
*
|
37 |
-
* @see Walker::end_lvl()
|
38 |
-
*
|
39 |
-
* @since 1.0
|
40 |
-
*
|
41 |
-
* @param string $output Passed by reference. Used to append additional content.
|
42 |
-
* @param int $depth Depth of menu item. Used for padding.
|
43 |
-
* @param array $args An array of arguments. @see wp_nav_menu()
|
44 |
-
*/
|
45 |
-
function end_lvl( &$output, $depth = 0, $args = array() ) {
|
46 |
-
$indent = str_repeat("\t", $depth);
|
47 |
-
$output .= "$indent</ul>\n";
|
48 |
-
}
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
*/
|
63 |
-
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
64 |
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
$settings = $item->megamenu_settings;
|
69 |
-
} else {
|
70 |
-
$settings = Mega_Menu_Nav_Menus::get_menu_item_defaults();
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
|
|
87 |
|
88 |
-
|
89 |
-
if ( is_array( $classes ) && ! in_array( "menu-column", $classes ) && ! in_array( "menu-row", $classes ) ) {
|
90 |
-
$id = "mega-menu-item-{$item->ID}";
|
91 |
-
} else {
|
92 |
-
$id = "mega-menu-{$item->ID}";
|
93 |
-
}
|
94 |
|
95 |
-
|
|
|
96 |
|
97 |
-
|
|
|
98 |
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
|
102 |
-
$
|
103 |
|
104 |
-
|
105 |
|
106 |
-
|
|
|
107 |
|
108 |
-
|
109 |
-
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
110 |
-
$atts['class'] = '';
|
111 |
-
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
112 |
|
113 |
-
if ( isset( $settings['disable_link'] ) && $settings['disable_link'] != 'true') {
|
114 |
-
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
115 |
} else {
|
116 |
-
$atts['tabindex'] = 0;
|
117 |
-
}
|
118 |
|
119 |
-
|
120 |
-
$atts['class'] = $settings['icon'];
|
121 |
-
}
|
122 |
-
|
123 |
-
if ( isset( $settings['icon'] ) && $settings['icon'] == 'custom' ) {
|
124 |
-
$atts['class'] = 'mega-custom-icon';
|
125 |
-
}
|
126 |
|
127 |
-
|
|
|
|
|
|
|
128 |
|
129 |
-
$
|
130 |
-
|
|
|
|
|
|
|
131 |
|
132 |
-
if (
|
133 |
-
$atts['
|
134 |
}
|
135 |
|
136 |
-
if ( isset( $settings['
|
137 |
-
$atts['
|
138 |
}
|
139 |
-
}
|
140 |
|
141 |
-
|
142 |
-
$atts['tabindex'] = "0";
|
143 |
-
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
}
|
148 |
|
149 |
-
|
|
|
|
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
}
|
156 |
|
157 |
-
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
162 |
-
$attributes .= ' ' . $attr . '="' . $value . '"';
|
163 |
}
|
164 |
-
}
|
165 |
|
166 |
-
|
167 |
-
$item_output .= '<a'. $attributes .'>';
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
172 |
|
173 |
-
|
174 |
-
/** This filter is documented in wp-includes/post-template.php */
|
175 |
-
} else if ( property_exists( $item, 'mega_description' ) && strlen( $item->mega_description ) ) {
|
176 |
-
$item_output .= '<span class="mega-description-group"><span class="mega-menu-title">' . $args->link_before . apply_filters( 'megamenu_the_title', $item->title, $item->ID ) . $args->link_after . '</span><span class="mega-menu-description">' . $item->description . '</span></span>';
|
177 |
-
} else {
|
178 |
-
$item_output .= $args->link_before . apply_filters( 'megamenu_the_title', $item->title, $item->ID ) . $args->link_after;
|
179 |
-
}
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
184 |
|
185 |
-
|
186 |
-
$item_output .= '<
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
|
193 |
-
|
|
|
194 |
}
|
195 |
|
|
|
196 |
}
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
|
214 |
-
$output .= "</li>"; // remove new line to remove the 4px gap between menu items
|
215 |
}
|
216 |
-
}
|
217 |
|
218 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Walker' ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
/**
|
10 |
+
* @package WordPress
|
11 |
+
* @since 1.0.0
|
12 |
+
* @uses Walker
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
*/
|
14 |
+
class Mega_Menu_Walker extends Walker_Nav_Menu {
|
|
|
|
|
|
|
|
|
|
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
/**
|
18 |
+
* Starts the list before the elements are added.
|
19 |
+
*
|
20 |
+
* @see Walker::start_lvl()
|
21 |
+
*
|
22 |
+
* @since 1.0
|
23 |
+
*
|
24 |
+
* @param string $output Passed by reference. Used to append additional content.
|
25 |
+
* @param int $depth Depth of menu item. Used for padding.
|
26 |
+
* @param array $args An array of arguments. @see wp_nav_menu()
|
27 |
+
*/
|
28 |
+
function start_lvl( &$output, $depth = 0, $args = array() ) {
|
|
|
|
|
29 |
|
30 |
+
$indent = str_repeat( "\t", $depth );
|
31 |
|
32 |
+
$output .= "\n$indent<ul class=\"mega-sub-menu\">\n";
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
+
* Ends the list of after the elements are added.
|
37 |
+
*
|
38 |
+
* @see Walker::end_lvl()
|
39 |
+
*
|
40 |
+
* @since 1.0
|
41 |
+
*
|
42 |
+
* @param string $output Passed by reference. Used to append additional content.
|
43 |
+
* @param int $depth Depth of menu item. Used for padding.
|
44 |
+
* @param array $args An array of arguments. @see wp_nav_menu()
|
45 |
+
*/
|
46 |
+
function end_lvl( &$output, $depth = 0, $args = array() ) {
|
47 |
+
$indent = str_repeat( "\t", $depth );
|
48 |
+
$output .= "$indent</ul>\n";
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Custom walker. Add the widgets into the menu.
|
53 |
+
*
|
54 |
+
* @see Walker::start_el()
|
55 |
+
*
|
56 |
+
* @since 1.0
|
57 |
+
*
|
58 |
+
* @param string $output Passed by reference. Used to append additional content.
|
59 |
+
* @param object $item Menu item data object.
|
60 |
+
* @param int $depth Depth of menu item. Used for padding.
|
61 |
+
* @param array $args An array of arguments. @see wp_nav_menu()
|
62 |
+
* @param int $id Current item ID.
|
63 |
+
*/
|
64 |
+
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
65 |
+
|
66 |
+
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
67 |
+
|
68 |
+
if ( property_exists( $item, 'megamenu_settings' ) ) {
|
69 |
+
$settings = $item->megamenu_settings;
|
70 |
+
} else {
|
71 |
+
$settings = Mega_Menu_Nav_Menus::get_menu_item_defaults();
|
72 |
+
}
|
73 |
|
74 |
+
// Item Class
|
75 |
+
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
76 |
|
77 |
+
if ( is_array( $classes ) && ! in_array( 'menu-column', $classes ) && ! in_array( 'menu-row', $classes ) ) {
|
78 |
+
$classes[] = 'menu-item-' . $item->ID;
|
79 |
+
}
|
80 |
|
81 |
+
$class = join( ' ', apply_filters( 'megamenu_nav_menu_css_class', array_filter( $classes ), $item, $args ) );
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
// these classes are prepended with 'mega-'
|
84 |
+
$mega_classes = explode( ' ', $class );
|
85 |
|
86 |
+
// strip widget classes back to how they're intended to be output
|
87 |
+
$class = str_replace( 'mega-menu-widget-class-', '', $class );
|
88 |
|
89 |
+
// Item ID
|
90 |
+
if ( is_array( $classes ) && ! in_array( 'menu-column', $classes ) && ! in_array( 'menu-row', $classes ) ) {
|
91 |
+
$id = "mega-menu-item-{$item->ID}";
|
92 |
+
} else {
|
93 |
+
$id = "mega-menu-{$item->ID}";
|
94 |
+
}
|
95 |
|
96 |
+
$id = esc_attr( apply_filters( 'megamenu_nav_menu_item_id', $id, $item, $args ) );
|
97 |
|
98 |
+
$output .= "<li class='{$class}' id='{$id}'>";
|
99 |
|
100 |
+
// output the widgets
|
101 |
+
if ( $item->type == 'widget' && $item->content ) {
|
102 |
|
103 |
+
$item_output = $item->content;
|
|
|
|
|
|
|
104 |
|
|
|
|
|
105 |
} else {
|
|
|
|
|
106 |
|
107 |
+
$atts = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
+
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
|
110 |
+
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
111 |
+
$atts['class'] = '';
|
112 |
+
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
113 |
|
114 |
+
if ( isset( $settings['disable_link'] ) && $settings['disable_link'] != 'true' ) {
|
115 |
+
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
116 |
+
} else {
|
117 |
+
$atts['tabindex'] = 0;
|
118 |
+
}
|
119 |
|
120 |
+
if ( isset( $settings['icon'] ) && $settings['icon'] != 'disabled' && $settings['icon'] != 'custom' ) {
|
121 |
+
$atts['class'] = $settings['icon'];
|
122 |
}
|
123 |
|
124 |
+
if ( isset( $settings['icon'] ) && $settings['icon'] == 'custom' ) {
|
125 |
+
$atts['class'] = 'mega-custom-icon';
|
126 |
}
|
|
|
127 |
|
128 |
+
if ( is_array( $classes ) && in_array( 'menu-item-has-children', $classes ) && $item->parent_submenu_type == 'flyout' ) {
|
|
|
|
|
129 |
|
130 |
+
$atts['aria-haspopup'] = 'true'; // required for Surface/Win10/Edge
|
131 |
+
$atts['aria-expanded'] = 'false';
|
|
|
132 |
|
133 |
+
if ( is_array( $mega_classes ) && in_array( 'mega-toggle-on', $mega_classes ) ) {
|
134 |
+
$atts['aria-expanded'] = 'true';
|
135 |
+
}
|
136 |
|
137 |
+
if ( isset( $settings['disable_link'] ) && $settings['disable_link'] == 'true' ) {
|
138 |
+
$atts['role'] = 'button';
|
139 |
+
}
|
140 |
+
}
|
|
|
141 |
|
142 |
+
if ( $depth == 0 ) {
|
143 |
+
$atts['tabindex'] = '0';
|
144 |
+
}
|
145 |
|
146 |
+
if ( isset( $settings['hide_text'] ) && $settings['hide_text'] == 'true' ) {
|
147 |
+
$atts['aria-label'] = $item->title;
|
|
|
|
|
148 |
}
|
|
|
149 |
|
150 |
+
$atts = apply_filters( 'megamenu_nav_menu_link_attributes', $atts, $item, $args );
|
|
|
151 |
|
152 |
+
if ( isset( $atts['class'] ) && strlen( $atts['class'] ) ) {
|
153 |
+
$atts['class'] = $atts['class'] . ' mega-menu-link';
|
154 |
+
} else {
|
155 |
+
$atts['class'] = 'mega-menu-link';
|
156 |
+
}
|
157 |
|
158 |
+
$attributes = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
+
foreach ( $atts as $attr => $value ) {
|
161 |
+
if ( strlen( $value ) ) {
|
162 |
+
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
163 |
+
$attributes .= ' ' . $attr . '="' . $value . '"';
|
164 |
+
}
|
165 |
+
}
|
166 |
|
167 |
+
$item_output = $args->before;
|
168 |
+
$item_output .= '<a' . $attributes . '>';
|
169 |
+
|
170 |
+
if ( is_array( $classes ) && in_array( 'icon-top', $classes ) ) {
|
171 |
+
$item_output .= "<span class='mega-title-below'>";
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( isset( $settings['hide_text'] ) && $settings['hide_text'] == 'true' ) {
|
175 |
+
/**
|
176 |
+
* This filter is documented in wp-includes/post-template.php
|
177 |
+
*/
|
178 |
+
} elseif ( property_exists( $item, 'mega_description' ) && strlen( $item->mega_description ) ) {
|
179 |
+
$item_output .= '<span class="mega-description-group"><span class="mega-menu-title">' . $args->link_before . apply_filters( 'megamenu_the_title', $item->title, $item->ID ) . $args->link_after . '</span><span class="mega-menu-description">' . $item->description . '</span></span>';
|
180 |
+
} else {
|
181 |
+
$item_output .= $args->link_before . apply_filters( 'megamenu_the_title', $item->title, $item->ID ) . $args->link_after;
|
182 |
+
}
|
183 |
+
|
184 |
+
if ( is_array( $classes ) && in_array( 'icon-top', $classes ) ) {
|
185 |
+
$item_output .= '</span>';
|
186 |
+
}
|
187 |
|
188 |
+
if ( is_array( $classes ) && in_array( 'menu-item-has-children', $classes ) ) {
|
189 |
+
$item_output .= '<span class="mega-indicator"></span>';
|
190 |
+
}
|
191 |
+
|
192 |
+
$item_output .= '</a>';
|
193 |
+
$item_output .= $args->after;
|
194 |
|
195 |
+
if ( is_array( $classes ) && ( in_array( 'menu-column', $classes ) || in_array( 'menu-row', $classes ) ) ) {
|
196 |
+
$item_output = '';
|
197 |
+
}
|
198 |
}
|
199 |
|
200 |
+
$output .= apply_filters( 'megamenu_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
201 |
}
|
202 |
|
203 |
+
/**
|
204 |
+
* Ends the element output, if needed.
|
205 |
+
*
|
206 |
+
* @see Walker::end_el()
|
207 |
+
*
|
208 |
+
* @since 1.7
|
209 |
+
*
|
210 |
+
* @param string $output Passed by reference. Used to append additional content.
|
211 |
+
* @param object $item Page data object. Not used.
|
212 |
+
* @param int $depth Depth of page. Not Used.
|
213 |
+
* @param array $args An array of arguments. @see wp_nav_menu()
|
214 |
+
*/
|
215 |
+
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
|
216 |
+
$output .= '</li>'; // remove new line to remove the 4px gap between menu items
|
217 |
+
}
|
|
|
|
|
218 |
}
|
|
|
219 |
|
220 |
+
endif;
|
classes/widget-manager.class.php
CHANGED
@@ -1,1330 +1,1338 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Widget_Manager') ) :
|
8 |
|
9 |
-
/**
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
class Mega_Menu_Widget_Manager {
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
add_action( 'megamenu_after_widget_add', array( $this, 'clear_caches' ) );
|
39 |
-
add_action( 'megamenu_after_widget_save', array( $this, 'clear_caches' ) );
|
40 |
-
add_action( 'megamenu_after_widget_delete', array( $this, 'clear_caches' ) );
|
41 |
-
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Depending on how a widget has been written, it may not necessarily base the new widget settings on
|
47 |
-
* a copy the old settings. If this is the case, the mega menu data will be lost. This function
|
48 |
-
* checks to make sure widgets persist the mega menu data when they're saved.
|
49 |
-
*
|
50 |
-
* @since 1.0
|
51 |
-
*/
|
52 |
-
public function persist_mega_menu_widget_settings( $instance, $new_instance, $old_instance, $that ) {
|
53 |
-
|
54 |
-
if ( isset( $old_instance["mega_menu_columns"] ) && ! isset( $new_instance["mega_menu_columns"] ) ) {
|
55 |
-
$instance["mega_menu_columns"] = $old_instance["mega_menu_columns"];
|
56 |
-
}
|
57 |
-
|
58 |
-
if ( isset( $old_instance["mega_menu_order"] ) && ! isset( $new_instance["mega_menu_order"] ) ) {
|
59 |
-
$instance["mega_menu_order"] = $old_instance["mega_menu_order"];
|
60 |
-
}
|
61 |
-
|
62 |
-
if ( isset( $old_instance["mega_menu_parent_menu_id"] ) && ! isset( $new_instance["mega_menu_parent_menu_id"] ) ) {
|
63 |
-
$instance["mega_menu_parent_menu_id"] = $old_instance["mega_menu_parent_menu_id"];
|
64 |
-
}
|
65 |
-
|
66 |
-
return $instance;
|
67 |
-
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
* Display a widget settings form
|
72 |
-
*
|
73 |
-
* @since 1.0
|
74 |
-
*/
|
75 |
-
public function ajax_show_widget_form() {
|
76 |
|
77 |
-
|
78 |
|
79 |
-
|
|
|
|
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
* Display a menu item settings form
|
89 |
-
*
|
90 |
-
* @since 2.7
|
91 |
-
*/
|
92 |
-
public function ajax_show_menu_item_form() {
|
93 |
|
94 |
-
|
95 |
|
96 |
-
|
97 |
|
98 |
-
|
|
|
99 |
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
<input type='hidden' name='action' value='mm_save_menu_item' />
|
108 |
-
<input type='hidden' name='menu_item_id' value='<?php echo esc_attr( $menu_item_id ) ?>' />
|
109 |
-
<input type='hidden' name='_wpnonce' value='<?php echo esc_attr( $nonce ) ?>' />
|
110 |
-
<div class='widget-content'>
|
111 |
-
<?php
|
112 |
-
|
113 |
-
$css_version = get_transient("megamenu_css_version");
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
-
|
152 |
|
153 |
-
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
|
162 |
-
|
163 |
|
164 |
-
|
165 |
|
166 |
-
|
167 |
|
168 |
-
|
169 |
|
170 |
-
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
|
181 |
-
|
182 |
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
|
191 |
-
|
192 |
-
|
193 |
|
194 |
-
|
195 |
|
196 |
-
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
|
204 |
-
|
205 |
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
|
214 |
-
|
215 |
|
216 |
-
|
217 |
-
|
218 |
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
|
227 |
-
|
228 |
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
|
237 |
-
|
238 |
|
239 |
-
|
240 |
-
|
241 |
|
242 |
-
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
|
250 |
-
|
251 |
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
|
260 |
-
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
|
268 |
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
|
275 |
-
|
276 |
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
|
285 |
-
|
286 |
|
287 |
-
|
288 |
|
289 |
-
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
|
297 |
-
|
298 |
|
299 |
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
|
307 |
-
|
308 |
|
309 |
-
|
310 |
|
311 |
-
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
|
332 |
-
|
333 |
|
334 |
-
|
335 |
-
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
|
341 |
-
|
342 |
|
343 |
-
|
344 |
|
345 |
-
|
346 |
|
347 |
-
|
348 |
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
-
|
351 |
-
$this->send_json_success( sprintf( __( "Saved (%s)", "megamenu"), json_encode( $grid ) ) );
|
352 |
-
} else {
|
353 |
-
$this->send_json_error( sprintf( __( "Didn't save", "megamenu"), json_encode( $grid ) ) );
|
354 |
-
}
|
355 |
|
356 |
-
}
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
|
359 |
-
|
360 |
-
* Returns an object representing all widgets registered in WordPress
|
361 |
-
*
|
362 |
-
* @since 1.0
|
363 |
-
*/
|
364 |
-
public function get_available_widgets() {
|
365 |
-
global $wp_widget_factory;
|
366 |
|
367 |
-
|
368 |
|
369 |
-
|
370 |
|
371 |
-
|
372 |
|
373 |
-
|
374 |
|
375 |
-
|
|
|
|
|
|
|
376 |
|
377 |
-
|
378 |
-
|
379 |
-
'value' => $widget->id_base
|
380 |
-
);
|
381 |
|
382 |
-
|
383 |
|
384 |
-
|
385 |
|
386 |
-
|
387 |
|
388 |
-
return $widgets;
|
389 |
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
return strcmp( $a['text'], $b['text'] );
|
402 |
-
}
|
403 |
|
|
|
|
|
|
|
|
|
404 |
|
405 |
-
|
406 |
-
* Sorts a 2d array by the 'order' key
|
407 |
-
*
|
408 |
-
* @since 2.0
|
409 |
-
* @param array $a
|
410 |
-
* @param array $b
|
411 |
-
*/
|
412 |
-
function sort_by_order( $a, $b ) {
|
413 |
|
414 |
-
if ($a['order'] == $b['order']) {
|
415 |
-
return 1;
|
416 |
-
}
|
417 |
-
return ($a['order'] < $b['order']) ? -1 : 1;
|
418 |
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
|
|
421 |
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
* @return array
|
427 |
-
*/
|
428 |
-
private function get_second_level_menu_items( $parent_menu_item_id, $menu_id, $menu_items = false ) {
|
429 |
|
430 |
-
|
|
|
|
|
431 |
|
432 |
-
|
433 |
-
if ( ! is_nav_menu( $menu_id ) ) {
|
434 |
-
return $second_level_items;
|
435 |
-
}
|
436 |
|
437 |
-
|
438 |
-
$menu_items = wp_get_nav_menu_items( $menu_id );
|
439 |
-
}
|
440 |
|
441 |
-
|
|
|
442 |
|
443 |
-
|
444 |
|
445 |
-
|
446 |
-
if ( $item->menu_item_parent == $parent_menu_item_id ) {
|
447 |
|
448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
|
450 |
-
|
|
|
|
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
'type' => 'menu_item',
|
455 |
-
'title' => $item->title,
|
456 |
-
'columns' => $settings['mega_menu_columns'],
|
457 |
-
'order' => isset( $settings['mega_menu_order'][ $parent_menu_item_id ] ) ? $settings['mega_menu_order'][ $parent_menu_item_id ] : 0
|
458 |
-
);
|
459 |
|
460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
|
462 |
-
|
463 |
|
464 |
-
|
465 |
|
466 |
-
|
467 |
-
}
|
468 |
|
469 |
-
|
470 |
-
* Returns an array of all widgets belonging to a specified menu item ID.
|
471 |
-
*
|
472 |
-
* @since 1.0
|
473 |
-
* @param int $menu_item_id
|
474 |
-
*/
|
475 |
-
public function get_widgets_for_menu_id( $parent_menu_item_id, $menu_id ) {
|
476 |
|
477 |
-
|
478 |
|
479 |
-
|
480 |
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
-
|
|
|
|
|
484 |
|
485 |
-
|
486 |
|
487 |
-
|
488 |
|
489 |
-
$widgets[ $widget_id ] = array(
|
490 |
-
'id' => $widget_id,
|
491 |
-
'type' => 'widget',
|
492 |
-
'title' => $name,
|
493 |
-
'columns' => $settings['mega_menu_columns'],
|
494 |
-
'order' => isset( $settings['mega_menu_order'][ $parent_menu_item_id ] ) ? $settings['mega_menu_order'][ $parent_menu_item_id ] : 0
|
495 |
-
);
|
496 |
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
-
|
500 |
|
501 |
-
|
502 |
|
503 |
-
|
504 |
|
505 |
-
|
506 |
|
|
|
507 |
|
508 |
-
|
509 |
-
* Returns an array of widgets and second level menu items for a specified parent menu item.
|
510 |
-
* Used to display the widgets/menu items in the mega menu builder.
|
511 |
-
*
|
512 |
-
* @since 2.0
|
513 |
-
* @param int $parent_menu_item_id
|
514 |
-
* @param int $menu_id
|
515 |
-
* @return array
|
516 |
-
*/
|
517 |
-
public function get_widgets_and_menu_items_for_menu_id( $parent_menu_item_id, $menu_id ) {
|
518 |
|
519 |
-
|
520 |
|
521 |
-
|
|
|
522 |
|
523 |
-
|
|
|
|
|
|
|
|
|
|
|
524 |
|
525 |
-
|
526 |
|
527 |
-
|
528 |
|
529 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
|
533 |
-
|
534 |
-
|
|
|
|
|
|
|
535 |
|
536 |
-
|
537 |
-
if ( $value['order'] == 0 ) {
|
538 |
-
unset( $new_items[$key] );
|
539 |
-
$end_items[] = $value;
|
540 |
-
}
|
541 |
-
}
|
542 |
|
543 |
-
|
544 |
|
545 |
-
|
546 |
|
547 |
-
|
548 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
|
560 |
-
|
561 |
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
// return empty row
|
568 |
-
$saved_grid[0]['columns'][0]['meta']['span'] = 3;
|
569 |
-
$saved_grid = $this->populate_saved_grid_data( $parent_menu_item_id, $menu_id, $saved_grid, $menu_items );
|
570 |
-
|
571 |
-
}
|
572 |
|
573 |
-
|
574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
|
|
|
|
|
|
576 |
|
577 |
-
|
578 |
-
|
579 |
-
* Ensure second level menu items saved within the grid data are still actually second level menu itms within the menu structure
|
580 |
-
*
|
581 |
-
* @param $saved_grid - array representing rows, columns and widgets/menu items within each column
|
582 |
-
* @param $second_level_menu_items - array of second level menu items beneath the current menu item
|
583 |
-
* @since 2.4
|
584 |
-
* @return array
|
585 |
-
*/
|
586 |
-
public function populate_saved_grid_data( $parent_menu_item_id, $menu_id, $saved_grid, $menu_items ) {
|
587 |
-
|
588 |
-
$second_level_menu_items = $this->get_second_level_menu_items( $parent_menu_item_id, $menu_id, $menu_items );
|
589 |
-
|
590 |
-
$menu_items_included = array();
|
591 |
-
|
592 |
-
foreach ($saved_grid as $row => $row_data ) {
|
593 |
-
if ( isset( $row_data['columns'] ) ) {
|
594 |
-
foreach ( $row_data['columns'] as $col => $col_data ) {
|
595 |
-
if ( isset ( $col_data['items'] ) ) {
|
596 |
-
foreach ( $col_data['items'] as $key => $item ) {
|
597 |
-
if ( $item['type'] == 'item' ) {
|
598 |
-
$menu_items_included[] = $item['id'];
|
599 |
-
$is_child_of_parent = false;
|
600 |
-
|
601 |
-
foreach ( $second_level_menu_items as $menu_item ) {
|
602 |
-
if ( $menu_item['id'] == $item['id'] ) {
|
603 |
-
$is_child_of_parent = true;
|
604 |
-
}
|
605 |
-
}
|
606 |
-
|
607 |
-
if ( ! $is_child_of_parent ) {
|
608 |
-
unset( $saved_grid[$row]['columns'][$col]['items'][$key] ); // menu item has been deleted or moved
|
609 |
-
}
|
610 |
-
} else {
|
611 |
-
if ( ! $this->get_name_for_widget_id( $item['id'] ) ) {
|
612 |
-
unset( $saved_grid[$row]['columns'][$col]['items'][$key] ); // widget no longer exists
|
613 |
-
}
|
614 |
-
}
|
615 |
-
}
|
616 |
-
}
|
617 |
-
}
|
618 |
-
}
|
619 |
-
}
|
620 |
-
|
621 |
-
// Find any second level menu items that have been added to the menu but are not yet within the grid data
|
622 |
-
$orphaned_items = array();
|
623 |
-
|
624 |
-
foreach ( $second_level_menu_items as $menu_item ) {
|
625 |
-
if ( ! in_array($menu_item['id'], $menu_items_included ) ) {
|
626 |
-
$orphaned_items[] = $menu_item;
|
627 |
-
}
|
628 |
-
}
|
629 |
-
|
630 |
-
if ( ! isset( $saved_grid[0]['columns'][0]['items'][0])) {
|
631 |
-
$index = 0; // grid is empty
|
632 |
-
} else {
|
633 |
-
$index = 999; // create new row
|
634 |
-
}
|
635 |
-
|
636 |
-
foreach ($orphaned_items as $key => $menu_item) {
|
637 |
-
$saved_grid[$index]['columns'][0]['meta']['span'] = 3;
|
638 |
-
$saved_grid[$index]['columns'][0]['items'][$key] = array(
|
639 |
-
'id' => $menu_item['id'],
|
640 |
-
'type'=> 'item',
|
641 |
-
'title' => $menu_item['title'],
|
642 |
-
'description' => __("Menu Item", "megamenu")
|
643 |
-
);
|
644 |
-
}
|
645 |
-
|
646 |
-
if ( is_admin() ) {
|
647 |
-
$saved_grid = $this->populate_grid_menu_item_titles( $saved_grid, $menu_id );
|
648 |
-
}
|
649 |
-
|
650 |
-
return $saved_grid;
|
651 |
-
}
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Loop through the grid data and apply titles and labels to each menu item and widget.
|
656 |
-
*
|
657 |
-
* @param array $saved_grid
|
658 |
-
* @param int $menu_id
|
659 |
-
* @since 2.4
|
660 |
-
* @return array
|
661 |
-
*/
|
662 |
-
public function populate_grid_menu_item_titles( $saved_grid, $menu_id ) {
|
663 |
-
|
664 |
-
$menu_items = wp_get_nav_menu_items( $menu_id );
|
665 |
-
|
666 |
-
$menu_item_title_map = array();
|
667 |
-
|
668 |
-
foreach ( $menu_items as $item ) {
|
669 |
-
$menu_item_title_map[ $item->ID ] = $item->title;
|
670 |
-
}
|
671 |
-
|
672 |
-
foreach ($saved_grid as $row => $row_data ) {
|
673 |
-
if ( isset( $row_data['columns'] ) ) {
|
674 |
-
foreach ( $row_data['columns'] as $col => $col_data ) {
|
675 |
-
if ( isset ( $col_data['items'] ) ) {
|
676 |
-
foreach ( $col_data['items'] as $key => $item ) {
|
677 |
-
if ( $item['type'] == 'item' ) {
|
678 |
-
|
679 |
-
if ( isset( $menu_item_title_map[$item['id']] ) ) {
|
680 |
-
$title = $menu_item_title_map[$item['id']];
|
681 |
-
} else {
|
682 |
-
$title = __("(no label)");
|
683 |
-
}
|
684 |
-
|
685 |
-
$saved_grid[$row]['columns'][$col]['items'][$key]['title'] = $title;
|
686 |
-
$saved_grid[$row]['columns'][$col]['items'][$key]['description'] = __("Menu Item", "megamenu");
|
687 |
-
} else {
|
688 |
-
$saved_grid[$row]['columns'][$col]['items'][$key]['title'] = $this->get_title_for_widget_id($item['id']);
|
689 |
-
$saved_grid[$row]['columns'][$col]['items'][$key]['description'] = $this->get_name_for_widget_id($item['id']);
|
690 |
-
}
|
691 |
-
}
|
692 |
-
}
|
693 |
-
}
|
694 |
-
}
|
695 |
-
}
|
696 |
-
|
697 |
-
return $saved_grid;
|
698 |
-
}
|
699 |
-
|
700 |
-
|
701 |
-
/**
|
702 |
-
* Returns the widget data as stored in the options table
|
703 |
-
*
|
704 |
-
* @since 1.8.1
|
705 |
-
* @param string $widget_id
|
706 |
-
*/
|
707 |
-
public function get_settings_for_widget_id( $widget_id ) {
|
708 |
-
|
709 |
-
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
710 |
-
|
711 |
-
if ( ! $id_base ) {
|
712 |
-
return false;
|
713 |
-
}
|
714 |
-
|
715 |
-
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
716 |
-
|
717 |
-
$current_widgets = get_option( 'widget_' . $id_base );
|
718 |
-
|
719 |
-
return $current_widgets[ $widget_number ];
|
720 |
-
|
721 |
-
}
|
722 |
-
|
723 |
-
/**
|
724 |
-
* Returns the widget ID (number)
|
725 |
-
*
|
726 |
-
* @since 1.0
|
727 |
-
* @param string $widget_id - id_base-ID (eg meta-3)
|
728 |
-
* @return int
|
729 |
-
*/
|
730 |
-
public function get_widget_number_for_widget_id( $widget_id ) {
|
731 |
-
|
732 |
-
$parts = explode( "-", $widget_id );
|
733 |
-
|
734 |
-
return absint( end( $parts ) );
|
735 |
-
|
736 |
-
}
|
737 |
-
|
738 |
-
/**
|
739 |
-
* Returns the name/title of a Widget
|
740 |
-
*
|
741 |
-
* @since 1.0
|
742 |
-
* @param $widget_id - id_base-ID (eg meta-3)
|
743 |
-
* @return string e.g. "Custom HTML" or "Text"
|
744 |
-
*/
|
745 |
-
public function get_name_for_widget_id( $widget_id ) {
|
746 |
-
global $wp_registered_widgets;
|
747 |
-
|
748 |
-
if ( ! isset( $wp_registered_widgets[$widget_id] ) ) {
|
749 |
-
return false;
|
750 |
-
}
|
751 |
-
|
752 |
-
$registered_widget = $wp_registered_widgets[$widget_id];
|
753 |
-
|
754 |
-
return $registered_widget['name'];
|
755 |
-
|
756 |
-
}
|
757 |
-
|
758 |
-
|
759 |
-
/**
|
760 |
-
* Returns the title of a Widget
|
761 |
-
*
|
762 |
-
* @since 2.4
|
763 |
-
* @param $widget_id - id_base-ID (eg meta-3)
|
764 |
-
*/
|
765 |
-
public function get_title_for_widget_id( $widget_id ) {
|
766 |
-
$instance = $this->get_settings_for_widget_id( $widget_id );
|
767 |
-
|
768 |
-
if ( isset( $instance['title'] ) && strlen( $instance['title'] ) ) {
|
769 |
-
return $instance['title'];
|
770 |
-
}
|
771 |
-
|
772 |
-
return $this->get_name_for_widget_id( $widget_id );
|
773 |
-
|
774 |
-
}
|
775 |
-
|
776 |
-
/**
|
777 |
-
* Returns the id_base value for a Widget ID
|
778 |
-
*
|
779 |
-
* @since 1.0
|
780 |
-
*/
|
781 |
-
public function get_id_base_for_widget_id( $widget_id ) {
|
782 |
-
global $wp_registered_widget_controls;
|
783 |
-
|
784 |
-
if ( ! isset( $wp_registered_widget_controls[ $widget_id ] ) ) {
|
785 |
-
return false;
|
786 |
-
}
|
787 |
-
|
788 |
-
$control = $wp_registered_widget_controls[ $widget_id ];
|
789 |
-
|
790 |
-
$id_base = isset( $control['id_base'] ) ? $control['id_base'] : $control['id'];
|
791 |
-
|
792 |
-
return $id_base;
|
793 |
-
|
794 |
-
}
|
795 |
|
796 |
-
/**
|
797 |
-
* Returns the HTML for a single widget instance.
|
798 |
-
*
|
799 |
-
* @since 1.0
|
800 |
-
* @param string widget_id Something like meta-3
|
801 |
-
*/
|
802 |
-
public function show_widget( $id ) {
|
803 |
-
global $wp_registered_widgets;
|
804 |
-
|
805 |
-
$params = array_merge(
|
806 |
-
array( array_merge( array( 'widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name'] ) ) ),
|
807 |
-
(array) $wp_registered_widgets[$id]['params']
|
808 |
-
);
|
809 |
-
|
810 |
-
$params[0]['id'] = 'mega-menu';
|
811 |
-
$params[0]['before_title'] = apply_filters( "megamenu_before_widget_title", '<h4 class="mega-block-title">', $wp_registered_widgets[$id] );
|
812 |
-
$params[0]['after_title'] = apply_filters( "megamenu_after_widget_title", '</h4>', $wp_registered_widgets[$id] );
|
813 |
-
$params[0]['before_widget'] = apply_filters( "megamenu_before_widget", "", $wp_registered_widgets[$id] );
|
814 |
-
$params[0]['after_widget'] = apply_filters( "megamenu_after_widget", "", $wp_registered_widgets[$id] );
|
815 |
-
|
816 |
-
if ( defined("MEGAMENU_DYNAMIC_SIDEBAR_PARAMS") && MEGAMENU_DYNAMIC_SIDEBAR_PARAMS ) {
|
817 |
-
$params[0]['before_widget'] = apply_filters( "megamenu_before_widget", '<div id="" class="">', $wp_registered_widgets[$id] );
|
818 |
-
$params[0]['after_widget'] = apply_filters( "megamenu_after_widget", '</div>', $wp_registered_widgets[$id] );
|
819 |
-
|
820 |
-
$params = apply_filters('dynamic_sidebar_params', $params);
|
821 |
-
}
|
822 |
-
|
823 |
-
$callback = $wp_registered_widgets[$id]['callback'];
|
824 |
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
|
|
|
|
|
|
830 |
|
831 |
-
|
832 |
|
|
|
833 |
|
834 |
-
|
835 |
-
* Returns the class name for a widget instance.
|
836 |
-
*
|
837 |
-
* @since 1.8.1
|
838 |
-
* @param string widget_id Something like meta-3
|
839 |
-
*/
|
840 |
-
public function get_widget_class( $id ) {
|
841 |
-
global $wp_registered_widgets;
|
842 |
|
843 |
-
|
844 |
-
|
845 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
|
847 |
-
|
848 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
849 |
|
850 |
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
863 |
-
|
864 |
-
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
865 |
-
|
866 |
-
$nonce = wp_create_nonce('megamenu_save_widget_' . $widget_id);
|
867 |
-
|
868 |
-
?>
|
869 |
-
|
870 |
-
<form method='post'>
|
871 |
-
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr( $widget_id ); ?>" />
|
872 |
-
<input type='hidden' name='action' value='mm_save_widget' />
|
873 |
-
<input type='hidden' name='id_base' class="id_base" value='<?php echo esc_attr( $id_base ); ?>' />
|
874 |
-
<input type='hidden' name='widget_id' value='<?php echo esc_attr( $widget_id ) ?>' />
|
875 |
-
<input type='hidden' name='_wpnonce' value='<?php echo esc_attr( $nonce ) ?>' />
|
876 |
-
<div class='widget-content'>
|
877 |
-
<?php
|
878 |
-
if ( is_callable( $control['callback'] ) ) {
|
879 |
-
call_user_func_array( $control['callback'], $control['params'] );
|
880 |
-
}
|
881 |
-
?>
|
882 |
-
|
883 |
-
<div class='widget-controls'>
|
884 |
-
<a class='delete' href='#delete'><?php _e("Delete", "megamenu"); ?></a> |
|
885 |
-
<a class='close' href='#close'><?php _e("Close", "megamenu"); ?></a>
|
886 |
-
</div>
|
887 |
|
888 |
-
|
889 |
-
submit_button( __( 'Save' ), 'button-primary alignright', 'savewidget', false );
|
890 |
-
?>
|
891 |
-
</div>
|
892 |
-
</form>
|
893 |
-
|
894 |
-
|
895 |
-
<?php
|
896 |
-
}
|
897 |
-
|
898 |
-
|
899 |
-
/**
|
900 |
-
* Saves a widget. Calls the update callback on the widget.
|
901 |
-
* The callback inspects the post values and updates all widget instances which match the base ID.
|
902 |
-
*
|
903 |
-
* @since 1.0
|
904 |
-
* @param string $id_base - e.g. 'meta'
|
905 |
-
* @return bool
|
906 |
-
*/
|
907 |
-
public function save_widget( $id_base ) {
|
908 |
-
global $wp_registered_widget_updates;
|
909 |
-
|
910 |
-
$control = $wp_registered_widget_updates[$id_base];
|
911 |
-
|
912 |
-
if ( is_callable( $control['callback'] ) ) {
|
913 |
-
|
914 |
-
call_user_func_array( $control['callback'], $control['params'] );
|
915 |
|
916 |
-
|
917 |
|
918 |
-
|
919 |
-
}
|
920 |
|
921 |
-
|
922 |
|
923 |
-
|
|
|
924 |
|
|
|
925 |
|
926 |
-
|
927 |
-
* Adds a widget to WordPress. First creates a new widget instance, then
|
928 |
-
* adds the widget instance to the mega menu widget sidebar area.
|
929 |
-
*
|
930 |
-
* @since 1.0
|
931 |
-
* @param string $id_base
|
932 |
-
* @param int $menu_item_id
|
933 |
-
* @param string $title
|
934 |
-
*/
|
935 |
-
public function add_widget( $id_base, $menu_item_id, $title, $is_grid_widget ) {
|
936 |
|
937 |
-
require_once( ABSPATH . 'wp-admin/includes/widgets.php' );
|
938 |
|
939 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
940 |
|
941 |
-
|
942 |
|
943 |
-
|
944 |
|
945 |
-
|
946 |
-
$return .= ' <div class="widget-top">';
|
947 |
-
$return .= ' <div class="widget-title-action">';
|
948 |
|
949 |
-
|
950 |
-
$return .= ' <a class="widget-option widget-contract" title="' . esc_attr( __("Contract", "megamenu") ) . '"></a>';
|
951 |
-
$return .= ' <span class="widget-cols"><span class="widget-num-cols">2</span><span class="widget-of">/</span><span class="widget-total-cols">X</span></span>';
|
952 |
-
$return .= ' <a class="widget-option widget-expand" title="' . esc_attr( __("Expand", "megamenu") ) . '"></a>';
|
953 |
-
}
|
954 |
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
$return .= ' <h4>' . esc_html( $title ) . '</h4>';
|
959 |
-
|
960 |
-
if ( $is_grid_widget ) {
|
961 |
-
$return .= ' <span class="widget-desc">' . esc_html( $title ) . '</span>';
|
962 |
-
}
|
963 |
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
|
|
968 |
|
969 |
-
|
|
|
|
|
|
|
970 |
|
971 |
-
|
|
|
|
|
972 |
|
|
|
|
|
|
|
|
|
973 |
|
974 |
-
|
975 |
-
* Adds a new widget instance of the specified base ID to the database.
|
976 |
-
*
|
977 |
-
* @since 1.0
|
978 |
-
* @param string $id_base
|
979 |
-
* @param int $next_id
|
980 |
-
* @param int $menu_item_id
|
981 |
-
*/
|
982 |
-
private function add_widget_instance( $id_base, $next_id, $menu_item_id, $is_grid_widget ) {
|
983 |
|
984 |
-
|
985 |
|
986 |
-
$current_widgets[ $next_id ] = array(
|
987 |
-
"mega_menu_columns" => 2,
|
988 |
-
"mega_menu_parent_menu_id" => $menu_item_id
|
989 |
-
);
|
990 |
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
|
|
|
|
|
|
|
|
996 |
|
997 |
-
|
998 |
|
999 |
-
|
|
|
|
|
|
|
1000 |
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
* @return bool. True if widget has been deleted.
|
1007 |
-
*/
|
1008 |
-
private function remove_widget_instance( $widget_id ) {
|
1009 |
|
1010 |
-
|
1011 |
-
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1012 |
|
1013 |
-
|
1014 |
-
$current_widgets = get_option( 'widget_' . $id_base );
|
1015 |
|
1016 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1017 |
|
1018 |
-
|
|
|
1019 |
|
1020 |
-
|
|
|
1021 |
|
1022 |
-
|
1023 |
|
1024 |
-
|
1025 |
|
1026 |
-
|
1027 |
|
1028 |
-
|
1029 |
|
|
|
1030 |
|
1031 |
-
|
1032 |
-
* Updates the number of mega columns for a specified widget.
|
1033 |
-
*
|
1034 |
-
* @since 1.0
|
1035 |
-
* @param string $widget_id
|
1036 |
-
* @param int $columns
|
1037 |
-
*/
|
1038 |
-
public function update_widget_columns( $widget_id, $columns ) {
|
1039 |
|
1040 |
-
|
1041 |
|
1042 |
-
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1043 |
|
1044 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1045 |
|
1046 |
-
|
1047 |
|
1048 |
-
|
1049 |
|
1050 |
-
|
1051 |
|
1052 |
-
|
1053 |
|
1054 |
-
|
1055 |
|
|
|
1056 |
|
1057 |
-
|
1058 |
-
* Updates the number of mega columns for a specified widget.
|
1059 |
-
*
|
1060 |
-
* @since 1.10
|
1061 |
-
* @param string $menu_item_id
|
1062 |
-
* @param int $columns
|
1063 |
-
*/
|
1064 |
-
public function update_menu_item_columns( $menu_item_id, $columns ) {
|
1065 |
|
1066 |
-
|
1067 |
|
1068 |
-
$submitted_settings = array(
|
1069 |
-
'mega_menu_columns' => absint( $columns )
|
1070 |
-
);
|
1071 |
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
|
|
|
|
|
|
|
|
|
|
1075 |
|
1076 |
-
|
1077 |
|
1078 |
-
|
|
|
|
|
1079 |
|
1080 |
-
|
|
|
|
|
1081 |
|
|
|
1082 |
|
1083 |
-
|
1084 |
-
* Updates the order of a specified widget.
|
1085 |
-
*
|
1086 |
-
* @since 1.10
|
1087 |
-
* @param string $widget_id
|
1088 |
-
* @param int $columns
|
1089 |
-
*/
|
1090 |
-
public function update_widget_order( $widget_id, $order, $parent_menu_item_id ) {
|
1091 |
|
1092 |
-
|
1093 |
|
1094 |
-
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1095 |
|
1096 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1097 |
|
1098 |
-
|
1099 |
|
1100 |
-
|
1101 |
|
1102 |
-
|
1103 |
|
1104 |
-
|
1105 |
|
|
|
1106 |
|
1107 |
-
|
1108 |
-
* Updates the order of a specified menu item.
|
1109 |
-
*
|
1110 |
-
* @since 1.10
|
1111 |
-
* @param string $menu_item_id
|
1112 |
-
* @param int $order
|
1113 |
-
*/
|
1114 |
-
public function update_menu_item_order( $menu_item_id, $order, $parent_menu_item_id ) {
|
1115 |
|
1116 |
-
|
1117 |
|
1118 |
-
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true);
|
1119 |
|
1120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1121 |
|
1122 |
-
|
1123 |
|
1124 |
-
|
1125 |
|
1126 |
-
|
1127 |
|
1128 |
-
|
1129 |
|
1130 |
-
|
1131 |
|
|
|
1132 |
|
1133 |
-
|
1134 |
-
* Deletes a widget from WordPress
|
1135 |
-
*
|
1136 |
-
* @since 1.0
|
1137 |
-
* @param string $widget_id e.g. meta-3
|
1138 |
-
*/
|
1139 |
-
public function delete_widget( $widget_id ) {
|
1140 |
|
1141 |
-
|
1142 |
-
$this->remove_widget_instance( $widget_id );
|
1143 |
|
1144 |
-
do_action( "megamenu_after_widget_delete" );
|
1145 |
|
1146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1147 |
|
1148 |
-
|
|
|
1149 |
|
|
|
1150 |
|
1151 |
-
|
1152 |
-
* Moves a widget from one position to another.
|
1153 |
-
*
|
1154 |
-
* @since 1.10
|
1155 |
-
* @param array $items
|
1156 |
-
* @return string $widget_id. The widget that has been moved.
|
1157 |
-
*/
|
1158 |
-
public function reorder_items( $items ) {
|
1159 |
|
1160 |
-
|
1161 |
|
1162 |
-
if ( $item['parent_menu_item'] ) {
|
1163 |
|
1164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1165 |
|
1166 |
-
|
1167 |
|
1168 |
-
|
1169 |
|
1170 |
-
|
1171 |
|
1172 |
-
|
1173 |
|
1174 |
-
|
1175 |
-
}
|
1176 |
|
1177 |
-
|
1178 |
|
1179 |
-
|
1180 |
|
1181 |
-
|
|
|
1182 |
|
1183 |
-
|
1184 |
|
1185 |
-
|
1186 |
|
1187 |
-
|
1188 |
|
1189 |
-
|
1190 |
|
1191 |
-
|
1192 |
|
1193 |
-
|
|
|
1194 |
|
|
|
1195 |
|
1196 |
-
|
1197 |
-
* Adds a widget to the Mega Menu widget sidebar
|
1198 |
-
*
|
1199 |
-
* @since 1.0
|
1200 |
-
*/
|
1201 |
-
private function add_widget_to_sidebar( $id_base, $next_id ) {
|
1202 |
|
1203 |
-
$widget_id = $id_base . '-' . $next_id;
|
1204 |
|
1205 |
-
|
|
|
|
|
|
|
|
|
|
|
1206 |
|
1207 |
-
|
1208 |
|
1209 |
-
|
1210 |
|
1211 |
-
|
1212 |
|
1213 |
-
|
1214 |
|
1215 |
-
|
1216 |
|
|
|
1217 |
|
1218 |
-
|
1219 |
-
* Removes a widget from the Mega Menu widget sidebar
|
1220 |
-
*
|
1221 |
-
* @since 1.0
|
1222 |
-
* @return string The widget that was removed
|
1223 |
-
*/
|
1224 |
-
private function remove_widget_from_sidebar($widget_id) {
|
1225 |
|
1226 |
-
$widgets = $this->get_mega_menu_sidebar_widgets();
|
1227 |
|
1228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1229 |
|
1230 |
-
|
1231 |
|
1232 |
-
|
1233 |
-
$new_mega_menu_widgets[] = $widget;
|
1234 |
|
1235 |
-
|
1236 |
|
1237 |
-
|
|
|
|
|
|
|
1238 |
|
1239 |
-
|
1240 |
|
1241 |
-
|
1242 |
|
|
|
1243 |
|
1244 |
-
/**
|
1245 |
-
* Returns an unfiltered array of all widgets in our sidebar
|
1246 |
-
*
|
1247 |
-
* @since 1.0
|
1248 |
-
* @return array
|
1249 |
-
*/
|
1250 |
-
public function get_mega_menu_sidebar_widgets() {
|
1251 |
|
1252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1253 |
|
1254 |
-
|
1255 |
-
return false;
|
1256 |
-
}
|
1257 |
|
1258 |
-
|
|
|
|
|
1259 |
|
1260 |
-
|
1261 |
|
|
|
1262 |
|
1263 |
-
/**
|
1264 |
-
* Sets the sidebar widgets
|
1265 |
-
*
|
1266 |
-
* @since 1.0
|
1267 |
-
*/
|
1268 |
-
private function set_mega_menu_sidebar_widgets( $widgets ) {
|
1269 |
|
1270 |
-
|
|
|
|
|
|
|
|
|
|
|
1271 |
|
1272 |
-
|
1273 |
|
1274 |
-
|
1275 |
|
1276 |
-
|
1277 |
|
|
|
1278 |
|
1279 |
-
/**
|
1280 |
-
* Clear the cache when the Mega Menu is updated.
|
1281 |
-
*
|
1282 |
-
* @since 1.0
|
1283 |
-
*/
|
1284 |
-
public function clear_caches() {
|
1285 |
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
|
|
|
|
1290 |
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
|
1296 |
-
|
|
|
|
|
|
|
1297 |
|
|
|
1298 |
|
1299 |
-
/**
|
1300 |
-
* Send JSON response.
|
1301 |
-
*
|
1302 |
-
* Remove any warnings or output from other plugins which may corrupt the response
|
1303 |
-
*
|
1304 |
-
* @param string $json
|
1305 |
-
* @since 1.8
|
1306 |
-
*/
|
1307 |
-
public function send_json_success( $json ) {
|
1308 |
-
if ( ob_get_contents() ) ob_clean();
|
1309 |
|
1310 |
-
|
1311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1312 |
|
|
|
|
|
1313 |
|
1314 |
-
/**
|
1315 |
-
* Send JSON response.
|
1316 |
-
*
|
1317 |
-
* Remove any warnings or output from other plugins which may corrupt the response
|
1318 |
-
*
|
1319 |
-
* @param string $json
|
1320 |
-
* @since 1.8
|
1321 |
-
*/
|
1322 |
-
public function send_json_error( $json ) {
|
1323 |
-
if ( ob_get_contents() ) ob_clean();
|
1324 |
|
1325 |
-
|
1326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1327 |
|
1328 |
-
|
|
|
|
|
|
|
1329 |
|
1330 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Widget_Manager' ) ) :
|
8 |
|
9 |
+
/**
|
10 |
+
* Processes AJAX requests from the Mega Menu panel editor.
|
11 |
+
* Also registers our widget sidebar.
|
12 |
+
*
|
13 |
+
* There is very little in WordPress core to help with listing, editing, saving,
|
14 |
+
* deleting widgets etc so this class implements that functionality.
|
15 |
+
*/
|
16 |
+
class Mega_Menu_Widget_Manager {
|
17 |
|
18 |
+
/**
|
19 |
+
* Constructor
|
20 |
+
*
|
21 |
+
* @since 1.0
|
22 |
+
*/
|
23 |
+
public function __construct() {
|
24 |
|
25 |
+
add_action( 'wp_ajax_mm_edit_widget', array( $this, 'ajax_show_widget_form' ) );
|
26 |
+
add_action( 'wp_ajax_mm_edit_menu_item', array( $this, 'ajax_show_menu_item_form' ) );
|
27 |
+
add_action( 'wp_ajax_mm_save_widget', array( $this, 'ajax_save_widget' ) );
|
28 |
+
add_action( 'wp_ajax_mm_save_menu_item', array( $this, 'ajax_save_menu_item' ) );
|
29 |
+
add_action( 'wp_ajax_mm_update_widget_columns', array( $this, 'ajax_update_widget_columns' ) );
|
30 |
+
add_action( 'wp_ajax_mm_update_menu_item_columns', array( $this, 'ajax_update_menu_item_columns' ) );
|
31 |
+
add_action( 'wp_ajax_mm_delete_widget', array( $this, 'ajax_delete_widget' ) );
|
32 |
+
add_action( 'wp_ajax_mm_add_widget', array( $this, 'ajax_add_widget' ) );
|
33 |
+
add_action( 'wp_ajax_mm_reorder_items', array( $this, 'ajax_reorder_items' ) );
|
34 |
+
add_action( 'wp_ajax_mm_save_grid_data', array( $this, 'ajax_save_grid_data' ) );
|
35 |
|
36 |
+
add_filter( 'widget_update_callback', array( $this, 'persist_mega_menu_widget_settings' ), 10, 4 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
add_action( 'megamenu_after_widget_add', array( $this, 'clear_caches' ) );
|
39 |
+
add_action( 'megamenu_after_widget_save', array( $this, 'clear_caches' ) );
|
40 |
+
add_action( 'megamenu_after_widget_delete', array( $this, 'clear_caches' ) );
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Depending on how a widget has been written, it may not necessarily base the new widget settings on
|
47 |
+
* a copy the old settings. If this is the case, the mega menu data will be lost. This function
|
48 |
+
* checks to make sure widgets persist the mega menu data when they're saved.
|
49 |
+
*
|
50 |
+
* @since 1.0
|
51 |
+
*/
|
52 |
+
public function persist_mega_menu_widget_settings( $instance, $new_instance, $old_instance, $that ) {
|
53 |
+
|
54 |
+
if ( isset( $old_instance['mega_menu_columns'] ) && ! isset( $new_instance['mega_menu_columns'] ) ) {
|
55 |
+
$instance['mega_menu_columns'] = $old_instance['mega_menu_columns'];
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( isset( $old_instance['mega_menu_order'] ) && ! isset( $new_instance['mega_menu_order'] ) ) {
|
59 |
+
$instance['mega_menu_order'] = $old_instance['mega_menu_order'];
|
60 |
+
}
|
61 |
+
|
62 |
+
if ( isset( $old_instance['mega_menu_parent_menu_id'] ) && ! isset( $new_instance['mega_menu_parent_menu_id'] ) ) {
|
63 |
+
$instance['mega_menu_parent_menu_id'] = $old_instance['mega_menu_parent_menu_id'];
|
64 |
+
}
|
65 |
+
|
66 |
+
return $instance;
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Display a widget settings form
|
72 |
+
*
|
73 |
+
* @since 1.0
|
74 |
+
*/
|
75 |
+
public function ajax_show_widget_form() {
|
76 |
|
77 |
+
check_ajax_referer( 'megamenu_edit' );
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
$widget_id = sanitize_text_field( $_POST['widget_id'] );
|
80 |
|
81 |
+
if ( ob_get_contents() ) {
|
82 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
83 |
+
}
|
84 |
|
85 |
+
wp_die( trim( $this->show_widget_form( $widget_id ) ) );
|
86 |
|
87 |
+
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Display a menu item settings form
|
91 |
+
*
|
92 |
+
* @since 2.7
|
93 |
+
*/
|
94 |
+
public function ajax_show_menu_item_form() {
|
95 |
|
96 |
+
check_ajax_referer( 'megamenu_edit' );
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
$menu_item_id = sanitize_text_field( $_POST['widget_id'] );
|
99 |
|
100 |
+
$nonce = wp_create_nonce( 'megamenu_save_menu_item_' . $menu_item_id );
|
101 |
|
102 |
+
$saved_settings = array_filter( (array) get_post_meta( $menu_item_id, '_megamenu', true ) );
|
103 |
+
$menu_item_meta = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
104 |
|
105 |
+
if ( ob_get_contents() ) {
|
106 |
+
ob_clean(); // remove any warnings or output from other plugins which may corrupt the response
|
107 |
+
}
|
108 |
+
?>
|
109 |
|
110 |
+
<form method='post'>
|
111 |
+
<input type='hidden' name='action' value='mm_save_menu_item' />
|
112 |
+
<input type='hidden' name='menu_item_id' value='<?php echo esc_attr( $menu_item_id ); ?>' />
|
113 |
+
<input type='hidden' name='_wpnonce' value='<?php echo esc_attr( $nonce ); ?>' />
|
114 |
+
<div class='widget-content'>
|
115 |
+
<?php
|
116 |
|
117 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
+
if ( $css_version && version_compare( $css_version, '2.6.1', '<' ) ) {
|
120 |
+
$link = "<a href='" . esc_attr( admin_url( 'admin.php?page=maxmegamenu_tools' ) ) . "'>" . __( 'Mega Menu' ) . ' > ' . __( 'Tools' ) . '</a>';
|
121 |
+
$notice = "<div class='notice notice-success'><p>";
|
122 |
+
$notice .= sprintf( __( 'Your menu CSS needs to be updated before you can use the following setting. Please go to %s and Clear the CSS Cache (you will only need to do this once).', 'megamenu' ), $link );
|
123 |
+
$notice .= '</p></div>';
|
124 |
+
$notice .= '</div>';
|
125 |
|
126 |
+
echo $notice;
|
127 |
+
}
|
128 |
|
129 |
+
?>
|
130 |
|
131 |
+
<p>
|
132 |
+
<label><?php _e( 'Sub menu columns', 'megamenu' ); ?></label>
|
133 |
|
134 |
+
<select name="settings[submenu_columns]">
|
135 |
+
<option value='1' <?php selected( $menu_item_meta['submenu_columns'], 1, true ); ?> >1 <?php __( 'column', 'megamenu' ); ?></option>
|
136 |
+
<option value='2' <?php selected( $menu_item_meta['submenu_columns'], 2, true ); ?> >2 <?php __( 'columns', 'megamenu' ); ?></option>
|
137 |
+
<option value='3' <?php selected( $menu_item_meta['submenu_columns'], 3, true ); ?> >3 <?php __( 'columns', 'megamenu' ); ?></option>
|
138 |
+
<option value='4' <?php selected( $menu_item_meta['submenu_columns'], 4, true ); ?> >4 <?php __( 'columns', 'megamenu' ); ?></option>
|
139 |
+
<option value='5' <?php selected( $menu_item_meta['submenu_columns'], 5, true ); ?> >5 <?php __( 'columns', 'megamenu' ); ?></option>
|
140 |
+
<option value='6' <?php selected( $menu_item_meta['submenu_columns'], 6, true ); ?> >6 <?php __( 'columns', 'megamenu' ); ?></option>
|
141 |
+
</select>
|
142 |
+
</p>
|
143 |
+
<p>
|
144 |
+
<div class='widget-controls'>
|
145 |
+
<a class='close' href='#close'><?php _e( 'Close', 'megamenu' ); ?></a>
|
146 |
+
</div>
|
147 |
|
148 |
+
<?php
|
149 |
+
submit_button( __( 'Save' ), 'button-primary alignright', 'savewidget', false );
|
150 |
+
?>
|
151 |
+
</p>
|
152 |
+
</div>
|
153 |
+
</form>
|
154 |
|
155 |
+
<?php
|
156 |
|
157 |
+
}
|
158 |
|
159 |
+
/**
|
160 |
+
* Save a menu item
|
161 |
+
*
|
162 |
+
* @since 2.7
|
163 |
+
*/
|
164 |
+
public function ajax_save_menu_item() {
|
165 |
|
166 |
+
$menu_item_id = absint( sanitize_text_field( $_POST['menu_item_id'] ) );
|
167 |
|
168 |
+
check_ajax_referer( 'megamenu_save_menu_item_' . $menu_item_id );
|
169 |
|
170 |
+
$submitted_settings = isset( $_POST['settings'] ) ? $_POST['settings'] : array();
|
171 |
|
172 |
+
if ( $menu_item_id > 0 && is_array( $submitted_settings ) ) {
|
173 |
|
174 |
+
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true );
|
175 |
|
176 |
+
if ( is_array( $existing_settings ) ) {
|
177 |
+
$submitted_settings = array_merge( $existing_settings, $submitted_settings );
|
178 |
+
}
|
179 |
|
180 |
+
update_post_meta( $menu_item_id, '_megamenu', $submitted_settings );
|
181 |
+
}
|
182 |
|
183 |
+
$this->send_json_success( sprintf( __( 'Saved %s', 'megamenu' ), $id_base ) );
|
184 |
|
185 |
+
}
|
186 |
|
187 |
|
188 |
+
/**
|
189 |
+
* Save a widget
|
190 |
+
*
|
191 |
+
* @since 1.0
|
192 |
+
*/
|
193 |
+
public function ajax_save_widget() {
|
194 |
|
195 |
+
$widget_id = sanitize_text_field( $_POST['widget_id'] );
|
196 |
+
$id_base = sanitize_text_field( $_POST['id_base'] );
|
197 |
|
198 |
+
check_ajax_referer( 'megamenu_save_widget_' . $widget_id );
|
199 |
|
200 |
+
$saved = $this->save_widget( $id_base );
|
201 |
|
202 |
+
if ( $saved ) {
|
203 |
+
$this->send_json_success( sprintf( __( 'Saved %s', 'megamenu' ), $id_base ) );
|
204 |
+
} else {
|
205 |
+
$this->send_json_error( sprintf( __( 'Failed to save %s', 'megamenu' ), $id_base ) );
|
206 |
+
}
|
207 |
|
208 |
+
}
|
209 |
|
210 |
|
211 |
+
/**
|
212 |
+
* Update the number of mega columns for a widget
|
213 |
+
*
|
214 |
+
* @since 1.0
|
215 |
+
*/
|
216 |
+
public function ajax_update_widget_columns() {
|
217 |
|
218 |
+
check_ajax_referer( 'megamenu_edit' );
|
219 |
|
220 |
+
$widget_id = sanitize_text_field( $_POST['id'] );
|
221 |
+
$columns = absint( $_POST['columns'] );
|
222 |
|
223 |
+
$updated = $this->update_widget_columns( $widget_id, $columns );
|
224 |
|
225 |
+
if ( $updated ) {
|
226 |
+
$this->send_json_success( sprintf( __( 'Updated %1$s (new columns: %2$d)', 'megamenu' ), $widget_id, $columns ) );
|
227 |
+
} else {
|
228 |
+
$this->send_json_error( sprintf( __( 'Failed to update %s', 'megamenu' ), $widget_id ) );
|
229 |
+
}
|
230 |
|
231 |
+
}
|
232 |
|
233 |
|
234 |
+
/**
|
235 |
+
* Update the number of mega columns for a widget
|
236 |
+
*
|
237 |
+
* @since 1.0
|
238 |
+
*/
|
239 |
+
public function ajax_update_menu_item_columns() {
|
240 |
|
241 |
+
check_ajax_referer( 'megamenu_edit' );
|
242 |
|
243 |
+
$id = absint( $_POST['id'] );
|
244 |
+
$columns = absint( $_POST['columns'] );
|
245 |
|
246 |
+
$updated = $this->update_menu_item_columns( $id, $columns );
|
247 |
|
248 |
+
if ( $updated ) {
|
249 |
+
$this->send_json_success( sprintf( __( 'Updated %1$s (new columns: %2$d)', 'megamenu' ), $id, $columns ) );
|
250 |
+
} else {
|
251 |
+
$this->send_json_error( sprintf( __( 'Failed to update %s', 'megamenu' ), $id ) );
|
252 |
+
}
|
253 |
|
254 |
+
}
|
255 |
|
256 |
|
257 |
+
/**
|
258 |
+
* Add a widget to the panel
|
259 |
+
*
|
260 |
+
* @since 1.0
|
261 |
+
*/
|
262 |
+
public function ajax_add_widget() {
|
263 |
|
264 |
+
check_ajax_referer( 'megamenu_edit' );
|
265 |
|
266 |
+
$id_base = sanitize_text_field( $_POST['id_base'] );
|
267 |
+
$menu_item_id = absint( $_POST['menu_item_id'] );
|
268 |
+
$title = sanitize_text_field( $_POST['title'] );
|
269 |
+
$is_grid_widget = isset( $_POST['is_grid_widget'] ) && $_POST['is_grid_widget'] == 'true';
|
270 |
|
271 |
+
$added = $this->add_widget( $id_base, $menu_item_id, $title, $is_grid_widget );
|
272 |
|
273 |
+
if ( $added ) {
|
274 |
+
$this->send_json_success( $added );
|
275 |
+
} else {
|
276 |
+
$this->send_json_error( sprintf( __( 'Failed to add %1$s to %2$d', 'megamenu' ), $id_base, $menu_item_id ) );
|
277 |
+
}
|
278 |
|
279 |
+
}
|
280 |
|
281 |
|
282 |
+
/**
|
283 |
+
* Deletes a widget
|
284 |
+
*
|
285 |
+
* @since 1.0
|
286 |
+
*/
|
287 |
+
public function ajax_delete_widget() {
|
288 |
|
289 |
+
check_ajax_referer( 'megamenu_edit' );
|
290 |
|
291 |
+
$widget_id = sanitize_text_field( $_POST['widget_id'] );
|
292 |
|
293 |
+
$deleted = $this->delete_widget( $widget_id );
|
294 |
|
295 |
+
if ( $deleted ) {
|
296 |
+
$this->send_json_success( sprintf( __( 'Deleted %s', 'megamenu' ), $widget_id ) );
|
297 |
+
} else {
|
298 |
+
$this->send_json_error( sprintf( __( 'Failed to delete %s', 'megamenu' ), $widget_id ) );
|
299 |
+
}
|
300 |
|
301 |
+
}
|
302 |
|
303 |
|
304 |
+
/**
|
305 |
+
* Moves a widget to a new position
|
306 |
+
*
|
307 |
+
* @since 1.0
|
308 |
+
*/
|
309 |
+
public function ajax_reorder_items() {
|
310 |
|
311 |
+
check_ajax_referer( 'megamenu_edit' );
|
312 |
|
313 |
+
$items = isset( $_POST['items'] ) ? $_POST['items'] : false;
|
314 |
|
315 |
+
$saved = false;
|
316 |
|
317 |
+
if ( $items ) {
|
318 |
+
$moved = $this->reorder_items( $items );
|
319 |
+
}
|
320 |
|
321 |
+
if ( $moved ) {
|
322 |
+
$this->send_json_success( sprintf( __( 'Moved (%s)', 'megamenu' ), json_encode( $items ) ) );
|
323 |
+
} else {
|
324 |
+
$this->send_json_error( sprintf( __( "Didn't move items", 'megamenu' ), json_encode( $items ) ) );
|
325 |
+
}
|
326 |
|
327 |
+
}
|
328 |
|
329 |
+
/**
|
330 |
+
* Moves a widget to a new position
|
331 |
+
*
|
332 |
+
* @since 2.4
|
333 |
+
*/
|
334 |
+
public function ajax_save_grid_data() {
|
335 |
|
336 |
+
check_ajax_referer( 'megamenu_edit' );
|
337 |
|
338 |
+
$grid = isset( $_POST['grid'] ) ? $_POST['grid'] : false;
|
339 |
+
$parent_menu_item_id = absint( $_POST['parent_menu_item'] );
|
340 |
|
341 |
+
$saved = true;
|
342 |
|
343 |
+
$existing_settings = get_post_meta( $parent_menu_item_id, '_megamenu', true );
|
344 |
|
345 |
+
if ( is_array( $grid ) ) {
|
346 |
|
347 |
+
$submitted_settings = array_merge( $existing_settings, array( 'grid' => $grid ) );
|
348 |
|
349 |
+
}
|
350 |
|
351 |
+
update_post_meta( $parent_menu_item_id, '_megamenu', $submitted_settings );
|
352 |
|
353 |
+
if ( $saved ) {
|
354 |
+
$this->send_json_success( sprintf( __( 'Saved (%s)', 'megamenu' ), json_encode( $grid ) ) );
|
355 |
+
} else {
|
356 |
+
$this->send_json_error( sprintf( __( "Didn't save", 'megamenu' ), json_encode( $grid ) ) );
|
357 |
+
}
|
358 |
|
359 |
+
}
|
|
|
|
|
|
|
|
|
360 |
|
|
|
361 |
|
362 |
+
/**
|
363 |
+
* Returns an object representing all widgets registered in WordPress
|
364 |
+
*
|
365 |
+
* @since 1.0
|
366 |
+
*/
|
367 |
+
public function get_available_widgets() {
|
368 |
+
global $wp_widget_factory;
|
369 |
|
370 |
+
$widgets = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
+
foreach ( $wp_widget_factory->widgets as $widget ) {
|
373 |
|
374 |
+
$disabled_widgets = array( 'maxmegamenu' );
|
375 |
|
376 |
+
$disabled_widgets = apply_filters( 'megamenu_incompatible_widgets', $disabled_widgets );
|
377 |
|
378 |
+
if ( ! in_array( $widget->id_base, $disabled_widgets ) ) {
|
379 |
|
380 |
+
$widgets[] = array(
|
381 |
+
'text' => $widget->name,
|
382 |
+
'value' => $widget->id_base,
|
383 |
+
);
|
384 |
|
385 |
+
}
|
386 |
+
}
|
|
|
|
|
387 |
|
388 |
+
uasort( $widgets, array( $this, 'sort_by_text' ) );
|
389 |
|
390 |
+
return $widgets;
|
391 |
|
392 |
+
}
|
393 |
|
|
|
394 |
|
395 |
+
/**
|
396 |
+
* Sorts a 2d array by the 'text' key
|
397 |
+
*
|
398 |
+
* @since 1.2
|
399 |
+
* @param array $a
|
400 |
+
* @param array $b
|
401 |
+
*/
|
402 |
+
function sort_by_text( $a, $b ) {
|
403 |
+
return strcmp( $a['text'], $b['text'] );
|
404 |
+
}
|
405 |
|
406 |
|
407 |
+
/**
|
408 |
+
* Sorts a 2d array by the 'order' key
|
409 |
+
*
|
410 |
+
* @since 2.0
|
411 |
+
* @param array $a
|
412 |
+
* @param array $b
|
413 |
+
*/
|
414 |
+
function sort_by_order( $a, $b ) {
|
|
|
|
|
415 |
|
416 |
+
if ( $a['order'] == $b['order'] ) {
|
417 |
+
return 1;
|
418 |
+
}
|
419 |
+
return ( $a['order'] < $b['order'] ) ? -1 : 1;
|
420 |
|
421 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
|
|
|
|
|
|
|
|
|
423 |
|
424 |
+
/**
|
425 |
+
* Returns an array of immediate child menu items for the current item
|
426 |
+
*
|
427 |
+
* @since 1.5
|
428 |
+
* @return array
|
429 |
+
*/
|
430 |
+
private function get_second_level_menu_items( $parent_menu_item_id, $menu_id, $menu_items = false ) {
|
431 |
|
432 |
+
$second_level_items = array();
|
433 |
|
434 |
+
// check we're using a valid menu ID
|
435 |
+
if ( ! is_nav_menu( $menu_id ) ) {
|
436 |
+
return $second_level_items;
|
437 |
+
}
|
|
|
|
|
|
|
438 |
|
439 |
+
if ( ! $menu_items ) {
|
440 |
+
$menu_items = wp_get_nav_menu_items( $menu_id );
|
441 |
+
}
|
442 |
|
443 |
+
if ( count( $menu_items ) ) {
|
|
|
|
|
|
|
444 |
|
445 |
+
foreach ( $menu_items as $item ) {
|
|
|
|
|
446 |
|
447 |
+
// find the child menu items
|
448 |
+
if ( $item->menu_item_parent == $parent_menu_item_id ) {
|
449 |
|
450 |
+
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
|
451 |
|
452 |
+
$settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
|
|
453 |
|
454 |
+
$second_level_items[ $item->ID ] = array(
|
455 |
+
'id' => $item->ID,
|
456 |
+
'type' => 'menu_item',
|
457 |
+
'title' => $item->title,
|
458 |
+
'columns' => $settings['mega_menu_columns'],
|
459 |
+
'order' => isset( $settings['mega_menu_order'][ $parent_menu_item_id ] ) ? $settings['mega_menu_order'][ $parent_menu_item_id ] : 0,
|
460 |
+
);
|
461 |
|
462 |
+
}
|
463 |
+
}
|
464 |
+
}
|
465 |
|
466 |
+
return $second_level_items;
|
467 |
+
}
|
|
|
|
|
|
|
|
|
|
|
468 |
|
469 |
+
/**
|
470 |
+
* Returns an array of all widgets belonging to a specified menu item ID.
|
471 |
+
*
|
472 |
+
* @since 1.0
|
473 |
+
* @param int $menu_item_id
|
474 |
+
*/
|
475 |
+
public function get_widgets_for_menu_id( $parent_menu_item_id, $menu_id ) {
|
476 |
|
477 |
+
$widgets = array();
|
478 |
|
479 |
+
if ( $mega_menu_widgets = $this->get_mega_menu_sidebar_widgets() ) {
|
480 |
|
481 |
+
foreach ( $mega_menu_widgets as $widget_id ) {
|
|
|
482 |
|
483 |
+
$settings = $this->get_settings_for_widget_id( $widget_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
|
485 |
+
if ( ! isset( $settings['mega_menu_is_grid_widget'] ) && isset( $settings['mega_menu_parent_menu_id'] ) && $settings['mega_menu_parent_menu_id'] == $parent_menu_item_id ) {
|
486 |
|
487 |
+
$name = $this->get_name_for_widget_id( $widget_id );
|
488 |
|
489 |
+
$widgets[ $widget_id ] = array(
|
490 |
+
'id' => $widget_id,
|
491 |
+
'type' => 'widget',
|
492 |
+
'title' => $name,
|
493 |
+
'columns' => $settings['mega_menu_columns'],
|
494 |
+
'order' => isset( $settings['mega_menu_order'][ $parent_menu_item_id ] ) ? $settings['mega_menu_order'][ $parent_menu_item_id ] : 0,
|
495 |
+
);
|
496 |
|
497 |
+
}
|
498 |
+
}
|
499 |
+
}
|
500 |
|
501 |
+
return $widgets;
|
502 |
|
503 |
+
}
|
504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
+
/**
|
507 |
+
* Returns an array of widgets and second level menu items for a specified parent menu item.
|
508 |
+
* Used to display the widgets/menu items in the mega menu builder.
|
509 |
+
*
|
510 |
+
* @since 2.0
|
511 |
+
* @param int $parent_menu_item_id
|
512 |
+
* @param int $menu_id
|
513 |
+
* @return array
|
514 |
+
*/
|
515 |
+
public function get_widgets_and_menu_items_for_menu_id( $parent_menu_item_id, $menu_id ) {
|
516 |
|
517 |
+
$menu_items = $this->get_second_level_menu_items( $parent_menu_item_id, $menu_id );
|
518 |
|
519 |
+
$widgets = $this->get_widgets_for_menu_id( $parent_menu_item_id, $menu_id );
|
520 |
|
521 |
+
$items = array_merge( $menu_items, $widgets );
|
522 |
|
523 |
+
$parent_settings = get_post_meta( $parent_menu_item_id, '_megamenu', true );
|
524 |
|
525 |
+
$ordering = isset( $parent_settings['submenu_ordering'] ) ? $parent_settings['submenu_ordering'] : 'natural';
|
526 |
|
527 |
+
if ( $ordering == 'forced' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
|
529 |
+
uasort( $items, array( $this, 'sort_by_order' ) );
|
530 |
|
531 |
+
$new_items = $items;
|
532 |
+
$end_items = array();
|
533 |
|
534 |
+
foreach ( $items as $key => $value ) {
|
535 |
+
if ( $value['order'] == 0 ) {
|
536 |
+
unset( $new_items[ $key ] );
|
537 |
+
$end_items[] = $value;
|
538 |
+
}
|
539 |
+
}
|
540 |
|
541 |
+
$items = array_merge( $new_items, $end_items );
|
542 |
|
543 |
+
}
|
544 |
|
545 |
+
return $items;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Return a sorted array of grid data representing rows, columns and items within each column.
|
550 |
+
*
|
551 |
+
* @param int $parent_menu_item_id
|
552 |
+
* @param int $menu_id
|
553 |
+
* @since 2.4
|
554 |
+
* @return array
|
555 |
+
*/
|
556 |
+
public function get_grid_widgets_and_menu_items_for_menu_id( $parent_menu_item_id, $menu_id, $menu_items = false ) {
|
557 |
+
|
558 |
+
$meta = get_post_meta( $parent_menu_item_id, '_megamenu', true );
|
559 |
+
|
560 |
+
$saved_grid = array();
|
561 |
+
|
562 |
+
if ( isset( $meta['grid'] ) ) {
|
563 |
+
$saved_grid = $this->populate_saved_grid_data( $parent_menu_item_id, $menu_id, $meta['grid'], $menu_items );
|
564 |
+
} else {
|
565 |
+
// return empty row
|
566 |
+
$saved_grid[0]['columns'][0]['meta']['span'] = 3;
|
567 |
+
$saved_grid = $this->populate_saved_grid_data( $parent_menu_item_id, $menu_id, $saved_grid, $menu_items );
|
568 |
+
|
569 |
+
}
|
570 |
+
|
571 |
+
return $saved_grid;
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Ensure the widgets that are within the grid data still exist and have not been deleted (through the Widgets screen)
|
577 |
+
* Ensure second level menu items saved within the grid data are still actually second level menu itms within the menu structure
|
578 |
+
*
|
579 |
+
* @param $saved_grid - array representing rows, columns and widgets/menu items within each column
|
580 |
+
* @param $second_level_menu_items - array of second level menu items beneath the current menu item
|
581 |
+
* @since 2.4
|
582 |
+
* @return array
|
583 |
+
*/
|
584 |
+
public function populate_saved_grid_data( $parent_menu_item_id, $menu_id, $saved_grid, $menu_items ) {
|
585 |
+
|
586 |
+
$second_level_menu_items = $this->get_second_level_menu_items( $parent_menu_item_id, $menu_id, $menu_items );
|
587 |
+
|
588 |
+
$menu_items_included = array();
|
589 |
+
|
590 |
+
foreach ( $saved_grid as $row => $row_data ) {
|
591 |
+
if ( isset( $row_data['columns'] ) ) {
|
592 |
+
foreach ( $row_data['columns'] as $col => $col_data ) {
|
593 |
+
if ( isset( $col_data['items'] ) ) {
|
594 |
+
foreach ( $col_data['items'] as $key => $item ) {
|
595 |
+
if ( $item['type'] == 'item' ) {
|
596 |
+
$menu_items_included[] = $item['id'];
|
597 |
+
$is_child_of_parent = false;
|
598 |
+
|
599 |
+
foreach ( $second_level_menu_items as $menu_item ) {
|
600 |
+
if ( $menu_item['id'] == $item['id'] ) {
|
601 |
+
$is_child_of_parent = true;
|
602 |
+
}
|
603 |
+
}
|
604 |
+
|
605 |
+
if ( ! $is_child_of_parent ) {
|
606 |
+
unset( $saved_grid[ $row ]['columns'][ $col ]['items'][ $key ] ); // menu item has been deleted or moved
|
607 |
+
}
|
608 |
+
} else {
|
609 |
+
if ( ! $this->get_name_for_widget_id( $item['id'] ) ) {
|
610 |
+
unset( $saved_grid[ $row ]['columns'][ $col ]['items'][ $key ] ); // widget no longer exists
|
611 |
+
}
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
}
|
617 |
+
}
|
618 |
+
|
619 |
+
// Find any second level menu items that have been added to the menu but are not yet within the grid data
|
620 |
+
$orphaned_items = array();
|
621 |
+
|
622 |
+
foreach ( $second_level_menu_items as $menu_item ) {
|
623 |
+
if ( ! in_array( $menu_item['id'], $menu_items_included ) ) {
|
624 |
+
$orphaned_items[] = $menu_item;
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
if ( ! isset( $saved_grid[0]['columns'][0]['items'][0] ) ) {
|
629 |
+
$index = 0; // grid is empty
|
630 |
+
} else {
|
631 |
+
$index = 999; // create new row
|
632 |
+
}
|
633 |
+
|
634 |
+
foreach ( $orphaned_items as $key => $menu_item ) {
|
635 |
+
$saved_grid[ $index ]['columns'][0]['meta']['span'] = 3;
|
636 |
+
$saved_grid[ $index ]['columns'][0]['items'][ $key ] = array(
|
637 |
+
'id' => $menu_item['id'],
|
638 |
+
'type' => 'item',
|
639 |
+
'title' => $menu_item['title'],
|
640 |
+
'description' => __( 'Menu Item', 'megamenu' ),
|
641 |
+
);
|
642 |
+
}
|
643 |
+
|
644 |
+
if ( is_admin() ) {
|
645 |
+
$saved_grid = $this->populate_grid_menu_item_titles( $saved_grid, $menu_id );
|
646 |
+
}
|
647 |
+
|
648 |
+
return $saved_grid;
|
649 |
+
}
|
650 |
+
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Loop through the grid data and apply titles and labels to each menu item and widget.
|
654 |
+
*
|
655 |
+
* @param array $saved_grid
|
656 |
+
* @param int $menu_id
|
657 |
+
* @since 2.4
|
658 |
+
* @return array
|
659 |
+
*/
|
660 |
+
public function populate_grid_menu_item_titles( $saved_grid, $menu_id ) {
|
661 |
+
|
662 |
+
$menu_items = wp_get_nav_menu_items( $menu_id );
|
663 |
+
|
664 |
+
$menu_item_title_map = array();
|
665 |
+
|
666 |
+
foreach ( $menu_items as $item ) {
|
667 |
+
$menu_item_title_map[ $item->ID ] = $item->title;
|
668 |
+
}
|
669 |
+
|
670 |
+
foreach ( $saved_grid as $row => $row_data ) {
|
671 |
+
if ( isset( $row_data['columns'] ) ) {
|
672 |
+
foreach ( $row_data['columns'] as $col => $col_data ) {
|
673 |
+
if ( isset( $col_data['items'] ) ) {
|
674 |
+
foreach ( $col_data['items'] as $key => $item ) {
|
675 |
+
if ( $item['type'] == 'item' ) {
|
676 |
+
|
677 |
+
if ( isset( $menu_item_title_map[ $item['id'] ] ) ) {
|
678 |
+
$title = $menu_item_title_map[ $item['id'] ];
|
679 |
+
} else {
|
680 |
+
$title = __( '(no label)' );
|
681 |
+
}
|
682 |
+
|
683 |
+
$saved_grid[ $row ]['columns'][ $col ]['items'][ $key ]['title'] = $title;
|
684 |
+
$saved_grid[ $row ]['columns'][ $col ]['items'][ $key ]['description'] = __( 'Menu Item', 'megamenu' );
|
685 |
+
} else {
|
686 |
+
$saved_grid[ $row ]['columns'][ $col ]['items'][ $key ]['title'] = $this->get_title_for_widget_id( $item['id'] );
|
687 |
+
$saved_grid[ $row ]['columns'][ $col ]['items'][ $key ]['description'] = $this->get_name_for_widget_id( $item['id'] );
|
688 |
+
}
|
689 |
+
}
|
690 |
+
}
|
691 |
+
}
|
692 |
+
}
|
693 |
+
}
|
694 |
+
|
695 |
+
return $saved_grid;
|
696 |
+
}
|
697 |
+
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Returns the widget data as stored in the options table
|
701 |
+
*
|
702 |
+
* @since 1.8.1
|
703 |
+
* @param string $widget_id
|
704 |
+
*/
|
705 |
+
public function get_settings_for_widget_id( $widget_id ) {
|
706 |
+
|
707 |
+
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
708 |
+
|
709 |
+
if ( ! $id_base ) {
|
710 |
+
return false;
|
711 |
+
}
|
712 |
+
|
713 |
+
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
714 |
+
|
715 |
+
$current_widgets = get_option( 'widget_' . $id_base );
|
716 |
+
|
717 |
+
return $current_widgets[ $widget_number ];
|
718 |
+
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Returns the widget ID (number)
|
723 |
+
*
|
724 |
+
* @since 1.0
|
725 |
+
* @param string $widget_id - id_base-ID (eg meta-3)
|
726 |
+
* @return int
|
727 |
+
*/
|
728 |
+
public function get_widget_number_for_widget_id( $widget_id ) {
|
729 |
+
|
730 |
+
$parts = explode( '-', $widget_id );
|
731 |
+
|
732 |
+
return absint( end( $parts ) );
|
733 |
+
|
734 |
+
}
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Returns the name/title of a Widget
|
738 |
+
*
|
739 |
+
* @since 1.0
|
740 |
+
* @param $widget_id - id_base-ID (eg meta-3)
|
741 |
+
* @return string e.g. "Custom HTML" or "Text"
|
742 |
+
*/
|
743 |
+
public function get_name_for_widget_id( $widget_id ) {
|
744 |
+
global $wp_registered_widgets;
|
745 |
+
|
746 |
+
if ( ! isset( $wp_registered_widgets[ $widget_id ] ) ) {
|
747 |
+
return false;
|
748 |
+
}
|
749 |
+
|
750 |
+
$registered_widget = $wp_registered_widgets[ $widget_id ];
|
751 |
+
|
752 |
+
return $registered_widget['name'];
|
753 |
+
|
754 |
+
}
|
755 |
+
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Returns the title of a Widget
|
759 |
+
*
|
760 |
+
* @since 2.4
|
761 |
+
* @param $widget_id - id_base-ID (eg meta-3)
|
762 |
+
*/
|
763 |
+
public function get_title_for_widget_id( $widget_id ) {
|
764 |
+
$instance = $this->get_settings_for_widget_id( $widget_id );
|
765 |
+
|
766 |
+
if ( isset( $instance['title'] ) && strlen( $instance['title'] ) ) {
|
767 |
+
return $instance['title'];
|
768 |
+
}
|
769 |
+
|
770 |
+
return $this->get_name_for_widget_id( $widget_id );
|
771 |
+
|
772 |
+
}
|
773 |
|
774 |
+
/**
|
775 |
+
* Returns the id_base value for a Widget ID
|
776 |
+
*
|
777 |
+
* @since 1.0
|
778 |
+
*/
|
779 |
+
public function get_id_base_for_widget_id( $widget_id ) {
|
780 |
+
global $wp_registered_widget_controls;
|
781 |
|
782 |
+
if ( ! isset( $wp_registered_widget_controls[ $widget_id ] ) ) {
|
783 |
+
return false;
|
784 |
+
}
|
785 |
+
|
786 |
+
$control = $wp_registered_widget_controls[ $widget_id ];
|
787 |
|
788 |
+
$id_base = isset( $control['id_base'] ) ? $control['id_base'] : $control['id'];
|
|
|
|
|
|
|
|
|
|
|
789 |
|
790 |
+
return $id_base;
|
791 |
|
792 |
+
}
|
793 |
|
794 |
+
/**
|
795 |
+
* Returns the HTML for a single widget instance.
|
796 |
+
*
|
797 |
+
* @since 1.0
|
798 |
+
* @param string widget_id Something like meta-3
|
799 |
+
*/
|
800 |
+
public function show_widget( $id ) {
|
801 |
+
global $wp_registered_widgets;
|
802 |
|
803 |
+
$params = array_merge(
|
804 |
+
array(
|
805 |
+
array_merge(
|
806 |
+
array(
|
807 |
+
'widget_id' => $id,
|
808 |
+
'widget_name' => $wp_registered_widgets[ $id ]['name'],
|
809 |
+
)
|
810 |
+
),
|
811 |
+
),
|
812 |
+
(array) $wp_registered_widgets[ $id ]['params']
|
813 |
+
);
|
814 |
+
|
815 |
+
$params[0]['id'] = 'mega-menu';
|
816 |
+
$params[0]['before_title'] = apply_filters( 'megamenu_before_widget_title', '<h4 class="mega-block-title">', $wp_registered_widgets[ $id ] );
|
817 |
+
$params[0]['after_title'] = apply_filters( 'megamenu_after_widget_title', '</h4>', $wp_registered_widgets[ $id ] );
|
818 |
+
$params[0]['before_widget'] = apply_filters( 'megamenu_before_widget', '', $wp_registered_widgets[ $id ] );
|
819 |
+
$params[0]['after_widget'] = apply_filters( 'megamenu_after_widget', '', $wp_registered_widgets[ $id ] );
|
820 |
+
|
821 |
+
if ( defined( 'MEGAMENU_DYNAMIC_SIDEBAR_PARAMS' ) && MEGAMENU_DYNAMIC_SIDEBAR_PARAMS ) {
|
822 |
+
$params[0]['before_widget'] = apply_filters( 'megamenu_before_widget', '<div id="" class="">', $wp_registered_widgets[ $id ] );
|
823 |
+
$params[0]['after_widget'] = apply_filters( 'megamenu_after_widget', '</div>', $wp_registered_widgets[ $id ] );
|
824 |
+
|
825 |
+
$params = apply_filters( 'dynamic_sidebar_params', $params );
|
826 |
+
}
|
827 |
|
828 |
+
$callback = $wp_registered_widgets[ $id ]['callback'];
|
829 |
|
830 |
+
if ( is_callable( $callback ) ) {
|
831 |
+
ob_start();
|
832 |
+
call_user_func_array( $callback, $params );
|
833 |
+
return ob_get_clean();
|
834 |
+
}
|
|
|
|
|
|
|
|
|
|
|
835 |
|
836 |
+
}
|
837 |
+
|
838 |
+
|
839 |
+
/**
|
840 |
+
* Returns the class name for a widget instance.
|
841 |
+
*
|
842 |
+
* @since 1.8.1
|
843 |
+
* @param string widget_id Something like meta-3
|
844 |
+
*/
|
845 |
+
public function get_widget_class( $id ) {
|
846 |
+
global $wp_registered_widgets;
|
847 |
|
848 |
+
if ( isset( $wp_registered_widgets[ $id ]['classname'] ) ) {
|
849 |
+
return $wp_registered_widgets[ $id ]['classname'];
|
850 |
+
}
|
851 |
|
852 |
+
return '';
|
853 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
855 |
|
856 |
+
/**
|
857 |
+
* Shows the widget edit form for the specified widget.
|
858 |
+
*
|
859 |
+
* @since 1.0
|
860 |
+
* @param $widget_id - id_base-ID (eg meta-3)
|
861 |
+
*/
|
862 |
+
public function show_widget_form( $widget_id ) {
|
863 |
+
global $wp_registered_widget_controls;
|
864 |
|
865 |
+
$control = $wp_registered_widget_controls[ $widget_id ];
|
866 |
|
867 |
+
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
868 |
|
869 |
+
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
870 |
|
871 |
+
$nonce = wp_create_nonce( 'megamenu_save_widget_' . $widget_id );
|
872 |
+
|
873 |
+
?>
|
874 |
+
|
875 |
+
<form method='post'>
|
876 |
+
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr( $widget_id ); ?>" />
|
877 |
+
<input type='hidden' name='action' value='mm_save_widget' />
|
878 |
+
<input type='hidden' name='id_base' class="id_base" value='<?php echo esc_attr( $id_base ); ?>' />
|
879 |
+
<input type='hidden' name='widget_id' value='<?php echo esc_attr( $widget_id ); ?>' />
|
880 |
+
<input type='hidden' name='_wpnonce' value='<?php echo esc_attr( $nonce ); ?>' />
|
881 |
+
<div class='widget-content'>
|
882 |
+
<?php
|
883 |
+
if ( is_callable( $control['callback'] ) ) {
|
884 |
+
call_user_func_array( $control['callback'], $control['params'] );
|
885 |
+
}
|
886 |
+
?>
|
887 |
|
888 |
+
<div class='widget-controls'>
|
889 |
+
<a class='delete' href='#delete'><?php _e( 'Delete', 'megamenu' ); ?></a> |
|
890 |
+
<a class='close' href='#close'><?php _e( 'Close', 'megamenu' ); ?></a>
|
891 |
+
</div>
|
892 |
+
|
893 |
+
<?php
|
894 |
+
submit_button( __( 'Save' ), 'button-primary alignright', 'savewidget', false );
|
895 |
+
?>
|
896 |
+
</div>
|
897 |
+
</form>
|
898 |
+
|
899 |
+
|
900 |
+
<?php
|
901 |
+
}
|
902 |
|
903 |
|
904 |
+
/**
|
905 |
+
* Saves a widget. Calls the update callback on the widget.
|
906 |
+
* The callback inspects the post values and updates all widget instances which match the base ID.
|
907 |
+
*
|
908 |
+
* @since 1.0
|
909 |
+
* @param string $id_base - e.g. 'meta'
|
910 |
+
* @return bool
|
911 |
+
*/
|
912 |
+
public function save_widget( $id_base ) {
|
913 |
+
global $wp_registered_widget_updates;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
914 |
|
915 |
+
$control = $wp_registered_widget_updates[ $id_base ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
916 |
|
917 |
+
if ( is_callable( $control['callback'] ) ) {
|
918 |
|
919 |
+
call_user_func_array( $control['callback'], $control['params'] );
|
|
|
920 |
|
921 |
+
do_action( 'megamenu_after_widget_save' );
|
922 |
|
923 |
+
return true;
|
924 |
+
}
|
925 |
|
926 |
+
return false;
|
927 |
|
928 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
|
|
|
930 |
|
931 |
+
/**
|
932 |
+
* Adds a widget to WordPress. First creates a new widget instance, then
|
933 |
+
* adds the widget instance to the mega menu widget sidebar area.
|
934 |
+
*
|
935 |
+
* @since 1.0
|
936 |
+
* @param string $id_base
|
937 |
+
* @param int $menu_item_id
|
938 |
+
* @param string $title
|
939 |
+
*/
|
940 |
+
public function add_widget( $id_base, $menu_item_id, $title, $is_grid_widget ) {
|
941 |
|
942 |
+
require_once( ABSPATH . 'wp-admin/includes/widgets.php' );
|
943 |
|
944 |
+
$next_id = next_widget_id_number( $id_base );
|
945 |
|
946 |
+
$this->add_widget_instance( $id_base, $next_id, $menu_item_id, $is_grid_widget );
|
|
|
|
|
947 |
|
948 |
+
$widget_id = $this->add_widget_to_sidebar( $id_base, $next_id );
|
|
|
|
|
|
|
|
|
949 |
|
950 |
+
$return = '<div class="widget" title="' . esc_attr( $title ) . '" data-columns="2" id="' . $widget_id . '" data-type="widget" data-id="' . $widget_id . '">';
|
951 |
+
$return .= ' <div class="widget-top">';
|
952 |
+
$return .= ' <div class="widget-title-action">';
|
|
|
|
|
|
|
|
|
|
|
953 |
|
954 |
+
if ( ! $is_grid_widget ) {
|
955 |
+
$return .= ' <a class="widget-option widget-contract" title="' . esc_attr( __( 'Contract', 'megamenu' ) ) . '"></a>';
|
956 |
+
$return .= ' <span class="widget-cols"><span class="widget-num-cols">2</span><span class="widget-of">/</span><span class="widget-total-cols">X</span></span>';
|
957 |
+
$return .= ' <a class="widget-option widget-expand" title="' . esc_attr( __( 'Expand', 'megamenu' ) ) . '"></a>';
|
958 |
+
}
|
959 |
|
960 |
+
$return .= ' <a class="widget-option widget-action" title="' . esc_attr( __( 'Edit', 'megamenu' ) ) . '"></a>';
|
961 |
+
$return .= ' </div>';
|
962 |
+
$return .= ' <div class="widget-title">';
|
963 |
+
$return .= ' <h4>' . esc_html( $title ) . '</h4>';
|
964 |
|
965 |
+
if ( $is_grid_widget ) {
|
966 |
+
$return .= ' <span class="widget-desc">' . esc_html( $title ) . '</span>';
|
967 |
+
}
|
968 |
|
969 |
+
$return .= ' </div>';
|
970 |
+
$return .= ' </div>';
|
971 |
+
$return .= ' <div class="widget-inner widget-inside"></div>';
|
972 |
+
$return .= '</div>';
|
973 |
|
974 |
+
return $return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
|
976 |
+
}
|
977 |
|
|
|
|
|
|
|
|
|
978 |
|
979 |
+
/**
|
980 |
+
* Adds a new widget instance of the specified base ID to the database.
|
981 |
+
*
|
982 |
+
* @since 1.0
|
983 |
+
* @param string $id_base
|
984 |
+
* @param int $next_id
|
985 |
+
* @param int $menu_item_id
|
986 |
+
*/
|
987 |
+
private function add_widget_instance( $id_base, $next_id, $menu_item_id, $is_grid_widget ) {
|
988 |
|
989 |
+
$current_widgets = get_option( 'widget_' . $id_base );
|
990 |
|
991 |
+
$current_widgets[ $next_id ] = array(
|
992 |
+
'mega_menu_columns' => 2,
|
993 |
+
'mega_menu_parent_menu_id' => $menu_item_id,
|
994 |
+
);
|
995 |
|
996 |
+
if ( $is_grid_widget ) {
|
997 |
+
$current_widgets[ $next_id ] = array(
|
998 |
+
'mega_menu_is_grid_widget' => 'true',
|
999 |
+
);
|
1000 |
+
}
|
|
|
|
|
|
|
1001 |
|
1002 |
+
update_option( 'widget_' . $id_base, $current_widgets );
|
|
|
1003 |
|
1004 |
+
}
|
|
|
1005 |
|
1006 |
+
/**
|
1007 |
+
* Removes a widget instance from the database
|
1008 |
+
*
|
1009 |
+
* @since 1.0
|
1010 |
+
* @param string $widget_id e.g. meta-3
|
1011 |
+
* @return bool. True if widget has been deleted.
|
1012 |
+
*/
|
1013 |
+
private function remove_widget_instance( $widget_id ) {
|
1014 |
|
1015 |
+
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
1016 |
+
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1017 |
|
1018 |
+
// add blank widget
|
1019 |
+
$current_widgets = get_option( 'widget_' . $id_base );
|
1020 |
|
1021 |
+
if ( isset( $current_widgets[ $widget_number ] ) ) {
|
1022 |
|
1023 |
+
unset( $current_widgets[ $widget_number ] );
|
1024 |
|
1025 |
+
update_option( 'widget_' . $id_base, $current_widgets );
|
1026 |
|
1027 |
+
return true;
|
1028 |
|
1029 |
+
}
|
1030 |
|
1031 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1032 |
|
1033 |
+
}
|
1034 |
|
|
|
1035 |
|
1036 |
+
/**
|
1037 |
+
* Updates the number of mega columns for a specified widget.
|
1038 |
+
*
|
1039 |
+
* @since 1.0
|
1040 |
+
* @param string $widget_id
|
1041 |
+
* @param int $columns
|
1042 |
+
*/
|
1043 |
+
public function update_widget_columns( $widget_id, $columns ) {
|
1044 |
|
1045 |
+
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
1046 |
|
1047 |
+
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1048 |
|
1049 |
+
$current_widgets = get_option( 'widget_' . $id_base );
|
1050 |
|
1051 |
+
$current_widgets[ $widget_number ]['mega_menu_columns'] = absint( $columns );
|
1052 |
|
1053 |
+
update_option( 'widget_' . $id_base, $current_widgets );
|
1054 |
|
1055 |
+
do_action( 'megamenu_after_widget_save' );
|
1056 |
|
1057 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1058 |
|
1059 |
+
}
|
1060 |
|
|
|
|
|
|
|
1061 |
|
1062 |
+
/**
|
1063 |
+
* Updates the number of mega columns for a specified widget.
|
1064 |
+
*
|
1065 |
+
* @since 1.10
|
1066 |
+
* @param string $menu_item_id
|
1067 |
+
* @param int $columns
|
1068 |
+
*/
|
1069 |
+
public function update_menu_item_columns( $menu_item_id, $columns ) {
|
1070 |
|
1071 |
+
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true );
|
1072 |
|
1073 |
+
$submitted_settings = array(
|
1074 |
+
'mega_menu_columns' => absint( $columns ),
|
1075 |
+
);
|
1076 |
|
1077 |
+
if ( is_array( $existing_settings ) ) {
|
1078 |
+
$submitted_settings = array_merge( $existing_settings, $submitted_settings );
|
1079 |
+
}
|
1080 |
|
1081 |
+
update_post_meta( $menu_item_id, '_megamenu', $submitted_settings );
|
1082 |
|
1083 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
|
1085 |
+
}
|
1086 |
|
|
|
1087 |
|
1088 |
+
/**
|
1089 |
+
* Updates the order of a specified widget.
|
1090 |
+
*
|
1091 |
+
* @since 1.10
|
1092 |
+
* @param string $widget_id
|
1093 |
+
* @param int $columns
|
1094 |
+
*/
|
1095 |
+
public function update_widget_order( $widget_id, $order, $parent_menu_item_id ) {
|
1096 |
|
1097 |
+
$id_base = $this->get_id_base_for_widget_id( $widget_id );
|
1098 |
|
1099 |
+
$widget_number = $this->get_widget_number_for_widget_id( $widget_id );
|
1100 |
|
1101 |
+
$current_widgets = get_option( 'widget_' . $id_base );
|
1102 |
|
1103 |
+
$current_widgets[ $widget_number ]['mega_menu_order'] = array( $parent_menu_item_id => absint( $order ) );
|
1104 |
|
1105 |
+
update_option( 'widget_' . $id_base, $current_widgets );
|
1106 |
|
1107 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1108 |
|
1109 |
+
}
|
1110 |
|
|
|
1111 |
|
1112 |
+
/**
|
1113 |
+
* Updates the order of a specified menu item.
|
1114 |
+
*
|
1115 |
+
* @since 1.10
|
1116 |
+
* @param string $menu_item_id
|
1117 |
+
* @param int $order
|
1118 |
+
*/
|
1119 |
+
public function update_menu_item_order( $menu_item_id, $order, $parent_menu_item_id ) {
|
1120 |
|
1121 |
+
$submitted_settings['mega_menu_order'] = array( $parent_menu_item_id => absint( $order ) );
|
1122 |
|
1123 |
+
$existing_settings = get_post_meta( $menu_item_id, '_megamenu', true );
|
1124 |
|
1125 |
+
if ( is_array( $existing_settings ) ) {
|
1126 |
|
1127 |
+
$submitted_settings = array_merge( $existing_settings, $submitted_settings );
|
1128 |
|
1129 |
+
}
|
1130 |
|
1131 |
+
update_post_meta( $menu_item_id, '_megamenu', $submitted_settings );
|
1132 |
|
1133 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
1134 |
|
1135 |
+
}
|
|
|
1136 |
|
|
|
1137 |
|
1138 |
+
/**
|
1139 |
+
* Deletes a widget from WordPress
|
1140 |
+
*
|
1141 |
+
* @since 1.0
|
1142 |
+
* @param string $widget_id e.g. meta-3
|
1143 |
+
*/
|
1144 |
+
public function delete_widget( $widget_id ) {
|
1145 |
|
1146 |
+
$this->remove_widget_from_sidebar( $widget_id );
|
1147 |
+
$this->remove_widget_instance( $widget_id );
|
1148 |
|
1149 |
+
do_action( 'megamenu_after_widget_delete' );
|
1150 |
|
1151 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1152 |
|
1153 |
+
}
|
1154 |
|
|
|
1155 |
|
1156 |
+
/**
|
1157 |
+
* Moves a widget from one position to another.
|
1158 |
+
*
|
1159 |
+
* @since 1.10
|
1160 |
+
* @param array $items
|
1161 |
+
* @return string $widget_id. The widget that has been moved.
|
1162 |
+
*/
|
1163 |
+
public function reorder_items( $items ) {
|
1164 |
|
1165 |
+
foreach ( $items as $item ) {
|
1166 |
|
1167 |
+
if ( $item['parent_menu_item'] ) {
|
1168 |
|
1169 |
+
$submitted_settings = array( 'submenu_ordering' => 'forced' );
|
1170 |
|
1171 |
+
$existing_settings = get_post_meta( $item['parent_menu_item'], '_megamenu', true );
|
1172 |
|
1173 |
+
if ( is_array( $existing_settings ) ) {
|
|
|
1174 |
|
1175 |
+
$submitted_settings = array_merge( $existing_settings, $submitted_settings );
|
1176 |
|
1177 |
+
}
|
1178 |
|
1179 |
+
update_post_meta( $item['parent_menu_item'], '_megamenu', $submitted_settings );
|
1180 |
+
}
|
1181 |
|
1182 |
+
if ( $item['type'] == 'widget' ) {
|
1183 |
|
1184 |
+
$this->update_widget_order( $item['id'], $item['order'], $item['parent_menu_item'] );
|
1185 |
|
1186 |
+
}
|
1187 |
|
1188 |
+
if ( $item['type'] == 'menu_item' ) {
|
1189 |
|
1190 |
+
$this->update_menu_item_order( $item['id'], $item['order'], $item['parent_menu_item'] );
|
1191 |
|
1192 |
+
}
|
1193 |
+
}
|
1194 |
|
1195 |
+
return true;
|
1196 |
|
1197 |
+
}
|
|
|
|
|
|
|
|
|
|
|
1198 |
|
|
|
1199 |
|
1200 |
+
/**
|
1201 |
+
* Adds a widget to the Mega Menu widget sidebar
|
1202 |
+
*
|
1203 |
+
* @since 1.0
|
1204 |
+
*/
|
1205 |
+
private function add_widget_to_sidebar( $id_base, $next_id ) {
|
1206 |
|
1207 |
+
$widget_id = $id_base . '-' . $next_id;
|
1208 |
|
1209 |
+
$sidebar_widgets = $this->get_mega_menu_sidebar_widgets();
|
1210 |
|
1211 |
+
$sidebar_widgets[] = $widget_id;
|
1212 |
|
1213 |
+
$this->set_mega_menu_sidebar_widgets( $sidebar_widgets );
|
1214 |
|
1215 |
+
do_action( 'megamenu_after_widget_add' );
|
1216 |
|
1217 |
+
return $widget_id;
|
1218 |
|
1219 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1220 |
|
|
|
1221 |
|
1222 |
+
/**
|
1223 |
+
* Removes a widget from the Mega Menu widget sidebar
|
1224 |
+
*
|
1225 |
+
* @since 1.0
|
1226 |
+
* @return string The widget that was removed
|
1227 |
+
*/
|
1228 |
+
private function remove_widget_from_sidebar( $widget_id ) {
|
1229 |
|
1230 |
+
$widgets = $this->get_mega_menu_sidebar_widgets();
|
1231 |
|
1232 |
+
$new_mega_menu_widgets = array();
|
|
|
1233 |
|
1234 |
+
foreach ( $widgets as $widget ) {
|
1235 |
|
1236 |
+
if ( $widget != $widget_id ) {
|
1237 |
+
$new_mega_menu_widgets[] = $widget;
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
|
1241 |
+
$this->set_mega_menu_sidebar_widgets( $new_mega_menu_widgets );
|
1242 |
|
1243 |
+
return $widget_id;
|
1244 |
|
1245 |
+
}
|
1246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1247 |
|
1248 |
+
/**
|
1249 |
+
* Returns an unfiltered array of all widgets in our sidebar
|
1250 |
+
*
|
1251 |
+
* @since 1.0
|
1252 |
+
* @return array
|
1253 |
+
*/
|
1254 |
+
public function get_mega_menu_sidebar_widgets() {
|
1255 |
|
1256 |
+
$sidebar_widgets = wp_get_sidebars_widgets();
|
|
|
|
|
1257 |
|
1258 |
+
if ( ! isset( $sidebar_widgets['mega-menu'] ) ) {
|
1259 |
+
return false;
|
1260 |
+
}
|
1261 |
|
1262 |
+
return $sidebar_widgets['mega-menu'];
|
1263 |
|
1264 |
+
}
|
1265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1266 |
|
1267 |
+
/**
|
1268 |
+
* Sets the sidebar widgets
|
1269 |
+
*
|
1270 |
+
* @since 1.0
|
1271 |
+
*/
|
1272 |
+
private function set_mega_menu_sidebar_widgets( $widgets ) {
|
1273 |
|
1274 |
+
$sidebar_widgets = wp_get_sidebars_widgets();
|
1275 |
|
1276 |
+
$sidebar_widgets['mega-menu'] = $widgets;
|
1277 |
|
1278 |
+
wp_set_sidebars_widgets( $sidebar_widgets );
|
1279 |
|
1280 |
+
}
|
1281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1282 |
|
1283 |
+
/**
|
1284 |
+
* Clear the cache when the Mega Menu is updated.
|
1285 |
+
*
|
1286 |
+
* @since 1.0
|
1287 |
+
*/
|
1288 |
+
public function clear_caches() {
|
1289 |
|
1290 |
+
// https://wordpress.org/plugins/widget-output-cache/
|
1291 |
+
if ( function_exists( 'menu_output_cache_bump' ) ) {
|
1292 |
+
menu_output_cache_bump();
|
1293 |
+
}
|
1294 |
|
1295 |
+
// https://wordpress.org/plugins/widget-output-cache/
|
1296 |
+
if ( function_exists( 'widget_output_cache_bump' ) ) {
|
1297 |
+
widget_output_cache_bump();
|
1298 |
+
}
|
1299 |
|
1300 |
+
}
|
1301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1302 |
|
1303 |
+
/**
|
1304 |
+
* Send JSON response.
|
1305 |
+
*
|
1306 |
+
* Remove any warnings or output from other plugins which may corrupt the response
|
1307 |
+
*
|
1308 |
+
* @param string $json
|
1309 |
+
* @since 1.8
|
1310 |
+
*/
|
1311 |
+
public function send_json_success( $json ) {
|
1312 |
+
if ( ob_get_contents() ) {
|
1313 |
+
ob_clean();
|
1314 |
+
}
|
1315 |
|
1316 |
+
wp_send_json_success( $json );
|
1317 |
+
}
|
1318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1319 |
|
1320 |
+
/**
|
1321 |
+
* Send JSON response.
|
1322 |
+
*
|
1323 |
+
* Remove any warnings or output from other plugins which may corrupt the response
|
1324 |
+
*
|
1325 |
+
* @param string $json
|
1326 |
+
* @since 1.8
|
1327 |
+
*/
|
1328 |
+
public function send_json_error( $json ) {
|
1329 |
+
if ( ob_get_contents() ) {
|
1330 |
+
ob_clean();
|
1331 |
+
}
|
1332 |
|
1333 |
+
wp_send_json_error( $json );
|
1334 |
+
}
|
1335 |
+
|
1336 |
+
}
|
1337 |
|
1338 |
+
endif;
|
classes/widgets/widget-elementor-template.class.php
CHANGED
@@ -1,98 +1,104 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Widget_Elementor_Template') ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Outputs an Elementor template
|
11 |
-
*/
|
12 |
-
class Mega_Menu_Widget_Elementor_Template extends WP_Widget {
|
13 |
|
14 |
/**
|
15 |
-
*
|
16 |
*/
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
)
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
$widget_title = $template_id ? get_post_field( 'post_title', $template_id ) : '';
|
84 |
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
|
|
93 |
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
<input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
|
97 |
|
98 |
<p>
|
@@ -102,21 +108,21 @@ class Mega_Menu_Widget_Elementor_Template extends WP_Widget {
|
|
102 |
<?php foreach ( $posts as $post ) : ?>
|
103 |
|
104 |
|
105 |
-
|
106 |
-
$elementor_data = get_post_meta( $instance['template_id'],'_elementor_data' );
|
107 |
|
108 |
$type = $elementor_data['elType'];
|
109 |
|
110 |
-
|
111 |
<option value="<?php echo esc_attr( $post->ID ); ?>"<?php selected( $post->ID, $template_id ); ?>>
|
112 |
-
<?php echo esc_html( $post->post_title .
|
113 |
<?php endforeach; ?>
|
114 |
</select>
|
115 |
</p>
|
116 |
|
117 |
-
|
118 |
-
|
119 |
|
120 |
-
}
|
121 |
|
122 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Widget_Elementor_Template' ) ) :
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
/**
|
10 |
+
* Outputs an Elementor template
|
11 |
*/
|
12 |
+
class Mega_Menu_Widget_Elementor_Template extends WP_Widget {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Register widget with WordPress.
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
parent::__construct(
|
19 |
+
'maxmegamenu_elementor_template', // Base ID
|
20 |
+
'Elementor Template', // Name
|
21 |
+
array( 'description' => __( 'Outputs a saved Elementor template.', 'megamenu' ) ) // Args
|
22 |
+
);
|
23 |
+
}
|
24 |
|
25 |
|
26 |
+
/**
|
27 |
+
* Front-end display of widget.
|
28 |
+
*
|
29 |
+
* @since 2.7.4
|
30 |
+
* @see WP_Widget::widget()
|
31 |
+
* @param array $args Widget arguments.
|
32 |
+
* @param array $instance Saved values from database.
|
33 |
+
*/
|
34 |
+
public function widget( $args, $instance ) {
|
35 |
+
if ( empty( $instance['template_id'] ) || ! get_post_type( $instance['template_id'] ) ) {
|
36 |
+
return;
|
37 |
+
}
|
38 |
|
39 |
+
extract( $args );
|
40 |
|
41 |
+
echo $before_widget;
|
42 |
|
43 |
+
$contentElementor = '';
|
44 |
|
45 |
+
if ( class_exists( '\\Elementor\\Plugin' ) ) {
|
46 |
+
$pluginElementor = \Elementor\Plugin::instance();
|
47 |
+
$contentElementor = $pluginElementor->frontend->get_builder_content( $instance['template_id'] );
|
48 |
+
}
|
49 |
|
50 |
+
echo $contentElementor;
|
51 |
|
52 |
+
echo $after_widget;
|
53 |
+
}
|
54 |
|
55 |
|
56 |
+
/**
|
57 |
+
* Sanitize widget form values as they are saved.
|
58 |
+
*
|
59 |
+
* @since 2.7.4
|
60 |
+
* @see WP_Widget::update()
|
61 |
+
* @param array $new_instance Values just sent to be saved.
|
62 |
+
* @param array $old_instance Previously saved values from database.
|
63 |
+
* @return array Updated safe values to be saved.
|
64 |
+
*/
|
65 |
+
public function update( $new_instance, $old_instance ) {
|
66 |
+
$instance = array();
|
67 |
+
$instance['template_id'] = ! empty( $new_instance['template_id'] ) ? $new_instance['template_id'] : 0;
|
68 |
+
|
69 |
+
return $instance;
|
70 |
+
}
|
71 |
|
72 |
|
73 |
+
/**
|
74 |
+
* Back-end widget form.
|
75 |
+
*
|
76 |
+
* @since 2.7.4
|
77 |
+
* @see WP_Widget::form()
|
78 |
+
* @param array $instance Previously saved values from database.
|
79 |
+
*/
|
80 |
+
public function form( $instance ) {
|
81 |
+
$template_id = ! empty( $instance['template_id'] ) ? absint( $instance['template_id'] ) : 0;
|
|
|
|
|
82 |
|
83 |
+
$widget_title = $template_id ? get_post_field( 'post_title', $template_id ) : '';
|
84 |
|
85 |
+
$posts = get_posts(
|
86 |
+
array(
|
87 |
+
'post_type' => 'elementor_library',
|
88 |
+
'post_status' => 'publish',
|
89 |
+
'numberposts' => -1,
|
90 |
+
)
|
91 |
+
);
|
92 |
|
93 |
+
// No blocks found.
|
94 |
+
if ( empty( $posts ) ) {
|
95 |
+
printf( '<p>%s</p>', __( 'No Elementor Templates found.', 'megamenu' ) );
|
96 |
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
// Input field with id is required for WordPress to display the title in the widget header.
|
101 |
+
?>
|
102 |
<input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
|
103 |
|
104 |
<p>
|
108 |
<?php foreach ( $posts as $post ) : ?>
|
109 |
|
110 |
|
111 |
+
<?php
|
112 |
+
$elementor_data = get_post_meta( $instance['template_id'], '_elementor_data' );
|
113 |
|
114 |
$type = $elementor_data['elType'];
|
115 |
|
116 |
+
?>
|
117 |
<option value="<?php echo esc_attr( $post->ID ); ?>"<?php selected( $post->ID, $template_id ); ?>>
|
118 |
+
<?php echo esc_html( $post->post_title . ' (' . $post->ID . ' - ' . get_post_meta( $post->ID, '_elementor_template_type', true ) . ')' ); ?></option>
|
119 |
<?php endforeach; ?>
|
120 |
</select>
|
121 |
</p>
|
122 |
|
123 |
+
<?php
|
124 |
+
}
|
125 |
|
126 |
+
}
|
127 |
|
128 |
+
endif;
|
classes/widgets/widget-reusable-block.class.php
CHANGED
@@ -1,93 +1,99 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Widget_Reusable_Block') ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Outputs a reusable block
|
11 |
-
*
|
12 |
-
* Credit: Based on https://wordpress.org/plugins/block-widget/ by Maarten Menten
|
13 |
-
*/
|
14 |
-
class Mega_Menu_Widget_Reusable_Block extends WP_Widget {
|
15 |
|
16 |
/**
|
17 |
-
*
|
18 |
-
*/
|
19 |
-
public function __construct() {
|
20 |
-
parent::__construct(
|
21 |
-
'maxmegamenu_reusable_block', // Base ID
|
22 |
-
'Reusable Block', // Name
|
23 |
-
array( 'description' => __( 'Outputs a reusable block.', 'megamenu' ) ) // Args
|
24 |
-
);
|
25 |
-
}
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Front-end display of widget.
|
30 |
*
|
31 |
-
*
|
32 |
-
* @see WP_Widget::widget()
|
33 |
-
* @param array $args Widget arguments.
|
34 |
-
* @param array $instance Saved values from database.
|
35 |
*/
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
-
extract( $args );
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
}
|
49 |
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
*
|
54 |
-
* @since 2.7.4
|
55 |
-
* @see WP_Widget::update()
|
56 |
-
* @param array $new_instance Values just sent to be saved.
|
57 |
-
* @param array $old_instance Previously saved values from database.
|
58 |
-
* @return array Updated safe values to be saved.
|
59 |
-
*/
|
60 |
-
public function update( $new_instance, $old_instance ) {
|
61 |
-
$instance = array();
|
62 |
-
$instance['block'] = ! empty( $new_instance['block'] ) ? $new_instance['block'] : 0;
|
63 |
-
|
64 |
-
return $instance;
|
65 |
-
}
|
66 |
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
$posts = get_posts( array ( 'post_type' => 'wp_block', 'post_status' => 'publish', 'numberposts' => -1 ) );
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
<input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
|
92 |
|
93 |
<p>
|
@@ -100,9 +106,9 @@ class Mega_Menu_Widget_Reusable_Block extends WP_Widget {
|
|
100 |
</select>
|
101 |
</p>
|
102 |
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
}
|
107 |
|
108 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Widget_Reusable_Block' ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
/**
|
10 |
+
* Outputs a reusable block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
*
|
12 |
+
* Credit: Based on https://wordpress.org/plugins/block-widget/ by Maarten Menten
|
|
|
|
|
|
|
13 |
*/
|
14 |
+
class Mega_Menu_Widget_Reusable_Block extends WP_Widget {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Register widget with WordPress.
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
parent::__construct(
|
21 |
+
'maxmegamenu_reusable_block', // Base ID
|
22 |
+
'Reusable Block', // Name
|
23 |
+
array( 'description' => __( 'Outputs a reusable block.', 'megamenu' ) ) // Args
|
24 |
+
);
|
25 |
}
|
26 |
|
|
|
27 |
|
28 |
+
/**
|
29 |
+
* Front-end display of widget.
|
30 |
+
*
|
31 |
+
* @since 2.7.4
|
32 |
+
* @see WP_Widget::widget()
|
33 |
+
* @param array $args Widget arguments.
|
34 |
+
* @param array $instance Saved values from database.
|
35 |
+
*/
|
36 |
+
public function widget( $args, $instance ) {
|
37 |
+
if ( empty( $instance['block'] ) || ! get_post_type( $instance['block'] ) ) {
|
38 |
+
return;
|
39 |
+
}
|
40 |
|
41 |
+
extract( $args );
|
42 |
|
43 |
+
echo $before_widget;
|
|
|
44 |
|
45 |
+
echo do_blocks( get_post_field( 'post_content', $instance['block'] ) );
|
46 |
|
47 |
+
echo $after_widget;
|
48 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
|
51 |
+
/**
|
52 |
+
* Sanitize widget form values as they are saved.
|
53 |
+
*
|
54 |
+
* @since 2.7.4
|
55 |
+
* @see WP_Widget::update()
|
56 |
+
* @param array $new_instance Values just sent to be saved.
|
57 |
+
* @param array $old_instance Previously saved values from database.
|
58 |
+
* @return array Updated safe values to be saved.
|
59 |
+
*/
|
60 |
+
public function update( $new_instance, $old_instance ) {
|
61 |
+
$instance = array();
|
62 |
+
$instance['block'] = ! empty( $new_instance['block'] ) ? $new_instance['block'] : 0;
|
63 |
+
|
64 |
+
return $instance;
|
65 |
+
}
|
66 |
|
|
|
67 |
|
68 |
+
/**
|
69 |
+
* Back-end widget form.
|
70 |
+
*
|
71 |
+
* @since 2.7.4
|
72 |
+
* @see WP_Widget::form()
|
73 |
+
* @param array $instance Previously saved values from database.
|
74 |
+
*/
|
75 |
+
public function form( $instance ) {
|
76 |
+
$block_id = ! empty( $instance['block'] ) ? absint( $instance['block'] ) : 0;
|
77 |
|
78 |
+
$widget_title = $block_id ? get_post_field( 'post_title', $block_id ) : '';
|
79 |
+
|
80 |
+
$posts = get_posts(
|
81 |
+
array(
|
82 |
+
'post_type' => 'wp_block',
|
83 |
+
'post_status' => 'publish',
|
84 |
+
'numberposts' => -1,
|
85 |
+
)
|
86 |
+
);
|
87 |
|
88 |
+
// No blocks found.
|
89 |
+
if ( empty( $posts ) ) {
|
90 |
+
printf( '<p>%s</p>', __( 'No reusable blocks available.', 'megamenu' ) );
|
91 |
+
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
// Input field with id is required for WordPress to display the title in the widget header.
|
96 |
+
?>
|
97 |
<input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
|
98 |
|
99 |
<p>
|
106 |
</select>
|
107 |
</p>
|
108 |
|
109 |
+
<?php
|
110 |
+
}
|
111 |
|
112 |
+
}
|
113 |
|
114 |
+
endif;
|
classes/widgets/widget.class.php
CHANGED
@@ -1,100 +1,103 @@
|
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
|
5 |
}
|
6 |
|
7 |
-
if ( ! class_exists('Mega_Menu_Widget') ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Outputs a registered menu location using wp_nav_menu
|
11 |
-
*/
|
12 |
-
class Mega_Menu_Widget extends WP_Widget {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Register widget with WordPress.
|
16 |
-
*/
|
17 |
-
public function __construct() {
|
18 |
-
parent::__construct(
|
19 |
-
'maxmegamenu', // Base ID
|
20 |
-
'Max Mega Menu', // Name
|
21 |
-
array( 'description' => __( 'Outputs a menu for a selected theme location.', 'megamenu' ) ) // Args
|
22 |
-
);
|
23 |
-
}
|
24 |
|
25 |
/**
|
26 |
-
*
|
27 |
-
*
|
28 |
-
* @since 1.7.4
|
29 |
-
* @see WP_Widget::widget()
|
30 |
-
* @param array $args Widget arguments.
|
31 |
-
* @param array $instance Saved values from database.
|
32 |
*/
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
-
|
38 |
-
extract( $args );
|
39 |
-
|
40 |
-
if ( isset( $instance['location'] ) ) {
|
41 |
-
$location = $instance['location'];
|
42 |
-
|
43 |
-
$title = apply_filters( 'widget_title', $instance['title'] );
|
44 |
-
|
45 |
-
echo $before_widget;
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
-
|
52 |
-
wp_nav_menu( array( 'theme_location' => $location ) );
|
53 |
-
}
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
}
|
58 |
|
59 |
-
|
60 |
-
* Sanitize widget form values as they are saved.
|
61 |
-
*
|
62 |
-
* @since 1.7.4
|
63 |
-
* @see WP_Widget::update()
|
64 |
-
* @param array $new_instance Values just sent to be saved.
|
65 |
-
* @param array $old_instance Previously saved values from database.
|
66 |
-
* @return array Updated safe values to be saved.
|
67 |
-
*/
|
68 |
-
public function update( $new_instance, $old_instance ) {
|
69 |
-
$instance = array();
|
70 |
-
$instance['location'] = strip_tags( $new_instance['location'] );
|
71 |
-
$instance['title'] = strip_tags( $new_instance['title'] );
|
72 |
|
73 |
-
|
74 |
-
}
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
* @since 1.7.4
|
80 |
-
* @see WP_Widget::form()
|
81 |
-
* @param array $instance Previously saved values from database.
|
82 |
-
*/
|
83 |
-
public function form( $instance ) {
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
}
|
92 |
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
<p>
|
99 |
<?php if ( $locations ) { ?>
|
100 |
<p>
|
@@ -104,52 +107,54 @@ class Mega_Menu_Widget extends WP_Widget {
|
|
104 |
<label for="<?php echo $this->get_field_id( 'location' ); ?>"><?php _e( 'Menu Location:', 'megamenu' ); ?></label>
|
105 |
|
106 |
<select id="<?php echo $this->get_field_id( 'location' ); ?>" name="<?php echo $this->get_field_name( 'location' ); ?>">
|
107 |
-
<?php
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
?>
|
112 |
|
113 |
<?php
|
114 |
|
115 |
-
$enabled_locations
|
116 |
$disabled_locations = array();
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
}
|
124 |
}
|
|
|
|
|
|
|
|
|
125 |
|
126 |
-
|
127 |
-
echo "<
|
128 |
-
|
129 |
-
foreach ( $enabled_locations as $location => $description ) {
|
130 |
-
echo "<option value='{$location}'" . selected( $location, $selected_location ) . ">{$description}</option>";
|
131 |
-
}
|
132 |
-
|
133 |
-
echo "</optgroup>";
|
134 |
}
|
135 |
|
136 |
-
|
137 |
-
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
echo "</
|
144 |
}
|
|
|
|
|
|
|
145 |
?>
|
146 |
</select>
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
150 |
</p>
|
151 |
-
|
|
|
152 |
}
|
153 |
-
}
|
154 |
|
155 |
-
endif;
|
1 |
<?php
|
2 |
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // disable direct access
|
5 |
}
|
6 |
|
7 |
+
if ( ! class_exists( 'Mega_Menu_Widget' ) ) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
/**
|
10 |
+
* Outputs a registered menu location using wp_nav_menu
|
|
|
|
|
|
|
|
|
|
|
11 |
*/
|
12 |
+
class Mega_Menu_Widget extends WP_Widget {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Register widget with WordPress.
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
parent::__construct(
|
19 |
+
'maxmegamenu', // Base ID
|
20 |
+
'Max Mega Menu', // Name
|
21 |
+
array( 'description' => __( 'Outputs a menu for a selected theme location.', 'megamenu' ) ) // Args
|
22 |
+
);
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
/**
|
26 |
+
* Front-end display of widget.
|
27 |
+
*
|
28 |
+
* @since 1.7.4
|
29 |
+
* @see WP_Widget::widget()
|
30 |
+
* @param array $args Widget arguments.
|
31 |
+
* @param array $instance Saved values from database.
|
32 |
+
*/
|
33 |
+
public function widget( $args, $instance ) {
|
34 |
+
if ( ! is_array( $args ) ) {
|
35 |
+
$args = array(
|
36 |
+
'before_widget' => '',
|
37 |
+
'after_widget' => '',
|
38 |
+
);
|
39 |
}
|
40 |
|
41 |
+
extract( $args );
|
|
|
|
|
42 |
|
43 |
+
if ( isset( $instance['location'] ) ) {
|
44 |
+
$location = $instance['location'];
|
|
|
45 |
|
46 |
+
$title = apply_filters( 'widget_title', $instance['title'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
echo $before_widget;
|
|
|
49 |
|
50 |
+
if ( ! empty( $title ) ) {
|
51 |
+
echo $before_title . $title . $after_title;
|
52 |
+
}
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
if ( has_nav_menu( $location ) ) {
|
55 |
+
wp_nav_menu( array( 'theme_location' => $location ) );
|
56 |
+
}
|
57 |
|
58 |
+
echo $after_widget;
|
59 |
+
}
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
+
* Sanitize widget form values as they are saved.
|
64 |
+
*
|
65 |
+
* @since 1.7.4
|
66 |
+
* @see WP_Widget::update()
|
67 |
+
* @param array $new_instance Values just sent to be saved.
|
68 |
+
* @param array $old_instance Previously saved values from database.
|
69 |
+
* @return array Updated safe values to be saved.
|
70 |
+
*/
|
71 |
+
public function update( $new_instance, $old_instance ) {
|
72 |
+
$instance = array();
|
73 |
+
$instance['location'] = strip_tags( $new_instance['location'] );
|
74 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
75 |
+
|
76 |
+
return $instance;
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
+
* Back-end widget form.
|
81 |
+
*
|
82 |
+
* @since 1.7.4
|
83 |
+
* @see WP_Widget::form()
|
84 |
+
* @param array $instance Previously saved values from database.
|
85 |
+
*/
|
86 |
+
public function form( $instance ) {
|
87 |
+
|
88 |
+
$selected_location = 0;
|
89 |
+
$title = '';
|
90 |
+
$locations = get_registered_nav_menus();
|
91 |
+
|
92 |
+
if ( isset( $instance['location'] ) ) {
|
93 |
+
$selected_location = $instance['location'];
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( isset( $instance['title'] ) ) {
|
97 |
+
$title = $instance['title'];
|
98 |
+
}
|
99 |
+
|
100 |
+
?>
|
101 |
<p>
|
102 |
<?php if ( $locations ) { ?>
|
103 |
<p>
|
107 |
<label for="<?php echo $this->get_field_id( 'location' ); ?>"><?php _e( 'Menu Location:', 'megamenu' ); ?></label>
|
108 |
|
109 |
<select id="<?php echo $this->get_field_id( 'location' ); ?>" name="<?php echo $this->get_field_name( 'location' ); ?>">
|
110 |
+
<?php
|
111 |
+
if ( $selected_location === 0 ) {
|
112 |
+
echo "<option selected='true' disabled='disabled'>" . __( 'Select location', 'megamenu' ) . '</option>';
|
113 |
+
}
|
114 |
?>
|
115 |
|
116 |
<?php
|
117 |
|
118 |
+
$enabled_locations = array();
|
119 |
$disabled_locations = array();
|
120 |
|
121 |
+
foreach ( $locations as $location => $description ) {
|
122 |
+
if ( max_mega_menu_is_enabled( $location ) ) {
|
123 |
+
$enabled_locations[ $location ] = $description;
|
124 |
+
} else {
|
125 |
+
$disabled_locations[ $location ] = $description;
|
|
|
126 |
}
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( count( $enabled_locations ) ) {
|
130 |
+
echo "<optgroup label='✓ " . __( 'Active locations', 'megamenu' ) . "'>";
|
131 |
|
132 |
+
foreach ( $enabled_locations as $location => $description ) {
|
133 |
+
echo "<option value='{$location}'" . selected( $location, $selected_location ) . ">{$description}</option>";
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
+
echo '</optgroup>';
|
137 |
+
}
|
138 |
|
139 |
+
if ( count( $disabled_locations ) ) {
|
140 |
+
echo "<optgroup label='✘ " . __( 'Inactive locations', 'megamenu' ) . "'>";
|
141 |
+
|
142 |
+
foreach ( $disabled_locations as $location => $description ) {
|
143 |
+
echo "<option value='{$location}'" . selected( $location, $selected_location ) . ">{$description}</option>";
|
144 |
}
|
145 |
+
|
146 |
+
echo '</optgroup>';
|
147 |
+
}
|
148 |
?>
|
149 |
</select>
|
150 |
+
<?php
|
151 |
+
} else {
|
152 |
+
_e( 'No menu locations found', 'megamenu' );
|
153 |
+
}
|
154 |
+
?>
|
155 |
</p>
|
156 |
+
<?php
|
157 |
+
}
|
158 |
}
|
|
|
159 |
|
160 |
+
endif;
|
css/admin/admin.css
CHANGED
@@ -33,7 +33,7 @@
|
|
33 |
|
34 |
body[class*='_page_maxmegamenu_'] input.button-primary.is-busy,
|
35 |
body.toplevel_page_maxmegamenu input.button-primary.is-busy,
|
36 |
-
.nav-menus-php
|
37 |
pointer-events: none;
|
38 |
background-size: 100px 100% !important;
|
39 |
background-image: linear-gradient(-45deg, #007cba 28%, #006395 0, #006395 72%, #007cba 0) !important;
|
@@ -46,9 +46,9 @@ body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-disabled],
|
|
46 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip],
|
47 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled],
|
48 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
49 |
-
.nav-menus-php
|
50 |
-
.nav-menus-php
|
51 |
-
.nav-menus-php
|
52 |
position: relative; }
|
53 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip].mega-enabled:before,
|
54 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled].mega-enabled:before,
|
@@ -56,9 +56,9 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
56 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip].mega-enabled:before,
|
57 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled].mega-enabled:before,
|
58 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled].mega-enabled:before,
|
59 |
-
.nav-menus-php
|
60 |
-
.nav-menus-php
|
61 |
-
.nav-menus-php
|
62 |
content: attr(data-tooltip-enabled); }
|
63 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip].mega-disabled:before,
|
64 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled].mega-disabled:before,
|
@@ -66,9 +66,9 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
66 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip].mega-disabled:before,
|
67 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled].mega-disabled:before,
|
68 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled].mega-disabled:before,
|
69 |
-
.nav-menus-php
|
70 |
-
.nav-menus-php
|
71 |
-
.nav-menus-php
|
72 |
content: attr(data-tooltip-disabled); }
|
73 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip]:before,
|
74 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled]:before,
|
@@ -76,9 +76,9 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
76 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip]:before,
|
77 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:before,
|
78 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:before,
|
79 |
-
.nav-menus-php
|
80 |
-
.nav-menus-php
|
81 |
-
.nav-menus-php
|
82 |
position: absolute;
|
83 |
content: attr(data-tooltip);
|
84 |
top: -32px;
|
@@ -98,9 +98,9 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
98 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip]:after,
|
99 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:after,
|
100 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:after,
|
101 |
-
.nav-menus-php
|
102 |
-
.nav-menus-php
|
103 |
-
.nav-menus-php
|
104 |
top: -8px;
|
105 |
left: 8px;
|
106 |
border: solid transparent;
|
@@ -123,12 +123,12 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
123 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:after,
|
124 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:before,
|
125 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:after,
|
126 |
-
.nav-menus-php
|
127 |
-
.nav-menus-php
|
128 |
-
.nav-menus-php
|
129 |
-
.nav-menus-php
|
130 |
-
.nav-menus-php
|
131 |
-
.nav-menus-php
|
132 |
opacity: 0;
|
133 |
pointer-events: none;
|
134 |
text-align: center;
|
@@ -155,18 +155,18 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
155 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:focus:after,
|
156 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:hover:before,
|
157 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:hover:after,
|
158 |
-
.nav-menus-php
|
159 |
-
.nav-menus-php
|
160 |
-
.nav-menus-php
|
161 |
-
.nav-menus-php
|
162 |
-
.nav-menus-php
|
163 |
-
.nav-menus-php
|
164 |
-
.nav-menus-php
|
165 |
-
.nav-menus-php
|
166 |
-
.nav-menus-php
|
167 |
-
.nav-menus-php
|
168 |
-
.nav-menus-php
|
169 |
-
.nav-menus-php
|
170 |
opacity: 1; }
|
171 |
|
172 |
.nav-menus-php #cboxOverlay {
|
@@ -1282,16 +1282,37 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
1282 |
margin-right: 1px;
|
1283 |
height: auto; }
|
1284 |
|
|
|
|
|
|
|
1285 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content {
|
1286 |
-
padding: 0
|
1287 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion {
|
1288 |
float: left;
|
1289 |
width: 100%; }
|
|
|
|
|
|
|
|
|
|
|
1290 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title {
|
1291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1292 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content h4 {
|
1293 |
outline: none;
|
1294 |
-
float: left;
|
1295 |
border: 0;
|
1296 |
margin: 0;
|
1297 |
padding: 0;
|
@@ -1299,7 +1320,11 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
1299 |
overflow: hidden;
|
1300 |
text-overflow: ellipsis; }
|
1301 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content h4 .dashicons {
|
1302 |
-
margin-right:
|
|
|
|
|
|
|
|
|
1303 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content table {
|
1304 |
font-size: 0.9em;
|
1305 |
width: 100%;
|
@@ -1323,6 +1348,8 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
1323 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content table.sticky_settings td:nth-child(2) {
|
1324 |
text-align: right;
|
1325 |
min-width: 100px; }
|
|
|
|
|
1326 |
|
1327 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box p.submit {
|
1328 |
float: right;
|
@@ -1337,13 +1364,6 @@ body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
|
1337 |
.nav-menus-php .menu-item-handle .item-title {
|
1338 |
margin-right: 0; }
|
1339 |
|
1340 |
-
.toplevel_page_maxmegamenu .notice,
|
1341 |
-
.mega-menu_page_maxmegamenu_theme_editor .notice,
|
1342 |
-
.toplevel_page_maxmegamenu div.updated,
|
1343 |
-
.toplevel_page_maxmegamenu div.error {
|
1344 |
-
margin-left: 0;
|
1345 |
-
clear: both; }
|
1346 |
-
|
1347 |
body[class*='_page_maxmegamenu_'] .megamenu_outer_wrap,
|
1348 |
body.toplevel_page_maxmegamenu .megamenu_outer_wrap {
|
1349 |
display: inline-block;
|
@@ -1351,6 +1371,10 @@ body.toplevel_page_maxmegamenu .megamenu_outer_wrap {
|
|
1351 |
padding-right: 20px;
|
1352 |
padding-top: 10px;
|
1353 |
box-sizing: border-box; }
|
|
|
|
|
|
|
|
|
1354 |
|
1355 |
body[class*='_page_maxmegamenu_'] *:focus,
|
1356 |
body.toplevel_page_maxmegamenu *:focus {
|
@@ -1785,11 +1809,11 @@ body.toplevel_page_maxmegamenu .megamenu_right {
|
|
1785 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector,
|
1786 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector {
|
1787 |
margin-bottom: 20px;
|
1788 |
-
float: left;
|
1789 |
-
font-size: 12px; }
|
1790 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector select,
|
1791 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector select {
|
1792 |
-
max-width: 500px;
|
|
|
1793 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .mega-ellipsis,
|
1794 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .mega-ellipsis {
|
1795 |
float: left;
|
@@ -1823,6 +1847,13 @@ body.toplevel_page_maxmegamenu .megamenu_right {
|
|
1823 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location-disabled-assign-menu .mega-accordion-content,
|
1824 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location-disabled-assign-menu .mega-accordion-content {
|
1825 |
padding: 10px 20px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1826 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location,
|
1827 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location {
|
1828 |
font-size: 14px;
|
@@ -1855,6 +1886,14 @@ body.toplevel_page_maxmegamenu .megamenu_right {
|
|
1855 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content,
|
1856 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content {
|
1857 |
border-top: 1px solid #DFDFDF; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1858 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu_submit,
|
1859 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu_submit {
|
1860 |
background: #f7f7f7;
|
@@ -2341,14 +2380,29 @@ body.toplevel_page_maxmegamenu .mega-delete {
|
|
2341 |
.mega-ellipsis {
|
2342 |
float: right;
|
2343 |
position: relative;
|
2344 |
-
height:
|
2345 |
.mega-ellipsis svg {
|
2346 |
cursor: pointer;
|
2347 |
fill: black;
|
2348 |
-
height:
|
2349 |
-
width:
|
|
|
|
|
2350 |
.mega-ellipsis.mega-ellipsis-open ul.mega-ellipsis-content {
|
2351 |
display: block; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2352 |
.mega-ellipsis ul.mega-ellipsis-content {
|
2353 |
display: none;
|
2354 |
position: absolute;
|
33 |
|
34 |
body[class*='_page_maxmegamenu_'] input.button-primary.is-busy,
|
35 |
body.toplevel_page_maxmegamenu input.button-primary.is-busy,
|
36 |
+
.nav-menus-php input.button-primary.is-busy {
|
37 |
pointer-events: none;
|
38 |
background-size: 100px 100% !important;
|
39 |
background-image: linear-gradient(-45deg, #007cba 28%, #006395 0, #006395 72%, #007cba 0) !important;
|
46 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip],
|
47 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled],
|
48 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled],
|
49 |
+
.nav-menus-php .mega-tooltip[data-tooltip],
|
50 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled],
|
51 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled] {
|
52 |
position: relative; }
|
53 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip].mega-enabled:before,
|
54 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled].mega-enabled:before,
|
56 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip].mega-enabled:before,
|
57 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled].mega-enabled:before,
|
58 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled].mega-enabled:before,
|
59 |
+
.nav-menus-php .mega-tooltip[data-tooltip].mega-enabled:before,
|
60 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled].mega-enabled:before,
|
61 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled].mega-enabled:before {
|
62 |
content: attr(data-tooltip-enabled); }
|
63 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip].mega-disabled:before,
|
64 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled].mega-disabled:before,
|
66 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip].mega-disabled:before,
|
67 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled].mega-disabled:before,
|
68 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled].mega-disabled:before,
|
69 |
+
.nav-menus-php .mega-tooltip[data-tooltip].mega-disabled:before,
|
70 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled].mega-disabled:before,
|
71 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled].mega-disabled:before {
|
72 |
content: attr(data-tooltip-disabled); }
|
73 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip]:before,
|
74 |
body[class*='_page_maxmegamenu_'] .mega-tooltip[data-tooltip-enabled]:before,
|
76 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip]:before,
|
77 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:before,
|
78 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:before,
|
79 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:before,
|
80 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:before,
|
81 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:before {
|
82 |
position: absolute;
|
83 |
content: attr(data-tooltip);
|
84 |
top: -32px;
|
98 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip]:after,
|
99 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:after,
|
100 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:after,
|
101 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:after,
|
102 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:after,
|
103 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:after {
|
104 |
top: -8px;
|
105 |
left: 8px;
|
106 |
border: solid transparent;
|
123 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-enabled]:after,
|
124 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:before,
|
125 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:after,
|
126 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:before,
|
127 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:after,
|
128 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:before,
|
129 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:after,
|
130 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:before,
|
131 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:after {
|
132 |
opacity: 0;
|
133 |
pointer-events: none;
|
134 |
text-align: center;
|
155 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:focus:after,
|
156 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:hover:before,
|
157 |
body.toplevel_page_maxmegamenu .mega-tooltip[data-tooltip-disabled]:hover:after,
|
158 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:focus:before,
|
159 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:focus:after,
|
160 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:hover:before,
|
161 |
+
.nav-menus-php .mega-tooltip[data-tooltip]:hover:after,
|
162 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:focus:before,
|
163 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:focus:after,
|
164 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:hover:before,
|
165 |
+
.nav-menus-php .mega-tooltip[data-tooltip-enabled]:hover:after,
|
166 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:focus:before,
|
167 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:focus:after,
|
168 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:hover:before,
|
169 |
+
.nav-menus-php .mega-tooltip[data-tooltip-disabled]:hover:after {
|
170 |
opacity: 1; }
|
171 |
|
172 |
.nav-menus-php #cboxOverlay {
|
1282 |
margin-right: 1px;
|
1283 |
height: auto; }
|
1284 |
|
1285 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box .inside {
|
1286 |
+
margin: 0; }
|
1287 |
+
|
1288 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content {
|
1289 |
+
padding: 0; }
|
1290 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion {
|
1291 |
float: left;
|
1292 |
width: 100%; }
|
1293 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-content {
|
1294 |
+
padding: 10px 14px 0 14px;
|
1295 |
+
border-bottom: 1px solid #ccc; }
|
1296 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-content:last-child {
|
1297 |
+
border-bottom: 0; }
|
1298 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title {
|
1299 |
+
border-bottom: 1px solid #ccc;
|
1300 |
+
padding: 10px 3px 10px 10px;
|
1301 |
+
box-sizing: border-box; }
|
1302 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title.mega-last:not(.mega-accordion-open) {
|
1303 |
+
border-bottom: 0; }
|
1304 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title .dashicons {
|
1305 |
+
margin-right: 4px; }
|
1306 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title .dashicons-yes {
|
1307 |
+
display: none; }
|
1308 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title.mega-location-enabled .dashicons-yes {
|
1309 |
+
display: inline-block;
|
1310 |
+
margin-left: 4px;
|
1311 |
+
color: #46b450; }
|
1312 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-accordion-title.mega-location-enabled.mega-has-active-location .dashicons-yes {
|
1313 |
+
color: #F56E28; }
|
1314 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content h4 {
|
1315 |
outline: none;
|
|
|
1316 |
border: 0;
|
1317 |
margin: 0;
|
1318 |
padding: 0;
|
1320 |
overflow: hidden;
|
1321 |
text-overflow: ellipsis; }
|
1322 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content h4 .dashicons {
|
1323 |
+
margin-right: 0; }
|
1324 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-location-info {
|
1325 |
+
font-size: 10px;
|
1326 |
+
margin-left: 28px;
|
1327 |
+
line-height: 18px; }
|
1328 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content table {
|
1329 |
font-size: 0.9em;
|
1330 |
width: 100%;
|
1348 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content table.sticky_settings td:nth-child(2) {
|
1349 |
text-align: right;
|
1350 |
min-width: 100px; }
|
1351 |
+
.nav-menus-php #nav-menu-meta .mega_menu_meta_box div.accordion-section-content .mega-ellipsis {
|
1352 |
+
margin-right: 5px; }
|
1353 |
|
1354 |
.nav-menus-php #nav-menu-meta .mega_menu_meta_box p.submit {
|
1355 |
float: right;
|
1364 |
.nav-menus-php .menu-item-handle .item-title {
|
1365 |
margin-right: 0; }
|
1366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1367 |
body[class*='_page_maxmegamenu_'] .megamenu_outer_wrap,
|
1368 |
body.toplevel_page_maxmegamenu .megamenu_outer_wrap {
|
1369 |
display: inline-block;
|
1371 |
padding-right: 20px;
|
1372 |
padding-top: 10px;
|
1373 |
box-sizing: border-box; }
|
1374 |
+
body[class*='_page_maxmegamenu_'] .megamenu_outer_wrap .notice,
|
1375 |
+
body.toplevel_page_maxmegamenu .megamenu_outer_wrap .notice {
|
1376 |
+
margin: 0 0 20px 0;
|
1377 |
+
clear: both; }
|
1378 |
|
1379 |
body[class*='_page_maxmegamenu_'] *:focus,
|
1380 |
body.toplevel_page_maxmegamenu *:focus {
|
1809 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector,
|
1810 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector {
|
1811 |
margin-bottom: 20px;
|
1812 |
+
float: left; }
|
|
|
1813 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector select,
|
1814 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .theme_selector select {
|
1815 |
+
max-width: 500px;
|
1816 |
+
font-size: 12px; }
|
1817 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_themes .mega-ellipsis,
|
1818 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_themes .mega-ellipsis {
|
1819 |
float: left;
|
1847 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location-disabled-assign-menu .mega-accordion-content,
|
1848 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location-disabled-assign-menu .mega-accordion-content {
|
1849 |
padding: 10px 20px; }
|
1850 |
+
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-enabled-locations,
|
1851 |
+
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-enabled-locations {
|
1852 |
+
float: left;
|
1853 |
+
width: 100%; }
|
1854 |
+
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-enabled-locations:empty,
|
1855 |
+
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-enabled-locations:empty {
|
1856 |
+
display: none; }
|
1857 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location,
|
1858 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location {
|
1859 |
font-size: 14px;
|
1886 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content,
|
1887 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content {
|
1888 |
border-top: 1px solid #DFDFDF; }
|
1889 |
+
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu-edit-theme,
|
1890 |
+
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu-edit-theme {
|
1891 |
+
opacity: 0.6;
|
1892 |
+
line-height: 26px;
|
1893 |
+
margin-left: 5px; }
|
1894 |
+
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu-edit-theme:hover,
|
1895 |
+
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu-edit-theme:hover {
|
1896 |
+
opacity: 1; }
|
1897 |
body[class*='_page_maxmegamenu_'] .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu_submit,
|
1898 |
body.toplevel_page_maxmegamenu .megamenu_right .menu_settings.menu_settings_menu_locations .mega-location .mega-accordion-content .megamenu_submit {
|
1899 |
background: #f7f7f7;
|
2380 |
.mega-ellipsis {
|
2381 |
float: right;
|
2382 |
position: relative;
|
2383 |
+
height: 24px; }
|
2384 |
.mega-ellipsis svg {
|
2385 |
cursor: pointer;
|
2386 |
fill: black;
|
2387 |
+
height: 24px;
|
2388 |
+
width: 24px; }
|
2389 |
+
.mega-ellipsis.mega-ellipsis-horizontal svg {
|
2390 |
+
transform: rotate(90deg); }
|
2391 |
.mega-ellipsis.mega-ellipsis-open ul.mega-ellipsis-content {
|
2392 |
display: block; }
|
2393 |
+
.mega-ellipsis.mega-ellipsis-left ul.mega-ellipsis-content {
|
2394 |
+
left: -177px;
|
2395 |
+
top: -5px; }
|
2396 |
+
.mega-ellipsis.mega-ellipsis-left ul.mega-ellipsis-content:after {
|
2397 |
+
top: 8px;
|
2398 |
+
right: -14px;
|
2399 |
+
transform: rotate(90deg); }
|
2400 |
+
.mega-ellipsis.mega-ellipsis-left ul.mega-ellipsis-content:before {
|
2401 |
+
top: 7px;
|
2402 |
+
right: -16px;
|
2403 |
+
transform: rotate(90deg); }
|
2404 |
+
.mega-ellipsis.mega-ellipsis-left ul.mega-ellipsis-content li a {
|
2405 |
+
line-height: 30px; }
|
2406 |
.mega-ellipsis ul.mega-ellipsis-content {
|
2407 |
display: none;
|
2408 |
position: absolute;
|
css/admin/admin.scss
CHANGED
@@ -57,7 +57,7 @@ $header_height: 75px;
|
|
57 |
|
58 |
body[class*='_page_maxmegamenu_'],
|
59 |
body.toplevel_page_maxmegamenu,
|
60 |
-
.nav-menus-php
|
61 |
input.button-primary.is-busy {
|
62 |
pointer-events: none;
|
63 |
background-size: 100px 100% !important;
|
@@ -1418,21 +1418,56 @@ body.toplevel_page_maxmegamenu,
|
|
1418 |
}
|
1419 |
|
1420 |
#nav-menu-meta .mega_menu_meta_box {
|
|
|
|
|
|
|
1421 |
div.accordion-section-content {
|
1422 |
-
padding: 0
|
1423 |
|
1424 |
.mega-accordion {
|
1425 |
float: left;
|
1426 |
width: 100%;
|
1427 |
}
|
1428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1429 |
.mega-accordion-title {
|
1430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1431 |
}
|
1432 |
|
1433 |
h4 {
|
1434 |
outline: none;
|
1435 |
-
float: left;
|
1436 |
border: 0;
|
1437 |
margin: 0;
|
1438 |
padding: 0;
|
@@ -1441,10 +1476,16 @@ body.toplevel_page_maxmegamenu,
|
|
1441 |
text-overflow: ellipsis;
|
1442 |
|
1443 |
.dashicons {
|
1444 |
-
margin-right:
|
1445 |
}
|
1446 |
}
|
1447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1448 |
table {
|
1449 |
font-size: 0.9em;
|
1450 |
width: 100%;
|
@@ -1487,6 +1528,10 @@ body.toplevel_page_maxmegamenu,
|
|
1487 |
}
|
1488 |
}
|
1489 |
}
|
|
|
|
|
|
|
|
|
1490 |
}
|
1491 |
|
1492 |
p.submit {
|
@@ -1510,14 +1555,6 @@ body.toplevel_page_maxmegamenu,
|
|
1510 |
}
|
1511 |
}
|
1512 |
|
1513 |
-
.toplevel_page_maxmegamenu .notice,
|
1514 |
-
.mega-menu_page_maxmegamenu_theme_editor .notice,
|
1515 |
-
.toplevel_page_maxmegamenu div.updated,
|
1516 |
-
.toplevel_page_maxmegamenu div.error {
|
1517 |
-
margin-left: 0;
|
1518 |
-
clear: both;
|
1519 |
-
}
|
1520 |
-
|
1521 |
body[class*='_page_maxmegamenu_'],
|
1522 |
body.toplevel_page_maxmegamenu {
|
1523 |
|
@@ -1527,6 +1564,11 @@ body.toplevel_page_maxmegamenu {
|
|
1527 |
padding-right: 20px;
|
1528 |
padding-top: 10px;
|
1529 |
box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
|
1530 |
}
|
1531 |
*:focus {
|
1532 |
box-shadow: 0 0 0;
|
@@ -1922,7 +1964,7 @@ body.toplevel_page_maxmegamenu {
|
|
1922 |
}
|
1923 |
|
1924 |
.menu_settings {
|
1925 |
-
|
1926 |
.mega-tooltip {
|
1927 |
&:before {
|
1928 |
top: -29px;
|
@@ -2022,10 +2064,10 @@ body.toplevel_page_maxmegamenu {
|
|
2022 |
.theme_selector {
|
2023 |
margin-bottom: 20px;
|
2024 |
float: left;
|
2025 |
-
|
2026 |
-
|
2027 |
select {
|
2028 |
max-width: 500px;
|
|
|
2029 |
}
|
2030 |
}
|
2031 |
|
@@ -2072,6 +2114,15 @@ body.toplevel_page_maxmegamenu {
|
|
2072 |
.mega-location-disabled-assign-menu .mega-accordion-content {
|
2073 |
padding: 10px 20px;
|
2074 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2075 |
.mega-location {
|
2076 |
font-size: 14px;
|
2077 |
border: 0;
|
@@ -2094,7 +2145,7 @@ body.toplevel_page_maxmegamenu {
|
|
2094 |
display: none;
|
2095 |
}
|
2096 |
}
|
2097 |
-
|
2098 |
&.mega-location-enabled {
|
2099 |
.mega-accordion-title .dashicons-yes {
|
2100 |
color: $green;
|
@@ -2107,11 +2158,21 @@ body.toplevel_page_maxmegamenu {
|
|
2107 |
color: #F56E28;
|
2108 |
}
|
2109 |
}
|
|
|
2110 |
}
|
2111 |
|
2112 |
.mega-accordion-content {
|
2113 |
border-top: 1px solid $grey;
|
2114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2115 |
.megamenu_submit {
|
2116 |
background: $light_grey;
|
2117 |
padding: 20px 10px;
|
@@ -2684,13 +2745,17 @@ body.toplevel_page_maxmegamenu {
|
|
2684 |
.mega-ellipsis {
|
2685 |
float: right;
|
2686 |
position: relative;
|
2687 |
-
height:
|
2688 |
|
2689 |
svg {
|
2690 |
cursor: pointer;
|
2691 |
fill: black;
|
2692 |
-
height:
|
2693 |
-
width:
|
|
|
|
|
|
|
|
|
2694 |
}
|
2695 |
|
2696 |
&.mega-ellipsis-open {
|
@@ -2699,6 +2764,31 @@ body.toplevel_page_maxmegamenu {
|
|
2699 |
}
|
2700 |
}
|
2701 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2702 |
ul.mega-ellipsis-content {
|
2703 |
display: none;
|
2704 |
position: absolute;
|
57 |
|
58 |
body[class*='_page_maxmegamenu_'],
|
59 |
body.toplevel_page_maxmegamenu,
|
60 |
+
.nav-menus-php {
|
61 |
input.button-primary.is-busy {
|
62 |
pointer-events: none;
|
63 |
background-size: 100px 100% !important;
|
1418 |
}
|
1419 |
|
1420 |
#nav-menu-meta .mega_menu_meta_box {
|
1421 |
+
.inside {
|
1422 |
+
margin: 0;
|
1423 |
+
}
|
1424 |
div.accordion-section-content {
|
1425 |
+
padding: 0;
|
1426 |
|
1427 |
.mega-accordion {
|
1428 |
float: left;
|
1429 |
width: 100%;
|
1430 |
}
|
1431 |
|
1432 |
+
.mega-accordion-content {
|
1433 |
+
padding: 10px 14px 0 14px;
|
1434 |
+
border-bottom: 1px solid #ccc;
|
1435 |
+
|
1436 |
+
&:last-child {
|
1437 |
+
border-bottom: 0;
|
1438 |
+
}
|
1439 |
+
}
|
1440 |
+
|
1441 |
.mega-accordion-title {
|
1442 |
+
border-bottom: 1px solid #ccc;
|
1443 |
+
padding: 10px 3px 10px 10px;
|
1444 |
+
box-sizing: border-box;
|
1445 |
+
|
1446 |
+
&.mega-last:not(.mega-accordion-open) {
|
1447 |
+
border-bottom: 0;
|
1448 |
+
}
|
1449 |
+
.dashicons {
|
1450 |
+
margin-right: 4px;
|
1451 |
+
}
|
1452 |
+
.dashicons-yes {
|
1453 |
+
display: none;
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
&.mega-location-enabled {
|
1457 |
+
.dashicons-yes {
|
1458 |
+
display: inline-block;
|
1459 |
+
margin-left: 4px;
|
1460 |
+
color: $green;
|
1461 |
+
}
|
1462 |
+
|
1463 |
+
&.mega-has-active-location .dashicons-yes {
|
1464 |
+
color: #F56E28;
|
1465 |
+
}
|
1466 |
+
}
|
1467 |
}
|
1468 |
|
1469 |
h4 {
|
1470 |
outline: none;
|
|
|
1471 |
border: 0;
|
1472 |
margin: 0;
|
1473 |
padding: 0;
|
1476 |
text-overflow: ellipsis;
|
1477 |
|
1478 |
.dashicons {
|
1479 |
+
margin-right: 0;
|
1480 |
}
|
1481 |
}
|
1482 |
|
1483 |
+
.mega-location-info {
|
1484 |
+
font-size: 10px;
|
1485 |
+
margin-left: 28px;
|
1486 |
+
line-height: 18px;
|
1487 |
+
}
|
1488 |
+
|
1489 |
table {
|
1490 |
font-size: 0.9em;
|
1491 |
width: 100%;
|
1528 |
}
|
1529 |
}
|
1530 |
}
|
1531 |
+
|
1532 |
+
.mega-ellipsis {
|
1533 |
+
margin-right: 5px;
|
1534 |
+
}
|
1535 |
}
|
1536 |
|
1537 |
p.submit {
|
1555 |
}
|
1556 |
}
|
1557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1558 |
body[class*='_page_maxmegamenu_'],
|
1559 |
body.toplevel_page_maxmegamenu {
|
1560 |
|
1564 |
padding-right: 20px;
|
1565 |
padding-top: 10px;
|
1566 |
box-sizing: border-box;
|
1567 |
+
|
1568 |
+
.notice {
|
1569 |
+
margin: 0 0 20px 0;
|
1570 |
+
clear: both;
|
1571 |
+
}
|
1572 |
}
|
1573 |
*:focus {
|
1574 |
box-shadow: 0 0 0;
|
1964 |
}
|
1965 |
|
1966 |
.menu_settings {
|
1967 |
+
|
1968 |
.mega-tooltip {
|
1969 |
&:before {
|
1970 |
top: -29px;
|
2064 |
.theme_selector {
|
2065 |
margin-bottom: 20px;
|
2066 |
float: left;
|
2067 |
+
|
|
|
2068 |
select {
|
2069 |
max-width: 500px;
|
2070 |
+
font-size: 12px;
|
2071 |
}
|
2072 |
}
|
2073 |
|
2114 |
.mega-location-disabled-assign-menu .mega-accordion-content {
|
2115 |
padding: 10px 20px;
|
2116 |
}
|
2117 |
+
|
2118 |
+
.mega-enabled-locations {
|
2119 |
+
float: left;
|
2120 |
+
width: 100%;
|
2121 |
+
|
2122 |
+
&:empty {
|
2123 |
+
display: none;
|
2124 |
+
}
|
2125 |
+
}
|
2126 |
.mega-location {
|
2127 |
font-size: 14px;
|
2128 |
border: 0;
|
2145 |
display: none;
|
2146 |
}
|
2147 |
}
|
2148 |
+
|
2149 |
&.mega-location-enabled {
|
2150 |
.mega-accordion-title .dashicons-yes {
|
2151 |
color: $green;
|
2158 |
color: #F56E28;
|
2159 |
}
|
2160 |
}
|
2161 |
+
|
2162 |
}
|
2163 |
|
2164 |
.mega-accordion-content {
|
2165 |
border-top: 1px solid $grey;
|
2166 |
|
2167 |
+
.megamenu-edit-theme {
|
2168 |
+
opacity: 0.6;
|
2169 |
+
line-height: 26px;
|
2170 |
+
margin-left: 5px;
|
2171 |
+
|
2172 |
+
&:hover {
|
2173 |
+
opacity: 1;
|
2174 |
+
}
|
2175 |
+
}
|
2176 |
.megamenu_submit {
|
2177 |
background: $light_grey;
|
2178 |
padding: 20px 10px;
|
2745 |
.mega-ellipsis {
|
2746 |
float: right;
|
2747 |
position: relative;
|
2748 |
+
height: 24px;
|
2749 |
|
2750 |
svg {
|
2751 |
cursor: pointer;
|
2752 |
fill: black;
|
2753 |
+
height: 24px;
|
2754 |
+
width: 24px;
|
2755 |
+
}
|
2756 |
+
|
2757 |
+
&.mega-ellipsis-horizontal svg {
|
2758 |
+
transform: rotate(90deg);
|
2759 |
}
|
2760 |
|
2761 |
&.mega-ellipsis-open {
|
2764 |
}
|
2765 |
}
|
2766 |
|
2767 |
+
&.mega-ellipsis-left {
|
2768 |
+
ul.mega-ellipsis-content {
|
2769 |
+
left: -177px;
|
2770 |
+
top: -5px;
|
2771 |
+
|
2772 |
+
&:after {
|
2773 |
+
top: 8px;
|
2774 |
+
right: -14px;
|
2775 |
+
transform: rotate(90deg);
|
2776 |
+
}
|
2777 |
+
|
2778 |
+
&:before {
|
2779 |
+
top: 7px;
|
2780 |
+
right: -16px;
|
2781 |
+
transform: rotate(90deg);
|
2782 |
+
}
|
2783 |
+
|
2784 |
+
li {
|
2785 |
+
a {
|
2786 |
+
line-height: 30px;
|
2787 |
+
}
|
2788 |
+
}
|
2789 |
+
}
|
2790 |
+
}
|
2791 |
+
|
2792 |
ul.mega-ellipsis-content {
|
2793 |
display: none;
|
2794 |
position: absolute;
|
js/admin.js
CHANGED
@@ -57,7 +57,7 @@
|
|
57 |
return;
|
58 |
}
|
59 |
|
60 |
-
if ( confirm(
|
61 |
originalClose();
|
62 |
}
|
63 |
};
|
@@ -1227,7 +1227,9 @@ jQuery(function($) {
|
|
1227 |
$(".mega_menu_meta_box .spinner").css("visibility", "visible");
|
1228 |
|
1229 |
var settings = JSON.stringify($("[name^='megamenu_meta']").serializeArray());
|
1230 |
-
|
|
|
|
|
1231 |
// retrieve the widget settings form
|
1232 |
$.post(ajaxurl, {
|
1233 |
action: "mm_save_settings",
|
@@ -1236,21 +1238,31 @@ jQuery(function($) {
|
|
1236 |
nonce: megamenu.nonce
|
1237 |
}, function(response) {
|
1238 |
$(".mega_menu_meta_box .spinner").css("visibility", "hidden");
|
|
|
|
|
|
|
|
|
|
|
|
|
1239 |
});
|
1240 |
});
|
1241 |
|
1242 |
$(".mega-accordion-title").on('click', function(e) {
|
1243 |
e.preventDefault();
|
|
|
1244 |
|
1245 |
var title = $(this);
|
1246 |
var content = title.next('.mega-accordion-content');
|
1247 |
|
|
|
|
|
1248 |
if ( content.is(':hidden') ) {
|
1249 |
-
content.slideDown();
|
1250 |
title.addClass('mega-accordion-open');
|
1251 |
} else {
|
1252 |
-
content.slideUp()
|
1253 |
-
|
|
|
1254 |
}
|
1255 |
});
|
1256 |
|
57 |
return;
|
58 |
}
|
59 |
|
60 |
+
if ( confirm( megamenu.unsaved_changes ) ) {
|
61 |
originalClose();
|
62 |
}
|
63 |
};
|
1227 |
$(".mega_menu_meta_box .spinner").css("visibility", "visible");
|
1228 |
|
1229 |
var settings = JSON.stringify($("[name^='megamenu_meta']").serializeArray());
|
1230 |
+
var button = $(this);
|
1231 |
+
var enabled = button.parent().parent().find(".megamenu_enabled");
|
1232 |
+
var title = button.parent().parent().prev();
|
1233 |
// retrieve the widget settings form
|
1234 |
$.post(ajaxurl, {
|
1235 |
action: "mm_save_settings",
|
1238 |
nonce: megamenu.nonce
|
1239 |
}, function(response) {
|
1240 |
$(".mega_menu_meta_box .spinner").css("visibility", "hidden");
|
1241 |
+
|
1242 |
+
if ( enabled.is(":checked") ) {
|
1243 |
+
title.addClass("mega-location-enabled");
|
1244 |
+
} else {
|
1245 |
+
title.removeClass("mega-location-enabled");
|
1246 |
+
}
|
1247 |
});
|
1248 |
});
|
1249 |
|
1250 |
$(".mega-accordion-title").on('click', function(e) {
|
1251 |
e.preventDefault();
|
1252 |
+
e.stopPropagation();
|
1253 |
|
1254 |
var title = $(this);
|
1255 |
var content = title.next('.mega-accordion-content');
|
1256 |
|
1257 |
+
$(".mega-accordion-content:visible").slideUp('fast');
|
1258 |
+
|
1259 |
if ( content.is(':hidden') ) {
|
1260 |
+
content.slideDown('fast');
|
1261 |
title.addClass('mega-accordion-open');
|
1262 |
} else {
|
1263 |
+
content.slideUp('fast', function() {
|
1264 |
+
title.removeClass('mega-accordion-open');
|
1265 |
+
});
|
1266 |
}
|
1267 |
});
|
1268 |
|
js/maxmegamenu.js
CHANGED
@@ -512,9 +512,10 @@
|
|
512 |
};
|
513 |
|
514 |
plugin.initToggleBar = function() {
|
515 |
-
// mobile menu
|
516 |
$toggle_bar.on("click", function(e) {
|
517 |
if ( $(e.target).is(".mega-menu-toggle, .mega-menu-toggle-custom-block *, .mega-menu-toggle-block, .mega-menu-toggle-animated-block, .mega-menu-toggle-animated-block *, .mega-toggle-blocks-left, .mega-toggle-blocks-center, .mega-toggle-blocks-right, .mega-toggle-label, .mega-toggle-label span") ) {
|
|
|
|
|
518 |
if ($(this).hasClass("mega-menu-open")) {
|
519 |
plugin.hideMobileMenu();
|
520 |
} else {
|
@@ -574,6 +575,8 @@
|
|
574 |
});
|
575 |
|
576 |
$toggle_bar.removeClass("mega-menu-open");
|
|
|
|
|
577 |
};
|
578 |
|
579 |
plugin.showMobileMenu = function() {
|
@@ -598,6 +601,8 @@
|
|
598 |
}
|
599 |
|
600 |
$toggle_bar.addClass("mega-menu-open");
|
|
|
|
|
601 |
};
|
602 |
|
603 |
plugin.toggleBarForceWidth = function() {
|
512 |
};
|
513 |
|
514 |
plugin.initToggleBar = function() {
|
|
|
515 |
$toggle_bar.on("click", function(e) {
|
516 |
if ( $(e.target).is(".mega-menu-toggle, .mega-menu-toggle-custom-block *, .mega-menu-toggle-block, .mega-menu-toggle-animated-block, .mega-menu-toggle-animated-block *, .mega-toggle-blocks-left, .mega-toggle-blocks-center, .mega-toggle-blocks-right, .mega-toggle-label, .mega-toggle-label span") ) {
|
517 |
+
e.preventDefault();
|
518 |
+
|
519 |
if ($(this).hasClass("mega-menu-open")) {
|
520 |
plugin.hideMobileMenu();
|
521 |
} else {
|
575 |
});
|
576 |
|
577 |
$toggle_bar.removeClass("mega-menu-open");
|
578 |
+
|
579 |
+
$menu.triggerHandler("mmm:hideMobileMenu");
|
580 |
};
|
581 |
|
582 |
plugin.showMobileMenu = function() {
|
601 |
}
|
602 |
|
603 |
$toggle_bar.addClass("mega-menu-open");
|
604 |
+
|
605 |
+
$menu.triggerHandler("mmm:showMobileMenu");
|
606 |
};
|
607 |
|
608 |
plugin.toggleBarForceWidth = function() {
|
js/settings.js
CHANGED
@@ -220,6 +220,7 @@ jQuery(function ($) {
|
|
220 |
|
221 |
$(".mega-accordion-title").on('click', function(e) {
|
222 |
e.preventDefault();
|
|
|
223 |
|
224 |
var title = $(this);
|
225 |
var content = title.next('.mega-accordion-content');
|
@@ -227,13 +228,14 @@ jQuery(function ($) {
|
|
227 |
$(".mega-accordion-content:visible").slideUp('fast');
|
228 |
|
229 |
if ( content.is(':hidden') ) {
|
230 |
-
content.slideDown('fast')
|
231 |
-
|
|
|
232 |
} else {
|
233 |
-
content.slideUp('fast')
|
234 |
-
|
|
|
235 |
}
|
236 |
-
|
237 |
});
|
238 |
|
239 |
$(".mega-ellipsis").on('click', function(e) {
|
@@ -256,4 +258,9 @@ jQuery(function ($) {
|
|
256 |
}
|
257 |
});
|
258 |
|
|
|
|
|
|
|
|
|
|
|
259 |
});
|
220 |
|
221 |
$(".mega-accordion-title").on('click', function(e) {
|
222 |
e.preventDefault();
|
223 |
+
e.stopPropagation();
|
224 |
|
225 |
var title = $(this);
|
226 |
var content = title.next('.mega-accordion-content');
|
228 |
$(".mega-accordion-content:visible").slideUp('fast');
|
229 |
|
230 |
if ( content.is(':hidden') ) {
|
231 |
+
content.slideDown('fast', function() {
|
232 |
+
title.addClass('mega-accordion-open');
|
233 |
+
});
|
234 |
} else {
|
235 |
+
content.slideUp('fast', function() {
|
236 |
+
title.removeClass('mega-accordion-open');
|
237 |
+
});
|
238 |
}
|
|
|
239 |
});
|
240 |
|
241 |
$(".mega-ellipsis").on('click', function(e) {
|
258 |
}
|
259 |
});
|
260 |
|
261 |
+
$('.megamenu-edit-theme').on("click", function() {
|
262 |
+
var url = $(this).siblings("select").find(":selected").attr('data-url');
|
263 |
+
window.location.href = url;
|
264 |
+
});
|
265 |
+
|
266 |
});
|
megamenu.php
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
* Plugin Name: Max Mega Menu
|
5 |
* Plugin URI: https://www.megamenu.com
|
6 |
* Description: An easy to use mega menu plugin. Written the WordPress way.
|
7 |
-
* Version: 2.
|
8 |
* Author: megamenu.com
|
9 |
* Author URI: https://www.megamenu.com
|
10 |
* License: GPL-2.0+
|
@@ -22,1588 +21,1609 @@
|
|
22 |
*/
|
23 |
|
24 |
if ( ! defined( 'ABSPATH' ) ) {
|
25 |
-
|
26 |
}
|
27 |
|
28 |
if ( ! class_exists( 'Mega_Menu' ) ) :
|
29 |
|
30 |
-
/**
|
31 |
-
|
32 |
-
|
33 |
-
final class Mega_Menu {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
|
|
|
|
35 |
|
36 |
-
/**
|
37 |
-
* @var string
|
38 |
-
*/
|
39 |
-
public $version = '2.8.0.3';
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
public $scss_last_updated = '2.4.1.3';
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Init
|
50 |
-
*
|
51 |
-
* @since 1.0
|
52 |
-
*/
|
53 |
-
public static function init() {
|
54 |
-
$plugin = new self();
|
55 |
-
}
|
56 |
-
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Constructor
|
60 |
-
*
|
61 |
-
* @since 1.0
|
62 |
-
*/
|
63 |
-
public function __construct() {
|
64 |
-
|
65 |
-
|
66 |
-
$this->define_constants();
|
67 |
-
$this->includes();
|
68 |
-
|
69 |
-
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
|
70 |
-
add_action( 'init', array( $this, 'register_sidebar' ) );
|
71 |
-
add_action( 'admin_init', array( $this, 'install_upgrade_check' ) );
|
72 |
-
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
73 |
-
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
74 |
-
add_filter( 'in_widget_form', array( $this, 'add_notice_to_nav_menu_widget' ) , 10, 3 );
|
75 |
-
|
76 |
-
add_action( 'after_setup_theme', array( $this, 'register_nav_menus' ) );
|
77 |
-
|
78 |
-
add_filter( 'wp_nav_menu_args', array( $this, 'modify_nav_menu_args' ), 99999 );
|
79 |
-
add_filter( 'wp_nav_menu', array( $this, 'add_responsive_toggle' ), 10, 2 );
|
80 |
-
|
81 |
-
add_filter( 'wp_nav_menu_objects', array( $this, 'add_widgets_to_menu' ), apply_filters("megamenu_wp_nav_menu_objects_priority", 10), 2 );
|
82 |
-
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_depth_to_menu_items' ), 5, 2 );
|
83 |
-
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
84 |
-
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
85 |
-
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
86 |
-
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'set_descriptions_if_enabled' ), 8, 2 );
|
87 |
-
add_filter( 'body_class', array($this, 'add_megamenu_body_classes'), 10, 1);
|
88 |
-
|
89 |
-
add_filter( 'megamenu_nav_menu_css_class', array( $this, 'prefix_menu_classes' ), 10, 3 );
|
90 |
-
|
91 |
-
// plugin compatibility
|
92 |
-
add_filter( 'conditional_menus_theme_location', array( $this, 'conditional_menus_restore_theme_location'), 10, 3 );
|
93 |
-
add_filter( 'black_studio_tinymce_enable_pages' , array($this, 'megamenu_blackstudio_tinymce' ) );
|
94 |
-
|
95 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts'), 11 );
|
96 |
-
|
97 |
-
add_action( 'admin_print_footer_scripts-nav-menus.php', array( $this, 'admin_print_footer_scripts' ) );
|
98 |
-
add_action( 'admin_print_scripts-nav-menus.php', array( $this, 'admin_print_scripts' ) );
|
99 |
-
add_action( 'admin_print_styles-nav-menus.php', array( $this, 'admin_print_styles' ) );
|
100 |
-
|
101 |
-
add_shortcode( 'maxmenu', array( $this, 'register_shortcode' ) );
|
102 |
-
add_shortcode( 'maxmegamenu', array( $this, 'register_shortcode' ) );
|
103 |
-
|
104 |
-
if ( is_admin() ) {
|
105 |
-
$admin_classes = array(
|
106 |
-
"Mega_Menu_Nav_Menus",
|
107 |
-
"Mega_Menu_Widget_Manager",
|
108 |
-
"Mega_Menu_Menu_Item_Manager",
|
109 |
-
"Mega_Menu_Page",
|
110 |
-
"Mega_Menu_General",
|
111 |
-
"Mega_Menu_Locations",
|
112 |
-
"Mega_Menu_Themes",
|
113 |
-
"Mega_Menu_Tools"
|
114 |
-
);
|
115 |
-
|
116 |
-
foreach ( $admin_classes as $class ) {
|
117 |
-
if ( class_exists( $class ) ) {
|
118 |
-
new $class();
|
119 |
-
}
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
if ( class_exists( "Mega_Menu_Toggle_Blocks" ) ) {
|
124 |
-
new Mega_Menu_Toggle_Blocks();
|
125 |
-
}
|
126 |
-
|
127 |
-
if ( class_exists( "Mega_Menu_Style_Manager" ) ) {
|
128 |
-
$mega_menu_style_manager = new Mega_Menu_Style_Manager();
|
129 |
-
$mega_menu_style_manager->setup_actions();
|
130 |
-
}
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Add a body class for each active mega menu location.
|
137 |
-
*
|
138 |
-
* @since 2.3
|
139 |
-
* @param array $classes
|
140 |
-
* @return array
|
141 |
-
*/
|
142 |
-
public function add_megamenu_body_classes( $classes ) {
|
143 |
-
$locations = get_nav_menu_locations();
|
144 |
-
|
145 |
-
if ( count( $locations ) ) {
|
146 |
-
foreach ( $locations as $location => $id ) {
|
147 |
-
if ( has_nav_menu( $location ) && max_mega_menu_is_enabled( $location ) ) {
|
148 |
-
$classes[] = 'mega-menu-' . str_replace( "_", "-", $location );
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
return $classes;
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Add custom actions to allow enqueuing scripts on specific pages
|
159 |
-
*
|
160 |
-
* @since 1.8.3
|
161 |
-
*/
|
162 |
-
public function admin_enqueue_scripts( $hook ) {
|
163 |
-
if ( ! wp_script_is('maxmegamenu') ) {
|
164 |
-
|
165 |
-
if ( in_array( $hook, array('nav-menus.php', 'gutenberg_page_gutenberg-navigation') ) ) {
|
166 |
-
// load widget scripts and styles first to allow us to dequeue conflicting colorbox scripts from other plugins
|
167 |
-
do_action( 'sidebar_admin_setup' );
|
168 |
-
do_action( 'admin_enqueue_scripts', 'widgets.php' );
|
169 |
-
do_action( 'megamenu_nav_menus_scripts', $hook );
|
170 |
-
}
|
171 |
-
|
172 |
-
if ( strpos( $hook, 'maxmegamenu' ) !== false ) {
|
173 |
-
do_action( 'megamenu_admin_scripts', $hook );
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
181 |
-
*
|
182 |
-
* @since 2.3.7
|
183 |
-
*/
|
184 |
-
public function admin_print_footer_scripts( $hook ) {
|
185 |
-
do_action( 'admin_footer-widgets.php' );
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
191 |
-
*
|
192 |
-
* @since 2.3.7
|
193 |
-
*/
|
194 |
-
public function admin_print_scripts( $hook ) {
|
195 |
-
do_action( 'admin_print_scripts-widgets.php' );
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
201 |
-
*
|
202 |
-
* @since 2.3.7
|
203 |
-
*/
|
204 |
-
public function admin_print_styles( $hook ) {
|
205 |
-
do_action( 'admin_print_styles-widgets.php' );
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Register menu locations created within Max Mega Menu.
|
211 |
-
*
|
212 |
-
* @since 1.8
|
213 |
-
*/
|
214 |
-
public function register_nav_menus() {
|
215 |
-
|
216 |
-
$locations = get_option('megamenu_locations');
|
217 |
-
|
218 |
-
if ( is_array( $locations ) && count( $locations ) ) {
|
219 |
-
foreach ( $locations as $key => $val ) {
|
220 |
-
register_nav_menu( $key, $val );
|
221 |
-
}
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Black Studio TinyMCE Compatibility.
|
228 |
-
* Load TinyMCE assets on nav-menus.php page.
|
229 |
-
*
|
230 |
-
* @since 1.8
|
231 |
-
* @param array $pages
|
232 |
-
* @return array $pages
|
233 |
-
*/
|
234 |
-
public function megamenu_blackstudio_tinymce( $pages ) {
|
235 |
-
$pages[] = 'nav-menus.php';
|
236 |
-
return $pages;
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Detect new or updated installations and run actions accordingly.
|
242 |
-
*
|
243 |
-
* @since 1.3
|
244 |
-
*/
|
245 |
-
public function install_upgrade_check() {
|
246 |
-
$version = get_option( "megamenu_version" );
|
247 |
-
|
248 |
-
if ( $version ) {
|
249 |
-
|
250 |
-
if ( version_compare( $this->version, $version, '!=' ) ) {
|
251 |
-
|
252 |
-
update_option( "megamenu_version", $this->version );
|
253 |
-
|
254 |
-
do_action( "megamenu_after_update" );
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
} else {
|
259 |
-
|
260 |
-
add_option( "megamenu_version", $this->version );
|
261 |
-
add_option( "megamenu_initial_version", $this->version );
|
262 |
-
add_option( "megamenu_multisite_share_themes", 'false' );
|
263 |
-
|
264 |
-
do_action( "megamenu_after_install" );
|
265 |
-
|
266 |
-
$settings = get_option( "megamenu_settings" );
|
267 |
-
|
268 |
-
// set defaults
|
269 |
-
if ( ! $settings ) {
|
270 |
-
$settings['prefix'] = 'disabled';
|
271 |
-
$settings['descriptions'] = 'enabled';
|
272 |
-
$settings['second_click'] = 'go';
|
273 |
-
|
274 |
-
add_option( "megamenu_settings", $settings);
|
275 |
-
}
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Register widget
|
282 |
-
*
|
283 |
-
* @since 1.7.4
|
284 |
-
*/
|
285 |
-
public function register_widget() {
|
286 |
-
if ( class_exists( "Mega_Menu_Widget") ) {
|
287 |
-
register_widget( 'Mega_Menu_Widget' );
|
288 |
-
}
|
289 |
-
//register_widget( 'Mega_Menu_Widget_Reusable_Block' );
|
290 |
-
|
291 |
-
// Check if Elementor installed and activated
|
292 |
-
//if ( did_action( 'elementor/loaded' ) ) {
|
293 |
-
// register_widget( 'Mega_Menu_Widget_Elementor_Template' );
|
294 |
-
//}
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Create our own widget area to store all mega menu widgets.
|
300 |
-
* All widgets from all menus are stored here, they are filtered later
|
301 |
-
* to ensure the correct widgets show under the correct menu item.
|
302 |
-
*
|
303 |
-
* @since 1.0
|
304 |
-
*/
|
305 |
-
public function register_sidebar() {
|
306 |
-
|
307 |
-
register_sidebar(
|
308 |
-
array(
|
309 |
-
'id' => 'mega-menu',
|
310 |
-
'name' => __("Max Mega Menu Widgets", "megamenu"),
|
311 |
-
'description' => __("This is where Max Mega Menu stores widgets that you have added to sub menus using the mega menu builder. You can edit existing widgets here, but new widgets must be added through the Mega Menu interface (under Appearance > Menus).", "megamenu")
|
312 |
-
)
|
313 |
-
);
|
314 |
-
}
|
315 |
-
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Shortcode used to display a menu
|
319 |
-
*
|
320 |
-
* @since 1.3
|
321 |
-
* @return string
|
322 |
-
*/
|
323 |
-
public function register_shortcode( $atts ) {
|
324 |
-
if ( ! isset( $atts['location'] ) ) {
|
325 |
-
return false;
|
326 |
-
}
|
327 |
-
|
328 |
-
if ( has_nav_menu( $atts['location'] ) ) {
|
329 |
-
return wp_nav_menu( array( 'theme_location' => $atts['location'], 'echo' => false ) );
|
330 |
-
}
|
331 |
-
|
332 |
-
return "<!-- menu not found [maxmegamenu] -->";
|
333 |
-
|
334 |
-
}
|
335 |
-
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Initialise translations
|
339 |
-
*
|
340 |
-
* @since 1.0
|
341 |
-
*/
|
342 |
-
public function load_plugin_textdomain() {
|
343 |
-
load_plugin_textdomain( 'megamenu', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
344 |
-
}
|
345 |
-
|
346 |
-
|
347 |
-
/**
|
348 |
-
* Define Mega Menu constants
|
349 |
-
*
|
350 |
-
* @since 1.0
|
351 |
-
*/
|
352 |
-
private function define_constants() {
|
353 |
-
define( 'MEGAMENU_VERSION', $this->version );
|
354 |
-
define( 'MEGAMENU_BASE_URL', trailingslashit( plugins_url( 'megamenu' ) ) );
|
355 |
-
define( 'MEGAMENU_PATH', plugin_dir_path( __FILE__ ) );
|
356 |
-
}
|
357 |
-
|
358 |
-
|
359 |
-
/**
|
360 |
-
* All Mega Menu classes
|
361 |
-
*
|
362 |
-
* @since 1.0
|
363 |
-
*/
|
364 |
-
private function plugin_classes() {
|
365 |
-
$classes = array(
|
366 |
-
'Mega_Menu_Walker' => MEGAMENU_PATH . 'classes/walker.class.php',
|
367 |
-
'Mega_Menu_Widget_Manager' => MEGAMENU_PATH . 'classes/widget-manager.class.php',
|
368 |
-
'Mega_Menu_Menu_item_Manager' => MEGAMENU_PATH . 'classes/menu-item-manager.class.php',
|
369 |
-
'Mega_Menu_Nav_Menus' => MEGAMENU_PATH . 'classes/nav-menus.class.php',
|
370 |
-
'Mega_Menu_Style_Manager' => MEGAMENU_PATH . 'classes/style-manager.class.php',
|
371 |
-
'Mega_Menu_Page' => MEGAMENU_PATH . 'classes/pages/page.php',
|
372 |
-
'Mega_Menu_General' => MEGAMENU_PATH . 'classes/pages/general.php',
|
373 |
-
'Mega_Menu_Locations' => MEGAMENU_PATH . 'classes/pages/locations.php',
|
374 |
-
'Mega_Menu_Themes' => MEGAMENU_PATH . 'classes/pages/themes.php',
|
375 |
-
'Mega_Menu_Tools' => MEGAMENU_PATH . 'classes/pages/tools.php',
|
376 |
-
'Mega_Menu_Widget' => MEGAMENU_PATH . 'classes/widgets/widget.class.php',
|
377 |
-
'Mega_Menu_Widget_Reusable_Block' => MEGAMENU_PATH . 'classes/widgets/widget-reusable-block.class.php',
|
378 |
-
'Mega_Menu_Widget_Elementor_Template' => MEGAMENU_PATH . 'classes/widgets/widget-elementor-template.class.php',
|
379 |
-
'Mega_Menu_toggle_Blocks' => MEGAMENU_PATH . 'classes/toggle-blocks.class.php',
|
380 |
-
'scssc' => MEGAMENU_PATH . 'classes/scssc.inc.php'
|
381 |
-
);
|
382 |
-
|
383 |
-
return $classes;
|
384 |
-
}
|
385 |
-
|
386 |
-
|
387 |
-
/**
|
388 |
-
* Load required classes
|
389 |
-
*
|
390 |
-
* @since 1.0
|
391 |
-
*/
|
392 |
-
private function includes() {
|
393 |
-
foreach ( $this->plugin_classes() as $id => $path ) {
|
394 |
-
if ( is_readable( $path ) && ! class_exists( $id ) ) {
|
395 |
-
require_once $path;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
$template = get_template();
|
400 |
-
|
401 |
-
if ($template == 'zerif-pro') {
|
402 |
-
$template = 'zerif';
|
403 |
-
}
|
404 |
-
|
405 |
-
switch ( $template ) {
|
406 |
-
case "twentyseventeen":
|
407 |
-
case "zerif":
|
408 |
-
if ( is_readable( MEGAMENU_PATH . "integration/{$template}/functions.php" ) ) {
|
409 |
-
require_once( MEGAMENU_PATH . "integration/{$template}/functions.php" );
|
410 |
-
}
|
411 |
-
default:
|
412 |
-
break;
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Autoload classes to reduce memory consumption
|
419 |
-
*
|
420 |
-
* @since 1.0
|
421 |
-
* @param string $class
|
422 |
-
*/
|
423 |
-
public function autoload( $class ) {
|
424 |
-
|
425 |
-
$classes = $this->plugin_classes();
|
426 |
-
|
427 |
-
$class_name = strtolower( $class );
|
428 |
-
|
429 |
-
if ( isset( $classes[ $class_name ] ) && is_readable( $classes[ $class_name ] ) ) {
|
430 |
-
require_once $classes[ $class_name ];
|
431 |
-
}
|
432 |
-
}
|
433 |
-
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Appends "mega-" to all menu classes.
|
437 |
-
* This is to help avoid theme CSS conflicts.
|
438 |
-
*
|
439 |
-
* @since 1.0
|
440 |
-
* @param array $classes
|
441 |
-
* @return array
|
442 |
-
*/
|
443 |
-
public function prefix_menu_classes( $classes, $item, $args ) {
|
444 |
-
$return = array();
|
445 |
-
|
446 |
-
foreach ( $classes as $class ) {
|
447 |
-
$return[] = 'mega-' . $class;
|
448 |
-
}
|
449 |
-
|
450 |
-
$location = $args->theme_location;
|
451 |
-
$settings = get_option( 'megamenu_settings' );
|
452 |
-
|
453 |
-
$prefix = isset( $settings['prefix'] ) ? $settings['prefix'] : 'enabled';
|
454 |
-
|
455 |
-
if ( isset( $settings[$location]['prefix'] ) ) {
|
456 |
-
$prefix = $settings[$location]['prefix'];
|
457 |
-
}
|
458 |
-
|
459 |
-
if ( $prefix === 'disabled' ) {
|
460 |
-
// add in custom classes, sans 'mega-' prefix
|
461 |
-
foreach ( $classes as $class ) {
|
462 |
-
|
463 |
-
// custom classes are added before the 'menu-item' class
|
464 |
-
if ( $class == 'menu-item' ) {
|
465 |
-
break;
|
466 |
-
}
|
467 |
-
|
468 |
-
if ( in_array( $class, array( 'menu-column', 'menu-row', 'hide-on-mobile', 'hide-on-desktop') ) ) { // these are always prefixed
|
469 |
-
continue;
|
470 |
-
}
|
471 |
-
|
472 |
-
if ( strpos( $class, "menu-columns-" ) !== FALSE ) { // mega-menu-columns-X-of-Y are always prefixed
|
473 |
-
continue;
|
474 |
-
}
|
475 |
-
|
476 |
-
$return[] = $class;
|
477 |
-
}
|
478 |
-
}
|
479 |
-
|
480 |
-
return $return;
|
481 |
-
}
|
482 |
-
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Add the html for the responsive toggle box to the menu
|
486 |
-
*
|
487 |
-
* @param string $nav_menu
|
488 |
-
* @param object $args
|
489 |
-
* @return string
|
490 |
-
* @since 1.3
|
491 |
-
*/
|
492 |
-
public function add_responsive_toggle( $nav_menu, $args ) {
|
493 |
-
$args = (object) $args;
|
494 |
-
|
495 |
-
// make sure we're working with a Mega Menu
|
496 |
-
if ( ! $args->walker || ! is_a( $args->walker, 'Mega_Menu_Walker' ) ) {
|
497 |
-
return $nav_menu;
|
498 |
-
}
|
499 |
|
500 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
|
502 |
-
|
503 |
|
504 |
-
|
|
|
|
|
|
|
505 |
|
506 |
-
|
|
|
|
|
507 |
|
508 |
-
|
509 |
|
510 |
-
|
511 |
-
}
|
512 |
|
|
|
513 |
|
514 |
-
|
515 |
-
|
516 |
-
* menu is processed by the walker.
|
517 |
-
*
|
518 |
-
* @since 1.0
|
519 |
-
* @param array $items - All menu item objects
|
520 |
-
* @param object $args
|
521 |
-
* @return array - Menu objects including widgets
|
522 |
-
*/
|
523 |
-
public function add_widgets_to_menu( $items, $args ) {
|
524 |
|
525 |
-
|
526 |
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
}
|
531 |
-
|
532 |
-
$items = apply_filters( "megamenu_nav_menu_objects_before", $items, $args );
|
533 |
-
|
534 |
-
$widget_manager = new Mega_Menu_Widget_Manager();
|
535 |
-
|
536 |
-
$rolling_dummy_id = 999999999;
|
537 |
-
|
538 |
-
$items_to_move = array();
|
539 |
|
540 |
-
|
541 |
|
542 |
-
|
543 |
-
|
|
|
544 |
|
545 |
-
|
|
|
|
|
546 |
|
547 |
-
|
548 |
-
|
549 |
-
|
|
|
|
|
|
|
|
|
550 |
|
551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
|
553 |
-
|
554 |
-
$total_widgets_in_menu = count( $panel_widgets );
|
555 |
-
$next_order = $this->menu_order_of_next_sibling( $item->ID, $item->menu_item_parent, $items );
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
|
|
560 |
|
561 |
-
|
562 |
-
|
563 |
-
'mega_menu_columns' => absint( $widget['columns'] )
|
564 |
-
) );
|
565 |
|
566 |
-
|
567 |
-
'type' => 'widget',
|
568 |
-
'parent_submenu_type' => 'megamenu',
|
569 |
-
'title' => $widget['id'],
|
570 |
-
'content' => $widget_manager->show_widget( $widget['id'] ),
|
571 |
-
'menu_item_parent' => $item->ID,
|
572 |
-
'db_id' => 0, // This menu item does not have any childen
|
573 |
-
'ID' => $widget['id'],
|
574 |
-
'menu_order' => $next_order - $total_widgets_in_menu + $widget_position,
|
575 |
-
'megamenu_order' => $widget['order'],
|
576 |
-
'megamenu_settings' => $widget_settings,
|
577 |
-
'depth' => 1,
|
578 |
-
'classes' => array(
|
579 |
-
"menu-item",
|
580 |
-
"menu-item-type-widget",
|
581 |
-
"menu-widget-class-" . $widget_manager->get_widget_class( $widget['id'] )
|
582 |
-
)
|
583 |
-
);
|
584 |
-
|
585 |
-
$items[] = (object) $menu_item;
|
586 |
|
587 |
-
|
588 |
-
}
|
589 |
-
}
|
590 |
-
}
|
591 |
|
592 |
-
|
593 |
-
if ( $item->depth === 0 && $item->megamenu_settings['type'] == 'grid' || ( $item->depth === 1 && $item->parent_submenu_type == 'tabbed' && $item->megamenu_settings['type'] == 'grid' ) ) {
|
594 |
|
595 |
-
|
|
|
596 |
|
597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
|
599 |
-
|
|
|
|
|
|
|
600 |
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
}
|
609 |
-
|
610 |
-
if ( ! in_array( 'menu-megamenu', $item->classes ) ) {
|
611 |
-
$item->classes[] = 'menu-megamenu';
|
612 |
-
}
|
613 |
-
|
614 |
-
$classes = array("menu-row");
|
615 |
-
|
616 |
-
if ( isset( $row_data['meta']['class'] ) ) {
|
617 |
-
$classes = array_merge( $classes, array_unique( explode( " ", $row_data['meta']['class'] ) ) );
|
618 |
-
}
|
619 |
-
|
620 |
-
$row_item = array(
|
621 |
-
'menu_item_parent' => $item->ID,
|
622 |
-
'type' => 'mega_row',
|
623 |
-
'title' => 'Custom Row',
|
624 |
-
'parent_submenu_type' => '',
|
625 |
-
'menu_order' => $next_order,
|
626 |
-
'depth' => 0,
|
627 |
-
'ID' => "{$item->ID}-{$row}",
|
628 |
-
'megamenu_settings' => Mega_Menu_Nav_Menus::get_menu_item_defaults(),
|
629 |
-
'db_id' => $rolling_dummy_id,
|
630 |
-
'classes' => $classes
|
631 |
-
);
|
632 |
-
|
633 |
-
$items[] = (object) $row_item;
|
634 |
-
|
635 |
-
$row_dummy_id = $rolling_dummy_id;
|
636 |
-
|
637 |
-
foreach ( $row_data['columns'] as $col => $col_data ) {
|
638 |
-
|
639 |
-
$rolling_dummy_id++;
|
640 |
-
$next_order++;
|
641 |
-
|
642 |
-
$classes = array("menu-column");
|
643 |
-
|
644 |
-
if ( isset( $col_data['meta']['class'] ) ) {
|
645 |
-
$classes = array_merge( $classes, array_unique( explode( " ", $col_data['meta']['class'] ) ) );
|
646 |
-
}
|
647 |
-
|
648 |
-
if ( isset( $row_data['meta']['columns'] ) ) {
|
649 |
-
$row_columns = $row_data['meta']['columns'];
|
650 |
-
} else {
|
651 |
-
$row_columns = 12;
|
652 |
-
}
|
653 |
-
|
654 |
-
if ( isset( $col_data['meta']['span'] ) ) {
|
655 |
-
$classes[] = "menu-columns-{$col_data['meta']['span']}-of-{$row_columns}";
|
656 |
-
}
|
657 |
-
|
658 |
-
if ( isset( $col_data['meta']['hide-on-mobile'] ) && $col_data['meta']['hide-on-mobile'] == 'true' ) {
|
659 |
-
$classes[] = "hide-on-mobile";
|
660 |
-
}
|
661 |
-
|
662 |
-
if ( isset( $col_data['meta']['hide-on-mobile'] ) && $col_data['meta']['hide-on-desktop'] == 'true' ) {
|
663 |
-
$classes[] = "hide-on-desktop";
|
664 |
-
}
|
665 |
-
|
666 |
-
$col_item = array(
|
667 |
-
'menu_item_parent' => $row_dummy_id,
|
668 |
-
'type' => 'mega_column',
|
669 |
-
'title' => 'Custom Column',
|
670 |
-
'parent_submenu_type' => '',
|
671 |
-
'menu_order' => $next_order,
|
672 |
-
'depth' => 0,
|
673 |
-
'ID' => "{$item->ID}-{$row}-{$col}",
|
674 |
-
'megamenu_settings' => Mega_Menu_Nav_Menus::get_menu_item_defaults(),
|
675 |
-
'db_id' => $rolling_dummy_id,
|
676 |
-
'classes' => $classes
|
677 |
-
);
|
678 |
-
|
679 |
-
$items[] = (object) $col_item;
|
680 |
-
|
681 |
-
if ( isset( $col_data['items'] ) ) {
|
682 |
-
|
683 |
-
foreach ( $col_data['items'] as $key => $block ) {
|
684 |
-
|
685 |
-
$next_order++;
|
686 |
-
|
687 |
-
if ( $block['type'] == 'widget' ) {
|
688 |
-
|
689 |
-
$widget_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults() );
|
690 |
-
|
691 |
-
$menu_item = array(
|
692 |
-
'type' => 'widget',
|
693 |
-
'parent_submenu_type' => '',
|
694 |
-
'title' => '',
|
695 |
-
'content' => $widget_manager->show_widget( $block['id'] ),
|
696 |
-
'menu_item_parent' => $rolling_dummy_id,
|
697 |
-
'db_id' => 0, // This menu item does not have any childen
|
698 |
-
'ID' => $block['id'],
|
699 |
-
'menu_order' => $next_order,
|
700 |
-
'megamenu_order' => 0,
|
701 |
-
'megamenu_settings' => $widget_settings,
|
702 |
-
'depth' => 1,
|
703 |
-
'classes' => array(
|
704 |
-
"menu-item",
|
705 |
-
"menu-item-type-widget",
|
706 |
-
"menu-widget-class-" . $widget_manager->get_widget_class( $block['id'] )
|
707 |
-
)
|
708 |
-
);
|
709 |
-
|
710 |
-
$items[] = (object) $menu_item;
|
711 |
-
|
712 |
-
} else {
|
713 |
-
// mark this menu item to be moved into a new position
|
714 |
-
$items_to_move[$block['id']] = array('new_parent' => $rolling_dummy_id, 'new_order' => $next_order);
|
715 |
-
}
|
716 |
-
}
|
717 |
-
}
|
718 |
-
}
|
719 |
-
}
|
720 |
-
}
|
721 |
-
}
|
722 |
-
}
|
723 |
-
|
724 |
-
if ( count( $items_to_move ) ) {
|
725 |
-
foreach ( $items_to_move as $id => $new_parent ) {
|
726 |
-
$items_to_find[] = $id;
|
727 |
-
}
|
728 |
-
|
729 |
-
foreach ( $items as $item ) {
|
730 |
-
if ( in_array( $item->ID, $items_to_find ) ) {
|
731 |
-
$item->menu_item_parent = $items_to_move[ $item->ID ]['new_parent'];
|
732 |
-
$item->menu_order = $items_to_move[ $item->ID ]['new_order'];
|
733 |
-
}
|
734 |
-
}
|
735 |
-
}
|
736 |
-
|
737 |
-
$items = apply_filters( "megamenu_nav_menu_objects_after", $items, $args );
|
738 |
-
|
739 |
-
return $items;
|
740 |
-
}
|
741 |
-
|
742 |
-
|
743 |
-
/**
|
744 |
-
* Return the menu order of the next sibling menu item.
|
745 |
-
* Eg, given A as the $item_id, the menu order of D will be returned
|
746 |
-
* Eg, given B as the $item_id, the menu order of C will be returned
|
747 |
-
* Eg, given D as the $item_id, the menu order of D + 1000 will be returned
|
748 |
-
*
|
749 |
-
* - A
|
750 |
-
* --- B
|
751 |
-
* --- C
|
752 |
-
* - D
|
753 |
-
*
|
754 |
-
* @since 2.0
|
755 |
-
* @param int $item_id
|
756 |
-
* @param array $items
|
757 |
-
* @return int
|
758 |
-
*/
|
759 |
-
private function menu_order_of_next_sibling( $item_id, $menu_item_parent, $items ) {
|
760 |
-
|
761 |
-
$get_order_of_next_item = false;
|
762 |
-
|
763 |
-
foreach ( $items as $key => $item ) {
|
764 |
-
|
765 |
-
if ( $menu_item_parent != $item->menu_item_parent ) {
|
766 |
-
continue;
|
767 |
-
}
|
768 |
-
|
769 |
-
if ( $item->type == 'widget' ) {
|
770 |
-
continue;
|
771 |
-
}
|
772 |
-
|
773 |
-
if ( $get_order_of_next_item ) {
|
774 |
-
return $item->menu_order;
|
775 |
-
}
|
776 |
-
|
777 |
-
if ( $item->ID == $item_id ) {
|
778 |
-
$get_order_of_next_item = true;
|
779 |
-
}
|
780 |
-
|
781 |
-
if ( isset( $item->menu_order ) ) {
|
782 |
-
$rolling_last_menu_order = $item->menu_order;
|
783 |
-
}
|
784 |
-
|
785 |
-
}
|
786 |
-
|
787 |
-
// there isn't a next sibling
|
788 |
-
return $rolling_last_menu_order + 1000;
|
789 |
-
|
790 |
-
}
|
791 |
-
|
792 |
-
|
793 |
-
/**
|
794 |
-
* Determine if menu item is a top level item or a second level item
|
795 |
-
*
|
796 |
-
* @since 2.7.7
|
797 |
-
* @param array $items - All menu item objects
|
798 |
-
* @param object $args
|
799 |
-
* @return array
|
800 |
-
*/
|
801 |
-
public function apply_depth_to_menu_items( $items, $args ) {
|
802 |
-
$parents = array();
|
803 |
-
|
804 |
-
foreach ( $items as $key => $item ) {
|
805 |
-
if ( $item->menu_item_parent == 0 ) {
|
806 |
-
$parents[] = $item->ID;
|
807 |
-
$item->depth = 0;
|
808 |
-
}
|
809 |
-
}
|
810 |
-
|
811 |
-
if ( count( $parents ) ) {
|
812 |
-
foreach ( $items as $key => $item ) {
|
813 |
-
if ( in_array( $item->menu_item_parent, $parents ) ) {
|
814 |
-
$item->depth = 1;
|
815 |
-
}
|
816 |
-
}
|
817 |
-
}
|
818 |
-
|
819 |
-
return $items;
|
820 |
-
}
|
821 |
-
|
822 |
-
|
823 |
-
/**
|
824 |
-
* Setup the mega menu settings for each menu item
|
825 |
-
*
|
826 |
-
* @since 2.0
|
827 |
-
* @param array $items - All menu item objects
|
828 |
-
* @param object $args
|
829 |
-
* @return array
|
830 |
-
*/
|
831 |
-
public function setup_menu_items( $items, $args ) {
|
832 |
-
|
833 |
-
// apply saved metadata to each menu item
|
834 |
-
foreach ( $items as $item ) {
|
835 |
-
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
|
836 |
-
|
837 |
-
$item->megamenu_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
838 |
-
$item->megamenu_order = isset( $item->megamenu_settings['mega_menu_order'][$item->menu_item_parent] ) ? $item->megamenu_settings['mega_menu_order'][$item->menu_item_parent] : 0;
|
839 |
-
$item->parent_submenu_type = 'flyout';
|
840 |
-
|
841 |
-
if ( isset( $item->menu_order ) ) {
|
842 |
-
$item->menu_order = $item->menu_order * 1000;
|
843 |
-
}
|
844 |
-
|
845 |
-
// add parent mega menu type
|
846 |
-
if ( $item->depth == 1 ) {
|
847 |
-
$parent_settings = array_filter( (array) get_post_meta( $item->menu_item_parent, '_megamenu', true ) );
|
848 |
-
|
849 |
-
if ( isset( $parent_settings['type'] ) ) {
|
850 |
-
$item->parent_submenu_type = $parent_settings['type'];
|
851 |
-
}
|
852 |
-
}
|
853 |
-
}
|
854 |
-
|
855 |
-
return $items;
|
856 |
-
}
|
857 |
-
|
858 |
-
|
859 |
-
/**
|
860 |
-
* Reorder items within the mega menu.
|
861 |
-
*
|
862 |
-
* @since 2.0
|
863 |
-
* @param array $items
|
864 |
-
* @param object $args
|
865 |
-
* @return array
|
866 |
-
*/
|
867 |
-
public function reorder_menu_items_within_megamenus( $items, $args ) {
|
868 |
-
$new_items = array();
|
869 |
-
|
870 |
-
// reorder menu items within mega menus based on internal ordering
|
871 |
-
foreach ( $items as $item ) {
|
872 |
-
// items ordered with 'forced' ordering
|
873 |
-
if ( property_exists( $item, 'parent_submenu_type' ) && $item->parent_submenu_type == 'megamenu' && property_exists( $item, 'megamenu_order' ) && $item->megamenu_order !== 0 ) {
|
874 |
-
if ( $parent_menu_item = get_post( $item->menu_item_parent ) ) {
|
875 |
-
$item->menu_order = $parent_menu_item->menu_order * 1000 + $item->megamenu_order;
|
876 |
-
}
|
877 |
-
}
|
878 |
-
}
|
879 |
-
|
880 |
-
foreach ( $items as $item ) {
|
881 |
-
if ( in_array( 'wpml-ls-item', $item->classes ) ) {
|
882 |
-
$item->classes[] = 'menu-flyout';
|
883 |
-
}
|
884 |
-
|
885 |
-
$new_items[ $item->menu_order ] = $item;
|
886 |
-
}
|
887 |
-
|
888 |
-
ksort( $new_items );
|
889 |
-
|
890 |
-
return $new_items;
|
891 |
-
}
|
892 |
-
|
893 |
-
|
894 |
-
/**
|
895 |
-
* If descriptions are enabled, create a new 'mega_description' property.
|
896 |
-
* This is for backwards compatibility for users who have used filters
|
897 |
-
* to display descriptions
|
898 |
-
*
|
899 |
-
* @since 2.3
|
900 |
-
* @param array $items
|
901 |
-
* @param array $args
|
902 |
-
* @return array
|
903 |
-
*/
|
904 |
-
public function set_descriptions_if_enabled( $items, $args ) {
|
905 |
-
|
906 |
-
$location = $args->theme_location;
|
907 |
-
$settings = get_option( 'megamenu_settings' );
|
908 |
-
|
909 |
-
$descriptions = isset( $settings['descriptions'] ) ? $settings['descriptions'] : 'disabled';
|
910 |
-
|
911 |
-
if ( isset( $settings[$location]['descriptions'] ) ) {
|
912 |
-
$descriptions = $settings[$location]['descriptions'];
|
913 |
-
}
|
914 |
-
|
915 |
-
if ($descriptions == 'enabled') {
|
916 |
-
foreach ( $items as $item ) {
|
917 |
-
if ( property_exists( $item, 'description' ) && strlen( $item->description ) ) {
|
918 |
-
$item->mega_description = $item->description;
|
919 |
-
$item->classes[] = 'has-description';
|
920 |
-
}
|
921 |
-
}
|
922 |
-
}
|
923 |
-
|
924 |
-
return $items;
|
925 |
-
}
|
926 |
-
|
927 |
-
|
928 |
-
/**
|
929 |
-
* Apply column and clear classes to menu items (inc. widgets)
|
930 |
-
*
|
931 |
-
* @since 2.0
|
932 |
-
* @param array $items
|
933 |
-
* @param array $args
|
934 |
-
* @return array
|
935 |
-
*/
|
936 |
-
public function apply_classes_to_menu_items( $items, $args ) {
|
937 |
-
$parents = array();
|
938 |
-
|
939 |
-
foreach ( $items as $item ) {
|
940 |
-
|
941 |
-
if ( ! in_array("menu-row", $item->classes) && ! in_array("menu-column", $item->classes) ) {
|
942 |
-
if ( $item->depth === 0 ) {
|
943 |
-
$item->classes[] = 'align-' . $item->megamenu_settings['align'];
|
944 |
-
$item->classes[] = 'menu-' . $item->megamenu_settings['type'];
|
945 |
-
}
|
946 |
-
|
947 |
-
if ( $item->megamenu_settings['hide_arrow'] == 'true' ) {
|
948 |
-
$item->classes[] = 'hide-arrow';
|
949 |
-
}
|
950 |
-
|
951 |
-
if ( $item->megamenu_settings['icon'] != 'disabled' ) {
|
952 |
-
$item->classes[] = 'has-icon';
|
953 |
-
}
|
954 |
-
|
955 |
-
if ( $item->megamenu_settings['icon'] != 'disabled' && isset( $item->megamenu_settings['icon_position'] ) ) {
|
956 |
-
$item->classes[] = "icon-" . $item->megamenu_settings['icon_position'];
|
957 |
-
}
|
958 |
-
|
959 |
-
if ( $item->megamenu_settings['hide_text'] == 'true' && $item->depth === 0 ) {
|
960 |
-
$item->classes[] = 'hide-text';
|
961 |
-
}
|
962 |
-
|
963 |
-
if ( $item->megamenu_settings['item_align'] != 'left' && $item->depth === 0 ) {
|
964 |
-
$item->classes[] = 'item-align-' . $item->megamenu_settings['item_align'];
|
965 |
-
}
|
966 |
-
|
967 |
-
if ( $item->megamenu_settings['hide_on_desktop'] == 'true' ) {
|
968 |
-
$item->classes[] = 'hide-on-desktop';
|
969 |
-
}
|
970 |
-
|
971 |
-
if ( $item->megamenu_settings['hide_on_mobile'] == 'true' ) {
|
972 |
-
$item->classes[] = 'hide-on-mobile';
|
973 |
-
}
|
974 |
-
|
975 |
-
if ( $item->megamenu_settings['hide_sub_menu_on_mobile'] == 'true' ) {
|
976 |
-
$item->classes[] = 'hide-sub-menu-on-mobile';
|
977 |
-
}
|
978 |
-
|
979 |
-
if ( $item->megamenu_settings['disable_link'] == 'true') {
|
980 |
-
$item->classes[] = 'disable-link';
|
981 |
-
}
|
982 |
-
|
983 |
-
if ( $item->megamenu_settings['collapse_children'] == 'true' ) {
|
984 |
-
$item->classes[] = 'collapse-children';
|
985 |
-
}
|
986 |
-
|
987 |
-
if ( absint($item->megamenu_settings['submenu_columns']) > 1 ) {
|
988 |
-
$item->classes[] = absint($item->megamenu_settings['submenu_columns']) . '-columns';
|
989 |
-
}
|
990 |
-
}
|
991 |
-
|
992 |
-
// add column classes for second level menu items displayed in mega menus
|
993 |
-
if ( $item->parent_submenu_type == 'megamenu' ) {
|
994 |
-
|
995 |
-
$parent_settings = array_filter( (array) get_post_meta( $item->menu_item_parent, '_megamenu', true ) );
|
996 |
-
$parent_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $parent_settings );
|
997 |
-
|
998 |
-
$span = $item->megamenu_settings['mega_menu_columns'];
|
999 |
-
|
1000 |
-
$total_columns = $parent_settings['panel_columns'];
|
1001 |
-
|
1002 |
-
if ( $total_columns >= $span ) {
|
1003 |
-
$item->classes[] = "menu-columns-{$span}-of-{$total_columns}";
|
1004 |
-
$column_count = $span;
|
1005 |
-
} else {
|
1006 |
-
$item->classes[] = "menu-columns-{$total_columns}-of-{$total_columns}";
|
1007 |
-
$column_count = $total_columns;
|
1008 |
-
}
|
1009 |
|
1010 |
-
|
1011 |
-
|
1012 |
-
} else {
|
1013 |
-
$parents[ $item->menu_item_parent ] = $parents[ $item->menu_item_parent ] + $column_count;
|
1014 |
|
1015 |
-
if ( $parents[ $item->menu_item_parent ] > $total_columns ) {
|
1016 |
-
$parents[ $item->menu_item_parent ] = $column_count;
|
1017 |
-
$item->classes[] = 'menu-clear';
|
1018 |
-
}
|
1019 |
-
}
|
1020 |
|
1021 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1022 |
|
1023 |
-
|
|
|
|
|
1024 |
|
1025 |
-
|
1026 |
-
|
1027 |
|
|
|
1028 |
|
1029 |
-
|
1030 |
-
|
1031 |
-
* Resets all parameters used in the wp_nav_menu call
|
1032 |
-
* Wraps the menu in mega-menu IDs and classes
|
1033 |
-
*
|
1034 |
-
* @since 1.0
|
1035 |
-
* @param $args array
|
1036 |
-
* @return array
|
1037 |
-
*/
|
1038 |
-
public function modify_nav_menu_args( $args ) {
|
1039 |
-
|
1040 |
-
if ( ! isset( $args['theme_location'] ) ) {
|
1041 |
-
return $args;
|
1042 |
-
}
|
1043 |
|
1044 |
-
|
1045 |
-
do_action('megamenu_instance_counter_' . $args['theme_location']);
|
1046 |
|
1047 |
-
|
|
|
|
|
|
|
|
|
1048 |
|
1049 |
-
|
1050 |
-
|
|
|
1051 |
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1059 |
|
1060 |
-
|
1061 |
-
if ( strpos( $active_instance, "," ) || is_numeric( $active_instance ) ) {
|
1062 |
-
$active_instances = explode( ",", $active_instance );
|
1063 |
-
|
1064 |
-
if ( ! in_array( $num_times_called, $active_instances )) {
|
1065 |
-
return $args;
|
1066 |
-
}
|
1067 |
-
} else if ( isset( $args['container_id'] ) && $active_instance != $args['container_id'] ) {
|
1068 |
-
return $args;
|
1069 |
-
}
|
1070 |
-
}
|
1071 |
-
|
1072 |
-
$locations = get_nav_menu_locations();
|
1073 |
|
1074 |
-
if ( isset ( $settings[ $current_theme_location ]['enabled'] ) && $settings[ $current_theme_location ]['enabled'] == true ) {
|
1075 |
-
|
1076 |
-
if ( ! isset( $locations[ $current_theme_location ] ) ) {
|
1077 |
-
return $args;
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
$menu_id = $locations[ $current_theme_location ];
|
1081 |
-
|
1082 |
-
if ( ! $menu_id ) {
|
1083 |
-
return $args;
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
$menu_theme = mmm_get_theme_for_location( $current_theme_location );
|
1087 |
-
$menu_settings = $settings[ $current_theme_location ];
|
1088 |
-
|
1089 |
-
$effect = isset( $menu_settings['effect'] ) ? $menu_settings['effect'] : 'disabled';
|
1090 |
-
|
1091 |
-
// convert Pro JS based effect to CSS3 effect
|
1092 |
-
if ( $effect == 'fadeUp' ) {
|
1093 |
-
$effect = 'fade_up';
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
// as set on the main settings page
|
1097 |
-
$vertical_behaviour = isset( $settings['mobile_behaviour'] ) ? $settings['mobile_behaviour'] : 'standard';
|
1098 |
-
|
1099 |
-
if ( isset( $menu_settings['mobile_behaviour'] ) ) {
|
1100 |
-
$vertical_behaviour = $menu_settings['mobile_behaviour'];
|
1101 |
-
}
|
1102 |
-
|
1103 |
-
// as set on the main settings page
|
1104 |
-
$second_click = isset( $settings['second_click'] ) ? $settings['second_click'] : 'go';
|
1105 |
-
|
1106 |
-
if ( isset( $menu_settings['second_click'] ) ) {
|
1107 |
-
$second_click = $menu_settings['second_click'];
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
$unbind = isset( $settings['unbind'] ) ? $settings['unbind'] : 'enabled';
|
1111 |
-
|
1112 |
-
if ( isset( $menu_settings['unbind'] ) ) {
|
1113 |
-
$unbind = $menu_settings['unbind'];
|
1114 |
-
}
|
1115 |
-
|
1116 |
-
$event = 'hover_intent';
|
1117 |
-
|
1118 |
-
if ( isset( $menu_settings['event'] ) ) {
|
1119 |
-
if ( $menu_settings['event'] == 'hover' ) {
|
1120 |
-
$event = 'hover_intent';
|
1121 |
-
} elseif ( $menu_settings['event'] == 'hover_' ) {
|
1122 |
-
$event = 'hover';
|
1123 |
-
} else {
|
1124 |
-
$event = $menu_settings['event'];
|
1125 |
-
}
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
$mobile_force_width = 'false';
|
1129 |
-
|
1130 |
-
if ( isset( $menu_theme['mobile_menu_force_width'] ) && $menu_theme['mobile_menu_force_width'] == 'on' ) {
|
1131 |
-
if ( isset( $menu_theme['mobile_menu_force_width_selector'] ) ) {
|
1132 |
-
$mobile_force_width = $menu_theme['mobile_menu_force_width_selector'];
|
1133 |
-
} else {
|
1134 |
-
$mobile_force_width = 'body';
|
1135 |
-
}
|
1136 |
-
}
|
1137 |
-
|
1138 |
-
|
1139 |
-
$effect_mobile = 'disabled';
|
1140 |
-
|
1141 |
-
if ( isset( $menu_settings['effect_mobile'] ) ) {
|
1142 |
-
$effect_mobile = $menu_settings['effect_mobile'];
|
1143 |
-
}
|
1144 |
-
|
1145 |
-
$effect_speed_mobile = 200;
|
1146 |
-
|
1147 |
-
if ( isset( $menu_settings['effect_speed_mobile'] ) ) {
|
1148 |
-
$effect_speed_mobile = $menu_settings['effect_speed_mobile'];
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
$container = 'div';
|
1152 |
-
|
1153 |
-
if ( isset( $menu_settings['container'] ) ) {
|
1154 |
-
$container = $menu_settings['container'];
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
if ( $effect_mobile == 'disabled' ) {
|
1158 |
-
$effect_speed_mobile = 0;
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
$hover_intent_params = apply_filters("megamenu_javascript_localisation", // backwards compatiblity
|
1162 |
-
array(
|
1163 |
-
"timeout" => 300,
|
1164 |
-
"interval" => 100
|
1165 |
-
)
|
1166 |
-
);
|
1167 |
-
|
1168 |
-
$wrap_attributes = apply_filters("megamenu_wrap_attributes", array(
|
1169 |
-
"id" => '%1$s',
|
1170 |
-
"class" => '%2$s mega-no-js',
|
1171 |
-
"data-event" => $event,
|
1172 |
-
"data-effect" => $effect,
|
1173 |
-
"data-effect-speed" => isset( $menu_settings['effect_speed'] ) ? $menu_settings['effect_speed'] : '200',
|
1174 |
-
"data-effect-mobile" => $effect_mobile,
|
1175 |
-
"data-effect-speed-mobile" => $effect_speed_mobile,
|
1176 |
-
"data-panel-width" => preg_match('/^\d/', $menu_theme['panel_width']) !== 1 ? $menu_theme['panel_width'] : '',
|
1177 |
-
"data-panel-inner-width" => substr( trim( $menu_theme['panel_inner_width'] ), -1 ) !== '%' ? $menu_theme['panel_inner_width'] : '',
|
1178 |
-
"data-mobile-force-width" => $mobile_force_width,
|
1179 |
-
"data-second-click" => $second_click,
|
1180 |
-
"data-document-click" => 'collapse',
|
1181 |
-
"data-vertical-behaviour" => $vertical_behaviour,
|
1182 |
-
"data-breakpoint" => absint( $menu_theme['responsive_breakpoint'] ),
|
1183 |
-
"data-unbind" => $unbind === "disabled" ? "false" : "true",
|
1184 |
-
"data-hover-intent-timeout" => absint($hover_intent_params['timeout']),
|
1185 |
-
"data-hover-intent-interval" => absint($hover_intent_params['interval'])
|
1186 |
-
), $menu_id, $menu_settings, $settings, $current_theme_location );
|
1187 |
-
|
1188 |
-
$attributes = "";
|
1189 |
-
|
1190 |
-
foreach( $wrap_attributes as $attribute => $value ) {
|
1191 |
-
if ( strlen( $value ) ) {
|
1192 |
-
$attributes .= " " . $attribute . '="' . esc_attr( $value ) . '"';
|
1193 |
-
}
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
$sanitized_location = str_replace( apply_filters("megamenu_location_replacements", array("-", " ") ), "-", $current_theme_location );
|
1197 |
-
|
1198 |
-
$defaults = array(
|
1199 |
-
'menu' => wp_get_nav_menu_object( $menu_id ),
|
1200 |
-
'container' => $container,
|
1201 |
-
'container_class' => 'mega-menu-wrap',
|
1202 |
-
'container_id' => 'mega-menu-wrap-' . $sanitized_location,
|
1203 |
-
'menu_class' => 'mega-menu max-mega-menu mega-menu-horizontal',
|
1204 |
-
'menu_id' => 'mega-menu-' . $sanitized_location,
|
1205 |
-
'fallback_cb' => 'wp_page_menu',
|
1206 |
-
'before' => '',
|
1207 |
-
'after' => '',
|
1208 |
-
'link_before' => '',
|
1209 |
-
'link_after' => '',
|
1210 |
-
'items_wrap' => '<ul' . $attributes . '>%3$s</ul>',
|
1211 |
-
'depth' => 0,
|
1212 |
-
'walker' => new Mega_Menu_Walker()
|
1213 |
-
);
|
1214 |
-
|
1215 |
-
$args = array_merge( $args, apply_filters( "megamenu_nav_menu_args", $defaults, $menu_id, $current_theme_location ) );
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
return $args;
|
1219 |
-
}
|
1220 |
-
|
1221 |
-
|
1222 |
-
/**
|
1223 |
-
* Display admin notices.
|
1224 |
-
*/
|
1225 |
-
public function admin_notices() {
|
1226 |
-
|
1227 |
-
if ( ! $this->is_compatible_wordpress_version() ) :
|
1228 |
-
|
1229 |
-
?>
|
1230 |
-
<div class="error">
|
1231 |
-
<p><?php _e( 'Max Mega Menu is not compatible with your version of WordPress. Please upgrade WordPress to the latest version or disable Max Mega Menu.', 'megamenu' ); ?></p>
|
1232 |
-
</div>
|
1233 |
-
<?php
|
1234 |
-
|
1235 |
-
endif;
|
1236 |
-
|
1237 |
-
if ( did_action('megamenu_after_install') === 1 ) :
|
1238 |
-
|
1239 |
-
?>
|
1240 |
-
|
1241 |
-
<?php
|
1242 |
-
|
1243 |
-
endif;
|
1244 |
-
|
1245 |
-
if ( defined("MEGAMENU_HIDE_CSS_NAG") && MEGAMENU_HIDE_CSS_NAG === true ) {
|
1246 |
-
return;
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
$css_version = get_transient("megamenu_css_version");
|
1250 |
-
$css = get_transient("megamenu_css");
|
1251 |
-
|
1252 |
-
if ( $css && version_compare( $this->scss_last_updated, $css_version, '>' ) ) :
|
1253 |
-
|
1254 |
-
?>
|
1255 |
-
<div class="updated">
|
1256 |
-
<?php
|
1257 |
-
|
1258 |
-
$clear_cache_url = esc_url( add_query_arg(
|
1259 |
-
array(
|
1260 |
-
'action' => 'megamenu_clear_css_cache'
|
1261 |
-
),
|
1262 |
-
wp_nonce_url( admin_url("admin-post.php"), 'megamenu_clear_css_cache' )
|
1263 |
-
) );
|
1264 |
-
|
1265 |
-
$link = "<a href='{$clear_cache_url}'>" . __( "clear the CSS cache", 'megamenu' ) . "</a>";
|
1266 |
-
|
1267 |
-
?>
|
1268 |
-
<p><?php echo sprintf( __( 'Max Mega Menu has been updated. Please %s to ensure maximum compatibility with the latest version.', 'megamenu' ), $link); ?></p>
|
1269 |
-
</div>
|
1270 |
-
<?php
|
1271 |
-
|
1272 |
-
endif;
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
|
1276 |
-
/**
|
1277 |
-
* Checks this WordPress installation is v3.8 or above.
|
1278 |
-
* 3.8 is needed for dashicons.
|
1279 |
-
*/
|
1280 |
-
public function is_compatible_wordpress_version() {
|
1281 |
-
global $wp_version;
|
1282 |
-
|
1283 |
-
return $wp_version >= 3.8;
|
1284 |
-
}
|
1285 |
-
|
1286 |
-
/**
|
1287 |
-
* Add compatibility for conditional menus plugin
|
1288 |
-
*
|
1289 |
-
* @since 2.2
|
1290 |
-
*/
|
1291 |
-
public function conditional_menus_restore_theme_location( $location, $new_args, $old_args ) {
|
1292 |
-
return $old_args['theme_location'];
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
/**
|
1296 |
-
* Add a note to the Navigation Widget to explain that Max Mega Menu will not work with it.
|
1297 |
-
*
|
1298 |
-
* @since 2.5.1
|
1299 |
-
*/
|
1300 |
-
public function add_notice_to_nav_menu_widget( $widget, $return, $instance ) {
|
1301 |
-
if ( 'nav_menu' == $widget->id_base ) {
|
1302 |
-
?>
|
1303 |
-
<p style="font-size: 11px; font-style: italic;">
|
1304 |
-
<?php _e("If you are trying to display Max Mega Menu here, use the 'Max Mega Menu' widget instead.", "megamenu"); ?>
|
1305 |
-
<a href="https://www.megamenu.com/documentation/widget/" target="_blank"><?php _e("More information", "megamenu"); ?></a>
|
1306 |
-
</p>
|
1307 |
-
<?php
|
1308 |
-
}
|
1309 |
-
}
|
1310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1311 |
}
|
1312 |
|
1313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1314 |
|
1315 |
-
|
|
|
|
|
1316 |
|
|
|
|
|
|
|
1317 |
|
1318 |
-
if
|
|
|
1319 |
|
1320 |
-
|
1321 |
-
* @since 2.1
|
1322 |
-
* @param string $location - theme location identifier
|
1323 |
-
*/
|
1324 |
-
function mmm_get_theme_id_for_location( $location = false ) {
|
1325 |
|
1326 |
-
|
1327 |
-
return false;
|
1328 |
-
}
|
1329 |
|
1330 |
-
|
1331 |
-
|
1332 |
-
}
|
1333 |
|
1334 |
-
|
1335 |
-
$settings = get_option( 'megamenu_settings' );
|
1336 |
|
1337 |
-
|
1338 |
-
|
1339 |
-
}
|
1340 |
|
1341 |
-
|
1342 |
-
|
1343 |
}
|
1344 |
|
1345 |
-
if ( ! function_exists( 'mmm_get_theme_for_location' ) ) {
|
1346 |
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1352 |
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
|
1361 |
-
|
1362 |
-
|
|
|
1363 |
|
1364 |
-
|
1365 |
|
1366 |
-
|
|
|
1367 |
|
1368 |
-
|
1369 |
-
|
|
|
|
|
|
|
|
|
|
|
1370 |
|
1371 |
-
|
|
|
|
|
1372 |
|
1373 |
-
|
1374 |
-
}
|
1375 |
|
1376 |
-
|
1377 |
-
}
|
1378 |
}
|
1379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1380 |
|
1381 |
-
if ( !
|
|
|
|
|
1382 |
|
1383 |
-
|
1384 |
-
* Determines if Max Mega Menu has been enabled for a given menu location.
|
1385 |
-
*
|
1386 |
-
* Usage:
|
1387 |
-
*
|
1388 |
-
* Max Mega Menu is enabled:
|
1389 |
-
* function_exists( 'max_mega_menu_is_enabled' )
|
1390 |
-
*
|
1391 |
-
* Max Mega Menu has been enabled for a theme location:
|
1392 |
-
* function_exists( 'max_mega_menu_is_enabled' ) && max_mega_menu_is_enabled( $location )
|
1393 |
-
*
|
1394 |
-
* @since 1.8
|
1395 |
-
* @param string $location - theme location identifier
|
1396 |
-
*/
|
1397 |
-
function max_mega_menu_is_enabled( $location = false ) {
|
1398 |
-
|
1399 |
-
if ( ! $location ) {
|
1400 |
-
return true; // the plugin is enabled
|
1401 |
-
}
|
1402 |
-
|
1403 |
-
if ( ! has_nav_menu( $location ) ) {
|
1404 |
-
return false;
|
1405 |
-
}
|
1406 |
-
|
1407 |
-
// if a location has been passed, check to see if MMM has been enabled for the location
|
1408 |
-
$settings = get_option( 'megamenu_settings' );
|
1409 |
-
|
1410 |
-
return is_array( $settings ) && isset( $settings[ $location ]['enabled'] ) && $settings[ $location ]['enabled'] == true;
|
1411 |
-
}
|
1412 |
-
}
|
1413 |
|
1414 |
-
|
1415 |
-
/*
|
1416 |
-
* In the first version of MMM, themes were (incorrectly) shared between all sites in a multi site network.
|
1417 |
-
* Themes will not be shared across sites for new users installing v2.4.3 onwards, but they will be shared for existing (older) users.
|
1418 |
-
*
|
1419 |
-
* @since 2.3.7
|
1420 |
-
*/
|
1421 |
-
function max_mega_menu_share_themes_across_multisite() {
|
1422 |
-
|
1423 |
-
if ( defined('MEGAMENU_SHARE_THEMES_MULTISITE') && MEGAMENU_SHARE_THEMES_MULTISITE === false ) {
|
1424 |
-
return false;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
if ( defined('MEGAMENU_SHARE_THEMES_MULTISITE') && MEGAMENU_SHARE_THEMES_MULTISITE === true ) {
|
1428 |
-
return true;
|
1429 |
-
}
|
1430 |
-
|
1431 |
-
if ( get_option('megamenu_multisite_share_themes') === 'false' ) { // only exists if initially installed version is 2.4.3+
|
1432 |
-
return false;
|
1433 |
-
}
|
1434 |
-
|
1435 |
-
return apply_filters( 'megamenu_share_themes_across_multisite', true );
|
1436 |
-
|
1437 |
-
}
|
1438 |
}
|
1439 |
|
1440 |
-
if ( ! function_exists('
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
|
|
1447 |
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
|
1452 |
-
|
1453 |
|
1454 |
-
|
1455 |
}
|
1456 |
|
1457 |
-
if ( ! function_exists('
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1466 |
-
return update_option( "megamenu_themes", $themes );
|
1467 |
-
}
|
1468 |
-
|
1469 |
-
return update_site_option( "megamenu_themes", $themes );
|
1470 |
-
|
1471 |
-
}
|
1472 |
-
}
|
1473 |
|
1474 |
-
if ( !
|
1475 |
-
|
1476 |
-
|
1477 |
-
*
|
1478 |
-
* @since 2.3.7
|
1479 |
-
*/
|
1480 |
-
function max_mega_menu_save_last_updated_theme( $theme ) {
|
1481 |
-
|
1482 |
-
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1483 |
-
return update_option( "megamenu_themes_last_updated", $theme );
|
1484 |
-
}
|
1485 |
-
|
1486 |
-
return update_site_option( "megamenu_themes_last_updated", $theme );
|
1487 |
-
|
1488 |
-
}
|
1489 |
-
}
|
1490 |
|
1491 |
-
|
1492 |
-
/*
|
1493 |
-
* Return last updated theme
|
1494 |
-
*
|
1495 |
-
* @since 2.3.7
|
1496 |
-
*/
|
1497 |
-
function max_mega_menu_get_last_updated_theme() {
|
1498 |
-
|
1499 |
-
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1500 |
-
return get_option( "megamenu_themes_last_updated" );
|
1501 |
-
}
|
1502 |
-
|
1503 |
-
return get_site_option( "megamenu_themes_last_updated" );
|
1504 |
-
|
1505 |
-
}
|
1506 |
-
}
|
1507 |
|
1508 |
-
|
1509 |
-
/*
|
1510 |
-
* Return saved toggle blocks
|
1511 |
-
*
|
1512 |
-
* @since 2.3.7
|
1513 |
-
*/
|
1514 |
-
function max_mega_menu_get_toggle_blocks() {
|
1515 |
-
|
1516 |
-
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1517 |
-
return get_option( "megamenu_toggle_blocks" );
|
1518 |
-
}
|
1519 |
-
|
1520 |
-
return get_site_option( "megamenu_toggle_blocks" );
|
1521 |
-
|
1522 |
-
}
|
1523 |
}
|
1524 |
|
1525 |
-
if ( ! function_exists('
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
|
1537 |
-
|
1538 |
|
1539 |
-
|
1540 |
}
|
1541 |
|
1542 |
-
if ( ! function_exists('
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
|
1554 |
-
|
1555 |
|
1556 |
-
|
1557 |
}
|
1558 |
|
1559 |
-
if ( ! function_exists('
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
'litespeed-cache/litespeed-cache.php',
|
1571 |
-
'js-css-script-optimizer/js-css-script-optimizer.php',
|
1572 |
-
'merge-minify-refresh/merge-minify-refresh.php',
|
1573 |
-
'minify-html-markup/minify-html.php',
|
1574 |
-
'simple-cache/simple-cache.php',
|
1575 |
-
'w3-total-cache/w3-total-cache.php',
|
1576 |
-
'wp-fastest-cache/wpFastestCache.php',
|
1577 |
-
'wp-speed-of-light/wp-speed-of-light.php',
|
1578 |
-
'wp-super-cache/wp-cache.php',
|
1579 |
-
'wp-super-minify/wp-super-minify.php',
|
1580 |
-
'autoptimize/autoptimize.php',
|
1581 |
-
'bwp-minify/bwp-minify.php',
|
1582 |
-
'cache-enabler/cache-enabler.php',
|
1583 |
-
'cloudflare/cloudflare.php',
|
1584 |
-
'comet-cache/comet-cache.php',
|
1585 |
-
'css-optimizer/bpminifycss.php',
|
1586 |
-
'fast-velocity-minify/fvm.php',
|
1587 |
-
'hyper-cache/plugin.php',
|
1588 |
-
'remove-query-strings-littlebizzy/remove-query-strings.php',
|
1589 |
-
'remove-query-strings-from-static-resources/remove-query-strings.php',
|
1590 |
-
'query-strings-remover/query-strings-remover.php',
|
1591 |
-
'wp-rocket/wp-rocket.php',
|
1592 |
-
'hummingbird-performance/wp-hummingbird.php',
|
1593 |
-
'breeze/breeze.php'
|
1594 |
-
));
|
1595 |
-
|
1596 |
-
$active_plugins = array();
|
1597 |
-
|
1598 |
-
foreach ( $caching_plugins as $plugin_path ) {
|
1599 |
-
if ( is_plugin_active( $plugin_path ) ) {
|
1600 |
-
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
|
1601 |
-
$active_plugins[] = $plugin_data['Name'];
|
1602 |
-
}
|
1603 |
-
}
|
1604 |
-
|
1605 |
-
return $active_plugins;
|
1606 |
-
}
|
1607 |
-
}
|
1608 |
|
|
|
1609 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
/**
|
|
|
3 |
* Plugin Name: Max Mega Menu
|
4 |
* Plugin URI: https://www.megamenu.com
|
5 |
* Description: An easy to use mega menu plugin. Written the WordPress way.
|
6 |
+
* Version: 2.9
|
7 |
* Author: megamenu.com
|
8 |
* Author URI: https://www.megamenu.com
|
9 |
* License: GPL-2.0+
|
21 |
*/
|
22 |
|
23 |
if ( ! defined( 'ABSPATH' ) ) {
|
24 |
+
exit; // disable direct access.
|
25 |
}
|
26 |
|
27 |
if ( ! class_exists( 'Mega_Menu' ) ) :
|
28 |
|
29 |
+
/**
|
30 |
+
* Main plugin class
|
31 |
+
*/
|
32 |
+
final class Mega_Menu {
|
33 |
+
/**
|
34 |
+
* Current plugin version
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
public $version = '2.9';
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Identify the last version where a change was made to the CSS that requires the menu CSS to be rebuilt
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $scss_last_updated = '2.4.1.3';
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Init
|
51 |
+
*
|
52 |
+
* @since 1.0
|
53 |
+
*/
|
54 |
+
public static function init() {
|
55 |
+
$plugin = new self();
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Constructor
|
61 |
+
*
|
62 |
+
* @since 1.0
|
63 |
+
*/
|
64 |
+
public function __construct() {
|
65 |
+
$this->define_constants();
|
66 |
+
$this->includes();
|
67 |
+
|
68 |
+
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
|
69 |
+
add_action( 'init', array( $this, 'register_sidebar' ) );
|
70 |
+
add_action( 'admin_init', array( $this, 'install_upgrade_check' ) );
|
71 |
+
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
72 |
+
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
73 |
+
add_filter( 'in_widget_form', array( $this, 'add_notice_to_nav_menu_widget' ), 10, 3 );
|
74 |
+
|
75 |
+
add_action( 'after_setup_theme', array( $this, 'register_nav_menus' ) );
|
76 |
+
|
77 |
+
add_filter( 'wp_nav_menu_args', array( $this, 'modify_nav_menu_args' ), 99999 );
|
78 |
+
add_filter( 'wp_nav_menu', array( $this, 'add_responsive_toggle' ), 10, 2 );
|
79 |
+
|
80 |
+
add_filter( 'wp_nav_menu_objects', array( $this, 'add_widgets_to_menu' ), apply_filters( 'megamenu_wp_nav_menu_objects_priority', 10 ), 2 );
|
81 |
+
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'apply_depth_to_menu_items' ), 5, 2 );
|
82 |
+
add_filter( 'megamenu_nav_menu_objects_before', array( $this, 'setup_menu_items' ), 5, 2 );
|
83 |
+
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'reorder_menu_items_within_megamenus' ), 6, 2 );
|
84 |
+
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'apply_classes_to_menu_items' ), 7, 2 );
|
85 |
+
add_filter( 'megamenu_nav_menu_objects_after', array( $this, 'set_descriptions_if_enabled' ), 8, 2 );
|
86 |
+
add_filter( 'body_class', array( $this, 'add_megamenu_body_classes' ), 10, 1 );
|
87 |
+
|
88 |
+
add_filter( 'megamenu_nav_menu_css_class', array( $this, 'prefix_menu_classes' ), 10, 3 );
|
89 |
+
|
90 |
+
// plugin compatibility.
|
91 |
+
add_filter( 'conditional_menus_theme_location', array( $this, 'conditional_menus_restore_theme_location' ), 10, 3 );
|
92 |
+
add_filter( 'black_studio_tinymce_enable_pages', array( $this, 'megamenu_blackstudio_tinymce' ) );
|
93 |
+
|
94 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 11 );
|
95 |
+
|
96 |
+
add_action( 'admin_print_footer_scripts-nav-menus.php', array( $this, 'admin_print_footer_scripts' ) );
|
97 |
+
add_action( 'admin_print_scripts-nav-menus.php', array( $this, 'admin_print_scripts' ) );
|
98 |
+
add_action( 'admin_print_styles-nav-menus.php', array( $this, 'admin_print_styles' ) );
|
99 |
+
|
100 |
+
add_shortcode( 'maxmenu', array( $this, 'register_shortcode' ) );
|
101 |
+
add_shortcode( 'maxmegamenu', array( $this, 'register_shortcode' ) );
|
102 |
+
|
103 |
+
if ( is_admin() ) {
|
104 |
+
$admin_classes = array(
|
105 |
+
'Mega_Menu_Nav_Menus',
|
106 |
+
'Mega_Menu_Widget_Manager',
|
107 |
+
'Mega_Menu_Menu_Item_Manager',
|
108 |
+
'Mega_Menu_Page',
|
109 |
+
'Mega_Menu_General',
|
110 |
+
'Mega_Menu_Locations',
|
111 |
+
'Mega_Menu_Themes',
|
112 |
+
'Mega_Menu_Tools',
|
113 |
+
);
|
114 |
+
|
115 |
+
foreach ( $admin_classes as $class ) {
|
116 |
+
if ( class_exists( $class ) ) {
|
117 |
+
new $class();
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
if ( class_exists( 'Mega_Menu_Toggle_Blocks' ) ) {
|
123 |
+
new Mega_Menu_Toggle_Blocks();
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( class_exists( 'Mega_Menu_Style_Manager' ) ) {
|
127 |
+
$mega_menu_style_manager = new Mega_Menu_Style_Manager();
|
128 |
+
$mega_menu_style_manager->setup_actions();
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Add a body class for each active mega menu location.
|
136 |
+
*
|
137 |
+
* @since 2.3
|
138 |
+
* @param array $classes current body classes.
|
139 |
+
* @return array
|
140 |
+
*/
|
141 |
+
public function add_megamenu_body_classes( $classes ) {
|
142 |
+
$locations = get_nav_menu_locations();
|
143 |
+
|
144 |
+
if ( count( $locations ) ) {
|
145 |
+
foreach ( $locations as $location => $id ) {
|
146 |
+
if ( has_nav_menu( $location ) && max_mega_menu_is_enabled( $location ) ) {
|
147 |
+
$classes[] = 'mega-menu-' . str_replace( '_', '-', $location );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
return $classes;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Add custom actions to allow enqueuing scripts on specific pages
|
158 |
+
*
|
159 |
+
* @since 1.8.3
|
160 |
+
* @param string $hook page ID.
|
161 |
+
*/
|
162 |
+
public function admin_enqueue_scripts( $hook ) {
|
163 |
+
if ( ! wp_script_is( 'maxmegamenu' ) ) {
|
164 |
+
|
165 |
+
if ( in_array( $hook, array( 'nav-menus.php', 'gutenberg_page_gutenberg-navigation' ), true ) ) {
|
166 |
+
// load widget scripts and styles first to allow us to dequeue conflicting colorbox scripts from other plugins.
|
167 |
+
do_action( 'sidebar_admin_setup' );
|
168 |
+
do_action( 'admin_enqueue_scripts', 'widgets.php' );
|
169 |
+
do_action( 'megamenu_nav_menus_scripts', $hook );
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( strpos( $hook, 'maxmegamenu' ) !== false ) {
|
173 |
+
do_action( 'megamenu_admin_scripts', $hook );
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
181 |
+
*
|
182 |
+
* @since 2.3.7
|
183 |
+
* @param string $hook page ID.
|
184 |
+
*/
|
185 |
+
public function admin_print_footer_scripts( $hook ) {
|
186 |
+
do_action( 'admin_footer-widgets.php' );
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
192 |
+
*
|
193 |
+
* @since 2.3.7
|
194 |
+
* @param string $hook page ID.
|
195 |
+
*/
|
196 |
+
public function admin_print_scripts( $hook ) {
|
197 |
+
do_action( 'admin_print_scripts-widgets.php' );
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Print the widgets.php scripts on the nav-menus.php page. Required for 4.8 Core Media Widgets.
|
203 |
+
*
|
204 |
+
* @since 2.3.7
|
205 |
+
* @param string $hook page ID.
|
206 |
+
*/
|
207 |
+
public function admin_print_styles( $hook ) {
|
208 |
+
do_action( 'admin_print_styles-widgets.php' );
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Register menu locations created within Max Mega Menu.
|
214 |
+
*
|
215 |
+
* @since 1.8
|
216 |
+
*/
|
217 |
+
public function register_nav_menus() {
|
218 |
+
|
219 |
+
$locations = get_option( 'megamenu_locations' );
|
220 |
+
|
221 |
+
if ( is_array( $locations ) && count( $locations ) ) {
|
222 |
+
foreach ( $locations as $key => $val ) {
|
223 |
+
register_nav_menu( $key, $val );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Black Studio TinyMCE Compatibility.
|
231 |
+
* Load TinyMCE assets on nav-menus.php page.
|
232 |
+
*
|
233 |
+
* @since 1.8
|
234 |
+
. * @param array $pages Pages to load tinymce scripts on
|
235 |
+
* @return array $pages
|
236 |
+
*/
|
237 |
+
public function megamenu_blackstudio_tinymce( $pages ) {
|
238 |
+
$pages[] = 'nav-menus.php';
|
239 |
+
return $pages;
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Detect new or updated installations and run actions accordingly.
|
245 |
+
*
|
246 |
+
* @since 1.3
|
247 |
+
*/
|
248 |
+
public function install_upgrade_check() {
|
249 |
+
$version = get_option( 'megamenu_version' );
|
250 |
+
|
251 |
+
if ( $version ) {
|
252 |
+
|
253 |
+
if ( version_compare( $this->version, $version, '!=' ) ) {
|
254 |
+
|
255 |
+
update_option( 'megamenu_version', $this->version );
|
256 |
+
|
257 |
+
do_action( 'megamenu_after_update' );
|
258 |
+
|
259 |
+
}
|
260 |
+
} else {
|
261 |
+
|
262 |
+
add_option( 'megamenu_version', $this->version );
|
263 |
+
add_option( 'megamenu_initial_version', $this->version );
|
264 |
+
add_option( 'megamenu_multisite_share_themes', 'false' );
|
265 |
+
|
266 |
+
do_action( 'megamenu_after_install' );
|
267 |
+
|
268 |
+
$settings = get_option( 'megamenu_settings' );
|
269 |
+
|
270 |
+
// set defaults.
|
271 |
+
if ( ! $settings ) {
|
272 |
+
$settings['prefix'] = 'disabled';
|
273 |
+
$settings['descriptions'] = 'enabled';
|
274 |
+
$settings['second_click'] = 'go';
|
275 |
+
|
276 |
+
add_option( 'megamenu_settings', $settings );
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Register widget
|
284 |
+
*
|
285 |
+
* @since 1.7.4
|
286 |
+
*/
|
287 |
+
public function register_widget() {
|
288 |
+
if ( class_exists( 'Mega_Menu_Widget' ) ) {
|
289 |
+
register_widget( 'Mega_Menu_Widget' );
|
290 |
+
}
|
291 |
+
//register_widget( 'Mega_Menu_Widget_Reusable_Block' );
|
292 |
+
|
293 |
+
// Check if Elementor installed and activated
|
294 |
+
//if ( did_action( 'elementor/loaded' ) ) {
|
295 |
+
// register_widget( 'Mega_Menu_Widget_Elementor_Template' );
|
296 |
+
//}
|
297 |
+
}
|
298 |
+
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Create our own widget area to store all mega menu widgets.
|
302 |
+
* All widgets from all menus are stored here, they are filtered later
|
303 |
+
* to ensure the correct widgets show under the correct menu item.
|
304 |
+
*
|
305 |
+
* @since 1.0
|
306 |
+
*/
|
307 |
+
public function register_sidebar() {
|
308 |
+
|
309 |
+
register_sidebar(
|
310 |
+
array(
|
311 |
+
'id' => 'mega-menu',
|
312 |
+
'name' => __( 'Max Mega Menu Widgets', 'megamenu' ),
|
313 |
+
'description' => __( 'This is where Max Mega Menu stores widgets that you have added to sub menus using the mega menu builder. You can edit existing widgets here, but new widgets must be added through the Mega Menu interface (under Appearance > Menus).', 'megamenu' ),
|
314 |
+
)
|
315 |
+
);
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Shortcode used to display a menu.
|
321 |
+
*
|
322 |
+
* @since 1.3
|
323 |
+
* @param array $atts shortcode attributes.
|
324 |
+
* @return string
|
325 |
+
*/
|
326 |
+
public function register_shortcode( $atts ) {
|
327 |
+
if ( ! isset( $atts['location'] ) ) {
|
328 |
+
return false;
|
329 |
+
}
|
330 |
+
|
331 |
+
if ( has_nav_menu( $atts['location'] ) ) {
|
332 |
+
return wp_nav_menu(
|
333 |
+
array(
|
334 |
+
'theme_location' => $atts['location'],
|
335 |
+
'echo' => false,
|
336 |
+
)
|
337 |
+
);
|
338 |
+
}
|
339 |
+
|
340 |
+
return '<!-- menu not found [maxmegamenu] -->';
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Initialise translations
|
347 |
+
*
|
348 |
+
* @since 1.0
|
349 |
+
*/
|
350 |
+
public function load_plugin_textdomain() {
|
351 |
+
load_plugin_textdomain( 'megamenu', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
352 |
+
}
|
353 |
+
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Define Mega Menu constants
|
357 |
+
*
|
358 |
+
* @since 1.0
|
359 |
+
*/
|
360 |
+
private function define_constants() {
|
361 |
+
define( 'MEGAMENU_VERSION', $this->version );
|
362 |
+
define( 'MEGAMENU_BASE_URL', trailingslashit( plugins_url( 'megamenu' ) ) );
|
363 |
+
define( 'MEGAMENU_PATH', plugin_dir_path( __FILE__ ) );
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
/**
|
368 |
+
* All Mega Menu classes
|
369 |
+
*
|
370 |
+
* @since 1.0
|
371 |
+
*/
|
372 |
+
private function plugin_classes() {
|
373 |
+
$classes = array(
|
374 |
+
'Mega_Menu_Walker' => MEGAMENU_PATH . 'classes/walker.class.php',
|
375 |
+
'Mega_Menu_Widget_Manager' => MEGAMENU_PATH . 'classes/widget-manager.class.php',
|
376 |
+
'Mega_Menu_Menu_item_Manager' => MEGAMENU_PATH . 'classes/menu-item-manager.class.php',
|
377 |
+
'Mega_Menu_Nav_Menus' => MEGAMENU_PATH . 'classes/nav-menus.class.php',
|
378 |
+
'Mega_Menu_Style_Manager' => MEGAMENU_PATH . 'classes/style-manager.class.php',
|
379 |
+
'Mega_Menu_Page' => MEGAMENU_PATH . 'classes/pages/page.php',
|
380 |
+
'Mega_Menu_General' => MEGAMENU_PATH . 'classes/pages/general.php',
|
381 |
+
'Mega_Menu_Locations' => MEGAMENU_PATH . 'classes/pages/locations.php',
|
382 |
+
'Mega_Menu_Themes' => MEGAMENU_PATH . 'classes/pages/themes.php',
|
383 |
+
'Mega_Menu_Tools' => MEGAMENU_PATH . 'classes/pages/tools.php',
|
384 |
+
'Mega_Menu_Widget' => MEGAMENU_PATH . 'classes/widgets/widget.class.php',
|
385 |
+
'Mega_Menu_Widget_Reusable_Block' => MEGAMENU_PATH . 'classes/widgets/widget-reusable-block.class.php',
|
386 |
+
'Mega_Menu_Widget_Elementor_Template' => MEGAMENU_PATH . 'classes/widgets/widget-elementor-template.class.php',
|
387 |
+
'Mega_Menu_toggle_Blocks' => MEGAMENU_PATH . 'classes/toggle-blocks.class.php',
|
388 |
+
'scssc' => MEGAMENU_PATH . 'classes/scssc.inc.php',
|
389 |
+
);
|
390 |
+
|
391 |
+
return $classes;
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Load required classes
|
397 |
+
*
|
398 |
+
* @since 1.0
|
399 |
+
*/
|
400 |
+
private function includes() {
|
401 |
+
foreach ( $this->plugin_classes() as $id => $path ) {
|
402 |
+
if ( is_readable( $path ) && ! class_exists( $id ) ) {
|
403 |
+
include_once $path;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
$template = get_template();
|
408 |
+
|
409 |
+
if ( 'zerif-pro' === $template ) {
|
410 |
+
$template = 'zerif';
|
411 |
+
}
|
412 |
+
|
413 |
+
switch ( $template ) {
|
414 |
+
case 'twentyseventeen':
|
415 |
+
case 'zerif':
|
416 |
+
if ( is_readable( MEGAMENU_PATH . "integration/{$template}/functions.php" ) ) {
|
417 |
+
include_once MEGAMENU_PATH . "integration/{$template}/functions.php";
|
418 |
+
}
|
419 |
+
default:
|
420 |
+
break;
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Appends "mega-" to all menu classes.
|
427 |
+
* This is to help avoid theme CSS conflicts.
|
428 |
+
*
|
429 |
+
* @since 1.0
|
430 |
+
* @param array $classes classes for this menu item.
|
431 |
+
* @param object $item The menu item object.
|
432 |
+
* @param object $args Menu arguments.
|
433 |
+
* @return array
|
434 |
+
*/
|
435 |
+
public function prefix_menu_classes( $classes, $item, $args ) {
|
436 |
+
$return = array();
|
437 |
+
|
438 |
+
foreach ( $classes as $class ) {
|
439 |
+
$return[] = 'mega-' . $class;
|
440 |
+
}
|
441 |
+
|
442 |
+
$location = $args->theme_location;
|
443 |
+
$settings = get_option( 'megamenu_settings' );
|
444 |
+
|
445 |
+
$prefix = isset( $settings['prefix'] ) ? $settings['prefix'] : 'enabled';
|
446 |
+
|
447 |
+
if ( isset( $settings[ $location ]['prefix'] ) ) {
|
448 |
+
$prefix = $settings[ $location ]['prefix'];
|
449 |
+
}
|
450 |
+
|
451 |
+
if ( 'disabled' === $prefix ) {
|
452 |
+
// add in custom classes, sans 'mega-' prefix.
|
453 |
+
foreach ( $classes as $class ) {
|
454 |
+
|
455 |
+
// custom classes are added before the 'menu-item' class.
|
456 |
+
if ( 'menu-item' === $class ) {
|
457 |
+
break;
|
458 |
+
}
|
459 |
+
|
460 |
+
if ( in_array( $class, array( 'menu-column', 'menu-row', 'hide-on-mobile', 'hide-on-desktop' ), true ) ) { // these are always prefixed.
|
461 |
+
continue;
|
462 |
+
}
|
463 |
+
|
464 |
+
if ( strpos( $class, 'menu-columns-' ) !== false ) { // mega-menu-columns-X-of-Y are always prefixed.
|
465 |
+
continue;
|
466 |
+
}
|
467 |
+
|
468 |
+
$return[] = $class;
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
return $return;
|
473 |
+
}
|
474 |
+
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Add the html for the responsive toggle box to the menu
|
478 |
+
*
|
479 |
+
* @param string $nav_menu HTML markup of menu.
|
480 |
+
* @param object $args wp_nav_menu arguments.
|
481 |
+
* @return string
|
482 |
+
* @since 1.3
|
483 |
+
*/
|
484 |
+
public function add_responsive_toggle( $nav_menu, $args ) {
|
485 |
+
$args = (object) $args;
|
486 |
+
|
487 |
+
// make sure we're working with a Mega Menu.
|
488 |
+
if ( ! $args->walker || ! is_a( $args->walker, 'Mega_Menu_Walker' ) ) {
|
489 |
+
return $nav_menu;
|
490 |
+
}
|
491 |
+
|
492 |
+
$find = 'class="' . $args->container_class . '">';
|
493 |
+
|
494 |
+
$theme_id = mmm_get_theme_id_for_location( $args->theme_location );
|
495 |
+
|
496 |
+
$content = '';
|
497 |
+
|
498 |
+
$content = apply_filters( 'megamenu_toggle_bar_content', $content, $nav_menu, $args, $theme_id );
|
499 |
+
|
500 |
+
$replace = $find . '<div class="mega-menu-toggle">' . $content . '</div>';
|
501 |
|
502 |
+
return str_replace( $find, $replace, $nav_menu );
|
503 |
+
}
|
504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
+
/**
|
507 |
+
* Append the widget objects to the menu array before the
|
508 |
+
* menu is processed by the walker.
|
509 |
+
*
|
510 |
+
* @since 1.0
|
511 |
+
* @param array $items - All menu item objects.
|
512 |
+
* @param object $args wp_nav_menu arguments.
|
513 |
+
* @return array - Menu objects including widgets
|
514 |
+
*/
|
515 |
+
public function add_widgets_to_menu( $items, $args ) {
|
516 |
|
517 |
+
$args = (object) $args;
|
518 |
|
519 |
+
// make sure we're working with a Mega Menu.
|
520 |
+
if ( ! $args->walker || ! is_a( $args->walker, 'Mega_Menu_Walker' ) ) {
|
521 |
+
return $items;
|
522 |
+
}
|
523 |
|
524 |
+
$items = apply_filters( 'megamenu_nav_menu_objects_before', $items, $args );
|
525 |
+
|
526 |
+
$widget_manager = new Mega_Menu_Widget_Manager();
|
527 |
|
528 |
+
$rolling_dummy_id = 999999999;
|
529 |
|
530 |
+
$items_to_move = array();
|
|
|
531 |
|
532 |
+
foreach ( $items as $item ) {
|
533 |
|
534 |
+
// populate standard (non-grid) sub menus.
|
535 |
+
if ( 0 === $item->depth && 'megamenu' === $item->megamenu_settings['type'] || ( absint( $item->depth ) === 1 && 'tabbed' === $item->parent_submenu_type && 'grid' !== $item->megamenu_settings['type'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
|
537 |
+
$panel_widgets = $widget_manager->get_widgets_for_menu_id( $item->ID, $args->menu );
|
538 |
|
539 |
+
if ( ! in_array( 'menu-megamenu', $item->classes, true ) ) {
|
540 |
+
$item->classes[] = 'menu-megamenu';
|
541 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
|
543 |
+
if ( count( $panel_widgets ) ) {
|
544 |
|
545 |
+
$widget_position = 0;
|
546 |
+
$total_widgets_in_menu = count( $panel_widgets );
|
547 |
+
$next_order = $this->menu_order_of_next_sibling( $item->ID, $item->menu_item_parent, $items );
|
548 |
|
549 |
+
if ( ! in_array( 'menu-item-has-children', $item->classes, true ) ) {
|
550 |
+
$item->classes[] = 'menu-item-has-children';
|
551 |
+
}
|
552 |
|
553 |
+
foreach ( $panel_widgets as $widget ) {
|
554 |
+
$widget_settings = array_merge(
|
555 |
+
Mega_Menu_Nav_Menus::get_menu_item_defaults(),
|
556 |
+
array(
|
557 |
+
'mega_menu_columns' => absint( $widget['columns'] ),
|
558 |
+
)
|
559 |
+
);
|
560 |
|
561 |
+
$menu_item = array(
|
562 |
+
'type' => 'widget',
|
563 |
+
'parent_submenu_type' => 'megamenu',
|
564 |
+
'title' => $widget['id'],
|
565 |
+
'content' => $widget_manager->show_widget( $widget['id'] ),
|
566 |
+
'menu_item_parent' => $item->ID,
|
567 |
+
'db_id' => 0,
|
568 |
+
'ID' => $widget['id'],
|
569 |
+
'menu_order' => $next_order - $total_widgets_in_menu + $widget_position,
|
570 |
+
'megamenu_order' => $widget['order'],
|
571 |
+
'megamenu_settings' => $widget_settings,
|
572 |
+
'depth' => 1,
|
573 |
+
'classes' => array(
|
574 |
+
'menu-item',
|
575 |
+
'menu-item-type-widget',
|
576 |
+
'menu-widget-class-' . $widget_manager->get_widget_class( $widget['id'] ),
|
577 |
+
),
|
578 |
+
);
|
579 |
|
580 |
+
$items[] = (object) $menu_item;
|
|
|
|
|
581 |
|
582 |
+
$widget_position++;
|
583 |
+
}
|
584 |
+
}
|
585 |
+
}
|
586 |
|
587 |
+
// populate grid sub menus.
|
588 |
+
if ( absint( $item->depth ) === 0 && 'grid' === $item->megamenu_settings['type'] || ( absint( $item->depth ) === 1 && 'tabbed' === $item->parent_submenu_type && 'grid' === $item->megamenu_settings['type'] ) ) {
|
|
|
|
|
589 |
|
590 |
+
$saved_grid = $widget_manager->get_grid_widgets_and_menu_items_for_menu_id( $item->ID, $args->menu->term_id, $items );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
|
592 |
+
$next_order = $this->menu_order_of_next_sibling( $item->ID, $item->menu_item_parent, $items ) - 999;
|
|
|
|
|
|
|
593 |
|
594 |
+
foreach ( $saved_grid as $row => $row_data ) {
|
|
|
595 |
|
596 |
+
$rolling_dummy_id++;
|
597 |
+
$next_order++;
|
598 |
|
599 |
+
if ( isset( $row_data['columns'] ) ) {
|
600 |
+
|
601 |
+
if ( ! in_array( 'menu-item-has-children', $item->classes, true ) ) {
|
602 |
+
$item->classes[] = 'menu-item-has-children';
|
603 |
+
}
|
604 |
+
|
605 |
+
if ( ! in_array( 'menu-megamenu', $item->classes, true ) ) {
|
606 |
+
$item->classes[] = 'menu-megamenu';
|
607 |
+
}
|
608 |
+
|
609 |
+
$classes = array( 'menu-row' );
|
610 |
+
|
611 |
+
if ( isset( $row_data['meta']['class'] ) ) {
|
612 |
+
$classes = array_merge( $classes, array_unique( explode( ' ', $row_data['meta']['class'] ) ) );
|
613 |
+
}
|
614 |
+
|
615 |
+
$row_item = array(
|
616 |
+
'menu_item_parent' => $item->ID,
|
617 |
+
'type' => 'mega_row',
|
618 |
+
'title' => 'Custom Row',
|
619 |
+
'parent_submenu_type' => '',
|
620 |
+
'menu_order' => $next_order,
|
621 |
+
'depth' => 0,
|
622 |
+
'ID' => "{$item->ID}-{$row}",
|
623 |
+
'megamenu_settings' => Mega_Menu_Nav_Menus::get_menu_item_defaults(),
|
624 |
+
'db_id' => $rolling_dummy_id,
|
625 |
+
'classes' => $classes,
|
626 |
+
);
|
627 |
+
|
628 |
+
$items[] = (object) $row_item;
|
629 |
+
|
630 |
+
$row_dummy_id = $rolling_dummy_id;
|
631 |
+
|
632 |
+
foreach ( $row_data['columns'] as $col => $col_data ) {
|
633 |
+
|
634 |
+
$rolling_dummy_id++;
|
635 |
+
$next_order++;
|
636 |
+
|
637 |
+
$classes = array( 'menu-column' );
|
638 |
+
|
639 |
+
if ( isset( $col_data['meta']['class'] ) ) {
|
640 |
+
$classes = array_merge( $classes, array_unique( explode( ' ', $col_data['meta']['class'] ) ) );
|
641 |
+
}
|
642 |
+
|
643 |
+
if ( isset( $row_data['meta']['columns'] ) ) {
|
644 |
+
$row_columns = $row_data['meta']['columns'];
|
645 |
+
} else {
|
646 |
+
$row_columns = 12;
|
647 |
+
}
|
648 |
+
|
649 |
+
if ( isset( $col_data['meta']['span'] ) ) {
|
650 |
+
$classes[] = "menu-columns-{$col_data['meta']['span']}-of-{$row_columns}";
|
651 |
+
}
|
652 |
+
|
653 |
+
if ( isset( $col_data['meta']['hide-on-mobile'] ) && 'true' === $col_data['meta']['hide-on-mobile'] ) {
|
654 |
+
$classes[] = 'hide-on-mobile';
|
655 |
+
}
|
656 |
+
|
657 |
+
if ( isset( $col_data['meta']['hide-on-mobile'] ) && 'true' === $col_data['meta']['hide-on-desktop'] ) {
|
658 |
+
$classes[] = 'hide-on-desktop';
|
659 |
+
}
|
660 |
+
|
661 |
+
$col_item = array(
|
662 |
+
'menu_item_parent' => $row_dummy_id,
|
663 |
+
'type' => 'mega_column',
|
664 |
+
'title' => 'Custom Column',
|
665 |
+
'parent_submenu_type' => '',
|
666 |
+
'menu_order' => $next_order,
|
667 |
+
'depth' => 0,
|
668 |
+
'ID' => "{$item->ID}-{$row}-{$col}",
|
669 |
+
'megamenu_settings' => Mega_Menu_Nav_Menus::get_menu_item_defaults(),
|
670 |
+
'db_id' => $rolling_dummy_id,
|
671 |
+
'classes' => $classes,
|
672 |
+
);
|
673 |
+
|
674 |
+
$items[] = (object) $col_item;
|
675 |
+
|
676 |
+
if ( isset( $col_data['items'] ) ) {
|
677 |
+
|
678 |
+
foreach ( $col_data['items'] as $key => $block ) {
|
679 |
+
|
680 |
+
$next_order++;
|
681 |
+
|
682 |
+
if ( 'widget' === $block['type'] ) {
|
683 |
+
|
684 |
+
$widget_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults() );
|
685 |
+
|
686 |
+
$menu_item = array(
|
687 |
+
'type' => 'widget',
|
688 |
+
'parent_submenu_type' => '',
|
689 |
+
'title' => '',
|
690 |
+
'content' => $widget_manager->show_widget( $block['id'] ),
|
691 |
+
'menu_item_parent' => $rolling_dummy_id,
|
692 |
+
'db_id' => 0,
|
693 |
+
'ID' => $block['id'],
|
694 |
+
'menu_order' => $next_order,
|
695 |
+
'megamenu_order' => 0,
|
696 |
+
'megamenu_settings' => $widget_settings,
|
697 |
+
'depth' => 1,
|
698 |
+
'classes' => array(
|
699 |
+
'menu-item',
|
700 |
+
'menu-item-type-widget',
|
701 |
+
'menu-widget-class-' . $widget_manager->get_widget_class( $block['id'] ),
|
702 |
+
),
|
703 |
+
);
|
704 |
+
|
705 |
+
$items[] = (object) $menu_item;
|
706 |
+
|
707 |
+
} else {
|
708 |
+
// mark this menu item to be moved into a new position.
|
709 |
+
$items_to_move[ $block['id'] ] = array(
|
710 |
+
'new_parent' => $rolling_dummy_id,
|
711 |
+
'new_order' => $next_order,
|
712 |
+
);
|
713 |
+
}
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
}
|
721 |
+
|
722 |
+
if ( count( $items_to_move ) ) {
|
723 |
+
foreach ( $items_to_move as $id => $new_parent ) {
|
724 |
+
$items_to_find[] = $id;
|
725 |
+
}
|
726 |
+
|
727 |
+
foreach ( $items as $item ) {
|
728 |
+
if ( in_array( $item->ID, $items_to_find, true ) ) {
|
729 |
+
$item->menu_item_parent = $items_to_move[ $item->ID ]['new_parent'];
|
730 |
+
$item->menu_order = $items_to_move[ $item->ID ]['new_order'];
|
731 |
+
}
|
732 |
+
}
|
733 |
+
}
|
734 |
+
|
735 |
+
$items = apply_filters( 'megamenu_nav_menu_objects_after', $items, $args );
|
736 |
+
|
737 |
+
return $items;
|
738 |
+
}
|
739 |
+
|
740 |
+
|
741 |
+
/**
|
742 |
+
* Return the menu order of the next sibling menu item.
|
743 |
+
* Eg, given A as the $item_id, the menu order of D will be returned
|
744 |
+
* Eg, given B as the $item_id, the menu order of C will be returned
|
745 |
+
* Eg, given D as the $item_id, the menu order of D + 1000 will be returned
|
746 |
+
*
|
747 |
+
* - A
|
748 |
+
* --- B
|
749 |
+
* --- C
|
750 |
+
* - D
|
751 |
+
*
|
752 |
+
* @since 2.0
|
753 |
+
* @param int $item_id ID of the menu item.
|
754 |
+
* @param array $menu_item_parent ID of the parent menu item.
|
755 |
+
* @param array $items array of all items.
|
756 |
+
* @return int
|
757 |
+
*/
|
758 |
+
private function menu_order_of_next_sibling( $item_id, $menu_item_parent, $items ) {
|
759 |
+
|
760 |
+
$get_order_of_next_item = false;
|
761 |
+
|
762 |
+
foreach ( $items as $key => $item ) {
|
763 |
+
|
764 |
+
if ( $menu_item_parent !== $item->menu_item_parent ) {
|
765 |
+
continue;
|
766 |
+
}
|
767 |
+
|
768 |
+
if ( 'widget' === $item->type ) {
|
769 |
+
continue;
|
770 |
+
}
|
771 |
+
|
772 |
+
if ( $get_order_of_next_item ) {
|
773 |
+
return $item->menu_order;
|
774 |
+
}
|
775 |
+
|
776 |
+
if ( $item->ID === $item_id ) {
|
777 |
+
$get_order_of_next_item = true;
|
778 |
+
}
|
779 |
+
|
780 |
+
if ( isset( $item->menu_order ) ) {
|
781 |
+
$rolling_last_menu_order = $item->menu_order;
|
782 |
+
}
|
783 |
+
}
|
784 |
+
|
785 |
+
// there isn't a next sibling.
|
786 |
+
return $rolling_last_menu_order + 1000;
|
787 |
+
|
788 |
+
}
|
789 |
+
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Determine if menu item is a top level item or a second level item
|
793 |
+
*
|
794 |
+
* @since 2.7.7
|
795 |
+
* @param array $items - All menu item objects.
|
796 |
+
* @param object $args wp_nav_menu arguments.
|
797 |
+
* @return array
|
798 |
+
*/
|
799 |
+
public function apply_depth_to_menu_items( $items, $args ) {
|
800 |
+
$parents = array();
|
801 |
+
|
802 |
+
foreach ( $items as $key => $item ) {
|
803 |
+
if ( absint( $item->menu_item_parent ) === 0 ) {
|
804 |
+
$parents[] = $item->ID;
|
805 |
+
$item->depth = 0;
|
806 |
+
}
|
807 |
+
}
|
808 |
+
|
809 |
+
if ( count( $parents ) ) {
|
810 |
+
foreach ( $items as $key => $item ) {
|
811 |
+
if ( in_array( $item->menu_item_parent, $parents, true ) ) {
|
812 |
+
$item->depth = 1;
|
813 |
+
}
|
814 |
+
}
|
815 |
+
}
|
816 |
+
|
817 |
+
return $items;
|
818 |
+
}
|
819 |
+
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Setup the mega menu settings for each menu item
|
823 |
+
*
|
824 |
+
* @since 2.0
|
825 |
+
* @param array $items - All menu item objects.
|
826 |
+
* @param object $args wp_nav_menu arguments.
|
827 |
+
* @return array
|
828 |
+
*/
|
829 |
+
public function setup_menu_items( $items, $args ) {
|
830 |
+
|
831 |
+
// apply saved metadata to each menu item.
|
832 |
+
foreach ( $items as $item ) {
|
833 |
+
$saved_settings = array_filter( (array) get_post_meta( $item->ID, '_megamenu', true ) );
|
834 |
+
|
835 |
+
$item->megamenu_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $saved_settings );
|
836 |
+
$item->megamenu_order = isset( $item->megamenu_settings['mega_menu_order'][ $item->menu_item_parent ] ) ? $item->megamenu_settings['mega_menu_order'][ $item->menu_item_parent ] : 0;
|
837 |
+
$item->parent_submenu_type = 'flyout';
|
838 |
+
|
839 |
+
if ( isset( $item->menu_order ) ) {
|
840 |
+
$item->menu_order = $item->menu_order * 1000;
|
841 |
+
}
|
842 |
+
|
843 |
+
// add parent mega menu type.
|
844 |
+
if ( absint( $item->depth ) === 1 ) {
|
845 |
+
$parent_settings = array_filter( (array) get_post_meta( $item->menu_item_parent, '_megamenu', true ) );
|
846 |
+
|
847 |
+
if ( isset( $parent_settings['type'] ) ) {
|
848 |
+
$item->parent_submenu_type = $parent_settings['type'];
|
849 |
+
}
|
850 |
+
}
|
851 |
+
}
|
852 |
+
|
853 |
+
return $items;
|
854 |
+
}
|
855 |
+
|
856 |
+
|
857 |
+
/**
|
858 |
+
* Reorder items within the mega menu.
|
859 |
+
*
|
860 |
+
* @since 2.0
|
861 |
+
* @param array $items - All menu item objects.
|
862 |
+
* @param object $args wp_nav_menu arguments.
|
863 |
+
* @return array
|
864 |
+
*/
|
865 |
+
public function reorder_menu_items_within_megamenus( $items, $args ) {
|
866 |
+
$new_items = array();
|
867 |
+
|
868 |
+
// reorder menu items within mega menus based on internal ordering.
|
869 |
+
foreach ( $items as $item ) {
|
870 |
+
// items ordered with 'forced' ordering.
|
871 |
+
if ( property_exists( $item, 'parent_submenu_type' ) && 'megamenu' === $item->parent_submenu_type && property_exists( $item, 'megamenu_order' ) && 0 !== $item->megamenu_order ) {
|
872 |
+
if ( $parent_menu_item = get_post( $item->menu_item_parent ) ) {
|
873 |
+
$item->menu_order = $parent_menu_item->menu_order * 1000 + $item->megamenu_order;
|
874 |
+
}
|
875 |
+
}
|
876 |
+
}
|
877 |
+
|
878 |
+
foreach ( $items as $item ) {
|
879 |
+
if ( in_array( 'wpml-ls-item', $item->classes, true ) ) {
|
880 |
+
$item->classes[] = 'menu-flyout';
|
881 |
+
}
|
882 |
+
|
883 |
+
$new_items[ $item->menu_order ] = $item;
|
884 |
+
}
|
885 |
+
|
886 |
+
ksort( $new_items );
|
887 |
+
|
888 |
+
return $new_items;
|
889 |
+
}
|
890 |
+
|
891 |
+
|
892 |
+
/**
|
893 |
+
* If descriptions are enabled, create a new 'mega_description' property.
|
894 |
+
* This is for backwards compatibility for users who have used filters
|
895 |
+
* to display descriptions
|
896 |
+
*
|
897 |
+
* @since 2.3
|
898 |
+
* @param array $items All menu item objects.
|
899 |
+
* @param object $args wp_nav_menu arguments.
|
900 |
+
* @return array
|
901 |
+
*/
|
902 |
+
public function set_descriptions_if_enabled( $items, $args ) {
|
903 |
+
|
904 |
+
$location = $args->theme_location;
|
905 |
+
$settings = get_option( 'megamenu_settings' );
|
906 |
+
|
907 |
+
$descriptions = isset( $settings['descriptions'] ) ? $settings['descriptions'] : 'disabled';
|
908 |
+
|
909 |
+
if ( isset( $settings[ $location ]['descriptions'] ) ) {
|
910 |
+
$descriptions = $settings[ $location ]['descriptions'];
|
911 |
+
}
|
912 |
+
|
913 |
+
if ( 'enabled' === $descriptions ) {
|
914 |
+
foreach ( $items as $item ) {
|
915 |
+
if ( property_exists( $item, 'description' ) && strlen( $item->description ) ) {
|
916 |
+
$item->mega_description = $item->description;
|
917 |
+
$item->classes[] = 'has-description';
|
918 |
+
}
|
919 |
+
}
|
920 |
+
}
|
921 |
+
|
922 |
+
return $items;
|
923 |
+
}
|
924 |
+
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Apply column and clear classes to menu items (inc. widgets)
|
928 |
+
*
|
929 |
+
* @since 2.0
|
930 |
+
* @param array $items All menu item objects.
|
931 |
+
* @param object $args wp_nav_menu arguments.
|
932 |
+
* @return array
|
933 |
+
*/
|
934 |
+
public function apply_classes_to_menu_items( $items, $args ) {
|
935 |
+
$parents = array();
|
936 |
+
|
937 |
+
foreach ( $items as $item ) {
|
938 |
+
|
939 |
+
if ( ! in_array( 'menu-row', $item->classes, true ) && ! in_array( 'menu-column', $item->classes, true ) ) {
|
940 |
+
if ( 0 === $item->depth ) {
|
941 |
+
$item->classes[] = 'align-' . $item->megamenu_settings['align'];
|
942 |
+
$item->classes[] = 'menu-' . $item->megamenu_settings['type'];
|
943 |
+
}
|
944 |
+
|
945 |
+
if ( 'true' === $item->megamenu_settings['hide_arrow'] ) {
|
946 |
+
$item->classes[] = 'hide-arrow';
|
947 |
+
}
|
948 |
+
|
949 |
+
if ( 'disabled' !== $item->megamenu_settings['icon'] ) {
|
950 |
+
$item->classes[] = 'has-icon';
|
951 |
+
}
|
952 |
+
|
953 |
+
if ( 'disabled' !== $item->megamenu_settings['icon'] && isset( $item->megamenu_settings['icon_position'] ) ) {
|
954 |
+
$item->classes[] = 'icon-' . $item->megamenu_settings['icon_position'];
|
955 |
+
}
|
956 |
+
|
957 |
+
if ( 'true' === $item->megamenu_settings['hide_text'] && 0 === $item->depth ) {
|
958 |
+
$item->classes[] = 'hide-text';
|
959 |
+
}
|
960 |
+
|
961 |
+
if ( 'left' !== $item->megamenu_settings['item_align'] && 0 === $item->depth ) {
|
962 |
+
$item->classes[] = 'item-align-' . $item->megamenu_settings['item_align'];
|
963 |
+
}
|
964 |
+
|
965 |
+
if ( 'true' === $item->megamenu_settings['hide_on_desktop'] ) {
|
966 |
+
$item->classes[] = 'hide-on-desktop';
|
967 |
+
}
|
968 |
+
|
969 |
+
if ( 'true' === $item->megamenu_settings['hide_on_mobile'] ) {
|
970 |
+
$item->classes[] = 'hide-on-mobile';
|
971 |
+
}
|
972 |
+
|
973 |
+
if ( 'true' === $item->megamenu_settings['hide_sub_menu_on_mobile'] ) {
|
974 |
+
$item->classes[] = 'hide-sub-menu-on-mobile';
|
975 |
+
}
|
976 |
+
|
977 |
+
if ( 'true' === $item->megamenu_settings['disable_link'] ) {
|
978 |
+
$item->classes[] = 'disable-link';
|
979 |
+
}
|
980 |
+
|
981 |
+
if ( 'true' === $item->megamenu_settings['collapse_children'] ) {
|
982 |
+
$item->classes[] = 'collapse-children';
|
983 |
+
}
|
984 |
+
|
985 |
+
if ( absint( $item->megamenu_settings['submenu_columns'] ) > 1 ) {
|
986 |
+
$item->classes[] = absint( $item->megamenu_settings['submenu_columns'] ) . '-columns';
|
987 |
+
}
|
988 |
+
}
|
989 |
+
|
990 |
+
// add column classes for second level menu items displayed in mega menus.
|
991 |
+
if ( 'megamenu' === $item->parent_submenu_type ) {
|
992 |
+
|
993 |
+
$parent_settings = array_filter( (array) get_post_meta( $item->menu_item_parent, '_megamenu', true ) );
|
994 |
+
$parent_settings = array_merge( Mega_Menu_Nav_Menus::get_menu_item_defaults(), $parent_settings );
|
995 |
+
|
996 |
+
$span = $item->megamenu_settings['mega_menu_columns'];
|
997 |
+
|
998 |
+
$total_columns = $parent_settings['panel_columns'];
|
999 |
+
|
1000 |
+
if ( $total_columns >= $span ) {
|
1001 |
+
$item->classes[] = "menu-columns-{$span}-of-{$total_columns}";
|
1002 |
+
$column_count = $span;
|
1003 |
+
} else {
|
1004 |
+
$item->classes[] = "menu-columns-{$total_columns}-of-{$total_columns}";
|
1005 |
+
$column_count = $total_columns;
|
1006 |
+
}
|
1007 |
|
1008 |
+
if ( ! isset( $parents[ $item->menu_item_parent ] ) ) {
|
1009 |
+
$parents[ $item->menu_item_parent ] = $column_count;
|
1010 |
+
} else {
|
1011 |
+
$parents[ $item->menu_item_parent ] = $parents[ $item->menu_item_parent ] + $column_count;
|
1012 |
|
1013 |
+
if ( $parents[ $item->menu_item_parent ] > $total_columns ) {
|
1014 |
+
$parents[ $item->menu_item_parent ] = $column_count;
|
1015 |
+
$item->classes[] = 'menu-clear';
|
1016 |
+
}
|
1017 |
+
}
|
1018 |
+
}
|
1019 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1020 |
|
1021 |
+
return $items;
|
1022 |
+
}
|
|
|
|
|
1023 |
|
|
|
|
|
|
|
|
|
|
|
1024 |
|
1025 |
+
/**
|
1026 |
+
* Use the Mega Menu walker to output the menu
|
1027 |
+
* Resets all parameters used in the wp_nav_menu call
|
1028 |
+
* Wraps the menu in mega-menu IDs and classes
|
1029 |
+
*
|
1030 |
+
* @since 1.0
|
1031 |
+
* @param object $args wp_nav_menu arguments.
|
1032 |
+
* @return array
|
1033 |
+
*/
|
1034 |
+
public function modify_nav_menu_args( $args ) {
|
1035 |
|
1036 |
+
if ( ! isset( $args['theme_location'] ) ) {
|
1037 |
+
return $args;
|
1038 |
+
}
|
1039 |
|
1040 |
+
// internal action to use as a counter.
|
1041 |
+
do_action( 'megamenu_instance_counter_' . $args['theme_location'] );
|
1042 |
|
1043 |
+
$num_times_called = did_action( 'megamenu_instance_counter_' . $args['theme_location'] );
|
1044 |
|
1045 |
+
$settings = get_option( 'megamenu_settings' );
|
1046 |
+
$current_theme_location = $args['theme_location'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
|
1048 |
+
$active_instance = 0;
|
|
|
1049 |
|
1050 |
+
if ( isset( $settings[ $current_theme_location ]['active_instance'] ) ) {
|
1051 |
+
$active_instance = $settings[ $current_theme_location ]['active_instance'];
|
1052 |
+
} elseif ( isset( $settings['instances'][ $current_theme_location ] ) ) {
|
1053 |
+
$active_instance = $settings['instances'][ $current_theme_location ];
|
1054 |
+
}
|
1055 |
|
1056 |
+
if ( $active_instance != '0' && strlen( $active_instance ) ) {
|
1057 |
+
if ( strpos( $active_instance, ',' ) || is_numeric( $active_instance ) ) {
|
1058 |
+
$active_instances = explode( ',', $active_instance );
|
1059 |
|
1060 |
+
if ( ! in_array( $num_times_called, $active_instances, true ) ) {
|
1061 |
+
return $args;
|
1062 |
+
}
|
1063 |
+
} elseif ( isset( $args['container_id'] ) && $active_instance !== $args['container_id'] ) {
|
1064 |
+
return $args;
|
1065 |
+
}
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
$locations = get_nav_menu_locations();
|
1069 |
+
|
1070 |
+
if ( isset( $settings[ $current_theme_location ]['enabled'] ) && true === boolval( $settings[ $current_theme_location ]['enabled'] ) ) {
|
1071 |
+
|
1072 |
+
if ( ! isset( $locations[ $current_theme_location ] ) ) {
|
1073 |
+
return $args;
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
$menu_id = $locations[ $current_theme_location ];
|
1077 |
+
|
1078 |
+
if ( ! $menu_id ) {
|
1079 |
+
return $args;
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
$menu_theme = mmm_get_theme_for_location( $current_theme_location );
|
1083 |
+
$menu_settings = $settings[ $current_theme_location ];
|
1084 |
+
|
1085 |
+
$effect = isset( $menu_settings['effect'] ) ? $menu_settings['effect'] : 'disabled';
|
1086 |
+
|
1087 |
+
// as set on the main settings page.
|
1088 |
+
$vertical_behaviour = isset( $settings['mobile_behaviour'] ) ? $settings['mobile_behaviour'] : 'standard';
|
1089 |
+
|
1090 |
+
if ( isset( $menu_settings['mobile_behaviour'] ) ) {
|
1091 |
+
$vertical_behaviour = $menu_settings['mobile_behaviour'];
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
// as set on the main settings page.
|
1095 |
+
$second_click = isset( $settings['second_click'] ) ? $settings['second_click'] : 'go';
|
1096 |
+
|
1097 |
+
if ( isset( $menu_settings['second_click'] ) ) {
|
1098 |
+
$second_click = $menu_settings['second_click'];
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
$unbind = isset( $settings['unbind'] ) ? $settings['unbind'] : 'enabled';
|
1102 |
+
|
1103 |
+
if ( isset( $menu_settings['unbind'] ) ) {
|
1104 |
+
$unbind = $menu_settings['unbind'];
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
$event = 'hover_intent';
|
1108 |
+
|
1109 |
+
if ( isset( $menu_settings['event'] ) ) {
|
1110 |
+
if ( 'hover' === $menu_settings['event'] ) {
|
1111 |
+
$event = 'hover_intent';
|
1112 |
+
} elseif ( 'hover_' === $menu_settings['event'] ) {
|
1113 |
+
$event = 'hover';
|
1114 |
+
} else {
|
1115 |
+
$event = $menu_settings['event'];
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
$mobile_force_width = 'false';
|
1120 |
+
|
1121 |
+
if ( isset( $menu_theme['mobile_menu_force_width'] ) && 'on' === $menu_theme['mobile_menu_force_width'] ) {
|
1122 |
+
if ( isset( $menu_theme['mobile_menu_force_width_selector'] ) ) {
|
1123 |
+
$mobile_force_width = $menu_theme['mobile_menu_force_width_selector'];
|
1124 |
+
} else {
|
1125 |
+
$mobile_force_width = 'body';
|
1126 |
+
}
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
$effect_mobile = 'disabled';
|
1130 |
+
|
1131 |
+
if ( isset( $menu_settings['effect_mobile'] ) ) {
|
1132 |
+
$effect_mobile = $menu_settings['effect_mobile'];
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
$effect_speed_mobile = 200;
|
1136 |
+
|
1137 |
+
if ( isset( $menu_settings['effect_speed_mobile'] ) ) {
|
1138 |
+
$effect_speed_mobile = $menu_settings['effect_speed_mobile'];
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
$container = 'div';
|
1142 |
+
|
1143 |
+
if ( isset( $menu_settings['container'] ) ) {
|
1144 |
+
$container = $menu_settings['container'];
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
if ( 'disabled' === $effect_mobile ) {
|
1148 |
+
$effect_speed_mobile = 0;
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
$hover_intent_params = apply_filters(
|
1152 |
+
'megamenu_javascript_localisation', // backwards compatiblity.
|
1153 |
+
array(
|
1154 |
+
'timeout' => 300,
|
1155 |
+
'interval' => 100,
|
1156 |
+
)
|
1157 |
+
);
|
1158 |
+
|
1159 |
+
$wrap_attributes = apply_filters(
|
1160 |
+
'megamenu_wrap_attributes',
|
1161 |
+
array(
|
1162 |
+
'id' => '%1$s',
|
1163 |
+
'class' => '%2$s mega-no-js',
|
1164 |
+
'data-event' => $event,
|
1165 |
+
'data-effect' => $effect,
|
1166 |
+
'data-effect-speed' => isset( $menu_settings['effect_speed'] ) ? $menu_settings['effect_speed'] : '200',
|
1167 |
+
'data-effect-mobile' => $effect_mobile,
|
1168 |
+
'data-effect-speed-mobile' => $effect_speed_mobile,
|
1169 |
+
'data-panel-width' => preg_match( '/^\d/', $menu_theme['panel_width'] ) !== 1 ? $menu_theme['panel_width'] : '',
|
1170 |
+
'data-panel-inner-width' => substr( trim( $menu_theme['panel_inner_width'] ), -1 ) !== '%' ? $menu_theme['panel_inner_width'] : '',
|
1171 |
+
'data-mobile-force-width' => $mobile_force_width,
|
1172 |
+
'data-second-click' => $second_click,
|
1173 |
+
'data-document-click' => 'collapse',
|
1174 |
+
'data-vertical-behaviour' => $vertical_behaviour,
|
1175 |
+
'data-breakpoint' => absint( $menu_theme['responsive_breakpoint'] ),
|
1176 |
+
'data-unbind' => 'disabled' === $unbind ? 'false' : 'true',
|
1177 |
+
'data-hover-intent-timeout' => absint( $hover_intent_params['timeout'] ),
|
1178 |
+
'data-hover-intent-interval' => absint( $hover_intent_params['interval'] ),
|
1179 |
+
),
|
1180 |
+
$menu_id,
|
1181 |
+
$menu_settings,
|
1182 |
+
$settings,
|
1183 |
+
$current_theme_location
|
1184 |
+
);
|
1185 |
+
|
1186 |
+
$attributes = '';
|
1187 |
+
|
1188 |
+
foreach ( $wrap_attributes as $attribute => $value ) {
|
1189 |
+
if ( strlen( $value ) ) {
|
1190 |
+
$attributes .= ' ' . $attribute . '="' . esc_attr( $value ) . '"';
|
1191 |
+
}
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
$sanitized_location = str_replace( apply_filters( 'megamenu_location_replacements', array( '-', ' ' ) ), '-', $current_theme_location );
|
1195 |
+
|
1196 |
+
$defaults = array(
|
1197 |
+
'menu' => wp_get_nav_menu_object( $menu_id ),
|
1198 |
+
'container' => $container,
|
1199 |
+
'container_class' => 'mega-menu-wrap',
|
1200 |
+
'container_id' => 'mega-menu-wrap-' . $sanitized_location,
|
1201 |
+
'menu_class' => 'mega-menu max-mega-menu mega-menu-horizontal',
|
1202 |
+
'menu_id' => 'mega-menu-' . $sanitized_location,
|
1203 |
+
'fallback_cb' => 'wp_page_menu',
|
1204 |
+
'before' => '',
|
1205 |
+
'after' => '',
|
1206 |
+
'link_before' => '',
|
1207 |
+
'link_after' => '',
|
1208 |
+
'items_wrap' => '<ul' . $attributes . '>%3$s</ul>',
|
1209 |
+
'depth' => 0,
|
1210 |
+
'walker' => new Mega_Menu_Walker(),
|
1211 |
+
);
|
1212 |
+
|
1213 |
+
$args = array_merge( $args, apply_filters( 'megamenu_nav_menu_args', $defaults, $menu_id, $current_theme_location ) );
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
return $args;
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
|
1220 |
+
/**
|
1221 |
+
* Display admin notices.
|
1222 |
+
*/
|
1223 |
+
public function admin_notices() {
|
1224 |
+
|
1225 |
+
if ( ! $this->is_compatible_wordpress_version() ) :
|
1226 |
+
|
1227 |
+
?>
|
1228 |
+
<div class="error">
|
1229 |
+
<p><?php esc_html_e( 'Max Mega Menu is not compatible with your version of WordPress. Please upgrade WordPress to the latest version or disable Max Mega Menu.', 'megamenu' ); ?></p>
|
1230 |
+
</div>
|
1231 |
+
<?php
|
1232 |
+
|
1233 |
+
endif;
|
1234 |
+
|
1235 |
+
if ( did_action( 'megamenu_after_install' ) === 1 ) :
|
1236 |
+
|
1237 |
+
?>
|
1238 |
+
|
1239 |
+
<?php
|
1240 |
+
|
1241 |
+
endif;
|
1242 |
+
|
1243 |
+
if ( defined( 'MEGAMENU_HIDE_CSS_NAG' ) && MEGAMENU_HIDE_CSS_NAG === true ) {
|
1244 |
+
return;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
$css_version = get_transient( 'megamenu_css_version' );
|
1248 |
+
$css = get_transient( 'megamenu_css' );
|
1249 |
+
|
1250 |
+
if ( $css && version_compare( $this->scss_last_updated, $css_version, '>' ) ) :
|
1251 |
+
|
1252 |
+
?>
|
1253 |
+
<div class="updated">
|
1254 |
+
<?php
|
1255 |
+
|
1256 |
+
$clear_cache_url = esc_url(
|
1257 |
+
add_query_arg(
|
1258 |
+
array(
|
1259 |
+
'action' => 'megamenu_clear_css_cache',
|
1260 |
+
),
|
1261 |
+
wp_nonce_url( admin_url( 'admin-post.php' ), 'megamenu_clear_css_cache' )
|
1262 |
+
)
|
1263 |
+
);
|
1264 |
+
|
1265 |
+
$link = "<a href='{$clear_cache_url}'>" . __( 'clear the CSS cache', 'megamenu' ) . '</a>';
|
1266 |
+
|
1267 |
+
$allowed_html = array(
|
1268 |
+
'a' => array(
|
1269 |
+
'href' => array(),
|
1270 |
+
'title' => array(),
|
1271 |
+
),
|
1272 |
+
);
|
1273 |
+
|
1274 |
+
?>
|
1275 |
+
|
1276 |
+
<p>
|
1277 |
+
<?php
|
1278 |
+
printf(
|
1279 |
+
/* translators: %s is the link to clear the menu CSS cache */
|
1280 |
+
esc_html__( 'Max Mega Menu has been updated. Please %s to ensure maximum compatibility with the latest version.', 'megamenu' ),
|
1281 |
+
wp_kses( $link, $allowed_html )
|
1282 |
+
);
|
1283 |
+
?>
|
1284 |
+
</p>
|
1285 |
+
</div>
|
1286 |
+
<?php
|
1287 |
+
|
1288 |
+
endif;
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
|
1292 |
+
/**
|
1293 |
+
* Checks this WordPress installation is v3.8 or above.
|
1294 |
+
* 3.8 is needed for dashicons.
|
1295 |
+
*/
|
1296 |
+
public function is_compatible_wordpress_version() {
|
1297 |
+
global $wp_version;
|
1298 |
+
|
1299 |
+
return $wp_version >= 3.8;
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
/**
|
1303 |
+
* Add compatibility for conditional menus plugin
|
1304 |
+
*
|
1305 |
+
* @since 2.2
|
1306 |
+
*/
|
1307 |
+
public function conditional_menus_restore_theme_location( $location, $new_args, $old_args ) {
|
1308 |
+
return $old_args['theme_location'];
|
1309 |
+
}
|
1310 |
+
|
1311 |
+
/**
|
1312 |
+
* Add a note to the Navigation Widget to explain that Max Mega Menu will not work with it.
|
1313 |
+
*
|
1314 |
+
* @since 2.5.1
|
1315 |
+
*/
|
1316 |
+
public function add_notice_to_nav_menu_widget( $widget, $return, $instance ) {
|
1317 |
+
if ( 'nav_menu' === $widget->id_base ) {
|
1318 |
+
?>
|
1319 |
+
<p style="font-size: 11px; font-style: italic;">
|
1320 |
+
<?php esc_html_e( "If you are trying to display Max Mega Menu here, use the 'Max Mega Menu' widget instead.", 'megamenu' ); ?>
|
1321 |
+
<a href="https://www.megamenu.com/documentation/widget/" target="_blank"><?php esc_html_e( 'More information', 'megamenu' ); ?></a>
|
1322 |
+
</p>
|
1323 |
+
<?php
|
1324 |
+
}
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
add_action( 'plugins_loaded', array( 'Mega_Menu', 'init' ), 10 );
|
1330 |
|
1331 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1333 |
|
1334 |
+
if ( ! function_exists( 'mmm_get_theme_id_for_location' ) ) {
|
1335 |
+
/**
|
1336 |
+
* Get the menu theme for a specific location
|
1337 |
+
*
|
1338 |
+
* @since 2.1
|
1339 |
+
* @param string $location - theme location identifier.
|
1340 |
+
* @return array Menu Theme.
|
1341 |
+
*/
|
1342 |
+
function mmm_get_theme_id_for_location( $location = false ) {
|
1343 |
+
|
1344 |
+
if ( ! $location ) {
|
1345 |
+
return false;
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
if ( ! has_nav_menu( $location ) ) {
|
1349 |
+
return false;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
// if a location has been passed, check to see if MMM has been enabled for the location.
|
1353 |
+
$settings = get_option( 'megamenu_settings' );
|
1354 |
+
|
1355 |
+
if ( is_array( $settings ) && isset( $settings[ $location ]['enabled'] ) && isset( $settings[ $location ]['theme'] ) ) {
|
1356 |
+
return $settings[ $location ]['theme'];
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
return false;
|
1360 |
+
}
|
1361 |
}
|
1362 |
|
1363 |
+
if ( ! function_exists( 'mmm_get_theme_for_location' ) ) {
|
1364 |
+
/**
|
1365 |
+
* Get the theme assigned to a specified location
|
1366 |
+
*
|
1367 |
+
* @since 2.0.2
|
1368 |
+
* @param string $location - theme location identifier.
|
1369 |
+
*/
|
1370 |
+
function mmm_get_theme_for_location( $location = false ) {
|
1371 |
|
1372 |
+
if ( ! $location ) {
|
1373 |
+
return false;
|
1374 |
+
}
|
1375 |
|
1376 |
+
if ( ! has_nav_menu( $location ) ) {
|
1377 |
+
return false;
|
1378 |
+
}
|
1379 |
|
1380 |
+
// if a location has been passed, check to see if MMM has been enabled for the location.
|
1381 |
+
$settings = get_option( 'megamenu_settings' );
|
1382 |
|
1383 |
+
$style_manager = new Mega_Menu_Style_Manager();
|
|
|
|
|
|
|
|
|
1384 |
|
1385 |
+
$themes = $style_manager->get_themes();
|
|
|
|
|
1386 |
|
1387 |
+
if ( is_array( $settings ) && isset( $settings[ $location ]['enabled'] ) && isset( $settings[ $location ]['theme'] ) ) {
|
1388 |
+
$theme = $settings[ $location ]['theme'];
|
|
|
1389 |
|
1390 |
+
$menu_theme = isset( $themes[ $theme ] ) ? $themes[ $theme ] : $themes['default'];
|
|
|
1391 |
|
1392 |
+
return $menu_theme;
|
1393 |
+
}
|
|
|
1394 |
|
1395 |
+
return $themes['default'];
|
1396 |
+
}
|
1397 |
}
|
1398 |
|
|
|
1399 |
|
1400 |
+
if ( ! function_exists( 'max_mega_menu_is_enabled' ) ) {
|
1401 |
+
/**
|
1402 |
+
* Determines if Max Mega Menu has been enabled for a given menu location.
|
1403 |
+
*
|
1404 |
+
* Usage:
|
1405 |
+
*
|
1406 |
+
* Max Mega Menu is enabled:
|
1407 |
+
* function_exists( 'max_mega_menu_is_enabled' )
|
1408 |
+
*
|
1409 |
+
* Max Mega Menu has been enabled for a theme location:
|
1410 |
+
* function_exists( 'max_mega_menu_is_enabled' ) && max_mega_menu_is_enabled( $location )
|
1411 |
+
*
|
1412 |
+
* @since 1.8
|
1413 |
+
* @param string $location - theme location identifier.
|
1414 |
+
*/
|
1415 |
+
function max_mega_menu_is_enabled( $location = false ) {
|
1416 |
+
|
1417 |
+
if ( ! $location ) {
|
1418 |
+
return true; // the plugin is enabled.
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
if ( ! has_nav_menu( $location ) ) {
|
1422 |
+
return false;
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
// if a location has been passed, check to see if MMM has been enabled for the location.
|
1426 |
+
$settings = get_option( 'megamenu_settings' );
|
1427 |
+
|
1428 |
+
return is_array( $settings ) && isset( $settings[ $location ]['enabled'] ) && $settings[ $location ]['enabled'] == true;
|
1429 |
+
}
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
if ( ! function_exists( 'max_mega_menu_share_themes_across_multisite' ) ) {
|
1433 |
+
/**
|
1434 |
+
* In the first version of MMM, themes were (incorrectly) shared between all sites in a multi site network.
|
1435 |
+
* Themes will not be shared across sites for new users installing v2.4.3 onwards, but they will be shared for existing (older) users.
|
1436 |
+
*
|
1437 |
+
* @since 2.3.7
|
1438 |
+
*/
|
1439 |
+
function max_mega_menu_share_themes_across_multisite() {
|
1440 |
|
1441 |
+
if ( defined( 'MEGAMENU_SHARE_THEMES_MULTISITE' ) && MEGAMENU_SHARE_THEMES_MULTISITE === false ) {
|
1442 |
+
return false;
|
1443 |
+
}
|
1444 |
|
1445 |
+
if ( defined( 'MEGAMENU_SHARE_THEMES_MULTISITE' ) && MEGAMENU_SHARE_THEMES_MULTISITE === true ) {
|
1446 |
+
return true;
|
1447 |
+
}
|
1448 |
|
1449 |
+
if ( get_option( 'megamenu_multisite_share_themes' ) === 'false' ) { // only exists if initially installed version is 2.4.3+.
|
1450 |
+
return false;
|
1451 |
+
}
|
1452 |
|
1453 |
+
return apply_filters( 'megamenu_share_themes_across_multisite', true );
|
1454 |
|
1455 |
+
}
|
1456 |
+
}
|
1457 |
|
1458 |
+
if ( ! function_exists( 'max_mega_menu_get_themes' ) ) {
|
1459 |
+
/**
|
1460 |
+
* Return saved themes
|
1461 |
+
*
|
1462 |
+
* @since 2.3.7
|
1463 |
+
*/
|
1464 |
+
function max_mega_menu_get_themes() {
|
1465 |
|
1466 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1467 |
+
return get_option( 'megamenu_themes' );
|
1468 |
+
}
|
1469 |
|
1470 |
+
return get_site_option( 'megamenu_themes' );
|
|
|
1471 |
|
1472 |
+
}
|
|
|
1473 |
}
|
1474 |
|
1475 |
+
if ( ! function_exists( 'max_mega_menu_save_themes' ) ) {
|
1476 |
+
/**
|
1477 |
+
* Save menu theme
|
1478 |
+
*
|
1479 |
+
* @since 2.3.7
|
1480 |
+
* @param array $themes menu themes.
|
1481 |
+
*/
|
1482 |
+
function max_mega_menu_save_themes( $themes ) {
|
1483 |
|
1484 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1485 |
+
return update_option( 'megamenu_themes', $themes );
|
1486 |
+
}
|
1487 |
|
1488 |
+
return update_site_option( 'megamenu_themes', $themes );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1489 |
|
1490 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1491 |
}
|
1492 |
|
1493 |
+
if ( ! function_exists( 'max_mega_menu_save_last_updated_theme' ) ) {
|
1494 |
+
/**
|
1495 |
+
* Save last updated theme
|
1496 |
+
*
|
1497 |
+
* @since 2.3.7
|
1498 |
+
* @param string $theme The ID of the theme.
|
1499 |
+
*/
|
1500 |
+
function max_mega_menu_save_last_updated_theme( $theme ) {
|
1501 |
|
1502 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1503 |
+
return update_option( 'megamenu_themes_last_updated', $theme );
|
1504 |
+
}
|
1505 |
|
1506 |
+
return update_site_option( 'megamenu_themes_last_updated', $theme );
|
1507 |
|
1508 |
+
}
|
1509 |
}
|
1510 |
|
1511 |
+
if ( ! function_exists( 'max_mega_menu_get_last_updated_theme' ) ) {
|
1512 |
+
/**
|
1513 |
+
* Return last updated theme
|
1514 |
+
*
|
1515 |
+
* @since 2.3.7
|
1516 |
+
*/
|
1517 |
+
function max_mega_menu_get_last_updated_theme() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1518 |
|
1519 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1520 |
+
return get_option( 'megamenu_themes_last_updated' );
|
1521 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1522 |
|
1523 |
+
return get_site_option( 'megamenu_themes_last_updated' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1524 |
|
1525 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1526 |
}
|
1527 |
|
1528 |
+
if ( ! function_exists( 'max_mega_menu_get_toggle_blocks' ) ) {
|
1529 |
+
/**
|
1530 |
+
* Return saved toggle blocks
|
1531 |
+
*
|
1532 |
+
* @since 2.3.7
|
1533 |
+
*/
|
1534 |
+
function max_mega_menu_get_toggle_blocks() {
|
1535 |
|
1536 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1537 |
+
return get_option( 'megamenu_toggle_blocks' );
|
1538 |
+
}
|
1539 |
|
1540 |
+
return get_site_option( 'megamenu_toggle_blocks' );
|
1541 |
|
1542 |
+
}
|
1543 |
}
|
1544 |
|
1545 |
+
if ( ! function_exists( 'max_mega_menu_save_toggle_blocks' ) ) {
|
1546 |
+
/**
|
1547 |
+
* Save toggle blocks
|
1548 |
+
*
|
1549 |
+
* @since 2.3.7
|
1550 |
+
*/
|
1551 |
+
function max_mega_menu_save_toggle_blocks( $saved_blocks ) {
|
1552 |
|
1553 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1554 |
+
return update_option( 'megamenu_toggle_blocks', $saved_blocks );
|
1555 |
+
}
|
1556 |
|
1557 |
+
return update_site_option( 'megamenu_toggle_blocks', $saved_blocks );
|
1558 |
|
1559 |
+
}
|
1560 |
}
|
1561 |
|
1562 |
+
if ( ! function_exists( 'max_mega_menu_delete_themes' ) ) {
|
1563 |
+
/**
|
1564 |
+
* Delete saved themes
|
1565 |
+
*
|
1566 |
+
* @since 2.3.7
|
1567 |
+
*/
|
1568 |
+
function max_mega_menu_delete_themes() {
|
1569 |
+
|
1570 |
+
if ( ! max_mega_menu_share_themes_across_multisite() ) {
|
1571 |
+
return delete_option( 'megamenu_themes' );
|
1572 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1573 |
|
1574 |
+
return delete_site_option( 'megamenu_themes' );
|
1575 |
|
1576 |
+
}
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
if ( ! function_exists( 'max_mega_menu_get_active_caching_plugins' ) ) {
|
1580 |
+
/**
|
1581 |
+
* Return list of active caching/CDN/minification plugins
|
1582 |
+
*
|
1583 |
+
* @since 2.4
|
1584 |
+
* @return array
|
1585 |
+
*/
|
1586 |
+
function max_mega_menu_get_active_caching_plugins() {
|
1587 |
+
|
1588 |
+
$caching_plugins = apply_filters(
|
1589 |
+
'megamenu_caching_plugins',
|
1590 |
+
array(
|
1591 |
+
'litespeed-cache/litespeed-cache.php',
|
1592 |
+
'js-css-script-optimizer/js-css-script-optimizer.php',
|
1593 |
+
'merge-minify-refresh/merge-minify-refresh.php',
|
1594 |
+
'minify-html-markup/minify-html.php',
|
1595 |
+
'simple-cache/simple-cache.php',
|
1596 |
+
'w3-total-cache/w3-total-cache.php',
|
1597 |
+
'wp-fastest-cache/wpFastestCache.php',
|
1598 |
+
'wp-speed-of-light/wp-speed-of-light.php',
|
1599 |
+
'wp-super-cache/wp-cache.php',
|
1600 |
+
'wp-super-minify/wp-super-minify.php',
|
1601 |
+
'autoptimize/autoptimize.php',
|
1602 |
+
'bwp-minify/bwp-minify.php',
|
1603 |
+
'cache-enabler/cache-enabler.php',
|
1604 |
+
'cloudflare/cloudflare.php',
|
1605 |
+
'comet-cache/comet-cache.php',
|
1606 |
+
'css-optimizer/bpminifycss.php',
|
1607 |
+
'fast-velocity-minify/fvm.php',
|
1608 |
+
'hyper-cache/plugin.php',
|
1609 |
+
'remove-query-strings-littlebizzy/remove-query-strings.php',
|
1610 |
+
'remove-query-strings-from-static-resources/remove-query-strings.php',
|
1611 |
+
'query-strings-remover/query-strings-remover.php',
|
1612 |
+
'wp-rocket/wp-rocket.php',
|
1613 |
+
'hummingbird-performance/wp-hummingbird.php',
|
1614 |
+
'breeze/breeze.php',
|
1615 |
+
)
|
1616 |
+
);
|
1617 |
+
|
1618 |
+
$active_plugins = array();
|
1619 |
+
|
1620 |
+
foreach ( $caching_plugins as $plugin_path ) {
|
1621 |
+
if ( is_plugin_active( $plugin_path ) ) {
|
1622 |
+
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
|
1623 |
+
$active_plugins[] = $plugin_data['Name'];
|
1624 |
+
}
|
1625 |
+
}
|
1626 |
+
|
1627 |
+
return $active_plugins;
|
1628 |
+
}
|
1629 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,9 @@
|
|
2 |
Contributors: megamenu
|
3 |
Tags: menu, megamenu, mega menu, navigation, widget, dropdown menu, drag and drop, mobile, responsive, retina, theme editor, widget, shortcode, sidebar, icons, dashicons
|
4 |
Requires at least: 4.9
|
5 |
-
Tested up to: 5.
|
6 |
Stable tag: 2.8
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -47,7 +48,7 @@ Documentation & Demo: [https://www.megamenu.com](https://www.megamenu.com)
|
|
47 |
###Accessibility
|
48 |
|
49 |
* Keyboard Navigation built in
|
50 |
-
* `TAB` activates keyboard
|
51 |
* `ENTER` on a parent item opens a sub menu (pressing `ENTER` a second time will respect the "Second Click Behaviour" setting)
|
52 |
* `ENTER` on a standard item will follow the link
|
53 |
* `SPACE` toggles the sub menu visibility
|
@@ -133,11 +134,26 @@ See https://www.megamenu.com for more screenshots
|
|
133 |
|
134 |
== Changelog ==
|
135 |
|
136 |
-
= 2.
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
* Improvement: Add overflow-behaviour to offcanvas menu
|
|
|
|
|
|
|
|
|
139 |
* Fix: Indent third level items in mobile menu
|
140 |
* Fix: Divi adding linting to Custom CSS area of menu theme
|
|
|
|
|
141 |
|
142 |
= 2.8 =
|
143 |
|
2 |
Contributors: megamenu
|
3 |
Tags: menu, megamenu, mega menu, navigation, widget, dropdown menu, drag and drop, mobile, responsive, retina, theme editor, widget, shortcode, sidebar, icons, dashicons
|
4 |
Requires at least: 4.9
|
5 |
+
Tested up to: 5.5
|
6 |
Stable tag: 2.8
|
7 |
+
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
48 |
###Accessibility
|
49 |
|
50 |
* Keyboard Navigation built in
|
51 |
+
* `TAB` activates keyboard navigation and navigates through the menu
|
52 |
* `ENTER` on a parent item opens a sub menu (pressing `ENTER` a second time will respect the "Second Click Behaviour" setting)
|
53 |
* `ENTER` on a standard item will follow the link
|
54 |
* `SPACE` toggles the sub menu visibility
|
134 |
|
135 |
== Changelog ==
|
136 |
|
137 |
+
= 2.9 =
|
138 |
|
139 |
+
If you have PHP Opcache enabled you may want to update to WordPress 5.5 before applying this update, as it includes this change:
|
140 |
+
|
141 |
+
https://make.wordpress.org/core/2020/07/27/opcode-cache-invalidation-in-wordpress-5-5/
|
142 |
+
|
143 |
+
This release continues to pave the way for the new Appearance > Menus screen coming in WordPress 5.6 by allowing all location related settings to be managed from the Mega Menu > Menu Locations page.
|
144 |
+
|
145 |
+
* Improvement: Click Event Behaviour, Mobile Menu Behaviour, Menu Item Descriptions, Unbind JavaScript Events, Prefix Menu Item Classes and Active Menu Instance options have been moved from the General Settings page and can now be configured per menu location on the updated Mega Menu > Menu Locations page.
|
146 |
+
* Improvement: Move theme import/export options to theme editor page
|
147 |
+
* Improvement: Improve flow for creating new menu locations
|
148 |
* Improvement: Add overflow-behaviour to offcanvas menu
|
149 |
+
* Improvement: Remove jquery accordion dependency on nav-menus.php
|
150 |
+
* Improvement: Trigger custom events when the mobile menu is opened and closed
|
151 |
+
* New: Add container option to specify whether menu should be wrapped in a `div` or a `nav` element
|
152 |
+
* Experimental: Add sandbox option to preview your menu (without theme interference)
|
153 |
* Fix: Indent third level items in mobile menu
|
154 |
* Fix: Divi adding linting to Custom CSS area of menu theme
|
155 |
+
* Fix: Indent third level items in mobile menu
|
156 |
+
* Fix: Ensure page remains scrollable when off canvas mode is enabled, when the off canvas menu is open, and when the browser window is resized from mobile to desktop
|
157 |
|
158 |
= 2.8 =
|
159 |
|