wp_filter_pre_oembed_result

函数
wp_filter_pre_oembed_result ( $result, $url, $args )
参数
  • (null|string) $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
    Required:
  • (string) $url The URL that should be inspected for discovery `<link>` tags.
    Required:
  • (array) $args oEmbed remote get arguments.
    Required:
返回值
  • (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.
定义位置
相关方法
wp_filter_oembed_resultwp_filter_post_kseswp_filter_commentwp_filter_nohtml_kseswp_filter_oembed_iframe_title_attribute
引入
4.5.3
弃用
-

wp_filter_pre_oembed_result:这个过滤器用于在请求之前修改oEmbed的结果。它把oEmbed的URL作为一个参数,并返回修改后的URL。

在提出任何HTTP请求之前过滤oEmbed结果。

如果该URL属于当前站点,则直接获取结果,而不是通过oEmbed发现过程。

function wp_filter_pre_oembed_result( $result, $url, $args ) {
	$data = get_oembed_response_data_for_url( $url, $args );

	if ( $data ) {
		return _wp_oembed_get_object()->data2html( $data, $url );
	}

	return $result;
}

常见问题

FAQs
查看更多 >