本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}