diff --git a/src/Modules/BlockCategoryModule.php b/src/Modules/BlockCategoryModule.php index 2eb194b..5a17130 100644 --- a/src/Modules/BlockCategoryModule.php +++ b/src/Modules/BlockCategoryModule.php @@ -2,6 +2,7 @@ namespace Log1x\Poet\Modules; +use Illuminate\Support\Arr; use Illuminate\Support\Str; class BlockCategoryModule extends AbstractModule @@ -24,7 +25,7 @@ public function handle() return; } - add_filter('block_categories', function ($categories) { + add_filter($this->hook(), function ($categories) { $categories = $this->collect($categories)->keyBy('slug'); return $this->config->map(function ($value, $key) use ($categories) { @@ -68,4 +69,18 @@ public function handle() ->all(); }); } + + /** + * Retrieve the `block_categories` hook based on the current Wordpress version. + * + * @return string + */ + protected function hook() + { + return version_compare( + Arr::get($GLOBALS, 'wp_version'), + '5.8-beta0', + '<' + ) ? 'block_categories' : 'block_categories_all'; + } }