wp_oembed_ensure_format

函式
wp_oembed_ensure_format ( $format )
引數
  • (string) $format The oEmbed response format. Accepts 'json' or 'xml'.
    Required:
返回值
  • (string) The format, either 'xml' or 'json'. Default 'json'.
定義位置
相關方法
wp_media_insert_url_formwp_oembed_getwp_embed_defaultswp_embed_excerpt_more_oembed_create_xml
引入
4.4.0
棄用
-

wp_oembed_ensure_format: 這個函式確保一個給定的URL具有正確的oEmbed格式。它根據所有可用的oEmbed提供者檢查URL並返回格式化的URL。

確保指定的格式是”json”或”xml”。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_oembed_ensure_format( $format ) {
if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) {
return 'json';
}
return $format;
}
function wp_oembed_ensure_format( $format ) { if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) { return 'json'; } return $format; }
function wp_oembed_ensure_format( $format ) {
	if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) {
		return 'json';
	}

	return $format;
}

常見問題

FAQs
檢視更多 >