Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Add filters for block patterns and pattern categories.
Browse files Browse the repository at this point in the history
  • Loading branch information
desrosj authored and jffng committed Nov 16, 2021
1 parent b585df3 commit 8282db5
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions inc/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,35 @@
* @since Twenty Twenty-Two 1.0
*/
function twentytwentytwo_register_block_patterns() {

register_block_pattern_category(
'twentytwentytwo-general',
array( 'label' => __( 'Twenty Twenty-Two General', 'twentytwentytwo' ) )
);
register_block_pattern_category(
'twentytwentytwo-footers',
array( 'label' => __( 'Twenty Twenty-Two Footers', 'twentytwentytwo' ) )
);
register_block_pattern_category(
'twentytwentytwo-headers',
array( 'label' => __( 'Twenty Twenty-Two Headers', 'twentytwentytwo' ) )
);
register_block_pattern_category(
'twentytwentytwo-query',
array( 'label' => __( 'Twenty Twenty-Two Posts', 'twentytwentytwo' ) )
);
register_block_pattern_category(
'twentytwentytwo-pages',
array( 'label' => __( 'Twenty Twenty-Two Pages', 'twentytwentytwo' ) )
$block_pattern_categories = array(
'twentytwentytwo-general' => array( 'label' => __( 'Twenty Twenty-Two General', 'twentytwentytwo' ) ),
'twentytwentytwo-footers' => array( 'label' => __( 'Twenty Twenty-Two Footers', 'twentytwentytwo' ) ),
'twentytwentytwo-headers' => array( 'label' => __( 'Twenty Twenty-Two Headers', 'twentytwentytwo' ) ),
'twentytwentytwo-query' => array( 'label' => __( 'Twenty Twenty-Two Posts', 'twentytwentytwo' ) ),
'twentytwentytwo-pages' => array( 'label' => __( 'Twenty Twenty-Two Pages', 'twentytwentytwo' ) ),
);

/**
* Filters the theme block pattern categories.
*
* @since Twenty Twenty-Two 1.0
*
* @param array[] $block_pattern_categories {
* An associative array of block pattern categories, keyed by category name.
*
* @type array[] $properties {
* An array of block category properties.
*
* @type string $label A human-readable label for the pattern category.
* }
* }
*/
$block_pattern_categories = apply_filters( 'twentytwentytwo_block_pattern_categories', $block_pattern_categories );

foreach ( $block_pattern_categories as $name => $properties ) {
register_block_pattern_category( $name, $properties );
}

$block_patterns = array(
'footer-default',
'footer-dark',
Expand Down Expand Up @@ -104,6 +111,15 @@ function twentytwentytwo_register_block_patterns() {
'query-irregular-grid',
);

/**
* Filters the theme block patterns.
*
* @since Twenty Twenty-Two 1.0
*
* @param $block_patterns array List of block patterns by name.
*/
$block_patterns = apply_filters( 'twentytwentytwo_block_patterns', $block_patterns );

foreach ( $block_patterns as $block_pattern ) {
register_block_pattern(
'twentytwentytwo/' . $block_pattern,
Expand Down

0 comments on commit 8282db5

Please sign in to comment.