author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
19 | 1 |
<?php |
2 |
/** |
|
3 |
* REST API: WP_REST_Block_Patterns_Controller class |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage REST_API |
|
7 |
* @since 6.0.0 |
|
8 |
*/ |
|
9 |
||
10 |
/** |
|
11 |
* Core class used to access block patterns via the REST API. |
|
12 |
* |
|
13 |
* @since 6.0.0 |
|
14 |
* |
|
15 |
* @see WP_REST_Controller |
|
16 |
*/ |
|
17 |
class WP_REST_Block_Patterns_Controller extends WP_REST_Controller { |
|
18 |
||
19 |
/** |
|
20 |
* Defines whether remote patterns should be loaded. |
|
21 |
* |
|
22 |
* @since 6.0.0 |
|
23 |
* @var bool |
|
24 |
*/ |
|
25 |
private $remote_patterns_loaded; |
|
26 |
||
27 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
28 |
* An array that maps old categories names to new ones. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
29 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
30 |
* @since 6.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
* @var array |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
protected static $categories_migration = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
34 |
'buttons' => 'call-to-action', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
35 |
'columns' => 'text', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
36 |
'query' => 'posts', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
37 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
38 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
39 |
/** |
19 | 40 |
* Constructs the controller. |
41 |
* |
|
42 |
* @since 6.0.0 |
|
43 |
*/ |
|
44 |
public function __construct() { |
|
45 |
$this->namespace = 'wp/v2'; |
|
46 |
$this->rest_base = 'block-patterns/patterns'; |
|
47 |
} |
|
48 |
||
49 |
/** |
|
50 |
* Registers the routes for the objects of the controller. |
|
51 |
* |
|
52 |
* @since 6.0.0 |
|
53 |
*/ |
|
54 |
public function register_routes() { |
|
55 |
register_rest_route( |
|
56 |
$this->namespace, |
|
57 |
'/' . $this->rest_base, |
|
58 |
array( |
|
59 |
array( |
|
60 |
'methods' => WP_REST_Server::READABLE, |
|
61 |
'callback' => array( $this, 'get_items' ), |
|
62 |
'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
63 |
), |
|
64 |
'schema' => array( $this, 'get_public_item_schema' ), |
|
65 |
) |
|
66 |
); |
|
67 |
} |
|
68 |
||
69 |
/** |
|
70 |
* Checks whether a given request has permission to read block patterns. |
|
71 |
* |
|
72 |
* @since 6.0.0 |
|
73 |
* |
|
74 |
* @param WP_REST_Request $request Full details about the request. |
|
75 |
* @return true|WP_Error True if the request has read access, WP_Error object otherwise. |
|
76 |
*/ |
|
77 |
public function get_items_permissions_check( $request ) { |
|
78 |
if ( current_user_can( 'edit_posts' ) ) { |
|
79 |
return true; |
|
80 |
} |
|
81 |
||
82 |
foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { |
|
83 |
if ( current_user_can( $post_type->cap->edit_posts ) ) { |
|
84 |
return true; |
|
85 |
} |
|
86 |
} |
|
87 |
||
88 |
return new WP_Error( |
|
89 |
'rest_cannot_view', |
|
90 |
__( 'Sorry, you are not allowed to view the registered block patterns.' ), |
|
91 |
array( 'status' => rest_authorization_required_code() ) |
|
92 |
); |
|
93 |
} |
|
94 |
||
95 |
/** |
|
96 |
* Retrieves all block patterns. |
|
97 |
* |
|
98 |
* @since 6.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
99 |
* @since 6.2.0 Added migration for old core pattern categories to the new ones. |
19 | 100 |
* |
101 |
* @param WP_REST_Request $request Full details about the request. |
|
102 |
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
|
103 |
*/ |
|
104 |
public function get_items( $request ) { |
|
105 |
if ( ! $this->remote_patterns_loaded ) { |
|
106 |
// Load block patterns from w.org. |
|
107 |
_load_remote_block_patterns(); // Patterns with the `core` keyword. |
|
108 |
_load_remote_featured_patterns(); // Patterns in the `featured` category. |
|
109 |
_register_remote_theme_patterns(); // Patterns requested by current theme. |
|
110 |
||
111 |
$this->remote_patterns_loaded = true; |
|
112 |
} |
|
113 |
||
114 |
$response = array(); |
|
115 |
$patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered(); |
|
116 |
foreach ( $patterns as $pattern ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
117 |
$migrated_pattern = $this->migrate_pattern_categories( $pattern ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
$prepared_pattern = $this->prepare_item_for_response( $migrated_pattern, $request ); |
19 | 119 |
$response[] = $this->prepare_response_for_collection( $prepared_pattern ); |
120 |
} |
|
121 |
return rest_ensure_response( $response ); |
|
122 |
} |
|
123 |
||
124 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
125 |
* Migrates old core pattern categories to the new categories. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
126 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
127 |
* Core pattern categories are revamped. Migration is needed to ensure |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
128 |
* backwards compatibility. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
129 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
130 |
* @since 6.2.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
* @param array $pattern Raw pattern as registered, before applying any changes. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
* @return array Migrated pattern. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
134 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
135 |
protected function migrate_pattern_categories( $pattern ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
136 |
// No categories to migrate. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
137 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
138 |
! isset( $pattern['categories'] ) || |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
139 |
! is_array( $pattern['categories'] ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
140 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
141 |
return $pattern; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
142 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
143 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
144 |
foreach ( $pattern['categories'] as $index => $category ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
145 |
// If the category exists as a key, then it needs migration. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
146 |
if ( isset( static::$categories_migration[ $category ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
147 |
$pattern['categories'][ $index ] = static::$categories_migration[ $category ]; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
148 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
149 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
150 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
151 |
return $pattern; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
152 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
153 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
154 |
/** |
19 | 155 |
* Prepare a raw block pattern before it gets output in a REST API response. |
156 |
* |
|
157 |
* @since 6.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
158 |
* @since 6.3.0 Added `source` property. |
19 | 159 |
* |
160 |
* @param array $item Raw pattern as registered, before any changes. |
|
161 |
* @param WP_REST_Request $request Request object. |
|
162 |
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
|
163 |
*/ |
|
164 |
public function prepare_item_for_response( $item, $request ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
165 |
// Resolve pattern blocks so they don't need to be resolved client-side |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
166 |
// in the editor, improving performance. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
167 |
$blocks = parse_blocks( $item['content'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
168 |
$blocks = resolve_pattern_blocks( $blocks ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
169 |
$item['content'] = serialize_blocks( $blocks ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
170 |
|
19 | 171 |
$fields = $this->get_fields_for_response( $request ); |
172 |
$keys = array( |
|
173 |
'name' => 'name', |
|
174 |
'title' => 'title', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
175 |
'content' => 'content', |
19 | 176 |
'description' => 'description', |
177 |
'viewportWidth' => 'viewport_width', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
'inserter' => 'inserter', |
19 | 179 |
'categories' => 'categories', |
180 |
'keywords' => 'keywords', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
181 |
'blockTypes' => 'block_types', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
182 |
'postTypes' => 'post_types', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
183 |
'templateTypes' => 'template_types', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
184 |
'source' => 'source', |
19 | 185 |
); |
186 |
$data = array(); |
|
187 |
foreach ( $keys as $item_key => $rest_key ) { |
|
188 |
if ( isset( $item[ $item_key ] ) && rest_is_field_included( $rest_key, $fields ) ) { |
|
189 |
$data[ $rest_key ] = $item[ $item_key ]; |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
$context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
194 |
$data = $this->add_additional_fields_to_object( $data, $request ); |
|
195 |
$data = $this->filter_response_by_context( $data, $context ); |
|
196 |
return rest_ensure_response( $data ); |
|
197 |
} |
|
198 |
||
199 |
/** |
|
200 |
* Retrieves the block pattern schema, conforming to JSON Schema. |
|
201 |
* |
|
202 |
* @since 6.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
203 |
* @since 6.3.0 Added `source` property. |
19 | 204 |
* |
205 |
* @return array Item schema data. |
|
206 |
*/ |
|
207 |
public function get_item_schema() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
208 |
if ( $this->schema ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
209 |
return $this->add_additional_fields_schema( $this->schema ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
210 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
211 |
|
19 | 212 |
$schema = array( |
213 |
'$schema' => 'http://json-schema.org/draft-04/schema#', |
|
214 |
'title' => 'block-pattern', |
|
215 |
'type' => 'object', |
|
216 |
'properties' => array( |
|
217 |
'name' => array( |
|
218 |
'description' => __( 'The pattern name.' ), |
|
219 |
'type' => 'string', |
|
220 |
'readonly' => true, |
|
221 |
'context' => array( 'view', 'edit', 'embed' ), |
|
222 |
), |
|
223 |
'title' => array( |
|
224 |
'description' => __( 'The pattern title, in human readable format.' ), |
|
225 |
'type' => 'string', |
|
226 |
'readonly' => true, |
|
227 |
'context' => array( 'view', 'edit', 'embed' ), |
|
228 |
), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
229 |
'content' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
230 |
'description' => __( 'The pattern content.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
231 |
'type' => 'string', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
232 |
'readonly' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
233 |
'context' => array( 'view', 'edit', 'embed' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
234 |
), |
19 | 235 |
'description' => array( |
236 |
'description' => __( 'The pattern detailed description.' ), |
|
237 |
'type' => 'string', |
|
238 |
'readonly' => true, |
|
239 |
'context' => array( 'view', 'edit', 'embed' ), |
|
240 |
), |
|
241 |
'viewport_width' => array( |
|
242 |
'description' => __( 'The pattern viewport width for inserter preview.' ), |
|
243 |
'type' => 'number', |
|
244 |
'readonly' => true, |
|
245 |
'context' => array( 'view', 'edit', 'embed' ), |
|
246 |
), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
247 |
'inserter' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
248 |
'description' => __( 'Determines whether the pattern is visible in inserter.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
249 |
'type' => 'boolean', |
19 | 250 |
'readonly' => true, |
251 |
'context' => array( 'view', 'edit', 'embed' ), |
|
252 |
), |
|
253 |
'categories' => array( |
|
254 |
'description' => __( 'The pattern category slugs.' ), |
|
255 |
'type' => 'array', |
|
256 |
'readonly' => true, |
|
257 |
'context' => array( 'view', 'edit', 'embed' ), |
|
258 |
), |
|
259 |
'keywords' => array( |
|
260 |
'description' => __( 'The pattern keywords.' ), |
|
261 |
'type' => 'array', |
|
262 |
'readonly' => true, |
|
263 |
'context' => array( 'view', 'edit', 'embed' ), |
|
264 |
), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
'block_types' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
266 |
'description' => __( 'Block types that the pattern is intended to be used with.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
267 |
'type' => 'array', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
268 |
'readonly' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
269 |
'context' => array( 'view', 'edit', 'embed' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
270 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
271 |
'post_types' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
272 |
'description' => __( 'An array of post types that the pattern is restricted to be used with.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
273 |
'type' => 'array', |
19 | 274 |
'readonly' => true, |
275 |
'context' => array( 'view', 'edit', 'embed' ), |
|
276 |
), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
277 |
'template_types' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
278 |
'description' => __( 'An array of template types where the pattern fits.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
279 |
'type' => 'array', |
19 | 280 |
'readonly' => true, |
281 |
'context' => array( 'view', 'edit', 'embed' ), |
|
282 |
), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
283 |
'source' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
284 |
'description' => __( 'Where the pattern comes from e.g. core' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
285 |
'type' => 'string', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
'readonly' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
287 |
'context' => array( 'view', 'edit', 'embed' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
288 |
'enum' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
289 |
'core', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
290 |
'plugin', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
291 |
'theme', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
292 |
'pattern-directory/core', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
293 |
'pattern-directory/theme', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
294 |
'pattern-directory/featured', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
296 |
), |
19 | 297 |
), |
298 |
); |
|
299 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
300 |
$this->schema = $schema; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
return $this->add_additional_fields_schema( $this->schema ); |
19 | 303 |
} |
304 |
} |