|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* LSX: Block Patterns |
|
4
|
|
|
* |
|
5
|
|
|
* @since LSX 1.0 |
|
6
|
|
|
*/ |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Registers block patterns and categories. |
|
10
|
|
|
* |
|
11
|
|
|
* @since LSX 1.0 |
|
12
|
|
|
* |
|
13
|
|
|
* @return void |
|
14
|
|
|
*/ |
|
15
|
|
|
function lsx_register_block_patterns() { |
|
16
|
|
|
$block_pattern_categories = array( |
|
17
|
|
|
'featured' => array( 'label' => __( 'Featured', 'lsx' ) ), |
|
18
|
|
|
'footer' => array( 'label' => __( 'Footers', 'lsx' ) ), |
|
19
|
|
|
'header' => array( 'label' => __( 'Headers', 'lsx' ) ), |
|
20
|
|
|
'query' => array( 'label' => __( 'Query', 'lsx' ) ), |
|
21
|
|
|
'pages' => array( 'label' => __( 'Pages', 'lsx' ) ), |
|
22
|
|
|
); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Filters the theme block pattern categories. |
|
26
|
|
|
* |
|
27
|
|
|
* @since LSX 1.0 |
|
28
|
|
|
* |
|
29
|
|
|
* @param array[] $block_pattern_categories { |
|
30
|
|
|
* An associative array of block pattern categories, keyed by category name. |
|
31
|
|
|
* |
|
32
|
|
|
* @type array[] $properties { |
|
33
|
|
|
* An array of block category properties. |
|
34
|
|
|
* |
|
35
|
|
|
* @type string $label A human-readable label for the pattern category. |
|
36
|
|
|
* } |
|
37
|
|
|
* } |
|
38
|
|
|
*/ |
|
39
|
|
|
$block_pattern_categories = apply_filters( 'lsx_block_pattern_categories', $block_pattern_categories ); |
|
40
|
|
|
|
|
41
|
|
|
foreach ( $block_pattern_categories as $name => $properties ) { |
|
42
|
|
|
if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { |
|
43
|
|
|
register_block_pattern_category( $name, $properties ); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$block_patterns = array( |
|
48
|
|
|
'general-pricing-table', |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Filters the theme block patterns. |
|
53
|
|
|
* |
|
54
|
|
|
* @since LSX 1.0 |
|
55
|
|
|
* |
|
56
|
|
|
* @param array $block_patterns List of block patterns by name. |
|
57
|
|
|
*/ |
|
58
|
|
|
$block_patterns = apply_filters( 'lsx_block_patterns', $block_patterns ); |
|
59
|
|
|
|
|
60
|
|
|
foreach ( $block_patterns as $block_pattern ) { |
|
61
|
|
|
$pattern_file = get_theme_file_path( '/includes/patterns/' . $block_pattern . '.php' ); |
|
62
|
|
|
|
|
63
|
|
|
register_block_pattern( |
|
64
|
|
|
'lsx/' . $block_pattern, |
|
65
|
|
|
require $pattern_file |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
add_action( 'init', 'lsx_register_block_patterns', 9 ); |
|
70
|
|
|
|