PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.7
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.7
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.7, at Inc/Core/FB/Actions/ActionsTrait.php

137 lines 3.3 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.7 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 * @return string
118 */
119 private function _Custom()
120 {
121 return $this->item['customcode'];
122 }
123
124 /**
125 * Protect code scope by wrapping it with an anonymous fuction
126 *
127 * @param string $string The code to anonymise
128 *
129 * @return string
130 */
131 protected function anonymise($string)
132 {
133 // Keep the new line character inside return for code presentation purposes.
134 return '
135 !(function() { ' . $string . ' })();';
136 }
137 }