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發現過程。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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
檢視更多 >