当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_REST_Response::get_data方法代码示例

本文整理汇总了PHP中WP_REST_Response::get_data方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_REST_Response::get_data方法的具体用法?PHP WP_REST_Response::get_data怎么用?PHP WP_REST_Response::get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_REST_Response的用法示例。


在下文中一共展示了WP_REST_Response::get_data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare_response_for_collection

 /**
  * Prepare a response for inserting into a collection.
  *
  * @param WP_REST_Response $response Response object.
  * @return array Response data, ready for insertion into collection data.
  */
 public function prepare_response_for_collection($response)
 {
     if (!$response instanceof WP_REST_Response) {
         return $response;
     }
     $data = (array) $response->get_data();
     $server = rest_get_server();
     if (method_exists($server, 'get_compact_response_links')) {
         $links = call_user_func(array($server, 'get_compact_response_links'), $response);
     } else {
         $links = call_user_func(array($server, 'get_response_links'), $response);
     }
     if (!empty($links)) {
         $data['_links'] = $links;
     }
     return $data;
 }
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:23,代码来源:class-wp-rest-controller.php

示例2: filter_ee_metadata_into_index

 /**
  * Adds EE metadata to the index
  * @param WP_REST_Response $rest_response_obj
  * @return WP_REST_Response
  */
 public static function filter_ee_metadata_into_index($rest_response_obj)
 {
     $response_data = $rest_response_obj->get_data();
     $addons = array();
     foreach (\EE_Registry::instance()->addons as $addon) {
         $addon_json = array('name' => $addon->name(), 'version' => $addon->version());
         $addons[$addon_json['name']] = $addon_json;
     }
     $response_data['ee'] = array('version' => \EEM_System_Status::instance()->get_ee_version(), 'addons' => $addons, 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()));
     $rest_response_obj->set_data($response_data);
     return $rest_response_obj;
 }
开发者ID:teemuoksanen,项目名称:event-espresso-core,代码行数:17,代码来源:Meta.php

示例3: filter_ee_metadata_into_index

 /**
  * Adds EE metadata to the index
  * @param \WP_REST_Response $rest_response_obj
  * @return \WP_REST_Response
  */
 public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj)
 {
     $response_data = $rest_response_obj->get_data();
     $addons = array();
     foreach (\EE_Registry::instance()->addons as $addon) {
         $addon_json = array('name' => $addon->name(), 'version' => $addon->version());
         $addons[$addon_json['name']] = $addon_json;
     }
     $response_data['ee'] = array('version' => \EEM_System_Status::instance()->get_ee_version(), 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', 'addons' => $addons, 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()));
     $rest_response_obj->set_data($response_data);
     return $rest_response_obj;
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:17,代码来源:Meta.php

示例4: response_to_data

 /**
  * Converts a response to data to send.
  *
  * @since 4.4.0
  * @access public
  *
  * @param WP_REST_Response $response Response object.
  * @param bool             $embed    Whether links should be embedded.
  * @return array {
  *     Data with sub-requests embedded.
  *
  *     @type array [$_links]    Links.
  *     @type array [$_embedded] Embeddeds.
  * }
  */
 public function response_to_data($response, $embed)
 {
     $data = $response->get_data();
     $links = $this->get_compact_response_links($response);
     if (!empty($links)) {
         // Convert links to part of the data.
         $data['_links'] = $links;
     }
     if ($embed) {
         // Determine if this is a numeric array.
         if (wp_is_numeric_array($data)) {
             $data = array_map(array($this, 'embed_links'), $data);
         } else {
             $data = $this->embed_links($data);
         }
     }
     return $data;
 }
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:33,代码来源:class-wp-rest-server.php

示例5: prepare_response_for_collection

 /**
  * Prepare a response for inserting into a collection.
  *
  * @param WP_REST_Response $response Response object.
  * @return array Response data, ready for insertion into collection data.
  */
 public function prepare_response_for_collection($response)
 {
     if (!$response instanceof WP_REST_Response) {
         return $response;
     }
     $data = (array) $response->get_data();
     $links = WP_REST_Server::get_response_links($response);
     if (!empty($links)) {
         $data['_links'] = $links;
     }
     return $data;
 }
开发者ID:alexandrinos,项目名称:wp-api-rest,代码行数:18,代码来源:class-wp-rest-controller.php

示例6: response_to_data

 /**
  * Convert a response to data to send
  *
  * @param WP_REST_Response $response Response object
  * @param boolean $embed Should we embed links?
  * @return array
  */
 public function response_to_data($response, $embed)
 {
     $data = $this->prepare_response($response->get_data());
     $links = $this->get_response_links($response);
     if (!empty($links)) {
         // Convert links to part of the data
         $data['_links'] = $links;
     }
     if ($embed) {
         // Is this a numeric array?
         if (rest_is_list($data)) {
             $data = array_map(array($this, 'embed_links'), $data);
         } else {
             $data = $this->embed_links($data);
         }
     }
     return $data;
 }
开发者ID:hypenotic,项目名称:ingenuity,代码行数:25,代码来源:class-wp-rest-server.php

示例7: assertResponseData

 /**
  * Check response data.
  *
  * @since 4.4.0
  *
  * @param array            $data
  * @param WP_REST_Response $response
  */
 protected function assertResponseData($data, $response)
 {
     $response_data = $response->get_data();
     $tested_data = array();
     foreach ($data as $key => $value) {
         if (isset($response_data[$key])) {
             $tested_data[$key] = $response_data[$key];
         } else {
             $tested_data[$key] = null;
         }
     }
     $this->assertEquals($data, $tested_data);
 }
开发者ID:automattic,项目名称:jetpack,代码行数:21,代码来源:test_class.rest-api-endpoints.php


注:本文中的WP_REST_Response::get_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。