WP_REST_Server::json_error PHP Méthode

json_error() protected méthode

Note: This should only be used in WP_REST_Server::serve_request(), as it cannot handle WP_Error internally. All callbacks and other internal methods should instead return a WP_Error with the data set to an array that includes a 'status' key, with the value being the HTTP status to send.
Since: 4.4.0
protected json_error ( string $code, string $message, integer $status = null ) : string
$code string WP_Error-style code.
$message string Human-readable message.
$status integer Optional. HTTP status code to send. Default null.
Résultat string JSON representation of the error
    protected function json_error($code, $message, $status = null)
        if ($status) {
        $error = compact('code', 'message');
        return wp_json_encode($error);