[REST API] Include default params in batch create

This commit is contained in:
Claudio Sanches 2016-05-30 20:15:50 -03:00
parent b582febda0
commit 3fd54f0281
1 changed files with 12 additions and 0 deletions

View File

@ -90,6 +90,18 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
if ( ! empty( $items['create'] ) ) {
foreach ( $items['create'] as $item ) {
$_item = new WP_REST_Request( 'POST' );
// Default parameters.
$defaults = array();
$schema = $this->get_public_item_schema();
foreach ( $schema['properties'] as $arg => $options ) {
if ( isset( $options['default'] ) ) {
$defaults[ $arg ] = $options['default'];
}
}
$_item->set_default_params( $defaults );
// Set request parameters.
$_item->set_body_params( $item );
$_response = $this->create_item( $_item );