PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / trunk
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder vtrunk
3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 1.5.2 All 109 releases
buttonizer-multifunctional-button / app / Legacy / Utils / Update.php

Update.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder trunk, at app/Legacy/Utils/Update.php

1,380 lines 52.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * SOFTWARE LICENSE INFORMATION
4 *
5 * Copyright (c) 2017 Buttonizer, all rights reserved.
6 *
7 * This file is part of Buttonizer
8 *
9 * For detailed information regarding to the licensing of
10 * this software, please review the license.txt or visit:
11 * https://buttonizer.pro/license/
12 */
13
14 namespace Buttonizer\Legacy\Utils;
15
16 use Buttonizer\Legacy\Utils\Maintain;
17
18 /**
19 * Class Update Buttonizer to version 2.0 (or more)
20 *
21 * This PHP class contains NO premium code
22 *
23 * Thank you for updating Buttonizer and keeping Buttonizer UP TO DATE!
24 *
25 * By the way, not many people will ever see this comment after all...
26 * If you read this, email jasper@buttonizer.pro and say something nice referring to this comment!
27 *
28 * @package Buttonizer\Legacy\Utils
29 */
30 class Update
31 {
32 private $initialized = false;
33 private $removedAnything = false;
34 private $backupSettings = [];
35 private $backupButtons = [];
36 private $backupSchedule = [];
37 private $backupRules = [];
38 private $timeScheduleId = null;
39
40 public function __construct()
41 {
42 $this->timeScheduleId = time();
43 }
44
45 /**
46 * Run update to 2.0
47 */
48 public function run()
49 {
50 try {
51 $this->registerSettings();
52
53 // If there's no Buttonizer data, new install
54 if (!$this->backupButtons && !$this->backupSchedule && !$this->backupRules) {
55 $this->cleanup(true);
56 return; // all OK, new installation :)
57 }
58
59 $this->convertButtons();
60 $this->convertTimeSchedules();
61 if ($this->backupRules) {
62 $this->convertPageRules();
63 }
64
65 $this->cleanup();
66 } catch (\Exception $e) {
67 $this->beforeCrashRevert();
68
69 header('Content-Type: application/javascript');
70
71 echo wp_json_encode([
72 "status" => "error",
73 "message" => "Something went wrong while trying to migrate settings from version 1.5 to version 2.0. Please contact Buttonizer Support or go to the <a href=\"https://community.buttonizer.pro/\" target=\"_blank\">Buttonizer Community</a> and let us know the following message: " . esc_html($e->getMessage())
74 ]);
75 exit;
76 }
77 }
78
79 /**
80 * Selfmigrate
81 * @since 2.2
82 */
83 public function selfMigrate($currentVersion)
84 {
85 switch ($currentVersion) {
86 case "2.0":
87 $this->update20to21();
88 break;
89 case "2.1":
90 $this->update216to217();
91 break;
92 case "2.2":
93 $this->migration4();
94 break;
95 case "4":
96 $this->migration5();
97 break;
98 case "5":
99 $this->migration6();
100 break;
101 case "6":
102 $this->migrationTo7();
103 break;
104 default:
105 // No migration for this. Set to current migration version otherwise we're going into a loop
106 $this->registerSettings();
107 $buttonizerSettings = get_option('buttonizer_settings');
108 $buttonizerSettings["migration_version"] = BUTTONIZER_LAST_MIGRATION;
109 update_option('buttonizer_settings', $buttonizerSettings);
110 break;
111 }
112
113 // Make sure there is nothing to check anymore
114 $this->checkMigration();
115 }
116
117 /**
118 * Recheck migrate, otherwise run next migration
119 */
120 private function checkMigration()
121 {
122 $this->registerSettings();
123 $buttonizerSettings = get_option('buttonizer_settings');
124
125 // Run next migration
126 if ($buttonizerSettings['migration_version'] !== BUTTONIZER_LAST_MIGRATION) {
127 $this->selfMigrate($buttonizerSettings['migration_version']);
128 }
129 }
130
131 /**
132 * Register settings
133 */
134 private function registerSettings()
135 {
136 // Backup settings
137 register_setting("buttonizer", "buttonizer_buttons_backup", [
138 'type' => 'array',
139 'sanitize_callback' => function ($value) {
140 return is_array($value) ? $value : [];
141 }
142 ]);
143 register_setting("buttonizer", "buttonizer_opening_settings_backup", [
144 'type' => 'array',
145 'sanitize_callback' => function ($value) {
146 return is_array($value) ? $value : [];
147 }
148 ]);
149 register_setting("buttonizer", "buttonizer_page_categories_backup", [
150 'type' => 'array',
151 'sanitize_callback' => function ($value) {
152 return is_array($value) ? $value : [];
153 }
154 ]);
155 register_setting("buttonizer", "buttonizer_general_settings_backup", [
156 'type' => 'array',
157 'sanitize_callback' => function ($value) {
158 return is_array($value) ? $value : [];
159 }
160 ]);
161
162 // Get buttons
163 register_setting("buttonizer", "buttonizer_buttons", [
164 'type' => 'array',
165 'sanitize_callback' => function ($value) {
166 return is_array($value) ? $value : [];
167 }
168 ]);
169 register_setting("buttonizer", "buttonizer_opening_settings", [
170 'type' => 'array',
171 'sanitize_callback' => function ($value) {
172 return is_array($value) ? $value : [];
173 }
174 ]);
175 register_setting("buttonizer", "buttonizer_page_categories", [
176 'type' => 'array',
177 'sanitize_callback' => function ($value) {
178 return is_array($value) ? $value : [];
179 }
180 ]);
181
182 // Buttonizer 2.0 setting groups
183 register_setting("buttonizer", "buttonizer_buttons", [
184 'type' => 'array',
185 'sanitize_callback' => function ($value) {
186 return is_array($value) ? $value : [];
187 }
188 ]);
189 register_setting("buttonizer", "buttonizer_buttons_published", [
190 'type' => 'array',
191 'sanitize_callback' => function ($value) {
192 return is_array($value) ? $value : [];
193 }
194 ]);
195 register_setting("buttonizer", "buttonizer_settings", [
196 'type' => 'array',
197 'sanitize_callback' => function ($value) {
198 return is_array($value) ? $value : [];
199 }
200 ]);
201 register_setting("buttonizer", "buttonizer_schedules", [
202 'type' => 'array',
203 'sanitize_callback' => function ($value) {
204 return is_array($value) ? $value : [];
205 }
206 ]);
207 register_setting("buttonizer", "buttonizer_rules", [
208 'type' => 'array',
209 'sanitize_callback' => function ($value) {
210 return is_array($value) ? $value : [];
211 }
212 ]);
213
214 // Load buttons
215 $this->backupButtons = get_option('buttonizer_buttons');
216 $this->backupSettings = get_option('buttonizer_general_settings');
217 $this->backupSchedule = get_option('buttonizer_opening_settings');
218 $this->backupRules = get_option('buttonizer_page_categories');
219
220 $this->initialized = true;
221 }
222
223 /**
224 * Woah! Something went wrong :'(
225 */
226 private function beforeCrashRevert()
227 {
228 // Check if anything got removed
229 if (!$this->initialized || !$this->removedAnything) return;
230
231 // Delete created options
232 delete_option('buttonizer_general_settings_backup');
233 delete_option("buttonizer_buttons_backup");
234 delete_option("buttonizer_opening_settings_backup");
235 delete_option("buttonizer_page_categories_backup");
236 delete_option("buttonizer_general_settings_backup");
237
238
239 // Make sure that the old values are still there
240 update_option('buttonizer_general_settings', $this->backupSettings);
241 update_option('buttonizer_buttons', $this->backupButtons);
242 update_option('buttonizer_opening_settings', $this->backupSchedule);
243 update_option('buttonizer_page_categories', $this->backupRules);
244 }
245
246 /**
247 * Convert
248 */
249 private function convertButtons()
250 {
251 // Make backup
252 update_option('buttonizer_buttons_backup', $this->backupButtons);
253
254 $buttons = [];
255
256 $defaultButtonColor = $this->get15GeneralSettings('button_unpushed', '#ba54ff');
257 $defaultButtonColorHover = $this->get15GeneralSettings('button_pushed', '#ba54ff');
258
259 foreach ($this->backupButtons['buttonorder'] as $buttonId) {
260 // Skip the placeholder button
261 if ($buttonId == -1) continue;
262 $hasStyleChanges = false;
263
264 // Get action type and action
265 $actionType = $this->get15buttonValue($buttonId, 'action', '');
266 $action = $this->get15buttonValue($buttonId, 'url', '');
267
268 // Make sure social sharing actions get migrated
269 if ($actionType == 'socialsharing') {
270 $action = $this->get15buttonValue($buttonId, 'social', 'facebook');
271 } else if ($actionType == 'javascript') {
272 $actionType = 'javascript_pro';
273 }
274
275 // Make sure label gets migrated correctly
276 $showLabel = ($this->get15buttonValue($buttonId, 'show_label_on_hover', 'always') === 'default' ? 'always' : $this->get15buttonValue($buttonId, 'show_label_on_hover', 'always'));
277
278 // Hover on desktop, show on mobile
279 if ($showLabel === 'showOnHover') {
280 $showLabelDesktop = 'hover';
281 $showLabelMobile = 'always';
282 }
283 // Hover on desktop, hide on mobile
284 else if ($showLabel === 'showOnHoverDesktop') {
285 $showLabelDesktop = 'hover';
286 $showLabelMobile = 'hide';
287 }
288 // Hide on desktop, show on mobile
289 else if ($showLabel === 'showOnHoverMobile') {
290 $showLabelDesktop = 'hide';
291 $showLabelMobile = 'always';
292 }
293 // Always show label
294 else {
295 $showLabelDesktop = 'always';
296 $showLabelMobile = 'always';
297 }
298
299 $button = [
300 // Name
301 "name" => $this->get15buttonValue($buttonId, 'title', 'Button ' . count($buttons)),
302 "icon" => 'fa ' . $this->get15buttonValue($buttonId, 'icon', 'fa-lightbulb'),
303
304 // When do we show this button?
305 "show_desktop" => $this->get15buttonValue($buttonId, 'show_on_desktop', 0) == 1 ? 'true' : 'false',
306 "show_mobile" => $this->get15buttonValue($buttonId, 'show_on_phone', 0) == 1 ? 'true' : 'false',
307
308 // Button actions
309 "type" => $actionType,
310 "action" => $action,
311 "action_new_tab" => $this->get15buttonValue($buttonId, 'url_newtab', 0) == 1 ? 'true' : 'false',
312
313 // Button label
314 "label" => $this->get15buttonValue($buttonId, 'text', 'Button label'),
315 "show_label_desktop" => $showLabelDesktop,
316 "show_label_mobile" => $showLabelMobile
317 ];
318
319 // Custom colors
320 if ($this->get15buttonValue($buttonId, 'using_custom_colors', 0) == 1) {
321 // Button background color
322 if ($this->get15buttonValue($buttonId, 'colors_button', '#ba54ff') !== '#ba54ff' && $this->get15buttonValue($buttonId, 'colors_button', '#ba54ff') !== $defaultButtonColor) {
323 $hasStyleChanges = true;
324 $button['background_color'] = $this->fixColor($this->get15buttonValue($buttonId, 'colors_button', '#ba54ff'));
325 }
326
327 // Button background hover color
328 if ($this->get15buttonValue($buttonId, 'colors_pushed', '#8d1acc') !== '#8d1acc' && $this->get15buttonValue($buttonId, 'colors_pushed', '#8d1acc') !== $defaultButtonColorHover) {
329 $hasStyleChanges = true;
330 $button['background_color_interaction'] = $this->fixColor($this->get15buttonValue($buttonId, 'colors_pushed', '#8d1acc'));
331 }
332
333 // Button icon color
334 if ($this->fixColor($this->get15buttonValue($buttonId, 'colors_icon', '#FFFFFF')) !== '#FFFFFF' && $this->get15buttonValue($buttonId, 'colors_icon', '#FFFFFF') != $this->get15GeneralSettings('icon_color', '#FFFFFF')) {
335 $hasStyleChanges = true;
336 $button['icon_color'] = $this->fixColor($this->get15buttonValue($buttonId, 'colors_icon', '#FFFFFF'));
337 $button['icon_color_interaction'] = $this->fixColor($this->get15buttonValue($buttonId, 'colors_icon', '#FFFFFF'));
338 }
339 }
340
341 // Does it have a background image?
342 if ($this->get15buttonValue($buttonId, 'image', '') !== '') {
343 if ($this->get15buttonValue($buttonId, 'image_background', 0) == 1) {
344 $button['background_image'] = $this->get15buttonValue($buttonId, 'image', '');
345
346 // Empty icon
347 $button['icon'] = '';
348
349 $hasStyleChanges = true;
350 } else {
351 // is icon!
352 $button['icon_is_image'] = 'true';
353 $button['icon_image'] = $this->get15buttonValue($buttonId, 'image', '');
354 }
355 }
356
357 // Did it have a custom class
358 if ($this->get15buttonValue($buttonId, 'custom_class', '') !== '') {
359 $button['custom_class'] = $this->get15buttonValue($buttonId, 'custom_class', '');
360 }
361
362 // Time schedule
363 if ($this->get15buttonValue($buttonId, 'show_when_opened', 0) !== 0) {
364 $button['selected_schedule'] = $this->timeScheduleId;
365 }
366
367 // Page rule
368 if ($this->get15buttonValue($buttonId, 'show_on_pages', -1) >= 0) {
369 $button['selected_page_rule'] = $this->get15buttonValue($buttonId, 'show_on_pages', '');
370 }
371
372 // Using main button style
373 $button['use_main_button_style'] = $hasStyleChanges ? 'false' : 'true';
374
375 // Add button
376 $buttons[] = $button;
377 }
378
379 $menuStyle = $this->get15GeneralSettings('buttons_animation', 'default');
380
381 // Update to new style name
382 if ($menuStyle === 'circle') {
383 $menuStyle = 'corner-circle';
384 } else if ($menuStyle === 'fade-left-to-right') {
385 $menuStyle = 'faded';
386 }
387
388 // Group label
389 $showGroupLabel = $this->get15GeneralSettings('buttons_label_show_on_hover', 'always');
390
391 // Hover on desktop, show on mobile
392 if ($showGroupLabel === 'showOnHover') {
393 $showGroupLabelDesktop = 'hover';
394 $showGroupLabelMobile = 'always';
395 }
396 // Hover on desktop, hide on mobile
397 else if ($showGroupLabel === 'showOnHoverDesktop') {
398 $showGroupLabelDesktop = 'hover';
399 $showGroupLabelMobile = 'hide';
400 }
401 // Hide on desktop, show on mobile
402 else if ($showGroupLabel === 'showOnHoverMobile') {
403 $showGroupLabelDesktop = 'hide';
404 $showGroupLabelMobile = 'always';
405 }
406 // Always show label
407 else {
408 $showGroupLabelDesktop = 'always';
409 $showGroupLabelMobile = 'always';
410 }
411
412 $groups = [];
413 $groups[] = [
414 'data' => [
415 'name' => 'Buttonizer',
416
417 // Show on mobile and desktop
418 'show_desktop' => 'true',
419 'show_mobile' => 'true',
420
421 // Icon
422 'icon_is_image' => 'false',
423 'icon' => 'fa ' . $this->get15GeneralSettings('icon_icon', 'fa-plus'),
424 'icon_color' => $this->fixColor($this->get15GeneralSettings('icon_color', '#ffffff')),
425 'icon_color_interaction' => $this->fixColor($this->get15GeneralSettings('icon_color', '#ffffff')),
426
427 // Button background
428 'background_color' => $defaultButtonColor,
429 'background_color_interaction' => $defaultButtonColorHover,
430
431 // Position
432 'horizontal' => $this->get15GeneralSettings('position_horizontal', 5),
433 'vertical' => $this->get15GeneralSettings('position_bottom', 5),
434 'position' => (($this->get15GeneralSettings('position_horizontal', 5) != 5 || $this->get15GeneralSettings('position_vertical', 5) != 5) ? 'advanced' : 'bottomright'),
435
436 // Menu style & animation
437 'menu_style' => $menuStyle,
438 'menu_animation' => $this->get15GeneralSettings('attention_animation', 'none'),
439
440 // Label
441 'label' => $this->get15GeneralSettings('icon_label', ''),
442 'label_color' => $this->get15GeneralSettings('label_text_color', ''),
443 'label_background_color' => $this->get15GeneralSettings('label_color', ''),
444
445 // Show label
446 'show_label_desktop' => $showGroupLabelDesktop,
447 'show_label_mobile' => $showGroupLabelMobile,
448
449 'advanced_scroll' => $this->get15GeneralSettings('procent_to_scroll', ''),
450 'advanced_timeout' => $this->get15GeneralSettings('time_to_timeout', ''),
451 'advanced_exit_intent' => $this->get15GeneralSettings('enable_exit_intent', '')
452 ],
453
454 'buttons' => $buttons
455 ];
456
457 // Save new buttons and publish them
458 update_option('buttonizer_buttons', $groups);
459 update_option('buttonizer_buttons_published', $groups);
460
461 // Make backup from general settings and delete
462 update_option('buttonizer_general_settings_backup', $this->backupSettings);
463 delete_option('buttonizer_general_settings');
464 $this->removedAnything = true;
465 }
466
467 private function fixColor($hex)
468 {
469 if (strtoupper($hex) === '#FFFFF') {
470 return '#FFFFFF';
471 }
472
473 return $hex;
474 }
475
476 /**
477 * Convert 'opening hours' to time schedules
478 */
479 private function convertTimeSchedules()
480 {
481 $days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
482
483 $newSchedule = [
484 'name' => 'First time schedule',
485 'id' => $this->timeScheduleId,
486 'weekdays' => [],
487 'custom' => [],
488 'dates' => [],
489 ];
490
491 // Loop through all days
492 foreach ($days as $day) {
493 $opened = isset($this->backupSchedule['buttonizer_' . $day . '_opened']) && $this->backupSchedule['buttonizer_' . $day . '_opened'] == '1' ? 'true' : 'false';
494 $openingFrom = isset($this->backupSchedule['buttonizer_' . $day . '_opened_from']) ? $this->backupSchedule['buttonizer_' . $day . '_opened_from'] : '10:00';
495 $closingOn = isset($this->backupSchedule['buttonizer_' . $day . '_closing_on']) ? $this->backupSchedule['buttonizer_' . $day . '_closing_on'] : '17:00';
496
497 $newSchedule['weekdays'][] = [
498 'opened' => $opened,
499 'open' => $openingFrom,
500 'close' => $closingOn,
501 'weekday' => $day
502 ];
503 }
504
505 // Save time schedule
506 update_option('buttonizer_schedules', [$newSchedule]);
507
508 // Make backup and delete old one
509 update_option('buttonizer_opening_settings_backup', $this->backupSchedule);
510 delete_option('buttonizer_opening_settings');
511 }
512
513 /**
514 * Convert page rules, not many changes though
515 */
516 private function convertPageRules()
517 {
518 $pageRules = [];
519
520 // Full page rule
521 foreach ($this->backupRules as $pageRule) {
522 $container = [
523 'id' => $pageRule['id'],
524 'name' => $pageRule['title'],
525 'filter_role' => $pageRule['filter_role'],
526 'type' => $pageRule['andor'],
527 'rules' => []
528 ];
529
530 $rules = [];
531 foreach ($pageRule['rules'] as $rule) {
532 $rules[] = [
533 'type' => $rule['type'],
534 'value' => $rule['value']
535 ];
536 }
537
538 $container['rules'] = $rules;
539
540
541 $pageRules[] = $container;
542 }
543
544 // Save page rule
545 update_option('buttonizer_rules', $pageRules);
546 update_option('buttonizer_rules_published', $pageRules);
547
548 // Make backup and delete old one
549 update_option('buttonizer_page_categories_backup', $this->backupRules);
550 delete_option('buttonizer_page_categories');
551 }
552
553 /**
554 * Let's get the old Buttonizer values
555 *
556 * @param $id
557 * @param $option
558 * @param string $default
559 * @return mixed|string
560 */
561 private function get15buttonValue($id, $option, $default = '')
562 {
563 $optionName = 'button_' . $id . '_' . $option;
564
565 // Option does not exists OR has no value
566 if (!isset($this->backupButtons[$optionName])) return $default;
567
568 return $this->backupButtons[$optionName];
569 }
570
571 /**
572 * Let's get the old Buttonizer values
573 *
574 * @param $option
575 * @param string $default
576 * @return mixed|string
577 */
578 private function get15GeneralSettings($option, $default = '')
579 {
580 // Option does not exists OR has no value
581 if (!isset($this->backupSettings[$option])) return $default;
582
583 return $this->backupSettings[$option];
584 }
585
586 /**
587 * Cleanup
588 * @param bool $newInstall
589 */
590 private function cleanup($newInstall = false)
591 {
592 $settings = [];
593
594 $settings['migration_version'] = BUTTONIZER_LAST_MIGRATION;
595 $settings['import_icon_library'] = true;
596
597 if ($newInstall === false) {
598 $settings['google_analytics'] = $this->get15GeneralSettings('google_analytics', '');
599 $settings['icon_library'] = 'fontawesome';
600 $settings['icon_library_version'] = '4.7.0';
601 } else {
602 $settings['google_analytics'] = '';
603 $settings['no_ajax'] = true;
604 $settings['icon_library'] = 'fontawesome';
605 $settings['icon_library_version'] = '5.free';
606 $settings['welcome'] = true;
607 }
608
609 update_option('buttonizer_settings', $settings);
610 }
611
612 /**
613 * Run update 2.0 to 2.1
614 */
615 public function update20to21()
616 {
617 $this->registerSettings();
618
619 $groups = $this->convertButtons20to21($this->backupButtons);
620 $settings = get_option('buttonizer_settings');
621
622 //backup 2.0.x settings
623 update_option('buttonizer_buttons_backup_20', $this->backupButtons);
624 update_option('buttonizer_buttons_published_20', get_option('buttonizer_buttons_published'));
625 update_option('buttonizer_has_changes_20', get_option('buttonizer_has_changes'));
626 update_option('buttonizer_rules_20', get_option('buttonizer_rules'));
627 update_option('buttonizer_rules_published_20', get_option('buttonizer_rules_published'));
628 update_option('buttonizer_schedules_20', get_option('buttonizer_schedules'));
629 update_option('buttonizer_schedules_published_20', get_option('buttonizer_schedules_published'));
630 update_option('buttonizer_settings_20', get_option('buttonizer_settings'));
631
632 // Set migration version to 2.1
633 $settings["migration_version"] = "2.1";
634 update_option('buttonizer_settings', $settings);
635
636 // Overwrite new settings
637 update_option('buttonizer_buttons', $groups);
638
639 // If buttonizer was already published, update published.
640 if (get_option('buttonizer_buttons_published')) {
641 $published = $this->convertButtons20to21(get_option('buttonizer_buttons_published'));
642 update_option('buttonizer_buttons_published', $published);
643 }
644
645 // If buttonizer has timeschedules, convert booleans.
646 if (get_option('buttonizer_schedules')) {
647 $schedules = $this->convertSchedules20to21(get_option('buttonizer_schedules'));
648 update_option('buttonizer_schedules', $schedules);
649 }
650
651 // If buttonizer has timeschedules published, convert booleans.
652 if (get_option('buttonizer_schedules_published')) {
653 $schedules_published = $this->convertSchedules20to21(get_option('buttonizer_schedules_published'));
654 update_option('buttonizer_schedules_published', $schedules_published);
655 }
656 }
657
658 /**
659 * Return converted 2.0 schedule settings to 2.1
660 */
661 private function convertSchedules20to21($array)
662 {
663 $schedules = [];
664
665 foreach ($array as $scheduleID) {
666 $scheduleID['end_date'] = date("d-m-Y", strtotime($scheduleID['end_date']));
667 $scheduleID['start_date'] = date("d-m-Y", strtotime($scheduleID['start_date']));
668
669 $weekdays = [];
670 foreach ($scheduleID["weekdays"] as $days) {
671 $days['opened'] = filter_var($days['opened'], FILTER_VALIDATE_BOOLEAN);
672
673 $weekdays[] = $days;
674 }
675
676 $dates = [];
677 foreach ($scheduleID["dates"] as $days) {
678 $days['opened'] = filter_var($days['opened'], FILTER_VALIDATE_BOOLEAN);
679 $days['date'] = date("d-m-Y", strtotime($days['date']));
680
681 $dates[] = $days;
682 }
683
684 $scheduleID['weekdays'] = $weekdays;
685 $scheduleID['dates'] = $dates;
686
687 $schedules[] = $scheduleID;
688 }
689
690 return $schedules;
691 }
692
693
694 /**
695 * Return converted 2.0 button settings to 2.1
696 */
697 private function convertButtons20to21($array)
698 {
699 $groups = [];
700
701 foreach ($array as $group) {
702 // // if it has a background image, set background_is_image to true
703 if (!empty($group["data"]["background_image"])) {
704 $group["data"]["background_is_image"] = true;
705 }
706 // If icon is image and image size is not set, max width
707 if (!empty($group["data"]["icon_image"]) && empty($group["data"]["icon_image_size"])) {
708 $group["data"]["icon_image_size"] = "100";
709 $group["data"]["icon_size"] = "100";
710 }
711
712 $buttons = [];
713
714 foreach ($group["buttons"] as $button) {
715 // // if it has a background image, set background_is_image to true
716 if (!empty($button["background_image"])) {
717 $button["background_is_image"] = true;
718 }
719 // If icon is image and image size is not set, max width
720 if (!empty($button["icon_image"]) && empty($button["icon_image_size"])) {
721 $button["icon_image_size"] = "100";
722 $button["icon_size"] = "100";
723 }
724 // change all true values to boolean true
725 foreach (array_keys($button, "true", true) as $keys) {
726 $button[$keys] = true;
727 }
728 // change all false values to boolean false
729 foreach (array_keys($button, "false", true) as $keys) {
730 $button[$keys] = false;
731 }
732
733 $buttons[] = $button;
734 }
735
736 // change all true values to boolean true
737 foreach (array_keys($group["data"], "true", true) as $keys) {
738 $group["data"][$keys] = true;
739 }
740 // change all false values to boolean false
741 foreach (array_keys($group["data"], "false", true) as $keys) {
742 $group["data"][$keys] = false;
743 }
744
745 // Since we change how enabling of Exit Intent works on 2.1. Disable if exit intent is disabled
746 if ($group["data"]["exit_intent"] === false) {
747 $group["data"]["exit_intent_trigger_leaving_window"] = false;
748 $group["data"]["exit_intent_trigger_inactive"] = false;
749 }
750
751 $group["buttons"] = $buttons;
752
753 $groups[] = $group;
754 }
755
756 return $groups;
757 }
758
759 /**
760 * Run update 2.1.6 to 2.1.7
761 */
762 public function update216to217()
763 {
764 $this->registerSettings();
765
766 $groups = $this->convertButtons21to22($this->backupButtons);
767
768 // If buttonizer was already published, update published.
769 if (get_option('buttonizer_buttons_published')) {
770 $published = $this->convertButtons21to22(get_option('buttonizer_buttons_published'));
771 update_option('buttonizer_buttons_published', $published);
772 }
773
774 // Get all current settings first
775 $settings = get_option('buttonizer_settings');
776 // Set migration version to 2.2
777 $settings["migration_version"] = "2.2";
778 update_option('buttonizer_settings', $settings);
779
780 // Overwrite new settings
781 update_option('buttonizer_buttons', $groups);
782 }
783
784 /**
785 * Convert buttons
786 */
787 private function convertButtons21to22($array)
788 {
789 $groups = [];
790
791 foreach ($array as $group) {
792 // Convert position parameters
793 if (!empty($group["data"]["vertical"])) {
794 if ($group["data"]["vertical"] <= 50) $group["data"]["vertical"] = "bottom:" . $group['data']['vertical'] . '%;';
795 if ($group["data"]["vertical"] > 50) $group["data"]["vertical"] = "top:" . (100 - $group['data']['vertical']) . '%;';
796 }
797 if (!empty($group["data"]["horizontal"])) {
798 if ($group["data"]["horizontal"] <= 50) $group["data"]["horizontal"] = "right:" . $group['data']['horizontal'] . '%;';
799 if ($group["data"]["horizontal"] > 50) $group["data"]["horizontal"] = "left:" . (100 - $group['data']['horizontal']) . '%;';
800 }
801
802 $groups[] = $group;
803 }
804
805 return $groups;
806 }
807
808 /**
809 * Run update 2.1.9 to 2.2.0
810 */
811 public function migration4()
812 {
813 $this->registerSettings();
814
815 $groups = $this->migration4UpdateData($this->backupButtons);
816
817 // If buttonizer was already published, update published.
818 if (get_option('buttonizer_buttons_published')) {
819 $published = $this->migration4UpdateData(get_option('buttonizer_buttons_published'));
820 update_option('buttonizer_buttons_published', $published);
821 }
822
823 // Get all current settings first
824 $settings = get_option('buttonizer_settings');
825
826 // Set migration version to 2.2, we're moving to numbers
827 $settings["migration_version"] = 4;
828 update_option('buttonizer_settings', $settings);
829
830 // Overwrite new settings
831 update_option('buttonizer_buttons', $groups);
832 }
833
834 /**
835 * Convert buttons
836 */
837 private function migration4UpdateData($array)
838 {
839 $groups = [];
840
841
842 // Loop through the groups
843 foreach ($array as $group) {
844 //---------------- MIGRATE GROUP ----------------//
845 $group['data'] = $this->migration4UpdateColors($group['data']);
846
847 $group['data']['close_on_click_outside'] = false;
848
849 // migrate fonts
850 if (isset($group['data']['label_font_family'])) {
851 $fonts = "";
852 // combine the fonts
853 foreach ($group['data']['label_font_family'] as $font) {
854 $fonts .= ($fonts !== "" ? "," : "") . $font['title'];
855 }
856
857 $group['data']['label_font_family'] = $fonts;
858 }
859
860 if (isset($group["data"]["horizontal"])) {
861 preg_match_all('/^(right|left):\s*(\d+)(%|px);$/x', $group["data"]["horizontal"], $matches, PREG_SET_ORDER, 0);
862
863 // If results in (bottom/top): (number)(%/px);
864 $group["data"]["horizontal"] = is_numeric($matches[0][2]) ? $group["data"]["horizontal"] : "right: 5%;";
865 }
866
867 if (isset($group["data"]["vertical"])) {
868 preg_match_all('/^(bottom|top):\s*(\d+)(%|px);$/x', $group["data"]["vertical"], $matches, PREG_SET_ORDER, 0);
869
870 // If results in (bottom/top): (number)(%/px);
871 $group["data"]["vertical"] = is_numeric($matches[0][2]) ? $group["data"]["vertical"] : "bottom: 5%;";
872 }
873
874 //---------------- MIGRATE BUTTON ----------------//
875 // Update parameters
876 foreach ($group['buttons'] as $buttonKey => $button) {
877 // Loop through the items
878 $group['buttons'][$buttonKey] = $this->migration4UpdateColors($group['buttons'][$buttonKey]);
879
880 // Migrate button data
881 $group['buttons'][$buttonKey] = $this->migrate4Button($group['buttons'][$buttonKey], $group);
882 }
883
884 // Change opening animation
885 switch (isset($group['data']['menu_style']) ? $group['data']['menu_style'] : 'default') {
886 // Corner circle
887 case "faded":
888 case "corner-circle":
889 case "building-up":
890 case "pop":
891 $group['data']['menu_opening_animation'] = $group['data']['menu_style'];
892
893 // They all use the default menu style
894 unset($group['data']['menu_style']);
895 break;
896
897 // Square
898 case "square":
899 $group['data']['is_menu'] = false;
900 $group['data']['show_label_desktop'] = 'hover';
901 $group['data']['show_label_mobile'] = 'hide';
902 foreach ($group['buttons'] as $buttonKey => $button) {
903 // unset all buttons' label visibility
904 unset($group['buttons'][$buttonKey]['show_label_desktop']);
905 unset($group['buttons'][$buttonKey]['show_label_mobile']);
906 }
907 break;
908
909 // Rectangle
910 case "rectangle":
911 $group['data']['is_menu'] = false;
912 $group['data']['show_label_desktop'] = 'always';
913 $group['data']['show_label_mobile'] = 'always';
914 foreach ($group['buttons'] as $buttonKey => $button) {
915 // unset all buttons' label visibility
916 unset($group['buttons'][$buttonKey]['show_label_desktop']);
917 unset($group['buttons'][$buttonKey]['show_label_mobile']);
918 }
919 break;
920
921 // Text buttons aren't a menu by default
922 case "text":
923 case "text-icon":
924 $group['data']['is_menu'] = false;
925
926 break;
927
928 default:
929 // We don't need menu_style by default
930 // it will fallback to the buttonizer default values
931 unset($group['data']['menu_style']);
932
933 break;
934 }
935 $groups[] = $group;
936 }
937
938 return $groups;
939 }
940
941 private function migration4UpdateColors($data)
942 {
943 $mergedData = [
944 // Background color
945 [
946 "background_color" => "#48A4DC",
947 "background_color_interaction" => "#F08419"
948 ],
949 // Icon color
950 [
951 "icon_color" => "#FFFFFF",
952 "icon_color_interaction" => "#FFFFFF"
953 ],
954 // Label text color
955 [
956 "label_color" => "#FFFFFF",
957 "label_color_interaction" => "#FFFFFF"
958 ],
959 // Label background color
960 [
961 "label_background_color" => "#333333",
962 "label_background_color_interaction" => "#333333"
963 ]
964 ];
965
966 // Loop through the items
967 foreach ($mergedData as $migrateGroup) {
968 $migrateData = "";
969
970 // Loop through the group defaults
971 foreach ($migrateGroup as $migrateGroupKey => $migrateGroupDefault) {
972 // Set if it DID change
973 if (isset($data[$migrateGroupKey]) && $data[$migrateGroupKey] != $migrateGroupDefault) {
974 $migrateData .= ($migrateData !== "" || strpos($migrateGroupKey, '_interaction') !== false ? ";" : '') . $data[$migrateGroupKey];
975 }
976 // Set if it DIDN'T change
977 if (!isset($data[$migrateGroupKey]) || isset($data[$migrateGroupKey]) && $data[$migrateGroupKey] == $migrateGroupDefault) {
978 $migrateData .= ($migrateData !== "" || strpos($migrateGroupKey, '_interaction') !== false ? ";" : '') . $data[$migrateGroupKey] = $migrateGroupDefault;
979 }
980
981 // Unset key if it exists
982 if (strpos($migrateData, ';') !== false) {
983 unset($data[$migrateGroupKey]);
984 }
985 }
986
987 // Remove data
988 if ($migrateData !== "") {
989 $data[key($migrateGroup)] = $migrateData;
990 } else if (isset($data[key($migrateGroup)])) {
991 unset($data[key($migrateGroup)]);
992 }
993 }
994
995 return $data;
996 }
997
998 private function migrate4Button($data, $group)
999 {
1000 // Remove data if it used the group styling
1001 if (!isset($data['use_main_button_style']) || (isset($data['use_main_button_style']) && $data['use_main_button_style'] == true)) {
1002 unset($data['background_color']);
1003 unset($data['background_is_image']);
1004 unset($data['border_radius']);
1005 unset($data['icon_color']);
1006 unset($data['label_color']);
1007 unset($data['label_background_color']);
1008 unset($data['label_font_size']);
1009 unset($data['label_font_family']);
1010 unset($data['label_border_radius']);
1011 unset($data['label_margin']);
1012 unset($data['label_padding']);
1013 }
1014
1015 // migrate fonts
1016 if (isset($data['label_font_family'])) {
1017 $fonts = "";
1018 // combine the fonts
1019 foreach ($data['label_font_family'] as $font) {
1020 $fonts .= ($fonts !== "" ? "," : "") . $font['title'];
1021 }
1022
1023 $data['label_font_family'] = $fonts;
1024 }
1025
1026 // Since 2.2 now uses 42px buttons instead of transforming a 56px button into a 40px, sizes are a bit different.
1027 if (!in_array($group['data']['menu_style'], ["square", "rectangle"], true)) {
1028 if (isset($data['icon_size']) && is_numeric($data['icon_size'])) {
1029 $data['icon_size'] = round((int)$data['icon_size'] / 56 * 42);
1030 }
1031
1032 if (isset($data['icon_image_size']) && is_numeric($data['icon_image_size'])) {
1033 $data['icon_image_size'] = round((int)$data['icon_image_size'] / 56 * 42);
1034 }
1035
1036 if (isset($data['border_radius'])) {
1037 preg_match_all('/(\d+)(px|%)/', $data['border_radius'], $sides, PREG_SET_ORDER, 0);
1038 $newBorderRadius = '';
1039 foreach ($sides as $side) {
1040 $newBorderRadius .= ($newBorderRadius === '' ? "" : " ") . round($side[1] / 56 * 42) . $side[2];
1041 }
1042
1043 $data['border_radius'] = $newBorderRadius;
1044 } else if (isset($group['data']['border_radius']) && (!isset($data['use_main_button_style']) || (isset($data['use_main_button_style']) && $data['use_main_button_style'] == true))) {
1045 preg_match_all('/(\d+)(px|%)/', $group['data']['border_radius'], $sides, PREG_SET_ORDER, 0);
1046 $newBorderRadius = '';
1047 foreach ($sides as $side) {
1048 $newBorderRadius .= ($newBorderRadius === '' ? "" : " ") . round($side[1] / 56 * 42) . $side[2];
1049 }
1050
1051 $data['border_radius'] = $newBorderRadius;
1052 };
1053 }
1054
1055 // Set label to always show if not set
1056 if (!isset($data['show_label_desktop'])) $data['show_label_desktop'] = "always";
1057 if (!isset($data['show_label_mobile'])) $data['show_label_mobile'] = "always";
1058
1059 // Add old default values if it isn't using group styling AND it wasn't set
1060 if (isset($data['use_main_button_style']) && $data['use_main_button_style'] == false) {
1061 if (!isset($data['background_is_image'])) $data['background_is_image'] = false;
1062 if (!isset($data['border_radius'])) $data['border_radius'] = "50% 50% 50% 50%";
1063 if (!isset($data['icon_image_border_radius'])) $data['icon_image_border_radius'] = 0;
1064 if (!isset($data['label_font_size'])) $data['label_font_size'] = "12";
1065 if (!isset($data['label_border_radius'])) $data['label_border_radius'] = "3px 3px 3px 3px";
1066 if (!isset($data['label_margin'])) $data['label_margin'] = "0px 0px 0px 0px";
1067 if (!isset($data['label_padding'])) $data['label_padding'] = "5px 15px 5px 15px";
1068 }
1069
1070 unset($data['use_main_button_style']);
1071
1072 return $data;
1073 }
1074
1075 /**
1076 * Run update 2.5.3 to 2.5.4
1077 */
1078 public function migration5()
1079 {
1080 $this->registerSettings();
1081
1082 $groups = $this->migration5UpdateData($this->backupButtons);
1083
1084 // var_dump($groups);
1085
1086 // If buttonizer was already published, update published.
1087 if (get_option('buttonizer_buttons_published')) {
1088 $published = $this->migration5UpdateData(get_option('buttonizer_buttons_published'));
1089 update_option('buttonizer_buttons_published', $published);
1090 }
1091
1092 // Get all current settings first
1093 $settings = get_option('buttonizer_settings');
1094
1095 // Set migration version to 5
1096 $settings["migration_version"] = 5;
1097 update_option('buttonizer_settings', $settings);
1098
1099 // Overwrite new settings
1100 update_option('buttonizer_buttons', $groups);
1101 }
1102
1103
1104 /**
1105 * Convert buttons
1106 */
1107 public function migration5UpdateData($array)
1108 {
1109 $groups = [];
1110
1111 // Loop through the groups
1112 foreach ($array as $group) {
1113 //---------------- MIGRATE GROUP ----------------//
1114 // Remove data from certain meu styles
1115 switch (isset($group['data']['menu_style']) ? $group['data']['menu_style'] : 'default') {
1116 case "rectangle":
1117 case "square":
1118 unset($group['data']['border_radius']);
1119 unset($group['data']['label_margin']);
1120 unset($group['data']['label_padding']);
1121 unset($group['data']['label_border_radius']);
1122 foreach ($group['buttons'] as $buttonKey => $button) {
1123 unset($group['buttons'][$buttonKey]['label_margin']);
1124 unset($group['buttons'][$buttonKey]['label_padding']);
1125 unset($group['buttons'][$buttonKey]['label_border_radius']);
1126 }
1127 break;
1128 case "text":
1129 unset($group['data']['label_background_color']);
1130 unset($group['data']['label_border_radius']);
1131 unset($group['data']['label_margin']);
1132 unset($group['data']['label_padding']);
1133 unset($group['data']['icon_is_image']);
1134 foreach ($group['buttons'] as $buttonKey => $button) {
1135 unset($group['buttons'][$buttonKey]['label_background_color']);
1136 unset($group['buttons'][$buttonKey]['label_border_radius']);
1137 unset($group['buttons'][$buttonKey]['label_margin']);
1138 unset($group['buttons'][$buttonKey]['label_padding']);
1139 unset($group['buttons'][$buttonKey]['icon_is_image']);
1140 }
1141 break;
1142 case "text-icon":
1143 unset($group['data']['label_background_color']);
1144 unset($group['data']['label_border_radius']);
1145 unset($group['data']['label_margin']);
1146 unset($group['data']['label_padding']);
1147 foreach ($group['buttons'] as $buttonKey => $button) {
1148 unset($group['buttons'][$buttonKey]['label_background_color']);
1149 unset($group['buttons'][$buttonKey]['label_border_radius']);
1150 unset($group['buttons'][$buttonKey]['label_margin']);
1151 unset($group['buttons'][$buttonKey]['label_padding']);
1152 }
1153 break;
1154 }
1155
1156 // Replace icon_is_image with icon_type
1157 if (isset($group['data']['icon_is_image'])) {
1158 $group['data']['icon_type'] = $group['data']['icon_is_image'] === true ? "image" : "icon";
1159 unset($group['data']['icon_is_image']);
1160 }
1161 foreach ($group['buttons'] as $buttonKey => $button) {
1162 if (isset($group['buttons'][$buttonKey]['icon_is_image'])) {
1163 $group['buttons'][$buttonKey]['icon_type'] = $group['buttons'][$buttonKey]['icon_is_image'] === true ? "image" : "icon";
1164 unset($group['buttons'][$buttonKey]['icon_is_image']);
1165 }
1166 }
1167
1168 $groups[] = $group;
1169 }
1170
1171 return $groups;
1172 }
1173
1174 /**
1175 * Run update 2.6.2
1176 */
1177 public function migration6()
1178 {
1179 // $this->registerSettings();
1180
1181
1182 // Back it up
1183 update_option('buttonizer_rules_backup_6', get_option('buttonizer_rules'));
1184
1185 $rules = $this->migration6UpdateData(get_option('buttonizer_rules'));
1186
1187 // If buttonizer was already published, update published.
1188 if (get_option('buttonizer_rules_published')) {
1189 // Back it up
1190 update_option('buttonizer_rules_published_backup_6', get_option('buttonizer_rules_published'));
1191
1192 $published = $this->migration6UpdateData(get_option('buttonizer_rules_published'));
1193 update_option('buttonizer_rules_published', $published);
1194 }
1195
1196 // Get all current settings first
1197 $settings = get_option('buttonizer_settings');
1198
1199 // Set migration version to 6
1200 $settings["migration_version"] = 6;
1201 update_option('buttonizer_settings', $settings);
1202
1203 // Overwrite new settings
1204 update_option('buttonizer_rules', $rules);
1205 }
1206
1207 /**
1208 * Convert rules
1209 */
1210 public function migration6UpdateData($array)
1211 {
1212 $rules = [];
1213
1214 // Loop through the groups
1215 foreach ($array as $rule) {
1216 $conditions = [];
1217
1218 if (isset($rule["rules"])) {
1219 foreach ($rule["rules"] as $condition) {
1220 switch ($condition["type"]) {
1221 case "page_title":
1222 case "blog_title":
1223 $condition["operator"] = "contains";
1224 break;
1225 case "url_match":
1226 $condition["type"] = "path";
1227 $condition["operator"] = "match";
1228 break;
1229 case "url_match_exact":
1230 $condition["type"] = "path_query";
1231 $condition["operator"] = "match";
1232 break;
1233 case "url_contains":
1234 $condition["type"] = "url";
1235 $condition["operator"] = "contains";
1236 break;
1237 case "url_starts":
1238 $condition["type"] = "path";
1239 $condition["operator"] = "begins_with";
1240 $condition["value"] = (substr($condition['value'], 0, 1) !== '/' ? '/' : '') . $condition["value"];
1241 break;
1242 case "url_ends":
1243 $condition["type"] = "path";
1244 $condition["operator"] = "ends_with";
1245 $condition["value"] = $condition["value"] . (substr($condition["value"], -1) !== '/' ? '/' : '');
1246 break;
1247 case "url_regex":
1248 $condition["type"] = "url";
1249 $condition["operator"] = "match_regex";
1250 break;
1251 case "page":
1252 case "blog":
1253 case "category":
1254 case "user_roles":
1255 // Add array operator to array types
1256 $condition["operator"] = "is_any";
1257 break;
1258 }
1259
1260 $conditions[] = $condition;
1261 }
1262 }
1263
1264 // Add the type to condition group and conditions
1265 $rule["groups"][0]["rules"] = $conditions;
1266 $rule["groups"][0]["type"] = $rule["type"];
1267
1268 // Replace rule type with default "AND" and remove rules
1269 $rule["type"] = "and";
1270 unset($rule["rules"]);
1271
1272 $rules[] = $rule;
1273 }
1274
1275 return $rules;
1276 }
1277
1278 /**
1279 * Run update menu button
1280 */
1281 public function migrationTo7()
1282 {
1283 // Get all current settings first
1284 $settings = get_option('buttonizer_settings');
1285
1286 // Set migration version to 7
1287 $settings["migration_version"] = 7;
1288 update_option('buttonizer_settings', $settings);
1289
1290 // Back it up
1291 $groups = $this->migrationTo7UpdateData(get_option('buttonizer_buttons'));
1292
1293 // Overwrite new settings
1294 update_option('buttonizer_buttons', $groups);
1295
1296 // If buttonizer was already published, update published.
1297 if (get_option('buttonizer_buttons_published')) {
1298 $published = $this->migrationTo7UpdateData(get_option('buttonizer_buttons_published'));
1299 update_option('buttonizer_buttons_published', $published);
1300 }
1301 }
1302
1303 /**
1304 * Move settings to menu button
1305 */
1306 public function migrationTo7UpdateData($array)
1307 {
1308 $groups = [];
1309
1310 // Loop through the groups
1311 foreach ($array as $group) {
1312 //---------------- MIGRATE GROUP ----------------//
1313 // Move all icon stuffs to menu button
1314 if (isset($group['data']['icon'])) {
1315 $group['menu_button']['icon'] = $group['data']['icon'];
1316 unset($group['data']['icon']);
1317 }
1318 if (isset($group['data']['icon_type'])) {
1319 $group['menu_button']['icon_type'] = $group['data']['icon_type'];
1320 unset($group['data']['icon_type']);
1321 }
1322 if (isset($group['data']['icon_image'])) {
1323 $group['menu_button']['icon_image'] = $group['data']['icon_image'];
1324 unset($group['data']['icon_image']);
1325 }
1326 if (isset($group['data']['icon_size'])) {
1327 $group['menu_button']['icon_size'] = $group['data']['icon_size'];
1328 unset($group['data']['icon_size']);
1329 }
1330 if (isset($group['data']['icon_image_size'])) {
1331 $group['menu_button']['icon_image_size'] = $group['data']['icon_image_size'];
1332 unset($group['data']['icon_image_size']);
1333 }
1334
1335 // If is menu is disabled, don't show menu button
1336 if (isset($group['data']['is_menu']) && $group['data']['is_menu'] === false) {
1337 $group['menu_button']['show_mobile'] = false;
1338 $group['menu_button']['show_desktop'] = false;
1339 unset($group['data']['is_menu']);
1340 }
1341
1342 if (isset($group['data']['label'])) {
1343 $group['menu_button']['label'] = $group['data']['label'];
1344 unset($group['data']['label']);
1345 }
1346
1347 // Move all menu stuffs to menu button
1348 if (isset($group['data']['menu_opening_animation'])) {
1349 $group['menu_button']['menu_opening_animation'] = $group['data']['menu_opening_animation'];
1350 unset($group['data']['menu_opening_animation']);
1351 }
1352 if (isset($group['data']['start_opened'])) {
1353 $group['menu_button']['start_opened'] = $group['data']['start_opened'];
1354 unset($group['data']['start_opened']);
1355 }
1356 if (isset($group['data']['close_on_click_outside'])) {
1357 $group['menu_button']['close_on_click_outside'] = $group['data']['close_on_click_outside'];
1358 unset($group['data']['close_on_click_outside']);
1359 }
1360 if (isset($group['data']['close_on_click_inside'])) {
1361 $group['menu_button']['close_on_click_inside'] = $group['data']['close_on_click_inside'];
1362 unset($group['data']['close_on_click_inside']);
1363 }
1364 if (isset($group['data']['open_on_mouseover'])) {
1365 $group['menu_button']['open_on_mouseover'] = $group['data']['open_on_mouseover'];
1366 unset($group['data']['open_on_mouseover']);
1367 }
1368 if (isset($group['data']['close_on_mouseleave'])) {
1369 $group['menu_button']['close_on_mouseleave'] = $group['data']['close_on_mouseleave'];
1370 unset($group['data']['close_on_mouseleave']);
1371 }
1372
1373
1374 $groups[] = $group;
1375 }
1376
1377 return $groups;
1378 }
1379 }
1380