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