
如何提高WordPress中的PHP内存限制
rss_enclosure ( No parameters )
rss_enclosure: 这是一个WordPress函数,为一个给定的URL生成一个RSS外壳标签。RSS外壳用于将一个文件与一个RSS提要项目联系起来,允许读者直接从提要中下载和查看该文件。rss_enclosure函数为外壳生成必要的XML标签。
显示当前文章的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', '<enclosure url="' . esc_url( trim( $enclosure[0] ) ) . '" length="' . absint( trim( $enclosure[1] ) ) . '" type="' . esc_attr( $type ) . '" />' . "n" ); } } } }