最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rest api - Wordpress custom endpoint returning blank response

programmeradmin5浏览0评论

I have written some custom endpoints in wordpress plugin. Previously when i used wp_send_json to return data from custom endpoint. But as of wordpress 5.5 the usage of wp_send_json is deprecated. Now Iam returning WP_REST_Response from the custom endpoint. But when i try the request after this logic change Iam getting blank responses.

Here is the code iam using to send response from callback.

public static function sendJSON($data)
    {
        $response             = [];
        $response = ["result" => $data['data'], "result_length" => sizeof($data['data']), "status_message" => "Success", "status" => $data['status']];
        
        return new WP_REST_Response($response, 200);
    }
发布评论

评论列表(0)

  1. 暂无评论