Changeset 55168
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-patterns.php
r55098 r55168 303 303 * - Block Types (comma-separated values) 304 304 * - Post Types (comma-separated values) 305 * - Template Types (comma-separated values) 305 306 * - Inserter (yes/no) 306 307 * … … 319 320 'postTypes' => 'Post Types', 320 321 'inserter' => 'Inserter', 322 'templateTypes' => 'Template Types', 321 323 ); 322 324 … … 389 391 390 392 // For properties of type array, parse data as comma-separated. 391 foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes' ) as $property ) {393 foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes', 'templateTypes' ) as $property ) { 392 394 if ( ! empty( $pattern_data[ $property ] ) ) { 393 395 $pattern_data[ $property ] = array_filter( -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
r55125 r55168 174 174 'content' => 'content', 175 175 'inserter' => 'inserter', 176 'templateTypes' => 'template_types', 176 177 ); 177 178 $data = array(); … … 249 250 'context' => array( 'view', 'edit', 'embed' ), 250 251 ), 252 'template_types' => array( 253 'description' => __( 'An array of template types where the pattern fits.' ), 254 'type' => 'array', 255 'readonly' => true, 256 'context' => array( 'view', 'edit', 'embed' ), 257 ), 251 258 'content' => array( 252 259 'description' => __( 'The pattern content.' ), -
trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php
r55125 r55168 82 82 'viewportWidth' => 1440, 83 83 'content' => '<!-- wp:heading {"level":1} --><h1>One</h1><!-- /wp:heading -->', 84 'templateTypes' => array( 'page' ), 84 85 ) 85 86 ); … … 88 89 'test/two', 89 90 array( 90 'title' => 'Pattern Two', 91 'categories' => array( 'test' ), 92 'content' => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->', 91 'title' => 'Pattern Two', 92 'categories' => array( 'test' ), 93 'content' => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->', 94 'templateTypes' => array( 'single' ), 93 95 ) 94 96 ); … … 129 131 130 132 $request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE ); 131 $request['_fields'] = 'name,content ';133 $request['_fields'] = 'name,content,template_types'; 132 134 $response = rest_get_server()->dispatch( $request ); 133 135 $data = $response->get_data(); … … 137 139 $this->assertSame( 138 140 array( 139 'name' => 'test/one', 140 'content' => '<!-- wp:heading {"level":1} --><h1>One</h1><!-- /wp:heading -->', 141 'name' => 'test/one', 142 'content' => '<!-- wp:heading {"level":1} --><h1>One</h1><!-- /wp:heading -->', 143 'template_types' => array( 'page' ), 141 144 ), 142 145 $data[0], … … 145 148 $this->assertSame( 146 149 array( 147 'name' => 'test/two', 148 'content' => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->', 150 'name' => 'test/two', 151 'content' => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->', 152 'template_types' => array( 'single' ), 149 153 ), 150 154 $data[1],
Note: See TracChangeset
for help on using the changeset viewer.