PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.0.12
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.0.12
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
← All changes | Inc/Core/Blocks.php +35 -8 1.0.112.0.12 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.11 Free
4 + * @version 2.0.12 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2022 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2023 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;
@@ -27,9 +27,17 @@
27 27
28 28 add_action('enqueue_block_editor_assets', [$this, 'blocks_assets']);
29 29
30 30 // Register categories
31 - add_filter('block_categories_all', [$this, 'register_categories'], 10, 2);
31 + global $wp_version;
32 + if (version_compare($wp_version, '5.8', '>='))
33 + {
34 + add_action('block_categories_all', [$this, 'register_categories'], 10, 2);
35 + }
36 + else
37 + {
38 + add_action('block_categories', [$this, 'register_categories'], 10, 2);
39 + }
32 40
33 41 $this->register_blocks();
34 42 }
35 43
@@ -79,9 +87,9 @@
79 87 $ds = DIRECTORY_SEPARATOR;
80 88
81 89 $base_dir = implode($ds, [__DIR__, 'Blocks']);
82 90
83 - $files = array_diff(scandir($base_dir), ['.', '..', 'index.php', 'Block.php']);
91 + $files = array_diff(scandir($base_dir), ['.', '..', '.DS_Store', 'index.php', 'Block.php']);
84 92
85 93 $namespace = '\FireBox\Core\Blocks\\';
86 94
87 95 foreach ($files as $item)
@@ -89,9 +97,10 @@
89 97 // Check if this is a single file and load it
90 98 $file = implode($ds, [$base_dir, $item]);
91 99 if (is_file($file))
92 100 {
93 - $this->registerBlock($namespace . rtrim($item, '.php'));
101 + $class_name = preg_replace('/.php$/', '', $item);
102 + $this->registerBlock($namespace . $class_name);
94 103 continue;
95 104 }
96 105
97 106 // If that's not a file, we assume it is a directory of files
@@ -98,9 +107,10 @@
98 107 $blocks = array_diff(scandir($file), ['.', '..', 'index.php']);
99 108
100 109 foreach ($blocks as $key => $block_name)
101 110 {
102 - $class = $namespace . $item . '\\' . rtrim($block_name, '.php');
111 + $class_name = preg_replace('/.php$/', '', $block_name);
112 + $class = $namespace . $item . '\\' . $class_name;
103 113 $this->registerBlock($class);
104 114 }
105 115 }
106 116 }
@@ -125,9 +135,9 @@
125 135 * It also allows us to set custom CSS Classes to these blocks without triggering a popup.
126 136 */
127 137 public function blocks_assets()
128 138 {
129 - wp_register_script(
139 + wp_enqueue_script(
130 140 'fb-blocks-extend',
131 141 FBOX_MEDIA_ADMIN_URL . 'js/fb_blocks_extend.js',
132 142 ['wp-i18n', 'wp-blocks', 'wp-editor', 'wp-components', 'wp-api-fetch'],
133 143 FBOX_VERSION,
@@ -132,7 +142,24 @@
132 142 ['wp-i18n', 'wp-blocks', 'wp-editor', 'wp-components', 'wp-api-fetch'],
133 143 FBOX_VERSION,
134 144 true
135 145 );
136 - wp_enqueue_script('fb-blocks-extend');
146 +
147 + // Enqueue block editor style only in Gutenberg editor
148 + if (function_exists('get_current_screen'))
149 + {
150 + $screen = get_current_screen();
151 + if ($screen->is_block_editor)
152 + {
153 + if (get_post_type() === 'firebox')
154 + {
155 + wp_enqueue_style(
156 + 'firebox-block-editor',
157 + FBOX_MEDIA_ADMIN_URL . 'css/block-editor.css',
158 + [],
159 + FBOX_VERSION
160 + );
161 + }
162 + }
163 + }
137 164 }
138 165 }