Skip to content

Commit

Permalink
Fixed header location when creating attribute terms
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Mar 22, 2016
1 parent 5d5f995 commit 935a784
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion includes/abstracts/abstract-wc-rest-terms-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,13 @@ public function create_item( $request ) {
$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;
}
Expand Down

0 comments on commit 935a784

Please sign in to comment.