| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 3.0.1 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2025 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; |
| @@ -19,12 +19,25 @@ | ||
| 19 | 19 | class Blocks |
| 20 | 20 | { |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | + if (!function_exists('register_block_type')) | |
| 24 | + { | |
| 25 | + return; | |
| 26 | + } | |
| 27 | + | |
| 23 | 28 | add_action('enqueue_block_assets', [$this, 'blocks_assets']); |
| 24 | 29 | |
| 25 | 30 | // Register categories |
| 26 | - 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 | + } | |
| 27 | 40 | |
| 28 | 41 | $this->register_blocks(); |
| 29 | 42 | } |
| 30 | 43 | |
| @@ -57,21 +70,13 @@ | ||
| 57 | 70 | */ |
| 58 | 71 | public function register_blocks() |
| 59 | 72 | { |
| 60 | 73 | $ds = DIRECTORY_SEPARATOR; |
| 61 | - | |
| 74 | + | |
| 62 | 75 | $base_dir = implode($ds, [__DIR__, 'Blocks']); |
| 63 | - | |
| 64 | - $cache_key = 'firebox_block_files'; | |
| 65 | - $files = wp_cache_get($cache_key, 'firebox'); | |
| 66 | - | |
| 67 | - if ($files === false) | |
| 68 | - { | |
| 69 | - $files = array_diff(scandir($base_dir), ['.', '..', '.DS_Store', 'index.php', 'Block.php']); | |
| 70 | - | |
| 71 | - wp_cache_set($cache_key, $files, 'firebox', HOUR_IN_SECONDS); | |
| 72 | - } | |
| 73 | - | |
| 76 | + | |
| 77 | + $files = array_diff(scandir($base_dir), ['.', '..', '.DS_Store', 'index.php', 'Block.php']); | |
| 78 | + | |
| 74 | 79 | $namespace = '\FireBox\Core\Blocks\\'; |
| 75 | 80 | |
| 76 | 81 | foreach ($files as $item) |
| 77 | 82 | { |