You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add lazy schema factories with runtime enum validation
Convert several input schemas from static arrays to callable factories so
that post types, taxonomies, post statuses, user roles, and MIME types are
resolved at schema-exposure time rather than at construction time.
- Add `resolve_input_schema()` to invoke callables or pass arrays through
- Add `enum_string_prop()` and runtime registry helpers for post types,
taxonomies, post statuses, roles, and MIME types
- Add `validate_post_status()`, `validate_mime_type()`, and
`validate_user_role()` with 400 errors on unknown values
- Apply status/role/mime-type validation in `search_content`,
`search_content_items`, `save_content`, `upload_media`, and `save_user`
- Wrap schemas in `ContentManagementTools`, `MediaTools`, `SiteManagementTools`,
`TaxonomyTools` as factory callables
- Extend `tests/run.php` stubs for `get_post_stati`, `get_taxonomies`,
`get_editable_roles`, `get_allowed_mime_types`, and add assertions that
late-registered types and statuses appear in lazily-resolved schemas
'status' => $this->string_prop( 'Comment query status. Use a status accepted by WordPress comment queries; all returns every discoverable status.', 'all' ),
32
32
'search' => $this->string_prop( 'Search term.' ),
33
33
'page' => $this->int_prop( 'Page number.', 1 ),
34
34
'per_page' => $this->int_prop( 'Comments per page.', 20 ),
@@ -48,7 +48,7 @@ private function add_comment_abilities() {
'status' => $this->enum_string_prop( 'Registered post status or the WordPress query any pseudo-status.', $this->get_registered_post_status_names( true ), 'publish' ),
90
94
'author' => $this->int_prop( 'Author user ID.' ),
91
95
'taxonomy_query' => $taxonomy_query_schema,
92
96
'date_query' => $date_query_schema,
@@ -96,31 +100,36 @@ private function add_content_abilities() {
96
100
'per_page' => $this->int_prop( 'Items per page.', 10 ),
97
101
),
98
102
array( 'post_type' )
99
-
);
100
-
$save_content_schema = $this->schema(
103
+
);
104
+
};
105
+
$save_content_schema = function () use ( $taxonomies_schema, $meta_schema ) {
106
+
return$this->schema(
101
107
array(
102
-
'post_type' => $this->string_prop( 'Post type slug.' ),
108
+
'post_type' => $this->enum_string_prop( 'Registered post type slug.', $this->get_registered_post_type_slugs() ),
103
109
'id' => $this->int_prop( 'Content item ID. Omit to create a new item.' ),
104
110
'title' => $this->string_prop( 'Title. Required when creating content.' ),
$this->add_ability( self::INTERNAL_PREFIX . 'list-media', 'List Media', 'List WordPress media items with pagination and filtering', $list_schema, function ( $params ) {
0 commit comments