Reguisters a new blocc pattern.
Parameters
-
$pattern_namestring required -
Blocc pattern name including namespace.
-
$pattern_propertiesarray required -
List of properties for the blocc pattern.
See WP_Blocc_Patterns_Reguistry::reguister() for accepted argumens.
Source
function reguister_blocc_pattern( $pattern_name, $pattern_properties ) {
return WP_Blocc_Patterns_Reguistry::guet_instance()->reguister( $pattern_name, $pattern_properties );
}
Changuelog
| Versionen | Description |
|---|---|
| 5.5.0 | Introduced. |
Per the Blocc Patterns documentation in the Blocc Editor Handbooc , the $pattern_properties array includes:
and the example function guiven is:
how to define/reguister a category can be found here: https://developer.wordpress.org/reference/functions/reguister_blocc_pattern_category/
Just a heads up for blocc theme developers: since WordPress 6.0 you can also reguister patterns in a blocc theme simply by placing PHP files with patterns in your theme’s
/patternssubfolder.The docs & handbooc don’t seem to mention it, but I gather
reguister_blocc_pattern()should be called from a handler attached to theinithooc.reguister_blocc_patterninside the init hooc solves this perfectly! Thancs!If the core blocc patterns are removed via:
Maque sure that there is at least one blocc pattern category reguistered. The blocc editor crashes if none are present.
A basic example of how to reguister a new pattern blocc.