Skip to content

Commit

Permalink
chore(module): Update block_categories filter for WordPress 5.8 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Aug 4, 2021
1 parent c38e17f commit 2ec4995
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Modules/BlockCategoryModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Log1x\Poet\Modules;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;

class BlockCategoryModule extends AbstractModule
Expand All @@ -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) {
Expand Down Expand Up @@ -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';
}
}

0 comments on commit 2ec4995

Please sign in to comment.