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 +65 -33 1.0.12 → 3.1.14 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.12 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,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,17 +111,37 @@
102 111 * @return void
103 112 */
104 113 public function hooks()
105 114 {
106 - // Remove assignments
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
107 124 $this->box_data->params->remove('assignments');
125 + // Remove Rules
126 + $this->box_data->params->remove('rules');
108 127 // Enable Test Mode to prevent cookies
109 128 $this->box_data->params->set('testmode', true);
110 129 // Disable Statistics to prevent impressions from being tracked into the database
111 130 $this->box_data->params->set('stats', 0);
112 131
113 - firebox()->box->render($this->box_data);
114 -
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 +
115 144 \add_filter('the_title', [$this, 'the_title'], 100, 1);
116 145
117 146 \add_filter('the_content', [$this, 'the_content'], 999);
118 147
@@ -125,13 +154,13 @@
125 154 {
126 155 return '';
127 156 }
128 157
129 - if (!current_user_can('manage_options'))
158 + if (!current_user_can('read_firebox', $this->box_data->ID))
130 159 {
131 160 return '';
132 161 }
133 -
162 +
134 163 $links = [];
135 164
136 165 $links[] = [
137 166 'url' => esc_url(
@@ -142,9 +171,9 @@
142 171 ],
143 172 admin_url('post.php')
144 173 )
145 174 ),
146 - 'text' => esc_html(firebox()->_('FB_EDIT_FIREBOX')),
175 + 'text' => esc_html(firebox()->_('FB_EDIT_CAMPAIGN')),
147 176 ];
148 177
149 178 $links[] = [
150 179 'url' => esc_url(
@@ -154,29 +183,32 @@
154 183 ],
155 184 admin_url('edit.php')
156 185 )
157 186 ),
158 - 'text' => esc_html(firebox()->_('FB_VIEW_FIREBOX_ITEMS')),
187 + 'text' => esc_html(firebox()->_('FB_VIEW_CAMPAIGNS')),
159 188 ];
160 189
161 190 $content = '<div style="padding: 15px; background: #ededed;">';
162 191 $content .= '<p>';
163 192 $content .= esc_html(firebox()->_('FB_FIREBOX_PREVIEW_DESC'));
164 - if (!empty($links))
165 - {
166 - $content .= '<br>';
167 - foreach ($links as $key => $link)
168 - {
169 - $content .= '<a href="' . esc_url($link['url']) . '">' . esc_html($link['text']) . '</a>';
170 - $l = array_keys($links);
171 - if (end($l) !== $key)
172 - {
173 - $content .= ' <span style="display:inline-block;margin:0 6px;opacity: 0.5">|</span> ';
174 - }
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> ';
175 201 }
176 202 }
177 203 $content .= '</p>';
178 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 + }
179 211
180 212 return $content;
181 213 }
182 214
@@ -192,9 +224,9 @@
192 224 if (in_the_loop())
193 225 {
194 226 $title = sprintf(
195 227 esc_html('%s'),
196 - ! 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'))
197 229 );
198 230 }
199 231
200 232 return $title;