PluginProbe
Gutenberg / 14.7.0
Gutenberg v14.7.0
24.0.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 All 403 releases
gutenberg / lib / compat / wordpress-6.0 / block-patterns-update.php

block-patterns-update.php in Gutenberg 14.7.0, at lib/compat/wordpress-6.0/block-patterns-update.php

218 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Block patterns registration.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Register Gutenberg bundled patterns.
10 */
11 function gutenberg_register_gutenberg_patterns() {
12 $pattern_category_registry = WP_Block_Pattern_Categories_Registry::get_instance();
13
14 // Register categories used for block patterns.
15 if ( ! $pattern_category_registry->is_registered( 'query' ) ) {
16 register_block_pattern_category( 'query', array( 'label' => __( 'Query', 'gutenberg' ) ) );
17 }
18
19 if ( ! $pattern_category_registry->is_registered( 'featured' ) ) {
20 register_block_pattern_category( 'featured', array( 'label' => __( 'Featured', 'gutenberg' ) ) );
21 }
22
23 $patterns = array(
24 'query-standard-posts' => array(
25 'title' => _x( 'Standard', 'Block pattern title', 'gutenberg' ),
26 'blockTypes' => array( 'core/query' ),
27 'categories' => array( 'query' ),
28 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
29 <div class="wp-block-query">
30 <!-- wp:post-template -->
31 <!-- wp:post-title {"isLink":true} /-->
32 <!-- wp:post-featured-image {"isLink":true,"align":"wide"} /-->
33 <!-- wp:post-excerpt /-->
34 <!-- wp:separator -->
35 <hr class="wp-block-separator"/>
36 <!-- /wp:separator -->
37 <!-- wp:post-date /-->
38 <!-- /wp:post-template -->
39 </div>
40 <!-- /wp:query -->',
41 ),
42 'query-medium-posts' => array(
43 'title' => _x( 'Image at left', 'Block pattern title', 'gutenberg' ),
44 'blockTypes' => array( 'core/query' ),
45 'categories' => array( 'query' ),
46 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
47 <div class="wp-block-query">
48 <!-- wp:post-template -->
49 <!-- wp:columns {"align":"wide"} -->
50 <div class="wp-block-columns alignwide"><!-- wp:column {"width":"66.66%"} -->
51 <div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:post-featured-image {"isLink":true} /--></div>
52 <!-- /wp:column -->
53 <!-- wp:column {"width":"33.33%"} -->
54 <div class="wp-block-column" style="flex-basis:33.33%"><!-- wp:post-title {"isLink":true} /-->
55 <!-- wp:post-excerpt /--></div>
56 <!-- /wp:column --></div>
57 <!-- /wp:columns -->
58 <!-- /wp:post-template -->
59 </div>
60 <!-- /wp:query -->',
61 ),
62 'query-small-posts' => array(
63 'title' => _x( 'Small image and title', 'Block pattern title', 'gutenberg' ),
64 'blockTypes' => array( 'core/query' ),
65 'categories' => array( 'query' ),
66 'content' => '<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->
67 <div class="wp-block-query">
68 <!-- wp:post-template -->
69 <!-- wp:columns {"verticalAlignment":"center"} -->
70 <div class="wp-block-columns are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"25%"} -->
71 <div class="wp-block-column is-vertically-aligned-center" style="flex-basis:25%"><!-- wp:post-featured-image {"isLink":true} /--></div>
72 <!-- /wp:column -->
73 <!-- wp:column {"verticalAlignment":"center","width":"75%"} -->
74 <div class="wp-block-column is-vertically-aligned-center" style="flex-basis:75%"><!-- wp:post-title {"isLink":true} /--></div>
75 <!-- /wp:column --></div>
76 <!-- /wp:columns -->
77 <!-- /wp:post-template -->
78 </div>
79 <!-- /wp:query -->',
80 ),
81 'query-grid-posts' => array(
82 'title' => _x( 'Grid', 'Block pattern title', 'gutenberg' ),
83 'blockTypes' => array( 'core/query' ),
84 'categories' => array( 'query' ),
85 '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}} -->
86 <div class="wp-block-query">
87 <!-- wp:post-template -->
88 <!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
89 <div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:post-title {"isLink":true} /-->
90 <!-- wp:post-excerpt /-->
91 <!-- wp:post-date /--></div>
92 <!-- /wp:group -->
93 <!-- /wp:post-template -->
94 </div>
95 <!-- /wp:query -->',
96 ),
97 'query-large-title-posts' => array(
98 'title' => _x( 'Large title', 'Block pattern title', 'gutenberg' ),
99 'blockTypes' => array( 'core/query' ),
100 'categories' => array( 'query' ),
101 'content' => '<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"100px","right":"100px","bottom":"100px","left":"100px"}},"color":{"text":"#ffffff","background":"#000000"}}} -->
102 <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}} -->
103 <div class="wp-block-query"><!-- wp:post-template -->
104 <!-- wp:separator {"customColor":"#ffffff","align":"wide","className":"is-style-wide"} -->
105 <hr class="wp-block-separator alignwide has-text-color has-background is-style-wide" style="background-color:#ffffff;color:#ffffff"/>
106 <!-- /wp:separator -->
107
108 <!-- wp:columns {"verticalAlignment":"center","align":"wide"} -->
109 <div class="wp-block-columns alignwide are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"20%"} -->
110 <div class="wp-block-column is-vertically-aligned-center" style="flex-basis:20%"><!-- wp:post-date {"style":{"color":{"text":"#ffffff"}},"fontSize":"extra-small"} /--></div>
111 <!-- /wp:column -->
112
113 <!-- wp:column {"verticalAlignment":"center","width":"80%"} -->
114 <div class="wp-block-column is-vertically-aligned-center" style="flex-basis:80%"><!-- wp:post-title {"isLink":true,"style":{"typography":{"fontSize":"72px","lineHeight":"1.1"},"color":{"text":"#ffffff","link":"#ffffff"}}} /--></div>
115 <!-- /wp:column --></div>
116 <!-- /wp:columns -->
117 <!-- /wp:post-template --></div>
118 <!-- /wp:query --></div>
119 <!-- /wp:group -->',
120 ),
121 'query-offset-posts' => array(
122 'title' => _x( 'Offset', 'Block pattern title', 'gutenberg' ),
123 'blockTypes' => array( 'core/query' ),
124 'categories' => array( 'query' ),
125 'content' => '<!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
126 <div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:columns -->
127 <div class="wp-block-columns"><!-- wp:column {"width":"50%"} -->
128 <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"}} -->
129 <div class="wp-block-query"><!-- wp:post-template -->
130 <!-- wp:post-featured-image /-->
131 <!-- wp:post-title /-->
132 <!-- wp:post-date /-->
133 <!-- wp:spacer {"height":200} -->
134 <div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>
135 <!-- /wp:spacer -->
136 <!-- /wp:post-template --></div>
137 <!-- /wp:query --></div>
138 <!-- /wp:column -->
139 <!-- wp:column {"width":"50%"} -->
140 <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"}} -->
141 <div class="wp-block-query"><!-- wp:post-template -->
142 <!-- wp:spacer {"height":200} -->
143 <div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>
144 <!-- /wp:spacer -->
145 <!-- wp:post-featured-image /-->
146 <!-- wp:post-title /-->
147 <!-- wp:post-date /-->
148 <!-- /wp:post-template --></div>
149 <!-- /wp:query --></div>
150 <!-- /wp:column --></div>
151 <!-- /wp:columns --></div>
152 <!-- /wp:group -->',
153 ),
154 // Initial block pattern to be used with block transformations with patterns.
155 'social-links-shared-background-color' => array(
156 'title' => _x( 'Social links with a shared background color', 'Block pattern title', 'gutenberg' ),
157 'categories' => array( 'buttons' ),
158 'blockTypes' => array( 'core/social-links' ),
159 'viewportWidth' => 500,
160 'content' => '<!-- wp:social-links {"customIconColor":"#ffffff","iconColorValue":"#ffffff","customIconBackgroundColor":"#3962e3","iconBackgroundColorValue":"#3962e3","className":"has-icon-color"} -->
161 <ul class="wp-block-social-links has-icon-color has-icon-background-color"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->
162 <!-- wp:social-link {"url":"#","service":"chain"} /-->
163 <!-- wp:social-link {"url":"#","service":"mail"} /--></ul>
164 <!-- /wp:social-links -->',
165 ),
166 );
167
168 foreach ( $patterns as $name => $pattern ) {
169 $pattern_name = 'core/' . $name;
170 if ( ! WP_Block_Patterns_Registry::get_instance()->is_registered( $pattern_name ) ) {
171 register_block_pattern( $pattern_name, $pattern );
172 }
173 }
174 }
175
176 /**
177 * Deactivate the legacy patterns bundled with WordPress.
178 */
179 function gutenberg_remove_core_patterns() {
180 $core_block_patterns = array(
181 'text-two-columns',
182 'two-buttons',
183 'two-images',
184 'text-two-columns-with-images',
185 'text-three-columns-buttons',
186 'large-header',
187 'large-header-button',
188 'three-buttons',
189 'heading-paragraph',
190 'quote',
191 'query-standard-posts',
192 'query-medium-posts',
193 'query-small-posts',
194 'query-grid-posts',
195 'query-large-title-posts',
196 'query-offset-posts',
197 'social-links-shared-background-color',
198 );
199
200 foreach ( $core_block_patterns as $core_block_pattern ) {
201 $name = 'core/' . $core_block_pattern;
202 if ( WP_Block_Patterns_Registry::get_instance()->is_registered( $name ) ) {
203 unregister_block_pattern( $name );
204 }
205 }
206 }
207
208 add_action(
209 'init',
210 function() {
211 if ( ! get_theme_support( 'core-block-patterns' ) || ! function_exists( 'unregister_block_pattern' ) ) {
212 return;
213 }
214 gutenberg_remove_core_patterns();
215 gutenberg_register_gutenberg_patterns();
216 }
217 );
218