PluginProbe
Gutenberg / 12.1.0
Gutenberg v12.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
← All changes | lib/block-patterns.php +100 -7 12.6.012.1.0 View file →
@@ -18,9 +18,9 @@
18 18 'query-standard-posts' => array(
19 19 'title' => _x( 'Standard', 'Block pattern title', 'gutenberg' ),
20 20 'blockTypes' => array( 'core/query' ),
21 21 'categories' => array( 'query' ),
22 - 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
22 + 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
23 23 <div class="wp-block-query">
24 24 <!-- wp:post-template -->
25 25 <!-- wp:post-title {"isLink":true} /-->
26 26 <!-- wp:post-featured-image {"isLink":true,"align":"wide"} /-->
@@ -36,9 +36,9 @@
36 36 'query-medium-posts' => array(
37 37 'title' => _x( 'Image at left', 'Block pattern title', 'gutenberg' ),
38 38 'blockTypes' => array( 'core/query' ),
39 39 'categories' => array( 'query' ),
40 - 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
40 + 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
41 41 <div class="wp-block-query">
42 42 <!-- wp:post-template -->
43 43 <!-- wp:columns {"align":"wide"} -->
44 44 <div class="wp-block-columns alignwide"><!-- wp:column {"width":"66.66%"} -->
@@ -56,9 +56,9 @@
56 56 'query-small-posts' => array(
57 57 'title' => _x( 'Small image and title', 'Block pattern title', 'gutenberg' ),
58 58 'blockTypes' => array( 'core/query' ),
59 59 'categories' => array( 'query' ),
60 - 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
60 + 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
61 61 <div class="wp-block-query">
62 62 <!-- wp:post-template -->
63 63 <!-- wp:columns {"verticalAlignment":"center"} -->
64 64 <div class="wp-block-columns are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"25%"} -->
@@ -75,9 +75,9 @@
75 75 'query-grid-posts' => array(
76 76 'title' => _x( 'Grid', 'Block pattern title', 'gutenberg' ),
77 77 'blockTypes' => array( 'core/query' ),
78 78 'categories' => array( 'query' ),
79 - 'content' => '<!-- wp:query {"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"flex","columns":3}} -->
79 + 'content' => '<!-- wp:query {"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"flex","columns":3}} -->
80 80 <div class="wp-block-query">
81 81 <!-- wp:post-template -->
82 82 <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
83 83 <div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:post-title {"isLink":true} /-->
@@ -92,9 +92,9 @@
92 92 'title' => _x( 'Large title', 'Block pattern title', 'gutenberg' ),
93 93 'blockTypes' => array( 'core/query' ),
94 94 'categories' => array( 'query' ),
95 95 'content' => '<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"100px","right":"100px","bottom":"100px","left":"100px"}},"color":{"text":"#ffffff","background":"#000000"}}} -->
96 - <div class="wp-block-group alignfull has-text-color has-background" style="background-color:#000000;color:#ffffff;padding-top:100px;padding-right:100px;padding-bottom:100px;padding-left:100px"><!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
96 + <div class="wp-block-group alignfull has-text-color has-background" style="background-color:#000000;color:#ffffff;padding-top:100px;padding-right:100px;padding-bottom:100px;padding-left:100px"><!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
97 97 <div class="wp-block-query"><!-- wp:post-template -->
98 98 <!-- wp:separator {"customColor":"#ffffff","align":"wide","className":"is-style-wide"} -->
99 99 <hr class="wp-block-separator alignwide has-text-color has-background is-style-wide" style="background-color:#ffffff;color:#ffffff"/>
100 100 <!-- /wp:separator -->
@@ -118,9 +118,9 @@
118 118 'categories' => array( 'query' ),
119 119 'content' => '<!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
120 120 <div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:columns -->
121 121 <div class="wp-block-columns"><!-- wp:column {"width":"50%"} -->
122 - <div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
122 + <div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
123 123 <div class="wp-block-query"><!-- wp:post-template -->
124 124 <!-- wp:post-featured-image /-->
125 125 <!-- wp:post-title /-->
126 126 <!-- wp:post-date /-->
@@ -130,9 +130,9 @@
130 130 <!-- /wp:post-template --></div>
131 131 <!-- /wp:query --></div>
132 132 <!-- /wp:column -->
133 133 <!-- wp:column {"width":"50%"} -->
134 - <div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":2,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
134 + <div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":2,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->
135 135 <div class="wp-block-query"><!-- wp:post-template -->
136 136 <!-- wp:spacer {"height":200} -->
137 137 <div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>
138 138 <!-- /wp:spacer -->
@@ -198,8 +198,86 @@
198 198 }
199 199 }
200 200 }
201 201
202 +/**
203 + * Register Core's official patterns from wordpress.org/patterns.
204 + *
205 + * @since 5.8.0
206 + */
207 +function gutenberg_load_remote_core_patterns() {
208 + // This is the core function that provides the same feature.
209 + if ( function_exists( '_load_remote_block_patterns' ) ) {
210 + return;
211 + }
212 +
213 + /**
214 + * Filter to disable remote block patterns.
215 + *
216 + * @since 5.8.0
217 + *
218 + * @param bool $should_load_remote
219 + */
220 + $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
221 +
222 + if ( $should_load_remote ) {
223 + $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
224 + $core_keyword_id = 11; // 11 is the ID for "core".
225 + $request->set_param( 'keyword', $core_keyword_id );
226 + $response = rest_do_request( $request );
227 + if ( $response->is_error() ) {
228 + return;
229 + }
230 + $patterns = $response->get_data();
231 +
232 + foreach ( $patterns as $settings ) {
233 + $pattern_name = 'core/' . sanitize_title( $settings['title'] );
234 + register_block_pattern( $pattern_name, (array) $settings );
235 + }
236 + }
237 +}
238 +
239 +/**
240 + * Register `Featured` (category) patterns from wordpress.org/patterns.
241 + *
242 + * @since 5.9.0
243 + */
244 +function gutenberg_load_remote_featured_patterns() {
245 + /**
246 + * Filter to disable remote block patterns.
247 + *
248 + * @since 5.8.0
249 + *
250 + * @param bool $should_load_remote
251 + */
252 + $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
253 +
254 + if ( ! $should_load_remote ) {
255 + return;
256 + }
257 +
258 + if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'featured' ) ) {
259 + register_block_pattern_category( 'featured', array( 'label' => __( 'Featured', 'gutenberg' ) ) );
260 + }
261 + $request = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
262 + $request['category'] = 26; // This is the `Featured` category id from pattern directory.
263 + $response = rest_do_request( $request );
264 + if ( $response->is_error() ) {
265 + return;
266 + }
267 + $patterns = $response->get_data();
268 + foreach ( $patterns as $pattern ) {
269 + $pattern_name = sanitize_title( $pattern['title'] );
270 + $registry = WP_Block_Patterns_Registry::get_instance();
271 + // Some patterns might be already registerd as `core patterns with the `core` prefix.
272 + $is_registered = $registry->is_registered( $pattern_name ) || $registry->is_registered( "core/$pattern_name" );
273 + if ( ! $is_registered ) {
274 + register_block_pattern( $pattern_name, (array) $pattern );
275 + }
276 + }
277 +}
278 +
279 +
202 280 add_action(
203 281 'init',
204 282 function() {
205 283 if ( ! get_theme_support( 'core-block-patterns' ) || ! function_exists( 'unregister_block_pattern' ) ) {
@@ -206,6 +284,21 @@
206 284 return;
207 285 }
208 286 gutenberg_remove_core_patterns();
209 287 gutenberg_register_gutenberg_patterns();
288 + }
289 +);
290 +
291 +add_action(
292 + 'current_screen',
293 + function( $current_screen ) {
294 + if ( ! get_theme_support( 'core-block-patterns' ) ) {
295 + return;
296 + }
297 +
298 + $is_site_editor = ( function_exists( 'gutenberg_is_edit_site_page' ) && gutenberg_is_edit_site_page( $current_screen->id ) );
299 + if ( $current_screen->is_block_editor || $is_site_editor ) {
300 + gutenberg_load_remote_core_patterns();
301 + gutenberg_load_remote_featured_patterns();
302 + }
210 303 }
211 304 );