PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.8
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.8
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / FB / Meta.php

Meta.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.8, at Inc/Core/FB/Meta.php

401 lines 12.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.8 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\FB;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Meta
20 {
21 private $is_running = false;
22
23 public function __construct()
24 {
25 add_filter('get_post_metadata', [$this, 'get_legacy_meta'], 10, 4);
26
27 $this->register();
28 }
29
30 public function get_legacy_meta($value, $post_id, $meta_key, $single)
31 {
32 if ($this->is_running || $meta_key !== 'firebox_meta')
33 {
34 return $value;
35 }
36
37 $this->is_running = true;
38
39 // Get new format meta
40 $new_meta = get_post_meta($post_id, 'firebox_meta', true) ?: [];
41
42 // If we have new meta data, return it
43 if (is_array($new_meta) && count($new_meta))
44 {
45 $this->is_running = false;
46 return $value;
47 }
48
49 $defaults = $this->getDefaults();
50
51 // Get legacy meta
52 $legacy_meta = get_post_meta($post_id, 'fpframework_meta_settings', true);
53
54 // Merge legacy values if not already in new format
55 if (!empty($legacy_meta))
56 {
57 $map = [
58 // Campaign Format
59 'mode' => [],
60
61 // Trigger
62 'triggermethod' => [
63 'transform' => 'triggermethod_migration'
64 ],
65 'triggerelement' => [],
66 'close_out_viewport' => [],
67 'threshold' => [],
68 'exittimer' => [],
69 'idle_time' => [],
70 'triggerdelay' => [],
71 'scroll_depth' => [
72 'rename' => 'scroll_amount',
73 'transform' => 'scroll_depth_migration'
74 ],
75 'autohide' => [],
76 'firing_frequency' => [
77 'transform' => 'firing_frequency_toggle_migration'
78 ],
79 'floating_button_show_on_close' => [],
80 'floatingbutton_message' => [
81 'transform' => 'floatingbutton_message_migration'
82 ],
83 'floating_button_position' => [],
84 'assign_impressions_param_type' => [],
85 'assign_impressions_param_custom_period_times' => [],
86 'assign_impressions_param_custom_period' => [],
87 'opening_sound' => [],
88 'assign_cookietype' => [],
89 'assign_cookietype_param_custom_period_times' => [],
90 'assign_cookietype_param_custom_period' => [],
91 'box_auto_close' => [
92 'transform' => 'box_auto_close_migration'
93 ],
94 'box_auto_close_seconds' => [],
95 'autofocus' => [],
96 'close_on_esc' => [],
97
98 // Actions
99 'actions' => [
100 'transform' => 'actions_migration'
101 ],
102
103 // Display Conditions
104 'display_conditions_type' => [],
105 'mirror_box' => [],
106 'rules' => [
107 'transform' => 'rules_migration'
108 ],
109
110 // Position
111 'position' => [],
112
113 // Design
114 'width_control.width' => [
115 'rename' => 'width',
116 'transform' => 'migrate_unitvalue'
117 ],
118 'height_control.height' => [
119 'rename' => 'height',
120 'transform' => 'migrate_unitvalue'
121 ],
122 'fontsize_control.fontsize' => [
123 'rename' => 'fontsize',
124 'transform' => 'migrate_unitvalue'
125 ],
126 'padding_control.padding' => [
127 'rename' => 'padding',
128 'transform' => 'dimension'
129 ],
130 'margin_control.margin' => [
131 'rename' => 'margin',
132 'transform' => 'dimension'
133 ],
134 'textcolor' => [],
135 'backgroundcolor' => [],
136 'aligncontent' => [],
137 'boxshadow' => [
138 'transform' => 'shadow_migration'
139 ],
140 'animationin' => [
141 'transform' => 'animation_migration'
142 ],
143 'animationout' => [
144 'transform' => 'animation_migration'
145 ],
146 'duration' => [],
147 'border' => [
148 'transform' => 'border_migration'
149 ],
150 'borderradius_control.borderradius' => [
151 'rename' => 'borderradius',
152 'transform' => 'borderradius_migration'
153 ],
154 // Background Overlay
155 'overlay' => [
156 'transform' => 'overlay_enabled_migration'
157 ],
158 'overlay_color' => [],
159 'overlayblurradius' => [
160 'transform' => 'overlayblurradius_migration'
161 ],
162 'overlayclick' => [],
163 // Background Image
164 'bgimage' => [],
165 'bgimagefile' => [],
166 'bgrepeat' => [],
167 'bgsize' => [],
168 'bgposition' => [],
169
170 // Close Button
171 'closebutton' => [],
172
173 // Advanced
174 'customcode' => [],
175 'customcss' => [],
176 'testmode' => [],
177 'preventpagescroll' => [],
178 'stats' => [],
179 'classsuffix' => [],
180 'zindex' => [],
181
182
183 ];
184
185 foreach ($map as $key => $value)
186 {
187 $legacyValue = $this->getValueFromLegacyMeta($key, $value, $new_meta, $legacy_meta);
188
189 // Renames
190 if (isset($value['rename']))
191 {
192 $key = $value['rename'];
193 }
194
195 // Does the new meta value exist?
196 $valueExistsInNewMeta = isset($new_meta[$key]);
197
198 // Set new meta value from legacy meta value
199 if (!isset($new_meta[$key]) && isset($legacyValue))
200 {
201 $new_meta[$key] = $legacyValue;
202 }
203
204 // Transforms
205 if (isset($value['transform']))
206 {
207 $migrator = new MetaMigrator();
208 $migrator->applyTransform($value['transform'], $key, $new_meta, $legacy_meta, $defaults, $valueExistsInNewMeta);
209 }
210 }
211 }
212
213 // Set defaults if empty, i.e. we're creating a new blank campaign
214 if (empty($new_meta))
215 {
216 $new_meta = $defaults;
217 }
218
219 $this->is_running = false;
220
221 return $single ? $new_meta : [$new_meta];
222 }
223
224 private function getValueFromLegacyMeta($key, $value, $new_meta, $legacy_meta)
225 {
226 $_value = '';
227
228 if (strpos($key, '.') !== false)
229 {
230 list($first_part, $second_part) = explode('.', $key, 2);
231 if (!isset($new_meta[$value['rename']]) && isset($legacy_meta[$first_part][$second_part]))
232 {
233 $_value = $legacy_meta[$first_part][$second_part];
234 }
235 }
236 else
237 {
238 if (!isset($new_meta[$key]) && isset($legacy_meta[$key]))
239 {
240 $_value = $legacy_meta[$key];
241 }
242 }
243
244 return $_value;
245 }
246
247 private function getDefaults()
248 {
249 return [
250 'mode' => 'popup',
251
252 // For fullscreen
253 'center_content' => false,
254
255 'triggermethod' => 'pageload',
256 'triggerelement' => '',
257 'close_out_viewport' => false,
258 'threshold' => 25,
259 'exittimer' => 1,
260 'idle_time' => 10,
261 'triggerdelay' => 0,
262 'scroll_amount' => '80%',
263 'autohide' => false,
264 'firing_frequency' => '1',
265 'floating_button_show_on_close' => false,
266 'floatingbutton_message' => [
267 'text' => 'Open Popup',
268 'bgcolor' => '#4285F4',
269 'textcolor' => '#fff',
270 'fontsize' => '15px'
271 ],
272 'floating_button_position' => 'bottom-right',
273 'assign_impressions_param_type' => 'always',
274 'assign_impressions_param_custom_period_times' => 1,
275 'assign_impressions_param_custom_period' => 'session',
276 'opening_sound' => [
277 'source' => 'none',
278 'file' => '',
279 'url' => '',
280 ],
281 'assign_cookietype' => 'never',
282 'assign_cookietype_param_custom_period_times' => 1,
283 'assign_cookietype_param_custom_period' => 'days',
284 'box_auto_close' => false,
285 'box_auto_close_seconds' => 5,
286 'autofocus' => false,
287 'close_on_esc' => false,
288
289 // Actions
290 'actions' => [],
291
292 // Display Conditions
293 'display_conditions_type' => 'all',
294 'mirror_box' => '',
295 'rules' => [
296 [
297 'matching_method' => 'all',
298 'enabled' => true,
299 'rules' => [
300 [
301 'enabled' => true,
302 'name' => '',
303 'operator' => '',
304 'value' => ''
305 ]
306 ]
307 ]
308 ],
309
310 'position' => 'center',
311
312 'width' => [
313 'desktop' => '500px'
314 ],
315 'height' => [
316 'desktop' => 'auto'
317 ],
318 'padding' => [
319 'desktop' => [
320 'top' => '30px',
321 'right' => '30px',
322 'bottom' => '30px',
323 'left' => '30px'
324 ]
325 ],
326 'margin' => [
327 'desktop' => [
328 'top' => '',
329 'right' => '',
330 'bottom' => '',
331 'left' => ''
332 ]
333 ],
334 'closebutton' => [
335 'show' => '1',
336 'source' => 'icon',
337 'color' => 'rgba(136, 136, 136, 1)',
338 'hover' => 'rgba(85, 85, 85, 1)',
339 'size' => 30,
340 'image' => '',
341 'mediaId' => false,
342 'delay' => 0
343 ],
344 'backgroundcolor' => '#ffffff',
345 'boxshadow' => true,
346 'animationin' => 'fadeIn',
347 'animationout' => 'fadeOut',
348 'animation_type' => 'slide',
349 'duration' => 0.3,
350 'border' => [
351 'width' => '0',
352 'style' => 'solid',
353 'color' => 'rgba(0, 0, 0, 0.4)'
354 ],
355 'borderradius' => [
356 'desktop' => [
357 'topLeft' => '0px',
358 'topRight' => '0px',
359 'bottomLeft' => '0px',
360 'bottomRight' => '0px'
361 ]
362 ],
363 // Background Overlay
364 'overlay' => true,
365 'overlay_color' => 'rgba(0, 0, 0, 0.2)',
366 'overlayblurradius' => 0,
367 'overlayclick' => true,
368 // Background Image
369 'bgimage' => false,
370 'bgimagefile' => '',
371 'bgrepeat' => 'Repeat',
372 'bgsize' => 'Auto',
373 'bgposition' => 'Left Top',
374
375 // Deprecated
376 'fontsize' => [
377 'desktop' => '16px'
378 ],
379 'textcolor' => '#444444',
380 'aligncontent' => ''
381 ];
382 }
383
384 public function register()
385 {
386 register_meta('post', 'firebox_meta', [
387 'object_subtype' => 'firebox',
388 'show_in_rest' => [
389 'schema' => [
390 'type' => 'object',
391 'additionalProperties' => true
392 ]
393 ],
394 'type' => 'object',
395 'single' => true,
396 'auth_callback' => function($allowed, $meta_key, $post_id, $user_id, $cap, $caps) {
397 return current_user_can('edit_fireboxes');
398 }
399 ]);
400 }
401 }