WP_REST_Abilities_V1_Run_Controller::ensure_error_status( WP_Error $error, int $status ): WP_Error

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

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.

Return

WP_Error The error object, with a default status when needed.

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

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.