返回介绍

wp_filter_pre_oembed_result()

发布于 2017-09-11 11:57:19 字数 2310 浏览 854 评论 0 收藏 0

wp_filter_pre_oembed_result( null|string $result,  string $url,  array $args )

Filters the oEmbed result before any HTTP requests are made.


description

If the URL belongs to the current site, the result is fetched directly instead of going through the oEmbed discovery process.


参数

$result

(null|string) (Required) The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.

$url

(string) (Required) The URL that should be inspected for discovery <link> tags.

$args

(array) (Required) oEmbed remote get arguments.


返回值

(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.


源代码

File: wp-includes/embed.php

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;
}

更新日志

Versiondescription
4.5.3Introduced.

相关函数

Uses

  • wp-includes/embed.php: get_oembed_response_data()
  • wp-includes/class-wp-oembed-controller.php: oembed_request_post_id
  • wp-includes/embed.php: _wp_oembed_get_object()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/rewrite.php: url_to_postid()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文