WP_REST_Abilities_V1_Run_Controller::ensure_error_status
Ensures a WP_Error object carries an HTTP status, adding a default when none is set.
Method of the class: WP_REST_Abilities_V1_Run_Controller{}
No Hooks.
Returns
WP_Error. The error object, with a default status when needed.
Usage
// private - for code of main (parent) class only $result = $this->ensure_error_status( $error, $status ): WP_Error;
- $error(WP_Error) (required)
- Error object to update.
- $status(int) (required)
- HTTP status code to add if not already present.
Changelog
| Since 7.1.0 | Introduced. |
WP_REST_Abilities_V1_Run_Controller::ensure_error_status() WP REST Abilities V1 Run Controller::ensure error status code WP 7.1
private function ensure_error_status( WP_Error $error, int $status ): WP_Error {
$error_data = $error->get_error_data();
if ( ! is_array( $error_data ) || ! isset( $error_data['status'] ) ) {
$error->add_data( array( 'status' => $status ) );
}
return $error;
}