PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.9
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.9
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 1.1.1 All 122 releases
firebox / Inc / Core / Frontend.php

Frontend.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.9, at Inc/Core/Frontend.php

162 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.9 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Frontend
20 {
21 public function __construct()
22 {
23 // ensure we run only on front-end
24 if (is_admin())
25 {
26 return;
27 }
28
29 wp_register_script(
30 'firebox-main',
31 FBOX_MEDIA_PUBLIC_URL . 'js/firebox.js',
32 [],
33 FBOX_VERSION,
34 ['in_footer' => true, 'strategy' => 'defer']
35 );
36
37 // Prepare Gutenberg Blocks that contain attributes by FireBox
38 new \FireBox\Core\FB\BoxBlocksParser();
39
40 /**
41 * Event that runs before any rendering of popups.
42 */
43 do_action('firebox/boxes/before_render');
44
45 // Run Actions
46 \FireBox\Core\Helpers\Actions::run();
47
48 add_action('template_redirect', [$this, 'render']);
49
50 add_action('wp_enqueue_scripts', [$this, 'enqueueEmbedStylesEarly']);
51
52 /**
53 * Event that runs after popups have been rendered.
54 */
55 do_action('firebox/boxes/after_render');
56 }
57
58 /**
59 * Enqueues the embed-mode campaign CSS early (wp_enqueue_scripts, before wp_head closes)
60 * when the currently queried post/page contains an Embed Campaign block. This avoids a
61 * flash of unstyled content, since renderEmbed() otherwise only enqueues this CSS later,
62 * during content rendering.
63 *
64 * @return void
65 */
66 public function enqueueEmbedStylesEarly()
67 {
68 $post = get_queried_object();
69
70 if (!($post instanceof \WP_Post))
71 {
72 return;
73 }
74
75 if (!has_block('firebox/embed', $post))
76 {
77 return;
78 }
79
80 wp_enqueue_style(
81 'firebox',
82 FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css',
83 [],
84 FBOX_VERSION
85 );
86
87 wp_enqueue_style(
88 'fb-block-embed-campaign',
89 FBOX_MEDIA_PUBLIC_URL . 'css/blocks/embed-campaign.css',
90 [],
91 FBOX_VERSION
92 );
93 }
94
95 /**
96 * Renders all boxes on front-end
97 *
98 * @return void
99 */
100 public function render()
101 {
102 if ($this->checkForBoxPreview())
103 {
104 return;
105 }
106
107 // Don't render the popup if previewing with third party page builders
108 if (!$this->canRenderInEditors())
109 {
110 return;
111 }
112
113 /**
114 * Adds all boxes at the end of page.
115 */
116 firebox()->boxes->render();
117 }
118
119 /**
120 * Don't render when previewing with third party page builders.
121 *
122 * @return boolean
123 */
124 private function canRenderInEditors()
125 {
126 // Don't render the popup if previewing with Elementor
127 if (class_exists('\Elementor\Plugin') &&
128 property_exists(\Elementor\Plugin::$instance, 'preview') &&
129 method_exists(\Elementor\Plugin::$instance->preview, 'is_preview_mode') &&
130 \Elementor\Plugin::$instance->preview->is_preview_mode()
131 )
132 {
133 return;
134 }
135
136 // Don't render the popup if previewing with Beaver Builder
137 if (class_exists('\FLBuilderModel') && method_exists('\FLBuilderModel', 'is_builder_active') && \FLBuilderModel::is_builder_active())
138 {
139 return;
140 }
141
142 // Don't render the popup if previewing with Bricks Builder
143 if (function_exists('bricks_is_builder') && bricks_is_builder())
144 {
145 return;
146 }
147
148 return true;
149 }
150
151 /**
152 * Check if we are previewing a box and do not show other boxes.
153 *
154 * @return boolean
155 */
156 private function checkForBoxPreview()
157 {
158 $previewer = new Previewer();
159 return $previewer->init();
160 }
161 }
162