WP_REST_Controller::prepare_item_for_response( mixed $item, WP_REST_Request $request ): WP_REST_Response|WP_Error

In this article

Prepares the item for the REST response.

Parameters

$itemmixedrequired
WordPress representation of the item.
$requestWP_REST_Requestrequired
Request object.

Return

WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

Source

public function prepare_item_for_response( $item, $request ) {
	return new WP_Error(
		'invalid-method',
		/* translators: %s: Method name. */
		sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ),
		array( 'status' => 405 )
	);
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

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