PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.7
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.7
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 / Admin / Media.php

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

277 lines 6.9 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.7 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\Admin;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Media
20 {
21 public function __construct()
22 {
23 if (!is_admin())
24 {
25 return;
26 }
27
28 add_action('enqueue_block_editor_assets', [$this, 'block_editor_only_assets']);
29
30 add_action('enqueue_block_assets', [$this, 'enqueue_block_assets']);
31
32 add_filter('block_editor_settings_all', [$this, 'filterBlockEditorSettings'], 10, 2);
33 }
34
35 /**
36 * Disable template mode for FireBox campaigns.
37 *
38 * @param array $settings
39 * @param mixed $editor_context
40 *
41 * @return array
42 */
43 public function filterBlockEditorSettings($settings, $editor_context)
44 {
45 if (!is_admin() || !is_array($settings))
46 {
47 return $settings;
48 }
49
50 if (
51 !is_object($editor_context) ||
52 !property_exists($editor_context, 'post') ||
53 !is_object($editor_context->post) ||
54 !property_exists($editor_context->post, 'post_type') ||
55 $editor_context->post->post_type !== 'firebox'
56 )
57 {
58 return $settings;
59 }
60
61 $settings['supportsTemplateMode'] = false;
62
63 return $settings;
64 }
65
66 public function block_editor_only_assets()
67 {
68 if (!is_admin())
69 {
70 return;
71 }
72
73 // Enqueue block editor script only in Gutenberg editor
74 if (function_exists('get_current_screen'))
75 {
76 $screen = get_current_screen();
77 if ($screen->is_block_editor)
78 {
79 wp_enqueue_script(
80 'firebox-gutenberg-store',
81 FBOX_MEDIA_ADMIN_URL . 'js/blocks/gutenberg_store.js',
82 ['wp-data'],
83 FBOX_VERSION,
84 true
85 );
86
87 // Required for ProOnlyButton hover icon swap (closed/open lock) across plans.
88 wp_enqueue_style(
89 'firebox-editor-free',
90 FBOX_MEDIA_ADMIN_URL . 'css/editor-free.css',
91 [],
92 FBOX_VERSION
93 );
94
95 if ($this->shouldLoadFreeUpgradeModalsScript())
96 {
97 wp_enqueue_script(
98 'firebox-plugins-free-modals',
99 FBOX_MEDIA_ADMIN_URL . 'js/blocks/plugins/free-modals.js',
100 [],
101 FBOX_VERSION,
102 true
103 );
104 }
105
106 if (FBOX_LICENSE_TYPE === 'lite')
107 {
108 wp_enqueue_script('firebox-blocks-free', FBOX_MEDIA_ADMIN_URL . 'js/blocks/blocks-free.js', [], FBOX_VERSION, true);
109 }
110 else if (FBOX_LICENSE_TYPE === 'pro')
111 {
112 wp_enqueue_script('firebox-blocks-pro', FBOX_MEDIA_ADMIN_URL . 'js/blocks/blocks-pro.js', [], FBOX_VERSION, true);
113 }
114 }
115 }
116 }
117
118 /**
119 * Loads Gutenberg editor assets
120 *
121 * @return void
122 */
123 public function enqueue_block_assets()
124 {
125 if (!is_admin())
126 {
127 return;
128 }
129
130 // Enqueue block editor script only in Gutenberg editor
131 if (function_exists('get_current_screen'))
132 {
133 $screen = get_current_screen();
134 if ($screen->is_block_editor)
135 {
136 wp_enqueue_code_editor(['type' => 'text/css']);
137 wp_enqueue_code_editor(['type' => 'javascript']);
138
139 // Add the block editor styling for our blocks
140 wp_enqueue_style(
141 'firebox-blocks-editor-styles',
142 FBOX_MEDIA_ADMIN_URL . 'css/admin/blocks.css',
143 [],
144 FBOX_VERSION
145 );
146
147 // Add the FireBox block editor script only to FireBox post type
148 if (get_post_type() === 'firebox')
149 {
150 wp_enqueue_script(
151 'firebox-gutenberg-store',
152 FBOX_MEDIA_ADMIN_URL . 'js/blocks/gutenberg_store.js',
153 ['wp-data'],
154 FBOX_VERSION,
155 true
156 );
157
158 // FireBox main CSS file
159 wp_enqueue_style(
160 'firebox',
161 FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css',
162 [],
163 FBOX_VERSION
164 );
165
166 wp_enqueue_style(
167 'firebox-animations',
168 FBOX_MEDIA_PUBLIC_URL . 'css/vendor/animate.min.css',
169 [],
170 FBOX_VERSION
171 );
172
173 wp_enqueue_style(
174 'firebox-block-editor',
175 FBOX_MEDIA_ADMIN_URL . 'css/block-editor.css',
176 [],
177 FBOX_VERSION
178 );
179
180 wp_enqueue_script(
181 'firebox-editor',
182 FBOX_MEDIA_ADMIN_URL . 'js/blocks/editor.js',
183 ['wp-edit-post'],
184 FBOX_VERSION,
185 false
186 );
187
188 wp_enqueue_script(
189 'firebox-slotfills-general',
190 FBOX_MEDIA_ADMIN_URL . 'js/blocks/slotfills/general.js',
191 [],
192 FBOX_VERSION,
193 true
194 );
195
196 // Required for ProOnlyButton hover icon swap (closed/open lock) across plans.
197 wp_enqueue_style(
198 'firebox-editor-free',
199 FBOX_MEDIA_ADMIN_URL . 'css/editor-free.css',
200 [],
201 FBOX_VERSION
202 );
203
204 if ($this->shouldLoadFreeUpgradeModalsScript())
205 {
206 wp_enqueue_script(
207 'firebox-plugins-free-modals',
208 FBOX_MEDIA_ADMIN_URL . 'js/blocks/plugins/free-modals.js',
209 [],
210 FBOX_VERSION,
211 true
212 );
213 }
214
215
216 if (FBOX_LICENSE_TYPE === 'lite')
217 {
218 wp_enqueue_script(
219 'firebox-slotfills-free',
220 FBOX_MEDIA_ADMIN_URL . 'js/blocks/slotfills/free.js',
221 [],
222 FBOX_VERSION,
223 true
224 );
225 }
226
227
228
229 }
230
231
232
233 $integrations_registry = \FireBox\Core\Helpers\Integrations::getFormEditorIntegrationsRegistry();
234 $integration_connections = [];
235 foreach ($integrations_registry as $integration)
236 {
237 if (!is_array($integration) || empty($integration['slug']))
238 {
239 continue;
240 }
241
242 $integration_connections[$integration['slug']] = !empty($integration['connected']);
243 }
244
245 $data = [
246 'google_fonts' => \FPFramework\Libs\GoogleFonts::getFonts(),
247 'google_fonts_names' => \FPFramework\Libs\GoogleFonts::getFontsNames(),
248 'icons' => \FireBox\Core\Libs\Icons::getAll(),
249 'turnstile_site_key' => \FireBox\Core\Helpers\Captcha\Turnstile::getSiteKey(),
250 'turnstile_secret_key' => \FireBox\Core\Helpers\Captcha\Turnstile::getSecretKey(),
251 'hcaptcha_site_key' => \FireBox\Core\Helpers\Captcha\HCaptcha::getSiteKey(),
252 'hcaptcha_secret_key' => \FireBox\Core\Helpers\Captcha\HCaptcha::getSecretKey(),
253 'settings_url' => admin_url('admin.php?page=firebox-settings'),
254 'integrations_registry' => $integrations_registry,
255 'integration_connections' => $integration_connections,
256 'license_type' => defined('FBOX_LICENSE_TYPE') ? FBOX_LICENSE_TYPE : '',
257 'license_plan' => defined('FBOX_LICENSE_PLAN') ? FBOX_LICENSE_PLAN : '',
258 'media_url' => FBOX_MEDIA_URL,
259
260 ];
261
262 wp_register_script('firebox-block-editor-script', false);
263 wp_enqueue_script('firebox-block-editor-script');
264 wp_localize_script('firebox-block-editor-script', 'fbox_block_editor_object', $data);
265 }
266 }
267 }
268
269 private function shouldLoadFreeUpgradeModalsScript()
270 {
271 $license_type = defined('FBOX_LICENSE_TYPE') ? strtolower(trim((string) FBOX_LICENSE_TYPE)) : '';
272 $license_plan = defined('FBOX_LICENSE_PLAN') ? strtolower(trim((string) FBOX_LICENSE_PLAN)) : '';
273
274 return $license_type === 'lite' || in_array($license_plan, ['free', 'basic'], true);
275 }
276 }
277