Add customize sections REST endpoint. #10
Conversation
/** This action is documented in wp-includes/class-wp-customize-manager.php */ | ||
do_action( 'customize_register', $wp_customize ); | ||
} | ||
$wp_customize->prepare_controls(); |
miina
Jun 8, 2017
Author
Collaborator
@westonruter Added the prepare_controls
here since this will "fill in" the controls of a section. Do you think it's better to create a separate logic to detect the related controls instead? Seems that some get_item()
tests with custom sections are failing when using prepare_controls
. I haven't yet looked into that more thoroughly to detect the issue but wanted to ask your opinion about using prepare_controls
like this here first.
@westonruter Added the prepare_controls
here since this will "fill in" the controls of a section. Do you think it's better to create a separate logic to detect the related controls instead? Seems that some get_item()
tests with custom sections are failing when using prepare_controls
. I haven't yet looked into that more thoroughly to detect the issue but wanted to ask your opinion about using prepare_controls
like this here first.
westonruter
Jun 8, 2017
Member
I think you're right to call it here. 👍
I think you're right to call it here.
@westonruter Created the endpoint for sections as well. If you have time to take a look and let know if anything looks incorrect/missing, would be great. |
*/ | ||
public function get_item_schema() { | ||
|
||
$schema = array( |
westonruter
Jun 8, 2017
Member
Since the json
methods in WP_Customize_Setion
subclass can add additional params, it would probably be good to explicitly add the 'additionalProperties' => true,
to the schema. That would mean that the additional props could be included even if the WP_Customize_Section
didn't register the field's schema via register_rest_field()
.
Since the json
methods in WP_Customize_Setion
subclass can add additional params, it would probably be good to explicitly add the 'additionalProperties' => true,
to the schema. That would mean that the additional props could be included even if the WP_Customize_Section
didn't register the field's schema via register_rest_field()
.
miina
Jun 9, 2017
Author
Collaborator
@westonruter As far as I can read out from the schema documentation it's true
by default. Do you think it's still better to add it for clarity? Will do that.
@westonruter As far as I can read out from the schema documentation it's true
by default. Do you think it's still better to add it for clarity? Will do that.
westonruter
Jun 9, 2017
Member
OK, I wasn't aware it was true
by default. Either way then.
OK, I wasn't aware it was true
by default. Either way then.
@westonruter And same story here -- if you have time to check if anything seems to be incorrect or missing from the PR would be great. A sample output: {
"instance_number": 5,
"id": "background_image",
"priority": 80,
"panel": "",
"theme_supports": "custom-background",
"title": "Background Image",
"description": "",
"controls": [
"background_image",
"background_preset",
"background_position",
"background_size",
"background_repeat",
"background_attachment"
],
"type": "default",
"description_hidden": false,
"_links": {
"self": [
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/sections/background_image"
}
],
"controls": [
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_image"
},
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_preset"
},
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_position"
},
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_size"
},
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_repeat"
},
{
"href": "http://src.wordpress-develop.dev/wp-json/customize/v1/controls/background_attachment"
}
]
}
} |
@miina as noted in another PR, I think Also, as I just noted elsewhere, the I wonder if the |
@westonruter In this case should the Or you're thinking that in case of objects it should be |
@miina I think that in the REST API that an empty value like For example, when a post has a placeholder empty datetime as The comment resource's Nevertheless, the So I think it's ultimately your call. In practice I think it won't matter to much sine they are both falsey values. Both should be accepted as input, but as output personally I think |
Closing in favor of #15. |
miina commentedJun 8, 2017
No description provided.