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


PHP get_oembed_response_data函数代码示例

本文整理汇总了PHP中get_oembed_response_data函数的典型用法代码示例。如果您正苦于以下问题:PHP get_oembed_response_data函数的具体用法?PHP get_oembed_response_data怎么用?PHP get_oembed_response_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_item

 /**
  * Callback for our API endpoint.
  *
  * Returns the JSON object for the post.
  *
  * @param WP_REST_Request $request Full data about the request.
  * @return WP_Error|WP_REST_Response
  */
 public function get_item($request)
 {
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post id.
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requestd URL.
      */
     $post_id = apply_filters('oembed_request_post_id', $post_id, $request['url']);
     if (0 === $post_id) {
         return new WP_Error('oembed_invalid_url', __('Invalid URL.', 'oembed-api'), array('status' => 404));
     }
     return get_oembed_response_data($post_id, $request['maxwidth']);
 }
开发者ID:rmccue,项目名称:oEmbed-API,代码行数:23,代码来源:class-wp-rest-oembed-controller.php

示例2: get_item

 /**
  * Callback for the API endpoint.
  *
  * Returns the JSON object for the post.
  *
  * @since 4.4.0
  *
  * @param WP_REST_Request $request Full data about the request.
  * @return WP_Error|array oEmbed response data or WP_Error on failure.
  */
 public function get_item($request)
 {
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post ID.
      *
      * @since 4.4.0
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requested URL.
      */
     $post_id = apply_filters('oembed_request_post_id', $post_id, $request['url']);
     $data = get_oembed_response_data($post_id, $request['maxwidth']);
     if (!$data) {
         return new WP_Error('oembed_invalid_url', get_status_header_desc(404), array('status' => 404));
     }
     return $data;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:28,代码来源:class-wp-oembed-controller.php

示例3: get_item

 /**
  * Callback for our API endpoint.
  *
  * Returns the JSON object for the post.
  *
  * @param WP_REST_Request $request Full details about the request.
  *
  * @return WP_Error|WP_REST_Response
  */
 public function get_item(WP_REST_Request $request)
 {
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post id.
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requestd URL.
      */
     $post_id = apply_filters('oembed_request_post_id', $post_id, $request['url']);
     if (0 === $post_id) {
         return new WP_Error('oembed_invalid_url', __('Invalid URL.', 'oembed-api'), array('status' => 404));
     }
     // Todo: Perhaps just default to json if something invalid is provided.
     if (!in_array($request['format'], array('json', 'xml'))) {
         return new WP_Error('oembed_invalid_format', __('Invalid format.', 'oembed-api'), array('status' => 501));
     }
     return rest_ensure_response(get_oembed_response_data($post_id, $request['maxwidth']));
 }
开发者ID:noplanman,项目名称:oEmbed-API,代码行数:28,代码来源:class-wp-rest-oembed-controller.php

示例4: dispatch

 /**
  * Handle the whole request and print the response.
  *
  * @param array $request The request arguments.
  * @return string The oEmbed API response.
  */
 public function dispatch($request)
 {
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post id.
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requestd URL.
      */
     $post_id = apply_filters('oembed_request_post_id', $post_id, $request['url']);
     $data = get_oembed_response_data($post_id, $request['maxwidth']);
     if (false === $data) {
         status_header(404);
         return __('Invalid URL.', 'oembed-api');
     }
     if ('json' === $request['format']) {
         return $this->json_response($data, $request);
     }
     return $this->xml_response($data);
 }
开发者ID:kraftbj,项目名称:oEmbed-API,代码行数:26,代码来源:class-wp-legacy-oembed-controller.php

示例5: dispatch

 /**
  * Handle the whole request and print the response.
  *
  * @param array $request The request arguments.
  * @return string The oEmbed API response.
  */
 public function dispatch($request)
 {
     if (!in_array($request['format'], array('json', 'xml'))) {
         status_header(501);
         return 'Invalid format';
     }
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post id.
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requestd URL.
      */
     $post_id = apply_filters('rest_oembed_request_post_id', $post_id, $request['url']);
     if (0 === $post_id) {
         status_header(404);
         return 'Not Found';
     }
     $data = get_oembed_response_data($post_id, $request['maxwidth']);
     if ('json' === $request['format']) {
         return $this->json_response($data, $request);
     }
     return $this->xml_response($data);
 }
开发者ID:aaronjorbin,项目名称:oEmbed-API,代码行数:30,代码来源:class-wp-legacy-oembed-controller.php

示例6: test_get_oembed_response_data_attachment

 /**
  * Test oEmbed response data with attachments
  */
 function test_get_oembed_response_data_attachment()
 {
     $parent = $this->factory->post->create();
     $file = DIR_TESTDATA . '/images/canola.jpg';
     $post = $this->factory->attachment->create_object($file, $parent, array('post_mime_type' => 'image/jpeg'));
     $data = get_oembed_response_data($post, 400);
     $this->assertArrayHasKey('thumbnail_url', $data);
     $this->assertArrayHasKey('thumbnail_width', $data);
     $this->assertArrayHasKey('thumbnail_height', $data);
     $this->assertTrue(400 >= $data['thumbnail_width']);
 }
开发者ID:johnbillion,项目名称:oEmbed-API,代码行数:14,代码来源:test-plugin.php

示例7: wp_filter_pre_oembed_result

/**
 * Filters the oEmbed result before any HTTP requests are made.
 *
 * If the URL belongs to the current site, the result is fetched directly instead of
 * going through the oEmbed discovery process.
 *
 * @since 4.5.3
 *
 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
 * @param string      $url    The URL that should be inspected for discovery `<link>` tags.
 * @param array       $args   oEmbed remote get arguments.
 * @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
 *                     Null if the URL does not belong to the current site.
 */
function wp_filter_pre_oembed_result($result, $url, $args)
{
    $post_id = url_to_postid($url);
    /** This filter is documented in wp-includes/class-wp-oembed-controller.php */
    $post_id = apply_filters('oembed_request_post_id', $post_id, $url);
    if (!$post_id) {
        return $result;
    }
    $width = isset($args['width']) ? $args['width'] : 0;
    $data = get_oembed_response_data($post_id, $width);
    $data = _wp_oembed_get_object()->data2html((object) $data, $url);
    if (!$data) {
        return $result;
    }
    return $data;
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:30,代码来源:embed.php


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