Ensures a WP_Error object carries an HTTP status, adding a default when none is set.
Parameters
$errorWP_Errorrequired- Error object to update.
$statusintrequired- HTTP status code to add if not already present.
Source
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;
}
Changelog
| Version | Description |
|---|---|
| 7.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.