Changeset 56063
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-patterns.php
r55983 r56063 13 13 * 14 14 * @since 5.5.0 15 * @since 6.3.0 Added source to core block patterns. 15 16 * @access private 16 17 */ … … 30 31 31 32 foreach ( $core_block_patterns as $core_block_pattern ) { 32 register_block_pattern( 33 'core/' . $core_block_pattern, 34 require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php' 35 ); 33 $pattern = require __DIR__ . '/block-patterns/' . $core_block_pattern . '.php'; 34 $pattern['source'] = 'core'; 35 register_block_pattern( 'core/' . $core_block_pattern, $pattern ); 36 36 } 37 37 } … … 191 191 * @since 6.2.0 Normalize the pattern from the API (snake_case) to the 192 192 * format expected by `register_block_pattern` (camelCase). 193 * @since 6.3.0 Add 'pattern-directory/core' to the pattern's 'source'. 193 194 * 194 195 * @param WP_Screen $deprecated Unused. Formerly the screen that the current request was triggered from. … … 225 226 226 227 foreach ( $patterns as $pattern ) { 228 $pattern['source'] = 'pattern-directory/core'; 227 229 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern ); 228 230 $pattern_name = 'core/' . sanitize_title( $normalized_pattern['title'] ); … … 238 240 * @since 6.2.0 Normalized the pattern from the API (snake_case) to the 239 241 * format expected by `register_block_pattern()` (camelCase). 242 * @since 6.3.0 Add 'pattern-directory/featured' to the pattern's 'source'. 240 243 */ 241 244 function _load_remote_featured_patterns() { … … 259 262 $registry = WP_Block_Patterns_Registry::get_instance(); 260 263 foreach ( $patterns as $pattern ) { 264 $pattern['source'] = 'pattern-directory/featured'; 261 265 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern ); 262 266 $pattern_name = sanitize_title( $normalized_pattern['title'] ); … … 276 280 * @since 6.2.0 Normalized the pattern from the API (snake_case) to the 277 281 * format expected by `register_block_pattern()` (camelCase). 282 * @since 6.3.0 Add 'pattern-directory/theme' to the pattern's 'source'. 278 283 * @access private 279 284 */ … … 302 307 $patterns_registry = WP_Block_Patterns_Registry::get_instance(); 303 308 foreach ( $patterns as $pattern ) { 309 $pattern['source'] = 'pattern-directory/theme'; 304 310 $normalized_pattern = wp_normalize_remote_block_pattern( $pattern ); 305 311 $pattern_name = sanitize_title( $normalized_pattern['title'] ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
r55173 r56063 156 156 * 157 157 * @since 6.0.0 158 * @since 6.3.0 Added `source` property. 158 159 * 159 160 * @param array $item Raw pattern as registered, before any changes. … … 175 176 'postTypes' => 'post_types', 176 177 'templateTypes' => 'template_types', 178 'source' => 'source', 177 179 ); 178 180 $data = array(); … … 193 195 * 194 196 * @since 6.0.0 197 * @since 6.3.0 Added `source` property. 195 198 * 196 199 * @return array Item schema data. … … 268 271 'context' => array( 'view', 'edit', 'embed' ), 269 272 ), 273 'source' => array( 274 'description' => __( 'Where the pattern comes from e.g. core' ), 275 'type' => 'string', 276 'readonly' => true, 277 'context' => array( 'view', 'edit', 'embed' ), 278 'enum' => array( 279 'core', 280 'plugin', 281 'theme', 282 'pattern-directory/core', 283 'pattern-directory/theme', 284 'pattern-directory/featured', 285 ), 286 ), 270 287 ), 271 288 ); -
trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php
r55457 r56063 77 77 'categories' => array( 'test' ), 78 78 'templateTypes' => array( 'page' ), 79 'source' => 'theme', 79 80 ) 80 81 ); … … 87 88 'categories' => array( 'test' ), 88 89 'templateTypes' => array( 'single' ), 90 'source' => 'core', 89 91 ) 90 92 ); … … 96 98 'content' => '<!-- wp:paragraph --><p>Three</p><!-- /wp:paragraph -->', 97 99 'categories' => array( 'test', 'buttons', 'query' ), 100 'source' => 'pattern-directory/featured', 98 101 ) 99 102 ); … … 125 128 126 129 $request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE ); 127 $request['_fields'] = 'name,content, template_types';130 $request['_fields'] = 'name,content,source,template_types'; 128 131 $response = rest_get_server()->dispatch( $request ); 129 132 $data = $response->get_data(); … … 136 139 'content' => '<!-- wp:heading {"level":1} --><h1>One</h1><!-- /wp:heading -->', 137 140 'template_types' => array( 'page' ), 141 'source' => 'theme', 138 142 ), 139 143 $data[0], … … 145 149 'content' => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->', 146 150 'template_types' => array( 'single' ), 151 'source' => 'core', 147 152 ), 148 153 $data[1],
Note: See TracChangeset
for help on using the changeset viewer.