rss_enclosure

函数


rss_enclosure ( No parameters )
定义位置
  • wp-includes/feed.php
    , line 473
引入
1.5.0
弃用

显示当前文章的rss enclosure。

使用全局$post来检查该文章是否需要密码,以及用户是否有该文章的密码。如果没有,那么它将在显示之前返回。

也使用函数get_post_custom()来获取文章的’enclosure’元数据字段,并解析其值来显示enclosure(s)。围栏由带有URI和其他属性的围栏HTML标签组成。

function rss_enclosure() {
	if ( post_password_required() ) {
		return;
	}

	foreach ( (array) get_post_custom() as $key => $val ) {
		if ( 'enclosure' === $key ) {
			foreach ( (array) $val as $enc ) {
				$enclosure = explode( "n", $enc );

				// Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'.
				$t    = preg_split( '/[ t]/', trim( $enclosure[2] ) );
				$type = $t[0];

				/**
				 * Filters the RSS enclosure HTML link tag for the current post.
				 *
				 * @since 2.2.0
				 *
				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
				 */
				echo apply_filters( 'rss_enclosure', '' . "n" );
			}
		}
	}
}