run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄block-patterns.php
1<?php
2/**
3 * Register the block patterns and block patterns categories
4 *
5 * @package WordPress
6 * @since 5.5.0
7 */
8
9add_theme_support( 'core-block-patterns' );
10
11/**
12 * Registers the core block patterns and categories.
13 *
14 * @since 5.5.0
15 * @since 6.3.0 Added source to core block patterns.
16 * @access private
17 */
18function _register_core_block_patterns_and_categories() {
19 $should_register_core_patterns = get_theme_support( 'core-block-patterns' );
20
21 if ( $should_register_core_patterns ) {
22 $core_block_patterns = array(
23 'query-standard-posts',
24 'query-medium-posts',
25 'query-small-posts',
26 'query-grid-posts',
27 'query-large-title-posts',
28 'query-offset-posts',
29 );
30
31 foreach ( $core_block_patterns as $core_block_pattern ) {
32 $pattern = require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php';
33 $pattern['source'] = 'core';
34 register_block_pattern( 'core/' . $core_block_pattern, $pattern );
35 }
36 }
37
38 register_block_pattern_category(
39 'banner',
40 array(
41 'label' => _x( 'Banners', 'Block pattern category' ),
42 'description' => __( 'Bold sections designed to showcase key content.' ),
43 )
44 );
45 register_block_pattern_category(
46 'buttons',
47 array(
48 'label' => _x( 'Buttons', 'Block pattern category' ),
49 'description' => __( 'Patterns that contain buttons and call to actions.' ),
50 )
51 );
52 register_block_pattern_category(
53 'columns',
54 array(
55 'label' => _x( 'Columns', 'Block pattern category' ),
56 'description' => __( 'Multi-column patterns with more complex layouts.' ),
57 )
58 );
59 register_block_pattern_category(
60 'text',
61 array(
62 'label' => _x( 'Text', 'Block pattern category' ),
63 'description' => __( 'Patterns containing mostly text.' ),
64 )
65 );
66 register_block_pattern_category(
67 'query',
68 array(
69 'label' => _x( 'Posts', 'Block pattern category' ),
70 'description' => __( 'Display your latest posts in lists, grids or other layouts.' ),
71 )
72 );
73 register_block_pattern_category(
74 'featured',
75 array(
76 'label' => _x( 'Featured', 'Block pattern category' ),
77 'description' => __( 'A set of high quality curated patterns.' ),
78 )
79 );
80 register_block_pattern_category(
81 'call-to-action',
82 array(
83 'label' => _x( 'Call to action', 'Block pattern category' ),
84 'description' => __( 'Sections whose purpose is to trigger a specific action.' ),
85 )
86 );
87 register_block_pattern_category(
88 'team',
89 array(
90 'label' => _x( 'Team', 'Block pattern category' ),
91 'description' => __( 'A variety of designs to display your team members.' ),
92 )
93 );
94 register_block_pattern_category(
95 'testimonials',
96 array(
97 'label' => _x( 'Testimonials', 'Block pattern category' ),
98 'description' => __( 'Share reviews and feedback about your brand/business.' ),
99 )
100 );
101 register_block_pattern_category(
102 'services',
103 array(
104 'label' => _x( 'Services', 'Block pattern category' ),
105 'description' => __( 'Briefly describe what your business does and how you can help.' ),
106 )
107 );
108 register_block_pattern_category(
109 'contact',
110 array(
111 'label' => _x( 'Contact', 'Block pattern category' ),
112 'description' => __( 'Display your contact information.' ),
113 )
114 );
115 register_block_pattern_category(
116 'about',
117 array(
118 'label' => _x( 'About', 'Block pattern category' ),
119 'description' => __( 'Introduce yourself.' ),
120 )
121 );
122 register_block_pattern_category(
123 'portfolio',
124 array(
125 'label' => _x( 'Portfolio', 'Block pattern category' ),
126 'description' => __( 'Showcase your latest work.' ),
127 )
128 );
129 register_block_pattern_category(
130 'gallery',
131 array(
132 'label' => _x( 'Gallery', 'Block pattern category' ),
133 'description' => __( 'Different layouts for displaying images.' ),
134 )
135 );
136 register_block_pattern_category(
137 'media',
138 array(
139 'label' => _x( 'Media', 'Block pattern category' ),
140 'description' => __( 'Different layouts containing video or audio.' ),
141 )
142 );
143 register_block_pattern_category(
144 'videos',
145 array(
146 'label' => _x( 'Videos', 'Block pattern category' ),
147 'description' => __( 'Different layouts containing videos.' ),
148 )
149 );
150 register_block_pattern_category(
151 'audio',
152 array(
153 'label' => _x( 'Audio', 'Block pattern category' ),
154 'description' => __( 'Different layouts containing audio.' ),
155 )
156 );
157 register_block_pattern_category(
158 'posts',
159 array(
160 'label' => _x( 'Posts', 'Block pattern category' ),
161 'description' => __( 'Display your latest posts in lists, grids or other layouts.' ),
162 )
163 );
164 register_block_pattern_category(
165 'footer',
166 array(
167 'label' => _x( 'Footers', 'Block pattern category' ),
168 'description' => __( 'A variety of footer designs displaying information and site navigation.' ),
169 )
170 );
171 register_block_pattern_category(
172 'header',
173 array(
174 'label' => _x( 'Headers', 'Block pattern category' ),
175 'description' => __( 'A variety of header designs displaying your site title and navigation.' ),
176 )
177 );
178}
179
180/**
181 * Normalize the pattern properties to camelCase.
182 *
183 * The API's format is snake_case, `register_block_pattern()` expects camelCase.
184 *
185 * @since 6.2.0
186 * @access private
187 *
188 * @param array $pattern Pattern as returned from the Pattern Directory API.
189 * @return array Normalized pattern.
190 */
191function wp_normalize_remote_block_pattern( $pattern ) {
192 if ( isset( $pattern['block_types'] ) ) {
193 $pattern['blockTypes'] = $pattern['block_types'];
194 unset( $pattern['block_types'] );
195 }
196
197 if ( isset( $pattern['viewport_width'] ) ) {
198 $pattern['viewportWidth'] = $pattern['viewport_width'];
199 unset( $pattern['viewport_width'] );
200 }
201
202 return (array) $pattern;
203}
204
205/**
206 * Register Core's official patterns from wordpress.org/patterns.
207 *
208 * @since 5.8.0
209 * @since 5.9.0 The $current_screen argument was removed.
210 * @since 6.2.0 Normalize the pattern from the API (snake_case) to the
211 * format expected by `register_block_pattern` (camelCase).
212 * @since 6.3.0 Add 'pattern-directory/core' to the pattern's 'source'.
213 *
214 * @param WP_Screen $deprecated Unused. Formerly the screen that the current request was triggered from.
215 */
216function _load_remote_block_patterns( $deprecated = null ) {
217 if ( ! empty( $deprecated ) ) {
218 _deprecated_argument( __FUNCTION__, '5.9.0' );
219 $current_screen = $deprecated;
220 if ( ! $current_screen->is_block_editor ) {
221 return;
222 }
223 }
224
225 $supports_core_patterns = get_theme_support( 'core-block-patterns' );
226
227 /**
228 * Filter to disable remote block patterns.
229 *
230 * @since 5.8.0
231 *
232 * @param bool $should_load_remote
233 */
234 $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
235
236 if ( $supports_core_patterns && $should_load_remote ) {
237 $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
238 $core_keyword_id = 11; // 11 is the ID for "core".
239 $request->set_param( 'keyword', $core_keyword_id );
240 $response = rest_do_request( $request );
241 if ( $response->is_error() ) {
242 return;
243 }
244 $patterns = $response->get_data();
245
246 foreach ( $patterns as $pattern ) {
247 $pattern['source'] = 'pattern-directory/core';
248 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern );
249 $pattern_name = 'core/' . sanitize_title( $normalized_pattern['title'] );
250 register_block_pattern( $pattern_name, $normalized_pattern );
251 }
252 }
253}
254
255/**
256 * Register `Featured` (category) patterns from wordpress.org/patterns.
257 *
258 * @since 5.9.0
259 * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
260 * format expected by `register_block_pattern()` (camelCase).
261 * @since 6.3.0 Add 'pattern-directory/featured' to the pattern's 'source'.
262 */
263function _load_remote_featured_patterns() {
264 $supports_core_patterns = get_theme_support( 'core-block-patterns' );
265
266 /** This filter is documented in wp-includes/block-patterns.php */
267 $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
268
269 if ( ! $should_load_remote || ! $supports_core_patterns ) {
270 return;
271 }
272
273 $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
274 $featured_cat_id = 26; // This is the `Featured` category id from pattern directory.
275 $request->set_param( 'category', $featured_cat_id );
276 $response = rest_do_request( $request );
277 if ( $response->is_error() ) {
278 return;
279 }
280 $patterns = $response->get_data();
281 $registry = WP_Block_Patterns_Registry::get_instance();
282 foreach ( $patterns as $pattern ) {
283 $pattern['source'] = 'pattern-directory/featured';
284 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern );
285 $pattern_name = sanitize_title( $normalized_pattern['title'] );
286 // Some patterns might be already registered as core patterns with the `core` prefix.
287 $is_registered = $registry->is_registered( $pattern_name ) || $registry->is_registered( "core/$pattern_name" );
288 if ( ! $is_registered ) {
289 register_block_pattern( $pattern_name, $normalized_pattern );
290 }
291 }
292}
293
294/**
295 * Registers patterns from Pattern Directory provided by a theme's
296 * `theme.json` file.
297 *
298 * @since 6.0.0
299 * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
300 * format expected by `register_block_pattern()` (camelCase).
301 * @since 6.3.0 Add 'pattern-directory/theme' to the pattern's 'source'.
302 * @access private
303 */
304function _register_remote_theme_patterns() {
305 /** This filter is documented in wp-includes/block-patterns.php */
306 if ( ! apply_filters( 'should_load_remote_block_patterns', true ) ) {
307 return;
308 }
309
310 if ( ! wp_theme_has_theme_json() ) {
311 return;
312 }
313
314 $pattern_settings = wp_get_theme_directory_pattern_slugs();
315 if ( empty( $pattern_settings ) ) {
316 return;
317 }
318
319 $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
320 $request['slug'] = $pattern_settings;
321 $response = rest_do_request( $request );
322 if ( $response->is_error() ) {
323 return;
324 }
325 $patterns = $response->get_data();
326 $patterns_registry = WP_Block_Patterns_Registry::get_instance();
327 foreach ( $patterns as $pattern ) {
328 $pattern['source'] = 'pattern-directory/theme';
329 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern );
330 $pattern_name = sanitize_title( $normalized_pattern['title'] );
331 // Some patterns might be already registered as core patterns with the `core` prefix.
332 $is_registered = $patterns_registry->is_registered( $pattern_name ) || $patterns_registry->is_registered( "core/$pattern_name" );
333 if ( ! $is_registered ) {
334 register_block_pattern( $pattern_name, $normalized_pattern );
335 }
336 }
337}
338
339/**
340 * Register any patterns that the active theme may provide under its
341 * `./patterns/` directory.
342 *
343 * @since 6.0.0
344 * @since 6.1.0 The `postTypes` property was added.
345 * @since 6.2.0 The `templateTypes` property was added.
346 * @since 6.4.0 Uses the `WP_Theme::get_block_patterns` method.
347 * @access private
348 */
349function _register_theme_block_patterns() {
350
351 /*
352 * During the bootstrap process, a check for active and valid themes is run.
353 * If no themes are returned, the theme's functions.php file will not be loaded,
354 * which can lead to errors if patterns expect some variables or constants to
355 * already be set at this point, so bail early if that is the case.
356 */
357 if ( empty( wp_get_active_and_valid_themes() ) ) {
358 return;
359 }
360
361 /*
362 * Register patterns for the active theme. If the theme is a child theme,
363 * let it override any patterns from the parent theme that shares the same slug.
364 */
365 $themes = array();
366 $theme = wp_get_theme();
367 $themes[] = $theme;
368 if ( $theme->parent() ) {
369 $themes[] = $theme->parent();
370 }
371 $registry = WP_Block_Patterns_Registry::get_instance();
372
373 foreach ( $themes as $theme ) {
374 $patterns = $theme->get_block_patterns();
375 $dirpath = $theme->get_stylesheet_directory() . '/patterns/';
376 $text_domain = $theme->get( 'TextDomain' );
377
378 foreach ( $patterns as $file => $pattern_data ) {
379 if ( $registry->is_registered( $pattern_data['slug'] ) ) {
380 continue;
381 }
382
383 $file_path = $dirpath . $file;
384
385 if ( ! file_exists( $file_path ) ) {
386 _doing_it_wrong(
387 __FUNCTION__,
388 sprintf(
389 /* translators: %s: file name. */
390 __( 'Could not register file "%s" as a block pattern as the file does not exist.' ),
391 $file
392 ),
393 '6.4.0'
394 );
395 $theme->delete_pattern_cache();
396 continue;
397 }
398
399 $pattern_data['filePath'] = $file_path;
400
401 // Translate the pattern metadata.
402 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain,WordPress.WP.I18n.LowLevelTranslationFunction
403 $pattern_data['title'] = translate_with_gettext_context( $pattern_data['title'], 'Pattern title', $text_domain );
404 if ( ! empty( $pattern_data['description'] ) ) {
405 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain,WordPress.WP.I18n.LowLevelTranslationFunction
406 $pattern_data['description'] = translate_with_gettext_context( $pattern_data['description'], 'Pattern description', $text_domain );
407 }
408
409 register_block_pattern( $pattern_data['slug'], $pattern_data );
410 }
411 }
412}
413add_action( 'init', '_register_theme_block_patterns' );
414