BlockPatternCategories
in package
BlockPatternCategories Registration class.
Facilitates the batch registration of block pattern categories by providing a simple and efficient method to define and register multiple categories at once. This class leverages the BlockPatternCategory module for each category's registration, ensuring that the process aligns with WordPress standards and practices.
Tags
Table of Contents
Methods
- set() : void
- Registers multiple block pattern categories in bulk.
Methods
set()
Registers multiple block pattern categories in bulk.
public
static set([array<string|int, mixed> $block_pattern_categories = [] ]) : void
This method streamlines the registration of block pattern categories by accepting an array of category definitions. Each definition specifies the category's properties and attributes, allowing for a comprehensive setup with minimal code.
Example usage:
BlockPatternCategories::set([
[
'category_name' => 'custom-category',
'category_properties' => [
'label' => __('Custom Category', 'text-domain'),
],
],
...
]);
Parameters
- $block_pattern_categories : array<string|int, mixed> = []
-
An array of block pattern category definitions. Each definition is an associative array that must include 'category_name' and may include 'category_properties' which is an array of properties for the category (e.g., label).