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