PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.0
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.0
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 / Box.php

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

867 lines 21.0 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 1.0.0 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2021 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 use FireBox\Core\Helpers\BoxHelper;
20 use FPFramework\Libs\Registry;
21 use FPFramework\Helpers\Fields\DimensionsHelper;
22
23 class Box
24 {
25 /**
26 * Send useful JS snippet once in first box
27 *
28 * @var boolean
29 */
30 static $loadedLocalizedScript = false;
31
32 /**
33 * The box settings
34 */
35 private $boxSettings;
36
37 /**
38 * The factory
39 *
40 * @var Factory
41 */
42 protected $factory;
43
44 public function __construct($boxSettings = null, $factory = null)
45 {
46 if (!$factory)
47 {
48 $factory = new \FPFramework\Base\Factory();
49 }
50
51 $this->boxSettings = $boxSettings;
52 $this->factory = $factory;
53 }
54
55 /**
56 * Gets published box.
57 *
58 * @param integer $id
59 * @param string $status
60 *
61 * @return array
62 */
63 public function get($id, $status = 'publish')
64 {
65 $payload = [
66 'where' => [
67 'ID' => ' = ' . $id,
68 'post_type' => " = 'firebox'"
69 ]
70 ];
71
72 // apply status if given
73 if ($status)
74 {
75 $payload['where']['post_status'] = ' = \'' . $status . '\'';
76 }
77
78 if (!$box = firebox()->models->box->getResults($payload))
79 {
80 return [];
81 }
82
83 if (!isset($box[0]))
84 {
85 return [];
86 }
87
88 $box = $box[0];
89
90 // get meta options for box
91 $meta = self::getMeta($id);
92 $box->params = new Registry($meta);
93
94 return $box;
95 }
96
97 /**
98 * Get box meta
99 *
100 * @param int $id
101 *
102 * @return array
103 */
104 public static function getMeta($id)
105 {
106 return get_post_meta($id, 'fpframework_meta_settings', true);
107 }
108
109 /**
110 * Render box
111 *
112 * @return string
113 */
114 public function render($box = null)
115 {
116 // we do not have a passed box or box settings from constructor, abort
117 // as we cannot render a box without any box parameters
118 if (!$box && !$this->boxSettings)
119 {
120 return;
121 }
122
123 // if a box was given to the function, use these settings instead
124 if ($box)
125 {
126 $this->boxSettings = $box;
127 }
128
129 // if we have box settings, then set up our box with these settings
130 if ($this->boxSettings)
131 {
132 $box = $this->boxSettings;
133 }
134
135 // Check Publishing Assignments
136 if (!$this->pass($box))
137 {
138 return;
139 }
140
141 // get settings params
142 $params = BoxHelper::getParams();
143
144 if (!did_action('wp_enqueue_scripts'))
145 {
146 /**
147 * Loads all media files.
148 */
149 add_action('wp_enqueue_scripts', function() use ($box, $params) {
150 // load box media
151 $this->loadBoxMedia($box, $params);
152 });
153 }
154 else
155 {
156 // load box media
157 $this->loadBoxMedia($box, $params);
158 }
159
160 self::prepare($box);
161
162 if (!did_action('wp_head'))
163 {
164 /**
165 * Custom CSS
166 */
167 add_action('wp_head', function() use ($box) {
168 if (!empty($box->params->get('customcss', '')))
169 {
170 echo '<style type="text/css">' . $box->params->get('customcss') . '</style>';
171 }
172 });
173 }
174 else
175 {
176 if (!empty($box->params->get('customcss', '')))
177 {
178 echo '<style type="text/css">' . $box->params->get('customcss') . '</style>';
179 }
180 }
181
182 /**
183 * Runs before rendering the box.
184 */
185 do_action('firebox/box/before_render', $box);
186
187 // after we prepare it, update box settings
188 $this->boxSettings = $box;
189
190 // payload
191 $payload = [
192 'box' => $box,
193 'params' => $params,
194 ];
195
196 // return box template
197 add_action('wp_footer', function() use ($box, $payload) {
198 echo firebox()->renderer->public->render('box', $payload, true);
199 });
200 }
201
202 /**
203 * Send a helpful object to JavaScript files
204 *
205 * @return void
206 */
207 public static function setJSObject()
208 {
209 if (self::$loadedLocalizedScript)
210 {
211 return;
212 }
213 self::$loadedLocalizedScript = true;
214
215 $data = array(
216 'ajax_url' => admin_url('admin-ajax.php'),
217 'nonce' => wp_create_nonce('fbox_js_nonce'),
218 'site_url' => site_url('/'),
219 'referrer' => wp_get_referer()
220 );
221
222 wp_localize_script('firebox', 'fbox_js_object', $data);
223 }
224
225 /**
226 * Load Box Media
227 *
228 * @param array $box
229 * @param array $params
230 *
231 * @return void
232 */
233 public function loadBoxMedia($box, $params)
234 {
235 $box = new Registry($box);
236 $params = new Registry($params);
237
238 // Add polyfills for Internet Explorer
239 $browser = $this->factory->getBrowser();
240 if ($browser['name'] == 'ie')
241 {
242 wp_enqueue_script(
243 'firebox-ie11-polyfill',
244 'https://polyfill.io/v3/polyfill.min.js?features=NodeList.prototype.forEach%2CElement.prototype.closest%2CArray.prototype.forEach%2CArray.prototype.find%2CIntersectionObserver%2CIntersectionObserverEntry',
245 [],
246 FBOX_VERSION,
247 false
248 );
249 }
250
251 /**
252 * Velocity
253 */
254 if ($params->get('loadVelocity', true))
255 {
256 wp_enqueue_script(
257 'firebox-velocity',
258 FBOX_MEDIA_PUBLIC_URL . 'js/vendor/velocity.js',
259 [],
260 FBOX_VERSION,
261 false
262 );
263 wp_enqueue_script(
264 'firebox-velocity-ui',
265 FBOX_MEDIA_PUBLIC_URL . 'js/vendor/velocity.ui.js',
266 [],
267 FBOX_VERSION,
268 false
269 );
270
271 /**
272 * Animations
273 */
274 if (strpos($box->get('params.data.animationin'), 'firebox') !== false || strpos($box->get('params.data.animationout'), 'firebox') !== false)
275 {
276 wp_enqueue_script(
277 'firebox-animations',
278 FBOX_MEDIA_PUBLIC_URL . 'js/animations.js',
279 [],
280 FBOX_VERSION,
281 false
282 );
283 }
284 }
285
286 /**
287 * FireBox JS
288 */
289 wp_enqueue_script(
290 'firebox',
291 FBOX_MEDIA_PUBLIC_URL . 'js/firebox.js',
292 [],
293 FBOX_VERSION,
294 false
295 );
296
297 // run above the main JS script to run only once
298 self::setJSObject();
299
300 /**
301 * FireBox CSS
302 */
303 if ($params->get('loadCSS', true))
304 {
305 wp_enqueue_style(
306 'firebox',
307 FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css',
308 [],
309 FBOX_VERSION,
310 false
311 );
312 }
313
314 /**
315 * Page Slide mode JS
316 */
317 if ($box->get('params.data.mode') == 'pageslide')
318 {
319 wp_enqueue_script(
320 'firebox-pageslide-mode',
321 FBOX_MEDIA_PUBLIC_URL . 'js/pageslide_mode.js',
322 [],
323 FBOX_VERSION,
324 false
325 );
326 }
327
328
329
330 $this->loadThemeCSSOverrides();
331 }
332
333 /**
334 * Some themes require overrides to preserve as much as we can the styling of the popups.
335 *
336 * @return void
337 */
338 private function loadThemeCSSOverrides()
339 {
340 $active_theme = wp_get_theme();
341 $theme = $active_theme->template;
342
343 /**
344 * This is the listed of the themes that we have created overrides
345 */
346 $themes = [
347 'twentytwentyone'
348 ];
349
350 if (!in_array($theme, $themes))
351 {
352 return;
353 }
354
355 wp_enqueue_style(
356 'firebox-theme-' . $theme . '-override',
357 FBOX_MEDIA_PUBLIC_URL . 'css/themes/' . $theme . '.css',
358 [],
359 FBOX_VERSION,
360 false
361 );
362 }
363
364 /**
365 * Prepares the box before rendering
366 *
367 * @param array $box
368 *
369 * @return void
370 */
371 public static function prepare(&$box)
372 {
373 $cParam = BoxHelper::getParams();
374 $cParam = new Registry($cParam);
375
376 $box->post_content = apply_filters('the_content', $box->post_content);
377
378 $css_class_prefix = 'fb-';
379
380 $position = $box->params->get('position', '');
381 $position = !is_string($position) ? '' : $position;
382
383 /* Classes */
384 $css_class = [
385 $box->ID,
386 $position
387 ];
388
389 $rtl = $box->params->get('rtl', '0');
390 if ($rtl == '1')
391 {
392 $css_class[] = 'rtl';
393 }
394
395 self::prefixCSSClasses($css_class);
396
397 // class suffix
398 $classSuffix = $box->params->get('classsuffix', '');
399 $classSuffix = is_string($classSuffix) ? $classSuffix : '';
400
401 $css_class[] = $classSuffix;
402
403 $box->classes = $css_class;
404
405 // box shadow
406 $boxshadow = (is_string($box->params->get('boxshadow', '1')) || is_int($box->params->get('boxshadow', '1'))) ? $box->params->get('boxshadow', '1') : '0';
407
408 $dialog_css_classes = [
409 $boxshadow != '0' ? 'shd' . $boxshadow : null
410 ];
411
412 // Align Content
413 $aligncontent = is_string($box->params->get('aligncontent')) ? explode(' ', $box->params->get('aligncontent')) : [];
414 $dialog_css_classes = array_merge($dialog_css_classes, $aligncontent);
415
416 self::prefixCSSClasses($dialog_css_classes);
417 $box->dialog_classes = $dialog_css_classes;
418
419 /* CSS */
420 // border
421 $border = is_string($box->params->get('bordertype', 'none')) ? $box->params->get('bordertype', 'none') : 'none';
422 $border_width = $box->params->get('borderwidth.value', 0) ? $box->params->get('borderwidth.value', 0) : 0;
423 $border_unit = is_string($box->params->get('borderwidth.unit', 'px')) ? $box->params->get('borderwidth.unit', 'px') : 0;
424 $border_color = is_string($box->params->get('bordercolor')) ? $box->params->get('bordercolor') : '';
425
426 $style = [
427 'background-color' => $box->params->get('backgroundcolor'),
428 'color' => $box->params->get('textcolor'),
429 'border' => $border == 'none' ? null : $border . ' ' . $border_width . $border_unit . ' ' . $border_color,
430 ];
431
432 // add shared properties
433 $shared_properties = [
434 'width' => [
435 'prefix_only' => true
436 ],
437 'height' => [
438 'prefix_only' => true
439 ],
440 'padding' => [],
441 'margin' => []
442 ];
443 foreach ($shared_properties as $prop => $prop_data)
444 {
445 // add dekstop property
446 $value = (array) $box->params->get($prop . '_control.' . $prop, []);
447 if (isset($value['desktop']))
448 {
449 $prefix_only = isset($prop_data['prefix_only']) ? (bool) $prop_data['prefix_only'] : false;
450
451 $desktop_value = DimensionsHelper::parseDimensionsData($value['desktop'], $prop, false, $prefix_only);
452 $style = array_merge($style, $desktop_value);
453 }
454 }
455
456 // add dekstop border_radius
457 $border_radius = (array) $box->params->get('borderradius_control.borderradius', []);
458 if (isset($border_radius['desktop']))
459 {
460 $desktop_border_radius = DimensionsHelper::parseDimensionsBorderRadiusData($border_radius['desktop']);
461 $style = array_merge($style, $desktop_border_radius);
462 }
463
464 // Background Image
465 if ($box->params->get('bgimage', false))
466 {
467 $bgrepeat = is_string($box->params->get('bgrepeat')) ? $box->params->get('bgrepeat') : '';
468 $bgsize = is_string($box->params->get('bgsize')) ? $box->params->get('bgsize') : '';
469 $bgposition = is_string($box->params->get('bgposition')) ? $box->params->get('bgposition') : '';
470
471 $style['background-image'] = 'url(\'' . esc_url($box->params->get('bgimagefile')) . '\')';
472 $style['background-repeat'] = strtolower($bgrepeat);
473 $style['background-size'] = strtolower($bgsize);
474 $style['background-position'] = strtolower($bgposition);
475 }
476
477 $box->style = BoxHelper::arrayToCSSS($style);
478
479 $trigger_point_methods = [
480 'pageheight' => 'onScrollDepth',
481 'element' => 'onElementVisibility',
482 'pageready' => 'onPageReady',
483 'pageload' => 'onPageLoad',
484 'userleave' => 'onExit',
485 'onclick' => 'onClick',
486 'elementHover' => 'onHover',
487 'ondemand' => 'onDemand'
488 ];
489
490 // z index
491 $zindex = $box->params->get('zindex', 99999) != 99999 ? $box->params->get('zindex') : null;
492
493 $box->styles_container = BoxHelper::arrayToCSSS([
494 'z-index' => $zindex
495 ]);
496
497 /* Other Settings */
498 $scroll_depth = $box->params->get('scroll_depth', 'percentage');
499 $scroll_depth = !is_array($scroll_depth) ? $scroll_depth : '';
500
501 $animation_duration = $box->params->get('duration') ? (float) $box->params->get('duration') : 0;
502
503 // Use Namespaced classes for each trigger point and let them manipulate the settings dynamicaly.
504 $box->settings = [
505 'trigger' => (is_string($box->params->get('triggermethod'))) && array_key_exists($box->params->get('triggermethod'), $trigger_point_methods) ? $trigger_point_methods[$box->params->get('triggermethod')] : $box->params->get('triggermethod'),
506 'trigger_selector' => $box->params->get('triggerelement'),
507 'delay' => (int) $box->params->get('triggerdelay') * 1000,
508 'scroll_depth' => $scroll_depth,
509 'scroll_depth_value' => $scroll_depth == 'percentage' ? (int) $box->params->get('triggerpercentage') : (int) $box->params->get('scroll_pixel'),
510 'firing_frequency' => (int) $box->params->get('firing_frequency', 1),
511 'reverse_scroll_close' => (bool) $box->params->get('autohide'),
512 'threshold' => (float) $box->params->get('threshold', 0) / 100,
513 'close_out_viewport' => (bool) $box->params->get('close_out_viewport', false),
514 'exit_timer' => (int) $box->params->get('exittimer') * 1000,
515 'idle_time' => (int) $box->params->get('idle_time') * 1000,
516 'animation_open' => $box->params->get('animationin'),
517 'animation_close' => $box->params->get('animationout'),
518 'animation_duration' => (float) $animation_duration * 1000,
519 'prevent_default' => (bool) $box->params->get('preventdefault', true),
520 'backdrop' => (bool) $box->params->get('overlay'),
521 'backdrop_color' => $box->params->get('overlay_color'),
522 'backdrop_click' => (bool) $box->params->get('overlayclick'),
523 'disable_page_scroll' => (bool) $box->params->get('preventpagescroll'),
524 'test_mode' => (bool) $box->params->get('testmode'),
525 'debug' => (bool) $cParam->get('debug', false),
526 'ga_tracking' => (bool) $cParam->get('gaTrack', 0),
527 'ga_tracking_id' => $cParam->get('gaID', 0),
528 'ga_tracking_label' => $cParam->get('gaCategory')
529 ];
530
531 // set padding and margin for other devices as well
532 self::setResponsiveCSS($box);
533
534 self::replaceBoxSmartTags($box);
535 }
536
537 /**
538 * Sets all responsive CSS to use in box view
539 *
540 * @param object $box
541 *
542 * @return void
543 */
544 private static function setResponsiveCSS(&$box)
545 {
546 $tablet = '';
547 $mobile = '';
548
549 /**
550 * Handle width, height, padding, margin the same way.
551 */
552 $shared_properties = [
553 'width' => [
554 'prefix_only' => true
555 ],
556 'height' => [
557 'prefix_only' => true
558 ],
559 'padding' => [],
560 'margin' => []
561 ];
562
563 foreach ($shared_properties as $prop => $prop_settings)
564 {
565 $prop_data = (array) $box->params->get($prop . '_control.' . $prop, []);
566
567 $prefix_only = isset($prop_settings['prefix_only']) ? $prop_settings['prefix_only'] : false;
568
569 // assign each device CSS
570 if (isset($prop_data['tablet']))
571 {
572 $tablet .= BoxHelper::arrayToCSSS(DimensionsHelper::parseDimensionsData($prop_data['tablet'], $prop, true, $prefix_only));
573 }
574 if (isset($prop_data['mobile']))
575 {
576 $mobile .= BoxHelper::arrayToCSSS(DimensionsHelper::parseDimensionsData($prop_data['mobile'], $prop, true, $prefix_only));
577 }
578 }
579
580 // border radius requires a special method
581 $border_radius = (array) $box->params->get('borderradius_control.borderradius', []);
582 if (isset($border_radius['tablet']))
583 {
584 $tablet .= BoxHelper::arrayToCSSS(DimensionsHelper::parseDimensionsBorderRadiusData($border_radius['tablet'], true));
585 }
586 if (isset($border_radius['mobile']))
587 {
588 $mobile .= BoxHelper::arrayToCSSS(DimensionsHelper::parseDimensionsBorderRadiusData($border_radius['mobile'], true));
589 }
590
591 $responsive_css = [
592 'tablet' => $tablet,
593 'mobile' => $mobile
594 ];
595 $box->params->set('responsive_css', $responsive_css);
596 }
597
598 /**
599 * Replaces all box smart tags
600 *
601 * @param object $box
602 *
603 * @return object
604 */
605 public static function replaceBoxSmartTags(&$box)
606 {
607 $tags = new \FPFramework\Base\SmartTags\SmartTags();
608
609 // register FB Smart Tags
610 $tags->register('\FireBox\Core\SmartTags', FBOX_BASE_FOLDER . '/Inc/Core/SmartTags', $box);
611
612 $box = $tags->replace($box);
613 }
614
615 /**
616 * Checks if a box passes assignments
617 *
618 * @param object $box
619 *
620 * @return boolean
621 */
622 public function pass($box)
623 {
624 if (!$box || !is_object($box))
625 {
626 return false;
627 }
628
629 // set box settings if empty
630 if (empty($this->boxSettings))
631 {
632 $this->boxSettings = $box;
633 }
634
635 // Prepare boxes that mirror other boxes assignments
636 if ($box->params->get('mirror', false) && $mirror_box_id = $box->params->get('mirror_box'))
637 {
638 $box->params->merge(self::getAssignmentsForMirroring($mirror_box_id));
639 }
640
641 // Check first local assignments
642 if (!$this->passLocalAssignments($box))
643 {
644 return false;
645 }
646
647 // If testmode is enabled disable the User Groups assignment
648 if ($box->params->get('testmode'))
649 {
650 $box->params->set('assignments.assign_grouplevel.selection', '0');
651 }
652
653 $globalAssignments = $this->passGlobalAssignments($box);
654
655 // Check framework based assignments
656 return $globalAssignments;
657 }
658
659 /**
660 * Passes framework based global assignments
661 *
662 * @param object $box
663 *
664 * @return boolean
665 */
666 private function passGlobalAssignments($box)
667 {
668 $assignments = new \FPFramework\Base\Assignments($this->factory);
669 $pass = $assignments->passAll($box, $box->params->get('assignmentMatchingMethod', 'and'));
670 return $pass;
671 }
672
673 /**
674 * Check if a box passes local assignments
675 *
676 * @param object $box
677 *
678 * @return boolean
679 */
680 private function passLocalAssignments($box)
681 {
682 $localAssignments = new \FireBox\Core\FB\Assignments($this, $this->factory);
683 return $localAssignments->passAll();
684 }
685
686 /**
687 * Gets assignments of mirrored box
688 *
689 * @param int $box_id
690 *
691 * @return object
692 */
693 private static function getAssignmentsForMirroring($box_id)
694 {
695 $payload = [
696 'where' => [
697 'ID' => ' = ' . $box_id,
698 'post_status' => " = 'publish'",
699 'post_type' => " = 'firebox'"
700 ]
701 ];
702
703 // Load box
704 if (!$box = firebox()->models->box->getResults($payload))
705 {
706 return;
707 }
708
709 $box = $box[0];
710
711 // get meta options for box
712 $meta = get_post_meta($box_id, 'fpframework_meta_settings', true);
713 $box->params = $meta;
714
715 // To prevent user frustration, we ignore the following assignments because they are not displayed in the Publishing Assignments.
716 $params_to_ignore = [
717 'assign_impressions'
718 ];
719
720 $assignments = [];
721
722 // Gather params to merge
723 foreach ($box->params as $param_key => $param_value)
724 {
725 if (strpos($param_key, 'assign') === false || in_array($param_key, $params_to_ignore))
726 {
727 continue;
728 }
729
730 $assignments[$param_key] = $param_value;
731 }
732
733 return new Registry($assignments);
734 }
735
736 /**
737 * Prefixes the CSS classes
738 *
739 * @param array $classes
740 * @param string $prefix
741 *
742 * @return void
743 */
744 private static function prefixCSSClasses(&$classes, $prefix = 'fb-')
745 {
746 $classes = array_filter($classes);
747
748 if (empty($classes))
749 {
750 return;
751 }
752
753 foreach ($classes as &$class)
754 {
755 $class = $prefix . $class;
756 }
757 }
758
759 /**
760 * Track box open
761 *
762 * @param integer $box_id
763 * @param string $page
764 * @param string $referrer
765 *
766 * @return void
767 */
768 public function logOpenEvent($box_id, $page = null, $referrer = null)
769 {
770 $box = $this->get($box_id);
771
772 // Do not track if statistics option is disabled
773 $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? BoxHelper::getParams()->get('stats', 1) : $box->params->get('stats'));
774 if (!$track_open_event)
775 {
776 return;
777 }
778
779 return firebox()->log->track($box_id, 1, null, $page, $referrer);
780 }
781
782 /**
783 * Track box close
784 *
785 * @param integer $box_id
786 * @param integer $box_log_id
787 *
788 * @return void
789 */
790 public function logCloseEvent($box_id, $box_log_id)
791 {
792 $box = $this->get($box_id);
793
794 // Do not track if statistics option is disabled
795 $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? BoxHelper::getParams()->get('stats', 1) : $box->params->get('stats'));
796 if (!$track_open_event)
797 {
798 return null;
799 }
800
801 firebox()->log->track($box_id, 2, $box_log_id);
802 }
803
804 /**
805 * Get box impressions
806 *
807 * @param array $payload
808 *
809 * @return array
810 */
811 public function getImpressions($payload)
812 {
813 return firebox()->models->boxlog->getResults($payload);
814 }
815
816 /**
817 * Get total box impressions
818 *
819 * @param array $payload
820 *
821 * @return array
822 */
823 public function getTotalImpressions($payload)
824 {
825 return count($this->getImpressions($payload));
826 }
827
828 /**
829 * Return the box settings
830 *
831 * @return object
832 */
833 public function getBoxSettings()
834 {
835 return $this->boxSettings;
836 }
837
838 /**
839 * Sets the box settings
840 *
841 * @param object $settings
842 *
843 * @return object
844 */
845 public function setBoxSettings($settings)
846 {
847 $this->boxSettings = $settings;
848 }
849
850 /**
851 * Returns the box cookie
852 *
853 * @param string $cookie
854 *
855 * @return mixed
856 */
857 public function getCookie($cookie = null)
858 {
859 $cookie = $cookie ? $cookie : (isset($this->boxSettings->ID) ? $this->boxSettings->ID : null);
860 if (!isset($cookie))
861 {
862 return;
863 }
864
865 return new Cookie($cookie);
866 }
867 }