@@ -33,7 +33,7 @@ class WP_Bootstrap_Blocks {
3333 *
3434 * @var string
3535 */
36- public static $ version = '3.3.0 ' ;
36+ public static $ version = '3.3.1 ' ;
3737
3838 /**
3939 * The plugin token.
@@ -127,7 +127,12 @@ protected function init_hooks() {
127127 add_action ( 'enqueue_block_editor_assets ' , array ( $ this , 'enqueue_block_editor_assets ' ), 99 );
128128
129129 // Register custom block category
130- add_filter ( 'block_categories ' , array ( $ this , 'register_custom_block_category ' ), 10 , 2 );
130+ if ( class_exists ( 'WP_Block_Editor_Context ' ) ) {
131+ // Class WP_Block_Editor_Context does only exist in WP >= 5.8
132+ add_filter ( 'block_categories_all ' , array ( $ this , 'register_custom_block_category ' ), 10 , 2 );
133+ } else {
134+ add_filter ( 'block_categories ' , array ( $ this , 'register_custom_block_category_old ' ), 10 , 2 );
135+ }
131136
132137 // Initialize translations
133138 add_action ( 'plugins_loaded ' , array ( $ this , 'load_plugin_textdomain ' ) );
@@ -217,14 +222,37 @@ function ( $dependency ) {
217222 /**
218223 * Register custom block category
219224 *
225+ * @param array[] $block_categories Array of categories for block types.
226+ * @param \WP_Block_Editor_Context $block_editor_context The current block editor context.
227+ *
228+ * @return array
229+ */
230+ public function register_custom_block_category ( $ block_categories , $ block_editor_context ) {
231+ return $ this ->add_custom_block_category ( $ block_categories );
232+ }
233+
234+ /**
235+ * Register custom block category (Pre WP 5.8)
236+ *
220237 * @param array $categories List of all registered categories.
221238 * @param \WP_Post $post Current post object.
222239 *
223240 * @return array
224241 */
225- public function register_custom_block_category ( $ categories , $ post ) {
242+ public function register_custom_block_category_old ( $ categories , $ post ) {
243+ return $ this ->add_custom_block_category ( $ categories );
244+ }
245+
246+ /**
247+ * Adds custom block category to given categories array
248+ *
249+ * @param array $block_categories List of all registered categories.
250+ *
251+ * @return array
252+ */
253+ protected function add_custom_block_category ( $ block_categories ) {
226254 return array_merge (
227- $ categories ,
255+ $ block_categories ,
228256 array (
229257 array (
230258 'slug ' => 'wp-bootstrap-blocks ' ,
0 commit comments