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
← All changes | Inc/Core/Previewer.php +71 -32 1.0.4 → 3.1.14 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.4 Free
4 + * @version 3.1.14 Free
5 5 *
6 6 * @author FirePlugins <[email protected]>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2021 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core;
@@ -15,11 +15,10 @@
15 15 {
16 16 exit; // Exit if accessed directly.
17 17 }
18 18
19 -use \FPFramework\Libs\Registry;
20 -
21 -class Previewer {
19 +class Previewer
20 +{
22 21 /**
23 22 * FireBox data.
24 23 *
25 24 * @var array
@@ -25,8 +24,10 @@
25 24 * @var array
26 25 */
27 26 public $box_data;
28 27
28 + protected $embed_html = '';
29 +
29 30 /**
30 31 * Inits Previewer
31 32 *
32 33 * @return void
@@ -48,30 +49,40 @@
48 49 * @return boolean
49 50 */
50 51 public function is_preview_page()
51 52 {
53 + global $post;
54 + $post_type = isset($_GET['post_type']) ? sanitize_key($_GET['post_type']) : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
55 + $post_id = isset($_GET['p']) ? \absint($_GET['p']) : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
56 +
57 + if (!$post_type && !$post_id && $post)
58 + {
59 + $post_type = $post->post_type;
60 + $post_id = $post->ID;
61 + }
62 +
52 63 // Only proceed if we have a item to preview
53 - if (empty($_GET['post_type']))
64 + if (empty($post_type))
54 65 {
55 66 return false;
56 67 }
57 68
58 - if ($_GET['post_type'] != 'firebox')
69 + if ($post_type != 'firebox')
59 70 {
60 71 return false;
61 72 }
62 73
63 - if (empty($_GET['p']))
74 + if (empty($post_id))
64 75 {
65 76 return false;
66 77 }
67 78
68 - if (empty($_GET['preview']))
79 + if (empty($_GET['preview'])) //phpcs:ignore WordPress.Security.NonceVerification.Recommended
69 80 {
70 81 return false;
71 82 }
72 83
73 - if (!$_GET['preview'])
84 + if (!sanitize_key(wp_unslash($_GET['preview']))) //phpcs:ignore WordPress.Security.NonceVerification.Recommended
74 85 {
75 86 return false;
76 87 }
77 88
@@ -80,16 +91,14 @@
80 91 {
81 92 return false;
82 93 }
83 94
84 - if (!\current_user_can('manage_options'))
95 + if (!\current_user_can('read_firebox', $post_id))
85 96 {
86 97 return false;
87 98 }
88 99
89 - $box_id = \absint($_GET['p']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
90 -
91 - if (!$this->box_data = firebox()->box->get($box_id))
100 + if (!$this->box_data = firebox()->box->get($post_id))
92 101 {
93 102 return false;
94 103 }
95 104
@@ -102,10 +111,37 @@
102 111 * @return void
103 112 */
104 113 public function hooks()
105 114 {
106 - firebox()->box->render($this->box_data);
107 -
115 + if ($this->box_data->params->get('mode') !== 'embed')
116 + {
117 + // Set to trigger on Page Load
118 + $this->box_data->params->set('triggermethod', 'pageload');
119 + }
120 +
121 + // Remove Impressions
122 + $this->box_data->params->set('assign_impressions_param_type', 'always');
123 + // Remove Assignments
124 + $this->box_data->params->remove('assignments');
125 + // Remove Rules
126 + $this->box_data->params->remove('rules');
127 + // Enable Test Mode to prevent cookies
128 + $this->box_data->params->set('testmode', true);
129 + // Disable Statistics to prevent impressions from being tracked into the database
130 + $this->box_data->params->set('stats', 0);
131 +
132 + \FireBox\Core\Helpers\Actions::run();
133 +
134 + if ($this->box_data->params->get('mode') !== 'embed')
135 + {
136 + firebox()->box->setBox($this->box_data)->render();
137 + }
138 + else
139 + {
140 + global $post;
141 + $this->embed_html = \FireBox\Core\Helpers\Embed::renderCampaign($post->ID, ['draft']);
142 + }
143 +
108 144 \add_filter('the_title', [$this, 'the_title'], 100, 1);
109 145
110 146 \add_filter('the_content', [$this, 'the_content'], 999);
111 147
@@ -118,13 +154,13 @@
118 154 {
119 155 return '';
120 156 }
121 157
122 - if (!current_user_can('manage_options'))
158 + if (!current_user_can('read_firebox', $this->box_data->ID))
123 159 {
124 160 return '';
125 161 }
126 -
162 +
127 163 $links = [];
128 164
129 165 $links[] = [
130 166 'url' => esc_url(
@@ -135,9 +171,9 @@
135 171 ],
136 172 admin_url('post.php')
137 173 )
138 174 ),
139 - 'text' => esc_html(firebox()->_('FB_EDIT_FIREBOX')),
175 + 'text' => esc_html(firebox()->_('FB_EDIT_CAMPAIGN')),
140 176 ];
141 177
142 178 $links[] = [
143 179 'url' => esc_url(
@@ -147,29 +183,32 @@
147 183 ],
148 184 admin_url('edit.php')
149 185 )
150 186 ),
151 - 'text' => esc_html(firebox()->_('FB_VIEW_FIREBOX_ITEMS')),
187 + 'text' => esc_html(firebox()->_('FB_VIEW_CAMPAIGNS')),
152 188 ];
153 189
154 190 $content = '<div style="padding: 15px; background: #ededed;">';
155 191 $content .= '<p>';
156 192 $content .= esc_html(firebox()->_('FB_FIREBOX_PREVIEW_DESC'));
157 - if (!empty($links))
158 - {
159 - $content .= '<br>';
160 - foreach ($links as $key => $link)
161 - {
162 - $content .= '<a href="' . $link['url'] . '">' . $link['text'] . '</a>';
163 - $l = array_keys($links);
164 - if (end($l) !== $key)
165 - {
166 - $content .= ' <span style="display:inline-block;margin:0 6px;opacity: 0.5">|</span> ';
167 - }
193 + $content .= '<br>';
194 + foreach ($links as $key => $link)
195 + {
196 + $content .= '<a href="' . esc_url($link['url']) . '">' . esc_html($link['text']) . '</a>';
197 + $l = array_keys($links);
198 + if (end($l) !== $key)
199 + {
200 + $content .= ' <span style="display:inline-block;margin:0 6px;opacity: 0.5">|</span> ';
168 201 }
169 202 }
170 203 $content .= '</p>';
171 204 $content .= '</div>';
205 +
206 + // Add embed campaign to preview page
207 + if ($this->box_data->params->get('mode') === 'embed')
208 + {
209 + $content .= '<div style="margin: 30px auto; display: flex; justify-content: center;">' . $this->embed_html . '</div>';
210 + }
172 211
173 212 return $content;
174 213 }
175 214
@@ -185,9 +224,9 @@
185 224 if (in_the_loop())
186 225 {
187 226 $title = sprintf(
188 227 esc_html('%s'),
189 - ! empty($this->box_data->post_title) ? sanitize_text_field($this->box_data->post_title) . ' ' . firebox()->_('FB_PREVIEW') : esc_html(firebox()->_('FB_FIREBOX_POPUP_PREVIEW'))
228 + ! empty($this->box_data->post_title) ? sanitize_text_field($this->box_data->post_title) . ' ' . firebox()->_('FB_PREVIEW') : esc_html(firebox()->_('FB_FIREBOX_CAMPAIGN_PREVIEW'))
190 229 );
191 230 }
192 231
193 232 return $title;