Fixed header location when creating attribute terms

This commit is contained in:
Claudio Sanches 2016-03-22 15:34:27 -03:00
parent 5d5f995011
commit 935a784061
1 changed files with 7 additions and 1 deletions

View File

@ -361,7 +361,13 @@ abstract class WC_REST_Terms_Controller extends WP_REST_Controller {
$response = $this->prepare_item_for_response( $term, $request );
$response = rest_ensure_response( $response );
$response->set_status( 201 );
$response->header( 'Location', rest_url( '/' . $this->namespace . '/' . $this->rest_base . '/' . $term->term_id ) );
$base = '/' . $this->namespace . '/' . $this->rest_base;
if ( ! empty( $request['attribute_id'] ) ) {
$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request['attribute_id'], $base );
}
$response->header( 'Location', rest_url( $base . '/' . $term->term_id ) );
return $response;
}