Merge pull request #12791 from mattallan/system_status_endpoint_editable

Make the `GET /system_status` API response more customisable
This commit is contained in:
Claudio Sanches 2017-01-10 12:30:35 -02:00 committed by GitHub
commit 4b3c44fea3
1 changed files with 25 additions and 0 deletions

View File

@ -83,6 +83,8 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$response[ $section ] = $values;
}
$response = $this->prepare_item_for_response( $response, $request );
return rest_ensure_response( $response );
}
@ -848,4 +850,27 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
);
}
/**
* Prepare the system status response
*
* @param array $system_status
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response( $system_status, $request ) {
$data = $this->add_additional_fields_to_object( $system_status, $request );
$data = $this->filter_response_by_context( $data, 'view' );
$response = rest_ensure_response( $data );
/**
* Filter the system status returned from the REST API.
*
* @param WP_REST_Response $response The response object.
* @param mixed $system_status System status
* @param WP_REST_Request $request Request object.
*/
return apply_filters( 'woocommerce_rest_prepare_system_status', $response, $system_status, $request );
}
}