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


PHP WC_Webhook::get_post_data方法代码示例

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


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

示例1: get_webhook

 /**
  * Get the webhook for the given ID
  *
  * @since 2.2
  * @param int $id webhook ID
  * @param array $fields
  * @return array
  */
 public function get_webhook($id, $fields = null)
 {
     // ensure webhook ID is valid & user has permission to read
     $id = $this->validate_request($id, 'shop_webhook', 'read');
     if (is_wp_error($id)) {
         return $id;
     }
     $webhook = new WC_Webhook($id);
     $webhook_data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'created_at' => $this->server->format_datetime($webhook->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($webhook->get_post_data()->post_modified_gmt));
     return array('webhook' => apply_filters('woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this));
 }
开发者ID:abcode619,项目名称:wpstuff,代码行数:19,代码来源:class-wc-api-webhooks.php

示例2: prepare_item_for_response

 /**
  * Prepare a single webhook output for response.
  *
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response $response Response data.
  */
 public function prepare_item_for_response($post, $request)
 {
     $id = (int) $post->ID;
     $webhook = new WC_Webhook($id);
     $data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'date_created' => wc_rest_prepare_date_response($webhook->get_post_data()->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($webhook->get_post_data()->post_modified_gmt));
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($data, $request);
     $data = $this->filter_response_by_context($data, $context);
     // Wrap the data in a response object.
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($post));
     /**
      * Filter webhook object returned from the REST API.
      *
      * @param WP_REST_Response $response The response object.
      * @param WC_Webhook       $webhook  Webhook object used to create response.
      * @param WP_REST_Request  $request  Request object.
      */
     return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request);
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:26,代码来源:class-wc-rest-webhooks-controller.php


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