PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 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 All 123 releases
firebox / Inc / Core / FB / Actions / ActionsTrait.php

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

146 lines 3.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.14 Free
5 *
6 * @author FirePlugins <[email protected]>
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\Actions;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 trait ActionsTrait
20 {
21 /**
22 * Execute code block with a delay
23 *
24 * @param string $function
25 *
26 * @return string
27 */
28 protected function delayFunction($delay = 0, $function = '')
29 {
30 if ($delay == 0)
31 {
32 return $function;
33 }
34
35 return 'setTimeout(function() { ' . $function . ' }, ' . esc_attr($delay) . ');';
36 }
37
38 /**
39 * The script for the "Open a Box" action. It opens the specified the box.
40 *
41 * @return string
42 */
43 private function _OpenBox()
44 {
45 if (!isset($this->item['box']))
46 {
47 return;
48 }
49
50 return $this->delayFunction($this->item['delay'], 'FireBox.getInstance(' . $this->item['box'] . ').open();');
51 }
52
53 /**
54 * The script for the "Close a Box" action. It closes the specified the box.
55 *
56 * @return string
57 */
58 private function _CloseBox()
59 {
60 if (!isset($this->item['box']))
61 {
62 return;
63 }
64
65 return $this->delayFunction($this->item['delay'], 'FireBox.getInstance(' . $this->item['box'] . ').close();');
66 }
67
68 /**
69 * The script for the "Close all opened Boxes" action. It used the closeAll() static method to close all boxes.
70 *
71 * @return string
72 */
73 private function _CloseAll()
74 {
75 return 'FireBox.closeAll();';
76 }
77
78 /**
79 * The script for the "Destroy Box" action. It destroys the box instance.
80 *
81 * @return string
82 */
83 private function _DestroyBox()
84 {
85 if (!isset($this->item['box']))
86 {
87 return;
88 }
89
90 return 'FireBox.getInstance(' . esc_attr($this->item['box']) . ').destroy();';
91 }
92
93 /**
94 * The script for the "Redirect to a URL" action. It redirects the visitor to a URL.
95 *
96 * @return string
97 */
98 private function _GoToURL()
99 {
100 $target = isset($this->item['newtab']) && $this->item['newtab'] ? '_blank' : '_self';
101 return 'window.open("' . esc_url($this->item['url']) . '", "' . esc_attr($target) . '")';
102 }
103
104 /**
105 * The script for the "Reload Page" action.
106 *
107 * @return string
108 */
109 private function _ReloadPage()
110 {
111 return 'location.reload();';
112 }
113
114 /**
115 * The script for the "Run Javascript" action. It executes the custom Javascript code specified by the administrator.
116 *
117 * The code is campaign-authored and emitted verbatim, so it runs only when the
118 * campaign's author holds unfiltered_html — the same gate as the Custom
119 * JavaScript setting.
120 *
121 * @return string
122 */
123 private function _Custom()
124 {
125 if (!\FireBox\Core\Helpers\CustomCode::isAllowedForCampaign($this->box_id))
126 {
127 return;
128 }
129
130 return $this->item['customcode'];
131 }
132
133 /**
134 * Protect code scope by wrapping it with an anonymous fuction
135 *
136 * @param string $string The code to anonymise
137 *
138 * @return string
139 */
140 protected function anonymise($string)
141 {
142 // Keep the new line character inside return for code presentation purposes.
143 return '
144 !(function() { ' . $string . ' })();';
145 }
146 }