PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.3
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.3
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.3, at Inc/Core/FB/Box.php

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