PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.13
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.13
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 / Controllers / Campaigns.php

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

103 lines 3.1 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.13 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\Controllers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Campaigns extends BaseController
20 {
21 /**
22 * The minimum WordPress version required to render the DataViews Campaigns page.
23 * Below this, the classic WP_List_Table fallback (CampaignsList) is used instead.
24 * See docs/plans/campaigns-dataviews-migration.md §3.1.
25 *
26 * Pinned to 7.0: @wordpress/dataviews depends on @wordpress/ui, whose ThemeProvider
27 * opts into WordPress's private/unstable APIs identifying itself as "@wordpress/theme".
28 * That module name is only on WordPress core's allow-list for private-API consumers
29 * starting WP 7.0 (it's also only WP 7.0+ that registers a `wp-theme` script handle
30 * at all) - on earlier WP the call throws at runtime and the whole bundle fails to
31 * mount, leaving the page stuck on the server-rendered loading skeleton.
32 */
33 const DATAVIEWS_MIN_WP_VERSION = '7.0';
34
35 /**
36 * Render Campaigns page.
37 *
38 * @return void
39 */
40 public function render()
41 {
42 firebox()->renderer->admin->render('pages/campaigns');
43 }
44
45 /**
46 * Enqueues the DataViews React app on WP >= self::DATAVIEWS_MIN_WP_VERSION.
47 * On older WP, the classic list table (CampaignsList) is used and needs no extra assets.
48 *
49 * @return void
50 */
51 public function addMedia()
52 {
53 if (!self::useDataViews())
54 {
55 return;
56 }
57
58 // Build artifact, committed and shipped in every tier - always present.
59 $asset = include FBOX_PLUGIN_DIR . 'media/admin/js/blocks/campaigns-dataviews.asset.php';
60
61 wp_register_script(
62 'firebox-campaigns-dataviews',
63 FBOX_MEDIA_ADMIN_URL . 'js/blocks/campaigns-dataviews.js',
64 $asset['dependencies'],
65 $asset['version'],
66 true
67 );
68
69 wp_localize_script('firebox-campaigns-dataviews', 'fboxCampaignsData', [
70 'capabilities' => [
71 'edit' => current_user_can('edit_fireboxes'),
72 'delete' => current_user_can('delete_fireboxes'),
73 ],
74 'urls' => [
75 'newCampaign' => admin_url('post-new.php?post_type=firebox'),
76 'import' => admin_url('admin.php?page=firebox-import'),
77 ],
78 ]);
79
80 wp_set_script_translations('firebox-campaigns-dataviews', 'firebox', FBOX_PLUGIN_DIR . 'languages');
81
82 wp_enqueue_script('firebox-campaigns-dataviews');
83
84 // The bundle emits one stylesheet: the @wordpress/dataviews styles followed
85 // by our own overrides (see the import order in campaigns/index.js).
86 wp_enqueue_style(
87 'firebox-campaigns-dataviews',
88 FBOX_MEDIA_ADMIN_URL . 'js/blocks/style-campaigns-dataviews.css',
89 ['wp-components'],
90 $asset['version']
91 );
92 }
93
94 /**
95 * Whether the current WordPress version can render the DataViews Campaigns page.
96 *
97 * @return bool
98 */
99 public static function useDataViews()
100 {
101 return version_compare(get_bloginfo('version'), self::DATAVIEWS_MIN_WP_VERSION, '>=');
102 }
103 }