PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5.1
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5.1
3.6.0 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 All 110 releases
buttonizer-multifunctional-button / classes / Utils / Maintain.php

Maintain.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.5.1, at classes/Utils/Maintain.php

177 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; either version 2
6 of the License, or (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 Copyright 2017 Buttonizer
18 */
19 namespace Buttonizer\Utils;
20
21 # No script kiddies
22 defined( 'ABSPATH' ) or die('No script kiddies please!');
23
24 class Maintain {
25
26 // Construct
27 public function __construct($sReady = false) {
28 if(!$sReady) return;
29
30 if (!session_id())
31 session_start();
32
33 register_activation_hook('buttonizer', array(&$this, 'pluginActivate'));
34 register_deactivation_hook('buttonizer', array(&$this, 'pluginDeactivate'));
35
36 add_action('upgrader_process_complete', array(&$this, 'pluginUpdated'), 10, 2);
37 }
38
39 /**
40 * Activate Buttonizer, AWESOMAAH!
41 */
42 public function pluginActivate() {
43 // Check updated data
44 $this->pluginUpdated();
45
46 /*
47 * General settings
48 */
49 $aGeneralSettings = get_option('buttonizer_general_settings');
50
51 // Check stored old data
52 if($aGeneralSettings == ''){
53 $aGeneralSettings = array(
54 'button_unpushed' => '#48A4DC',
55 'button_pushed' => '#1D9BDB',
56 'icon_color' => '#FFFFFF',
57 'icon_icon' => 'fa-plus',
58 'position_right' => '5',
59 'position_bottom' => '5',
60 'google_analytics' => ''
61 );
62
63 // Update and save general Utils settings
64 update_option('buttonizer_general_settings', $aGeneralSettings);
65 }
66
67 /*
68 * Add Utils buttons
69 */
70 $aButtonizerDefaultButtons = get_option('buttonizer_buttons');
71
72 // Check stored old data
73 if($aButtonizerDefaultButtons == ''){
74 $aButtonizerDefaultButtons = [];
75
76 // Update and save general Utils settings
77 update_option('buttonizer_buttons', $aButtonizerDefaultButtons);
78 }
79
80 /*
81 * Opening settings
82 */
83 $aDefaultOpeningSettings = get_option('buttonizer_opening_settings');
84
85 // Do we have old opening data?
86 if($aDefaultOpeningSettings == '') {
87 $aDefaultOpeningSettings =
88 array(
89 // Monday
90 'monday_opened_from' => '10:00',
91 'monday_closing_on' => '17:00',
92 'monday_opened' => false,
93
94 // Tuesday
95 'tuesday_opened_from' => '10:00',
96 'tuesday_closing_on' => '17:00',
97 'tuesday_opened' => false,
98
99 // Wednesday
100 'wednesday_opened_from' => '10:00',
101 'wednesday_closing_on' => '17:00',
102 'wednesday_opened' => false,
103
104 // Thursday
105 'thursday_opened_from' => '10:00',
106 'thursday_closing_on' => '17:00',
107 'thursday_opened' => false,
108
109 // Friday
110 'friday_opened_from' => '10:00',
111 'friday_closing_on' => '17:00',
112 'friday_opened' => false,
113
114 // Saturday
115 'saturday_opened_from' => '10:00',
116 'saturday_closing_on' => '17:00',
117 'saturday_opened' => true,
118
119 // Sunday
120 'sunday_opened_from' => '10:00',
121 'sunday_closing_on' => '17:00',
122 'sunday_opened' => true,
123 );
124
125 // Update and save Utils opening settings
126 update_option('buttonizer_opening_settings', $aDefaultOpeningSettings);
127 }
128 }
129
130 /**
131 * Deactivate plugin, SEE YOU SOON!
132 */
133 public function pluginDeactivate(){
134 // Nothing to handle right now. Maybe later
135 }
136
137 /**
138 * Updated?
139 */
140 public function pluginUpdated()
141 {
142 $pageCategories = get_option('buttonizer_page_categories');
143
144 // Old version of the page categories, we need to renew it...
145 if(isset($pageCategories['categorieOrder']))
146 {
147 // Empty all categories, sorry for this :'(
148 update_option('buttonizer_page_categories', []);
149 }
150 }
151
152 /*
153 * Mobile or desktop check
154 */
155 public function isMobile() {
156 if (
157 isset($_SERVER['HTTP_USER_AGENT']) &&
158 (
159 strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false ||
160 strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false ||
161 strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false ||
162 strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false ||
163 strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false ||
164 strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ||
165 strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false
166 )
167 )
168 {
169 // Is mobile
170 return true;
171 } else {
172 // Is desktop
173 return false;
174 }
175 }
176 }
177