WP_REST_Server::error_to_response()
Converts an error to a response object.
This iterates over all error codes and messages to change it into a flat array. This enables simpler client behavior, as it is represented as a list in JSON rather than an object/map.
Метод класса: WP_REST_Server{}
Хуков нет.
Возвращает
WP_REST_Response
. List of associative arrays with code and message keys.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->error_to_response( $error );
- $error(WP_Error) (обязательный)
- WP_Error instance.
Список изменений
С версии 4.4.0 | Введена. |
С версии 5.7.0 | Converted to a wrapper of rest_convert_error_to_response(). |
Код WP_REST_Server::error_to_response() WP REST Server::error to response WP 6.2.2
protected function error_to_response( $error ) { return rest_convert_error_to_response( $error ); }