REST API: Call WP_REST_Server::get_compact_response_links()
and ::get_raw_data()
static methods the right way.
Props andizer, TimothyBlynJacobs. Fixes #47578. git-svn-id: https://develop.svn.wordpress.org/trunk@45566 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fc10b6bbcd
commit
5118e5e266
@ -1395,7 +1395,7 @@ function rest_preload_api_request( $memo, $path ) {
|
|||||||
if ( 200 === $response->status ) {
|
if ( 200 === $response->status ) {
|
||||||
$server = rest_get_server();
|
$server = rest_get_server();
|
||||||
$data = (array) $response->get_data();
|
$data = (array) $response->get_data();
|
||||||
$links = $server->get_compact_response_links( $response );
|
$links = $server::get_compact_response_links( $response );
|
||||||
if ( ! empty( $links ) ) {
|
if ( ! empty( $links ) ) {
|
||||||
$data['_links'] = $links;
|
$data['_links'] = $links;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ class WP_REST_Server {
|
|||||||
$request->set_body_params( wp_unslash( $_POST ) );
|
$request->set_body_params( wp_unslash( $_POST ) );
|
||||||
$request->set_file_params( $_FILES );
|
$request->set_file_params( $_FILES );
|
||||||
$request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
|
$request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
|
||||||
$request->set_body( $this->get_raw_data() );
|
$request->set_body( self::get_raw_data() );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check
|
* HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check
|
||||||
@ -437,7 +437,7 @@ class WP_REST_Server {
|
|||||||
*/
|
*/
|
||||||
public function response_to_data( $response, $embed ) {
|
public function response_to_data( $response, $embed ) {
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$links = $this->get_compact_response_links( $response );
|
$links = self::get_compact_response_links( $response );
|
||||||
|
|
||||||
if ( ! empty( $links ) ) {
|
if ( ! empty( $links ) ) {
|
||||||
// Convert links to part of the data.
|
// Convert links to part of the data.
|
||||||
|
@ -212,7 +212,7 @@ abstract class WP_REST_Controller {
|
|||||||
|
|
||||||
$data = (array) $response->get_data();
|
$data = (array) $response->get_data();
|
||||||
$server = rest_get_server();
|
$server = rest_get_server();
|
||||||
$links = $server->get_compact_response_links( $response );
|
$links = $server::get_compact_response_links( $response );
|
||||||
|
|
||||||
if ( ! empty( $links ) ) {
|
if ( ! empty( $links ) ) {
|
||||||
$data['_links'] = $links;
|
$data['_links'] = $links;
|
||||||
|
Loading…
Reference in New Issue
Block a user