| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -19,25 +19,12 @@ | ||
| 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 | - | |
| 28 | 23 | add_action('enqueue_block_assets', [$this, 'blocks_assets']); |
| 29 | 24 | |
| 30 | 25 | // Register categories |
| 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 | - } | |
| 26 | + add_filter('block_categories_all', [$this, 'register_categories'], 10, 2); | |
| 40 | 27 | |
| 41 | 28 | $this->register_blocks(); |
| 42 | 29 | } |
| 43 | 30 | |
| @@ -70,13 +57,21 @@ | ||
| 70 | 57 | */ |
| 71 | 58 | public function register_blocks() |
| 72 | 59 | { |
| 73 | 60 | $ds = DIRECTORY_SEPARATOR; |
| 74 | - | |
| 61 | + | |
| 75 | 62 | $base_dir = implode($ds, [__DIR__, 'Blocks']); |
| 76 | - | |
| 77 | - $files = array_diff(scandir($base_dir), ['.', '..', '.DS_Store', 'index.php', 'Block.php']); | |
| 78 | - | |
| 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 | + | |
| 79 | 74 | $namespace = '\FireBox\Core\Blocks\\'; |
| 80 | 75 | |
| 81 | 76 | foreach ($files as $item) |
| 82 | 77 | { |