PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.0
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.0
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / FrontEnd / Preview.php

Preview.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.3.0, at includes/FrontEnd/Preview.php

530 lines 25.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Admin Class File.
5 *
6 * @package NotificationX\Admin
7 */
8
9 namespace NotificationX\FrontEnd;
10
11 use NotificationX\Core\Helper;
12 use NotificationX\Core\Rules;
13 use NotificationX\GetInstance;
14
15 /**
16 * Preview Class, this class is responsible for all Preview Actions
17 * @method static Preview get_instance($args = null)
18 */
19 class Preview {
20 /**
21 * Instance of Preview
22 *
23 * @var Preview
24 */
25 use GetInstance;
26
27 protected $notificationXArr = [];
28
29 public function __construct() {
30 add_action('wp_head', [$this, 'header_scripts']);
31 add_action('wp_print_footer_scripts', [$this, 'footer_scripts']);
32
33 add_filter('nx_before_enqueue_scripts', [$this, 'enqueue_scripts']);
34 add_filter('nx_inline_notifications_data', [$this, 'inline_notifications_data'], 10, 4);
35 add_filter('nx_metabox_config', [$this, 'content_heading']);
36
37 if ($this->is_preview()) {
38 show_admin_bar(false);
39 }
40
41 if ($this->is_preview() && class_exists('QueryMonitor')) {
42 // Query Monitor renders its own output into the preview iframe and
43 // corrupts it, so display is silenced while building a preview.
44 // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged
45 ini_set('display_errors', 'Off');
46 // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged
47 ini_set('error_reporting', E_ALL);
48 $qm = \QueryMonitor::init();
49 remove_action('plugins_loaded', [$qm, 'action_plugins_loaded']);
50 }
51 }
52
53
54 /**
55 * This method is responsible for enqueueing scripts for public use.
56 *
57 * @return void
58 */
59 public function enqueue_scripts($return) {
60 if ($this->is_preview()) {
61 $args = [
62 'total' => 1,
63 'nxPreview' => true,
64 'pressbar' => [],
65 'active' => [],
66 'gdpr' => [],
67 'popup' => [],
68 'exit_intent' => [],
69 ];
70
71 $settings = $this->preview_settings();
72 if (empty($settings['source']) || empty($settings['type']))
73 return;
74 if ('inline' === $settings['type'] || 'woocommerce_sales_inline' == $settings['source'] ){
75 $args['total'] = 0;
76 return $args;
77 }
78
79 $source = $settings['source'];
80 $type = $settings['type'];
81 if ($type === 'exit_intent') {
82 $args['exit_intent'] = [
83 $source => [
84 'entries' => [
85 $this->preview_entry($settings),
86 ],
87 'post' => $settings,
88 ]
89 ];
90 } else if ($source === 'press_bar') {
91 $args['pressbar'] = [
92 $source => [
93 'content' => FrontEnd::get_instance()->get_bar_content($settings, true),
94 'post' => $settings,
95 ]
96 ];
97 } else if($source === 'gdpr_notification') {
98 $args['gdpr'] = [
99 $source => [
100 'entries' => [
101 $this->preview_entry($settings),
102 ],
103 'post' => $settings,
104 ]
105 ];
106 } else if($source === 'popup_notification') {
107 $args['popup'] = [
108 $source => [
109 'entries' => [
110 $this->preview_entry($settings),
111 ],
112 'post' => $settings,
113 ]
114 ];
115 } else {
116 $args['active'] = [
117 $source => [
118 'entries' => [
119 $this->preview_entry($settings),
120 ],
121 'post' => $settings,
122 ]
123 ];
124 }
125
126 $args['settings'] = FrontEnd::get_instance()->get_settings();
127
128 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
129 $this->notificationXArr = apply_filters('get_notifications_ids', $args);
130 wp_enqueue_style('notificationx-public');
131 wp_enqueue_script('notificationx-public');
132 do_action('notificationx_scripts', $this->notificationXArr);
133
134 add_filter('show_admin_bar', '__return_false');
135
136 return $this->notificationXArr;
137 }
138 return $return;
139 }
140
141 public function header_scripts() {
142 if ($this->is_preview()) {
143 ?>
144 <style>
145 .notificationx-woo-shortcode-inline-wrapper > * {
146 display: inline-block;
147 /* background: rgb(255 255 0 / 20%);
148 color: red; */
149 font-weight: 600;
150 }
151 .notificationx-woo-shortcode-inline-wrapper > div.woo_inline_conv-theme-seven span:first-child,
152 .notificationx-woo-shortcode-inline-wrapper > div.edd_inline_conv-theme-seven span:first-child,
153 .notificationx-woo-shortcode-inline-wrapper > div.woocommerce_sales_inline_conv-theme-seven span:first-child {
154 color: #61BD6D;
155 }
156 .notificationx-woo-shortcode-inline-wrapper > div.woo_inline_conv-theme-seven span:last-child,
157 .notificationx-woo-shortcode-inline-wrapper > div.woocommerce_sales_inline_conv-theme-seven span:last-child,
158 .notificationx-woo-shortcode-inline-wrapper > div.edd_inline_conv-theme-seven span:last-child,
159 .notificationx-woo-shortcode-inline-wrapper > div.tutor_inline_conv-theme-seven span:last-child,
160 .notificationx-woo-shortcode-inline-wrapper > div.learndash_inline_conv-theme-seven span:last-child{
161 color: #E25042;
162 }
163
164 .notificationx-woo-shortcode-inline-wrapper > div.woo_inline_stock-theme-one span,
165 .notificationx-woo-shortcode-inline-wrapper > div.woocommerce_sales_inline_stock-theme-one span {
166 color: #E25042;
167 }
168 </style>
169 <?php
170 }
171 }
172
173 public function footer_scripts() {
174 if ($this->is_preview()) {
175 ?>
176 <script data-no-optimize="1">
177 (function() {
178 document.addEventListener("click", function(event) {
179 // if (event.target.tagName === "A") {
180 event.preventDefault();
181 event.stopPropagation();
182 event.stopImmediatePropagation();
183 // }
184 });
185 document.addEventListener("submit", function(event) {
186 event.preventDefault();
187 });
188 })();
189 </script>
190 <?php
191 }
192 }
193
194
195 public function preview_entry($settings) {
196 $source = !empty($settings['source']) ? $settings['source'] : '';
197 $type = !empty($settings['type']) ? $settings['type'] : '';
198 $nx_id = !empty($settings['nx_id']) ? $settings['nx_id'] : '';
199 $defaults = [
200 'nx_id' => $nx_id,
201 'active_installs' => wp_rand(50, 70),
202 'active_installs_text' => 'Try It Out',
203 'all_time' => wp_rand(50, 70),
204 'all_time_text' => 'Why Don\'t You?',
205 'anonymous_title' => 'Anonymous Title',
206 'author' => '<a href="https://wpdeveloper.com/">WPDeveloper</a>',
207 'author_profile' => 'https://profiles.wordpress.org/wpdevteam/',
208 'amount' => wp_rand(50, 70),
209 'avatar' => [
210 'src' => NOTIFICATIONX_PUBLIC_URL . 'image/icons/pink-face-looped.gif',
211 ],
212 'picture' => NOTIFICATIONX_PUBLIC_URL . 'image/icons/pink-face-looped.gif',
213 'city' => 'Dhaka',
214 'city_country' => 'Dhaka, Bangladesh',
215 'content' => 'Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.',
216 'count' => wp_rand(50, 70),
217 'country' => 'Bangladesh',
218 'course_title' => 'PHP Beginners – Become a PHP Master',
219 'created_at' => wp_date('Y-m-d H:i:s', strtotime('2 days ago')),
220 'day' => 'days',
221 'downloaded' => wp_rand(50, 70),
222 'email' => 'support@wpdeveloper.com',
223 'entry_id' => wp_rand(1000, 9999),
224 'entry_key' => 'ChIJ0cpDbNvBVTcRGX9JNhhpC8I',
225 'first_name' => 'John',
226 '_first_name' => 'John',
227 'formatted_address' => 'House 592, Road 8 Avenue 5, Dhaka 1216, Bangladesh',
228 'ga_title' => 'NotificationX',
229 'icon' => 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png',
230 'icons' => array(
231 '1x' => "https://ps.w.org/notificationx/assets/icon-128x128.gif?rev=2783824",
232 '2x' => "https://ps.w.org/notificationx/assets/icon-256x256.gif?rev=2783824",
233 ),
234 'id' => 5,
235 'image_data' => array(
236 'url' => NOTIFICATIONX_PUBLIC_URL . 'image/icons/pink-face-looped.gif',
237 'alt' => '',
238 'classes' => 'greview_icon',
239 ),
240 'ip' => '103.108.146.88',
241 'key' => '7368a455f5c113afbfd3d8c3ea89a5ed-5719',
242 'last_name' => 'Doe',
243 '_last_name' => 'Doe',
244 'last_updated' => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
245 'last_week' => wp_rand(50, 70),
246 'last_week_text' => 'Get Started for Free.',
247 'lat' => 23.8371427,
248 'link' => '#',
249 'lon' => 90.3704629,
250 'month' => 'months',
251 'name' => 'John Doe',
252 'names' => 'John Doe',
253 'none' => '',
254 'num_ratings' => 2974,
255 'nx_id' => '60',
256 'order_id' => 5815,
257 'place_id' => 'ChIJ0cpDbNvBVTcRGX9JNhhpC8I',
258 'place_name' => 'WPDeveloper',
259 'plugin_name' => 'NotificationX',
260 'plugin_name_text' => 'try it out',
261 'plugin_review' => 'Lorem Ipsum is simply dummy text...',
262 'place_review' => 'Lorem Ipsum is simply dummy text...',
263 'plugin_theme_name' => 'NotificationX',
264 'post_link' => '#',
265 'product_id' => 168,
266 'product_title' => 'Assorted Coffee',
267 'rated' => wp_rand(50, 70),
268 'rating' => 4.4,
269 'ratings' => array(
270 0 => 48,
271 1 => 13,
272 2 => 21,
273 3 => 66,
274 4 => 2826,
275 ),
276 'realtime_siteview' => wp_rand(50, 70),
277 'siteview' => wp_rand(50, 70),
278 'slug' => 'notificafionx',
279 'sometime' => 'Some time ago',
280 'source' => 'google_reviews',
281 'status' => 'wc-processing',
282 'this_page' => 'this page',
283 'timestamp' => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
284 'title' => 'Hoodie with Logo',
285 'today' => wp_rand(50, 70),
286 'today_text' => 'Try It Out',
287 'type' => 'realtime_siteview',
288 'updated_at' => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
289 'url' => '#',
290 'user_id' => '1',
291 'username' => 'johndoe',
292 'version' => '5.5.2',
293 'views' => wp_rand(50, 70),
294 'website' => 'https://wpdeveloper.com/',
295 'year' => 'years',
296 'yesterday' => wp_rand(50, 70),
297 'your-email' => 'support@wpdeveloper.com',
298 'your-message' => 'Lorem Ipsum is simply dummy text.',
299 'your-name' => 'John Doe',
300 'your-subject' => 'Lorem Ipsum',
301 'post_title' => 'Hello World',
302 'sales_count' => wp_rand(50, 70),
303 'donation_count' => wp_rand(50, 70),
304 '1day' => __('In last 1 day', 'notificationx'),
305 '7days' => __('In last 7 days', 'notificationx'),
306 '30days' => __('In last 30 days', 'notificationx'),
307 'post_comment' => 'Lorem Ipsum is simply dummy text...',
308 // 'select_a_tag' => 'Jhon',
309
310 ];
311
312 if (!empty($settings['custom_contents']) && is_array($settings['custom_contents']) && count($settings['custom_contents'])) {
313 $custom = !empty($settings['custom_contents'][0]) ? $settings['custom_contents'][0] : [];
314 if (isset($custom['first_name'], $custom['last_name'])) {
315 $custom['name'] = Helper::name($custom['first_name'], $custom['last_name']);
316 }
317 $defaults = array_merge($defaults, $custom);
318 }
319
320 $settings['freemius_plugins'] = '';
321
322 $defaults['image_data'] = FrontEnd::get_instance()->apply_defaults((array) FrontEnd::get_instance()->get_image_url($defaults, $settings), $defaults['image_data']);
323
324 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
325 $defaults = apply_filters("nx_preview_entry_$type", $defaults, $settings);
326 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
327 $defaults = apply_filters("nx_preview_entry_$source", $defaults, $settings);
328 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
329 $_defaults = apply_filters("nx_fallback_data_$source", $defaults, $defaults, $settings);
330 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
331 $_defaults = apply_filters('nx_fallback_data', $_defaults, $_defaults, $settings);
332 $defaults = FrontEnd::get_instance()->apply_defaults($defaults, $_defaults);
333 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
334 $defaults = apply_filters("nx_filtered_entry_$type", $defaults, $settings);
335 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
336 $defaults = apply_filters("nx_filtered_entry_$source", $defaults, $settings);
337 // $defaults = $this->link_url($defaults, $settings);
338 if (strpos($settings['theme'], 'maps_theme') !== false && 'maps_image' === $settings['show_notification_image']) {
339 $defaults['image_data'] = array(
340 'url' => NOTIFICATIONX_ASSETS . 'admin/images/map.jpg',
341 'alt' => '',
342 'classes' => 'greview_icon',
343 );
344 }
345 if ('gravatar' === $settings['show_notification_image']) {
346 $defaults['image_data'] = array(
347 'url' => NOTIFICATIONX_PUBLIC_URL . 'image/icons/pink-face-looped.gif',
348 'alt' => '',
349 'classes' => 'greview_icon',
350 );
351 }
352 if ('none' === $settings['show_notification_image'] && !$settings['show_default_image']) {
353 $defaults['image_data'] = false;
354 }
355 return $defaults;
356 }
357
358 public function get_settings() {
359 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reviewed for the NotificationX codebase: acceptable in this context.
360 if ( empty($_POST['nx-preview']) ) {
361 return array();
362 }
363
364 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reviewed for the NotificationX codebase: acceptable in this context.
365 $settings = base64_decode( sanitize_text_field( wp_unslash( $_POST['nx-preview'] ) ), true );
366 $settings = json_decode( $settings, true );
367
368 if ( ! is_array($settings) ) {
369 return array();
370 }
371
372 // Simple sanitization
373 array_walk_recursive( $settings, function ( &$value ) {
374 if ( is_string( $value ) ) {
375 $value = wp_strip_all_tags( $value );
376 }
377 });
378
379 return $settings;
380 }
381
382 public function preview_settings($settings = []) {
383 $settings = !empty($settings) ? $settings : $this->get_settings();
384
385 if (empty($settings['source'])){
386 return [];
387 }
388
389 if ($settings['global_queue']) {
390 $settings['global_queue'] = false;
391 $settings['_global_queue'] = true;
392 }
393 $settings['nx_id'] = wp_rand();
394 $settings['is_preview'] = true;
395 if (empty($settings['theme']) && !empty($settings['themes'])) {
396 $settings['theme'] = $settings['themes'];
397 }
398 if ('form' === $settings['type']) {
399 $settings['notification-template']['first_param'] = 'tag_first_name';
400 }
401 if( !empty( $settings['notification-template'] ) ) {
402 $settings['notification-template'] = array_map( 'esc_html', $settings['notification-template'] );
403 }
404
405 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
406 $settings = apply_filters("nx_get_post_{$settings['source']}", $settings);
407 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
408 $settings = apply_filters("nx_preview_settings_{$settings['source']}", $settings);
409 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
410 $settings = apply_filters('nx_get_post', $settings);
411 return $settings;
412 }
413
414 public function content_heading($tabs) {
415 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
416 $urls = apply_filters('nx_preview_url', [
417 'default' => trailingslashit(home_url()),
418 ]);
419
420 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
421 $tabs['config']['content_heading']['talk_to_support'] = apply_filters('talk_to_support', [
422 'text' => __('Talk to Support', 'notificationx'),
423 'classes' => 'nx-talk-to-support',
424 'type' => 'button',
425 'name' => 'talk_to_support',
426 'target' => '_blank',
427 'href' => esc_url('https://notificationx.com/support/?support=chat'),
428 ]);
429 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
430 $tabs['config']['content_heading']['preview'] = apply_filters('nx_content_heading_preview', [
431 'label' => __('Preview', 'notificationx'),
432 'type' => 'preview-modal',
433 'name' => 'preview',
434 'urls' => $urls,
435 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
436 'errors' => apply_filters('nx_content_heading_preview_errors', []),
437 'rules' => Rules::logicalRule([
438 Rules::includes('themes', ['woo_inline_stock-theme-two', 'tutor_inline_conv-theme-eight', 'flashing_tab_theme-1','flashing_tab_theme-2' ,'flashing_tab_theme-3' , 'flashing_tab_theme-4','woocommerce_sales_inline_stock-theme-two','learnpress_inline_conv-theme-eight'], true),
439 Rules::is('type', 'notification_bar', true),
440 ]),
441 ]);
442 return $tabs;
443 }
444
445 public function inline_notifications_data($return, $source, $id, $settings = []) {
446 if ($this->is_preview() && !empty($id)) {
447 $settings = $this->preview_settings($settings);
448 $settings['is_preview'] = true;
449
450 if ( ( empty($settings['source']) || empty($settings['type']) || 'inline' !== $settings['type']) && ('woocommerce_sales_inline' !== $settings['source']) ){
451 return;
452 }
453
454 remove_filter('nx_inline_notifications_data', [$this, 'inline_notifications_data'], 10);
455
456 $source = !empty($settings['source']) ? $settings['source'] : '';
457 $type = !empty($settings['type']) ? $settings['type'] : '';
458 $settings['inline_location'] = is_array($settings['inline_location']) ? $settings['inline_location'] : [];
459 $settings['inline_location'][] = 'woocommerce_before_add_to_cart_form';
460
461 $defaults = [
462 "nx_id" => wp_rand(),
463 "entry_id" => 78,
464 "order_id" => 96,
465 "product_id" => $id,
466 "id" => $id,
467 // "status" => "wc-pending",
468 "title" => get_the_title($id),
469 "product_title" => get_the_title($id),
470 "link" => "#",
471 "timestamp" => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
472 // "first_name" => "John",
473 // "last_name" => "Doe",
474 // "name" => "John Doe",
475 "email" => "support@wpdeveloper.com",
476 "source" => $source,
477 "entry_key" => "96-7",
478 "created_at" => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
479 "updated_at" => gmdate('Y-m-d H:i:s', strtotime('2 days ago')),
480 "none" => "",
481 // "anonymous_title" => "Anonymous Product",
482 // "sometime" => "Some time ago",
483 "sales_count" => wp_rand(50, 70),
484 "donation_count" => wp_rand(50, 70),
485 // "30days" => "in last 30 days",
486 // "day:30" => "30 days",
487 // "1day" => "in last 1 day",
488 // "7days" => "in last 7 days",
489 ];
490
491
492 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
493 $_defaults = apply_filters("nx_fallback_data_$source", $defaults, $defaults, $settings);
494 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
495 $_defaults = apply_filters('nx_fallback_data', $_defaults, $_defaults, $settings);
496 $defaults = FrontEnd::get_instance()->apply_defaults($defaults, $_defaults);
497 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
498 $defaults = apply_filters("nx_preview_entry_$type", $defaults, $settings);
499 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
500 $defaults = apply_filters("nx_preview_entry_$source", $defaults, $settings);
501 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
502 $defaults = apply_filters("nx_filtered_entry_$type", $defaults, $settings);
503 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
504 $defaults = apply_filters("nx_filtered_entry_$source", $defaults, $settings);
505
506 return [
507 'shortcode' => [
508 [
509 "entries" => [$defaults],
510 "post" => $settings,
511 ],
512 ],
513 ];
514 }
515
516 return $return;
517 }
518
519 public function is_preview() {
520 $is_preview = false;
521 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reviewed for the NotificationX codebase: acceptable in this context.
522 if (!empty($_POST['nx-preview'])) {
523 $is_preview = true;
524 }
525 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
526 $is_preview = apply_filters('nx_is_preview',$is_preview);
527 return $is_preview;
528 }
529 }
530