get_all_registered(); foreach ( $block_patterns as $block_pattern ) { if ( ! isset( $block_pattern['categories'] ) ) { continue; } foreach ( $block_pattern['categories'] as $category ) { $categories = wp_list_pluck( WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(), 'name' ); if ( in_array( $category, $categories ) ) { continue; } register_block_pattern_category( $category, [ 'label' => ucfirst( $category ), ] ); } } }