首页 WordPress函数大全 rest_ensure_response()

rest_ensure_response()

2020-05-02 / 6253阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

rest_ensure_response( WP_HTTP_Response|WP_Error|mixed $response )

确保REST响应是响应对象(出于一致性)。

描述

这实现了WP_HTTP_Response,允许使用set_status / header / etc,而无需再次检查对象。还将允许WP_Error指示错误响应,因此用户应立即检查该值。

参数

$response

(WP_HTTP_Response|WP_Error|mixed)
(Required)
Response to check.

返回

(WP_REST_Response|mixed) If response generated an error, WP_Error, if response is already an instance, WP_HTTP_Response, otherwise returns a new WP_REST_Response instance.

大家谈论
    我的见解