wp-api-customize-endpoints icon indicating copy to clipboard operation
wp-api-customize-endpoints copied to clipboard

Add 'ids' collection param for settings and partials to allow a set of dynamic items to be fetched

Open westonruter opened this issue 8 years ago • 0 comments

One use case in Customize Posts plugin is to fetch the settings for dynamic settings on demand. The customize-posts-fetch-settings admin ajax request takes a post_ids param and then returns the setting params for any post settings for these IDs. See the source: https://github.com/xwp/wp-customize-posts/blob/d87ff821ddb4611a1bade7859498cbb97d2b77ac/php/class-wp-customize-posts.php#L1473-L1499

Something like this should be possible with the REST API as well. I should be able to make a request to:

/wp-json/customize/v1/settings?ids=post[page][1],post[page][3],post[page][3]

And this should return a collection of just these three settings, which may or may not have been dynamically created.

Such an ids param would be similar to the include param in the posts endpoint: https://github.com/WordPress/wordpress-develop/blob/94d95184b04ccb49f593720ffb04fb0e36da23e5/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2100-L2107

Maybe the include name actually should be used instead even. The key thing is to just pass the array supplied to this param to the add_dynamic_settings method.

This should also be done for partials, sync they can also be dynamic.

westonruter avatar Jul 21 '17 21:07 westonruter