WP_REST_Response 返回结果类
WordPress 开发文档
收录了这篇文章

在开发 WordPress RESTful API 时,用来返回结果集。可以修改 http 请求的状态码。

$data = array( 'some', 'response', 'data' );
 
// Create the response object
$response = new WP_REST_Response( $data );
 
// Add a custom status code
$response->set_status( 201 );
 
// Add a custom header
$response->header( 'Location', 'http://example.com/' );

官方文档:

http://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/

http://developer.wordpress.org/reference/classes/wp_rest_response/

 

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
随机推荐
macOS 使用 crontab 定时任务
浏览器的同源和跨域
Node.js 实现 RBAC 权限模型
JavaScript 流式传输数据 SSE (Server-Sent Events)
WordPress 评论表单函数 comment_form()
Flame 插件
WordPress 插入文章函数 wp_insert_post()
JavaScript 和 CSS 检测横屏适配