PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / 4.0.2
Bubble Menu – Floating Button Menu with Sticky Navigation v4.0.2
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / classes / Update / ParamUpdater.php

ParamUpdater.php in Bubble Menu – Floating Button Menu with Sticky Navigation 4.0.2, at classes/Update/ParamUpdater.php

321 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BubbleMenu\Update;
4
5 class ParamUpdater {
6 private $param;
7
8 public function __construct( $param ) {
9 $this->param = $param;
10 }
11
12 public function update() {
13 $this->update_main_settings();
14 $this->update_items_settings();
15 $this->update_rules_settings();
16
17 return $this->param;
18 }
19
20 private function update_main_settings(): void {
21 $this->param['open_menu'] = $this->param['hold_open'] ?? '';
22
23 $this->param += [
24 'label' => '',
25 'label_on' => 0,
26 'open' => 0,
27 'margin_block' => 0,
28 'margin_inline' => 0,
29 'open_menu' => 0,
30 'hide_menus' => 0,
31 'close_menus' => 0,
32 'action' => '',
33 ];
34
35 // Update Position
36 $position = $this->param['menu'] ?? '-left';
37
38 $this->param['position'] = str_replace( [
39 'wow-bmp-pos-t',
40 'wow-bmp-pos-r',
41 'wow-bmp-pos-b',
42 'wow-bmp-pos-l',
43 'wow-bmp-pos-tl',
44 'wow-bmp-pos-tr',
45 'wow-bmp-pos-br',
46 'wow-bmp-pos-bl'
47 ], [
48 '-top',
49 '-right',
50 '-bottom',
51 '-left',
52 '-top-left',
53 '-top-right',
54 '-bottom-right',
55 '-bottom-left'
56 ], $position );
57
58
59 //Update Shapes
60 $shapes = empty( $this->param['shapes'] ) ? '-circle' : $this->param['shapes'];
61
62 // Update position
63 $this->param['shapes'] = str_replace( [
64 'wow-bmp-shape-rsquare',
65 'wow-bmp-shape-ellipse',
66 'wow-bmp-shape-square'
67 ], [
68 '-rounded',
69 '-ellipse',
70 '-square'
71 ], $shapes );
72
73 $animation = ! empty( $this->param['animation'] ) ? $this->param['animation'] : '-effect-obo';
74 if ( strpos( $animation, 'wow-bmp-effect-aao' ) === false ) {
75 $animation .= ' -effect-obo';
76 }
77
78 $animation = str_replace( [ 'wow-bmp', 'wow-bmp-effect-aao' ], [ '', '' ], $animation );
79
80 $this->param['animation'] = $animation;
81
82 // Update Main Icon
83 $this->param += [
84 'icon_type' => 'icon',
85 'icon_rotate' => 0,
86 'icon_flip' => '',
87 'icon_animation' => '',
88 'image' => '',
89 'image_alt' => '',
90 'icon_class' => '',
91 'emoji' => '',
92 ];
93
94 $this->param['icon'] = $this->param['menu_icon'] ?? 'fas fa-wand-magic-sparkles';
95
96 if ( ! empty( $this->param['main_icon_custom'] ) ) {
97 $this->param['icon_type'] = 'image';
98 $this->param['image'] = $this->param['main_item_custom_link'];
99 $this->param['image_alt'] = $this->param['main_image_alt'];
100 }
101
102 // Update Style
103 $color_search = [
104 'white',
105 'grey',
106 'black',
107 'red',
108 'orange',
109 'yellow',
110 'lime',
111 'green',
112 'cyan',
113 'blue',
114 'purple',
115 'pink',
116 ];
117
118 $color_replace = [
119 '#ffffff',
120 '#808080',
121 '#000000',
122 '#e3001b',
123 '#ff6600',
124 '#ffcc01',
125 '#b1c903',
126 '#27a22d',
127 '#00b1e5',
128 '#006bb3',
129 '#ad007c',
130 '#ea4c89'
131 ];
132
133 $color = $this->param['color'] ?? '#14102C';
134 $background = $this->param['hcolor'] ?? '#ffffff';
135
136 $this->param['color'] = str_replace( $color_search, $color_replace, $color );
137 $this->param['background_color'] = str_replace( $color_search, $color_replace, $background );
138
139 $this->param += [
140 'size' => '-size-md',
141 'shadow' => '',
142 'label_position' => '',
143 'label_color' => '#ffffff',
144 'label_background_color' => '#14102C',
145 'attribute_rel' => '',
146 ];
147
148 // Attributes
149 $this->param['attribute_id'] = $this->param['main_id'] ?? '';
150 $this->param['attribute_class'] = $this->param['main_class'] ?? '';
151 }
152
153 private function update_items_settings(): void {
154 if ( empty( $this->param['item_type'] ) || ! is_array( $this->param['item_type'] ) ) {
155 return;
156 }
157
158 $count = count( $this->param['item_type'] );
159 for ( $i = 0; $i < $count; $i ++ ) {
160 $this->update_item_settings( $i );
161 }
162 }
163
164 private function update_item_settings( $i ): void {
165 $this->param['item']['label'][ $i ] = $this->param['item_tooltip'][ $i ] ?? '';
166 $this->param['item']['label_on'][ $i ] = $this->param['item_tooltip_include'][ $i ] ?? '';
167 $this->param['item']['open'][ $i ] = ( isset( $this->param['item_tooltip_show'][ $i ] ) && $this->param['item_tooltip_show'][ $i ] === '2' ) ? 1 : 0;
168
169 // Item type
170 $this->param['item']['type'][ $i ] = $this->param['item_type'][ $i ] ?? 'link';
171 $this->param['item']['link'][ $i ] = $this->param['item_link'][ $i ] ?? '';
172 $this->param['item']['link_tab'][ $i ] = ( isset( $this->param['open_link'][ $i ] ) && $this->param['open_link'][ $i ] === '_blank' ) ? 1 : 0;
173 $this->param['item']['share'][ $i ] = ! empty( $this->param['item_share'][ $i ] ) ? mb_strtolower( $this->param['item_share'][ $i ] ) : 'blogger';
174 $this->param['item']['translate'][ $i ] = $this->param['gtranslate'][ $i ] ?? 'en';
175
176 // Icon
177 $this->param['item']['icon_type'][ $i ] = 'icon';
178 $this->param['item']['icon'][ $i ] = $this->param['item_icon'][ $i ] ?? '';
179
180 $this->param['item']['image'][ $i ] = '';
181 $this->param['item']['image_alt'][ $i ] = '';
182
183 if ( ! empty( $this->param['icon_custom'][ $i ] ) ) {
184 $this->param['item']['icon_type'][ $i ] = 'image';
185 $this->param['item']['image'][ $i ] = $this->param['item_custom_link'][ $i ] ?? '';
186 $this->param['item']['image_alt'][ $i ] = $this->param['image_alt'][ $i ] ?? '';
187 }
188
189 $this->param['item']['icon_class'][ $i ] = '';
190 $this->param['item']['emoji'][ $i ] = '';
191 $this->param['item']['icon_rotate'][ $i ] = 0;
192 $this->param['item']['icon_flip'][ $i ] = '';
193 $this->param['item']['icon_animation'][ $i ] = '';
194
195 // Style
196 $color_search = [
197 'white',
198 'grey',
199 'black',
200 'red',
201 'orange',
202 'yellow',
203 'lime',
204 'green',
205 'cyan',
206 'blue',
207 'purple',
208 'pink',
209 ];
210
211 $color_replace = [
212 '#ffffff',
213 '#808080',
214 '#000000',
215 '#e3001b',
216 '#ff6600',
217 '#ffcc01',
218 '#b1c903',
219 '#27a22d',
220 '#00b1e5',
221 '#006bb3',
222 '#ad007c',
223 '#ea4c89'
224 ];
225
226 $color = $this->param['item_color'][ $i ] ?? '#14102C';
227 $background = $this->param['item_hcolor'][ $i ] ?? '#ffffff';
228
229 $this->param['item']['color'][ $i ] = str_replace( $color_search, $color_replace, $color );
230 $this->param['item']['background_color'][ $i ] = str_replace( $color_search, $color_replace, $background );
231
232 $this->param['item']['label_position'][ $i ] = '';
233 $this->param['item']['label_color'][ $i ] = '#ffffff';
234 $this->param['item']['label_background_color'][ $i ] = '#14102C';
235
236 // Attributes
237 $this->param['item']['attribute_id'][ $i ] = $this->param['button_id'][ $i ] ?? '';
238 $this->param['item']['attribute_class'][ $i ] = $this->param['button_class'][ $i ] ?? '';
239 $this->param['item']['attribute_rel'][ $i ] = $this->param['link_rel'][ $i ] ?? '';
240
241 }
242
243 private function update_rules_settings(): void {
244 // Devices
245 $this->param['desktop_on'] = $this->param['include_more_screen'] ?? '';
246 $this->param['desktop'] = $this->param['screen_more'] ?? '';
247 $this->param['mobile_on'] = $this->param['include_mobile'] ?? '';
248 $this->param['mobile'] = $this->param['screen'] ?? '';
249
250
251 $this->param['fontawesome'] = ! empty( $this->param['disable_fontawesome'] ) ? 1 : 0;
252
253
254 $show_old = ! empty( $this->param['show'] ) ? $this->param['show'] : 'everywhere';
255
256 $this->param['show'] = [];
257 $this->param['operator'] = [];
258 $this->param['page_type'] = [];
259 $this->param['ids'] = [];
260
261 $this->param['show'][0] = 'shortcode';
262 $this->param['operator'][0] = '1';
263 $this->param['page_type'][0] = 'is_front_page';
264 $this->param['ids'][0] = ! empty( $this->param['id_post'] ) ? $this->param['id_post'] : '';
265
266 switch ( $show_old ) {
267 case 'all':
268 $this->param['show'][0] = 'everywhere';
269 break;
270 case 'onlypost':
271 $this->param['show'][0] = 'post_all';
272 break;
273 case 'posts':
274 $this->param['show'][0] = 'post_selected';
275 break;
276 case 'postsincat':
277 $this->param['show'][0] = 'post_category';
278 break;
279 case 'expost':
280 $this->param['show'][0] = 'post_selected';
281 $this->param['operator'][0] = 0;
282 break;
283 case 'onlypage':
284 $this->param['show'][0] = 'page_all';
285 break;
286 case 'pages':
287 $this->param['show'][0] = 'page_selected';
288 break;
289 case 'expage':
290 $this->param['show'][0] = 'page_selected';
291 $this->param['operator'][0] = 0;
292 break;
293 case 'homepage':
294 $this->param['show'][0] = 'page_type';
295 $this->param['page_type'][0] = 'is_front_page';
296 break;
297 case 'searchpage':
298 $this->param['show'][0] = 'page_type';
299 $this->param['page_type'][0] = 'is_search';
300 break;
301 case 'archivepage':
302 $this->param['show'][0] = 'page_type';
303 $this->param['page_type'][0] = 'is_archive';
304 break;
305 case 'error_page':
306 $this->param['show'][0] = 'page_type';
307 $this->param['page_type'][0] = 'is_404';
308 break;
309 case 'post_type':
310 $custom_post = $this->param['post_types'] ?? '';
311 $this->param['show'][0] = 'custom_post_all_' . $custom_post;
312 break;
313 case 'taxonomy':
314 $taxonomy = $this->param['taxonomy'] ?? '';
315 $this->param['show'][0] = 'custom_post_tax_|' . $taxonomy;
316 break;
317 }
318
319
320 }
321 }