| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.1.23 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2024 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\Admin; |
| @@ -24,99 +24,12 @@ | ||
| 24 | 24 | { |
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - add_action('enqueue_block_editor_assets', [$this, 'block_editor_only_assets']); | |
| 29 | - | |
| 30 | 28 | add_action('enqueue_block_assets', [$this, 'enqueue_block_assets']); |
| 31 | - | |
| 32 | - add_filter('block_editor_settings_all', [$this, 'filterBlockEditorSettings'], 10, 2); | |
| 33 | 29 | } |
| 34 | 30 | |
| 35 | 31 | /** |
| 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 | 32 | * Loads Gutenberg editor assets |
| 120 | 33 | * |
| 121 | 34 | * @return void |
| 122 | 35 | */ |
| @@ -132,11 +45,8 @@ | ||
| 132 | 45 | { |
| 133 | 46 | $screen = get_current_screen(); |
| 134 | 47 | if ($screen->is_block_editor) |
| 135 | 48 | { |
| 136 | - wp_enqueue_code_editor(['type' => 'text/css']); | |
| 137 | - wp_enqueue_code_editor(['type' => 'javascript']); | |
| 138 | - | |
| 139 | 49 | // Add the block editor styling for our blocks |
| 140 | 50 | wp_enqueue_style( |
| 141 | 51 | 'firebox-blocks-editor-styles', |
| 142 | 52 | FBOX_MEDIA_ADMIN_URL . 'css/admin/blocks.css', |
| @@ -147,123 +57,59 @@ | ||
| 147 | 57 | // Add the FireBox block editor script only to FireBox post type |
| 148 | 58 | if (get_post_type() === 'firebox') |
| 149 | 59 | { |
| 150 | 60 | wp_enqueue_script( |
| 151 | - 'firebox-gutenberg-store', | |
| 152 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/gutenberg_store.js', | |
| 153 | - ['wp-data'], | |
| 61 | + 'firebox-block-editor', | |
| 62 | + FBOX_MEDIA_ADMIN_URL . 'js/block-editor.js', | |
| 63 | + ['wp-edit-post', 'wp-plugins', 'wp-i18n'], | |
| 154 | 64 | FBOX_VERSION, |
| 155 | 65 | true |
| 156 | 66 | ); |
| 157 | 67 | |
| 158 | - // FireBox main CSS file | |
| 159 | - wp_enqueue_style( | |
| 160 | - 'firebox', | |
| 161 | - FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css', | |
| 68 | + | |
| 69 | + wp_enqueue_script( | |
| 70 | + 'firebox-slotfills-free', | |
| 71 | + FBOX_MEDIA_ADMIN_URL . 'js/blocks/slotfills/free.js', | |
| 162 | 72 | [], |
| 163 | - FBOX_VERSION | |
| 73 | + FBOX_VERSION, | |
| 74 | + true | |
| 164 | 75 | ); |
| 165 | 76 | |
| 166 | - wp_enqueue_style( | |
| 167 | - 'firebox-animations', | |
| 168 | - FBOX_MEDIA_PUBLIC_URL . 'css/vendor/animate.min.css', | |
| 77 | + wp_enqueue_script( | |
| 78 | + 'firebox-upgrade-cta-header', | |
| 79 | + FBOX_MEDIA_ADMIN_URL . 'js/blocks/free.js', | |
| 169 | 80 | [], |
| 170 | - FBOX_VERSION | |
| 81 | + FBOX_VERSION, | |
| 82 | + true | |
| 171 | 83 | ); |
| 84 | + | |
| 172 | 85 | |
| 173 | - wp_enqueue_style( | |
| 174 | - 'firebox-block-editor', | |
| 175 | - FBOX_MEDIA_ADMIN_URL . 'css/block-editor.css', | |
| 86 | + wp_enqueue_script( | |
| 87 | + 'firebox-campaign-editor-toolbar', | |
| 88 | + FBOX_MEDIA_ADMIN_URL . 'js/blocks/toolbar.js', | |
| 176 | 89 | [], |
| 177 | - FBOX_VERSION | |
| 90 | + FBOX_VERSION, | |
| 91 | + true | |
| 178 | 92 | ); |
| 179 | 93 | |
| 180 | - // Load the Phone Number widget styles on this hook so WordPress injects | |
| 181 | - // them into the editor iframe canvas (enqueue_block_editor_assets does not). | |
| 182 | - \FPFramework\Base\Widgets\PhoneNumber::register_assets(); | |
| 183 | - wp_enqueue_style('fpframework-widget'); | |
| 184 | - wp_enqueue_style('fpframework-phonenumber-widget'); | |
| 185 | - | |
| 186 | 94 | wp_enqueue_script( |
| 187 | 95 | 'firebox-editor', |
| 188 | 96 | FBOX_MEDIA_ADMIN_URL . 'js/blocks/editor.js', |
| 189 | - ['wp-edit-post'], | |
| 190 | - FBOX_VERSION, | |
| 191 | - false | |
| 192 | - ); | |
| 193 | - | |
| 194 | - wp_enqueue_script( | |
| 195 | - 'firebox-slotfills-general', | |
| 196 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/slotfills/general.js', | |
| 197 | 97 | [], |
| 198 | 98 | FBOX_VERSION, |
| 199 | 99 | true |
| 200 | 100 | ); |
| 201 | - | |
| 202 | - // Required for ProOnlyButton hover icon swap (closed/open lock) across plans. | |
| 203 | - wp_enqueue_style( | |
| 204 | - 'firebox-editor-free', | |
| 205 | - FBOX_MEDIA_ADMIN_URL . 'css/editor-free.css', | |
| 206 | - [], | |
| 207 | - FBOX_VERSION | |
| 208 | - ); | |
| 209 | - | |
| 210 | - if ($this->shouldLoadFreeUpgradeModalsScript()) | |
| 211 | - { | |
| 212 | - wp_enqueue_script( | |
| 213 | - 'firebox-plugins-free-modals', | |
| 214 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/plugins/free-modals.js', | |
| 215 | - [], | |
| 216 | - FBOX_VERSION, | |
| 217 | - true | |
| 218 | - ); | |
| 219 | - } | |
| 220 | - | |
| 221 | 101 | |
| 222 | - if (FBOX_LICENSE_TYPE === 'lite') | |
| 223 | - { | |
| 224 | - wp_enqueue_script( | |
| 225 | - 'firebox-slotfills-free', | |
| 226 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/slotfills/free.js', | |
| 227 | - [], | |
| 228 | - FBOX_VERSION, | |
| 229 | - true | |
| 230 | - ); | |
| 231 | - } | |
| 232 | 102 | |
| 233 | - | |
| 234 | - | |
| 235 | 103 | } |
| 236 | 104 | |
| 105 | + | |
| 106 | + | |
| 107 | + $data = [ | |
| 108 | + 'google_fonts' => \FPFramework\Libs\GoogleFonts::getFonts(), | |
| 109 | + 'google_fonts_names' => \FPFramework\Libs\GoogleFonts::getFontsNames(), | |
| 110 | + 'icons' => \FireBox\Core\Libs\Icons::getAll(), | |
| 237 | 111 | |
| 238 | - | |
| 239 | - $integrations_registry = \FireBox\Core\Helpers\Integrations::getFormEditorIntegrationsRegistry(); | |
| 240 | - $integration_connections = []; | |
| 241 | - foreach ($integrations_registry as $integration) | |
| 242 | - { | |
| 243 | - if (!is_array($integration) || empty($integration['slug'])) | |
| 244 | - { | |
| 245 | - continue; | |
| 246 | - } | |
| 247 | - | |
| 248 | - $integration_connections[$integration['slug']] = !empty($integration['connected']); | |
| 249 | - } | |
| 250 | - | |
| 251 | - $data = [ | |
| 252 | - 'google_fonts' => \FPFramework\Libs\GoogleFonts::getFonts(), | |
| 253 | - 'google_fonts_names' => \FPFramework\Libs\GoogleFonts::getFontsNames(), | |
| 254 | - 'icons' => \FireBox\Core\Libs\Icons::getAll(), | |
| 255 | - 'turnstile_site_key' => \FireBox\Core\Helpers\Captcha\Turnstile::getSiteKey(), | |
| 256 | - 'has_turnstile_secret_key' => (string) \FireBox\Core\Helpers\Captcha\Turnstile::getSecretKey() !== '', | |
| 257 | - 'hcaptcha_site_key' => \FireBox\Core\Helpers\Captcha\HCaptcha::getSiteKey(), | |
| 258 | - 'has_hcaptcha_secret_key' => (string) \FireBox\Core\Helpers\Captcha\HCaptcha::getSecretKey() !== '', | |
| 259 | - 'settings_url' => admin_url('admin.php?page=firebox-settings'), | |
| 260 | - 'integrations_registry' => $integrations_registry, | |
| 261 | - 'integration_connections' => $integration_connections, | |
| 262 | - 'license_type' => defined('FBOX_LICENSE_TYPE') ? FBOX_LICENSE_TYPE : '', | |
| 263 | - 'license_plan' => defined('FBOX_LICENSE_PLAN') ? FBOX_LICENSE_PLAN : '', | |
| 264 | - 'media_url' => FBOX_MEDIA_URL, | |
| 265 | - | |
| 266 | 112 | ]; |
| 267 | 113 | |
| 268 | 114 | wp_register_script('firebox-block-editor-script', false); |
| 269 | 115 | wp_enqueue_script('firebox-block-editor-script'); |
| @@ -270,13 +116,5 @@ | ||
| 270 | 116 | wp_localize_script('firebox-block-editor-script', 'fbox_block_editor_object', $data); |
| 271 | 117 | } |
| 272 | 118 | } |
| 273 | 119 | } |
| 274 | - | |
| 275 | - private function shouldLoadFreeUpgradeModalsScript() | |
| 276 | - { | |
| 277 | - $license_type = defined('FBOX_LICENSE_TYPE') ? strtolower(trim((string) FBOX_LICENSE_TYPE)) : ''; | |
| 278 | - $license_plan = defined('FBOX_LICENSE_PLAN') ? strtolower(trim((string) FBOX_LICENSE_PLAN)) : ''; | |
| 279 | - | |
| 280 | - return $license_type === 'lite' || in_array($license_plan, ['free', 'basic'], true); | |
| 281 | - } | |
| 282 | -} | |
| 120 | +} | |