get_enclosed

函式
get_enclosed ( $post_id )
引數
  • (int) $post_id Post ID.
    Required:
返回值
  • (string[]) Array of enclosures for the given post.
定義位置
相關方法
do_encloseatom_enclosureget_extendedrss_enclosureget_locale
引入
1.5.0
棄用
-

get_enclosed: 這個函式用來檢索一個給定的文章的附件URL的列表。附件是用來包括RSS提要中的多媒體內容。

檢索已經為一個文章附上的附件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_enclosed( $post_id ) {
$custom_fields = get_post_custom( $post_id );
$pung = array();
if ( ! is_array( $custom_fields ) ) {
return $pung;
}
foreach ( $custom_fields as $key => $val ) {
if ( 'enclosure' !== $key || ! is_array( $val ) ) {
continue;
}
foreach ( $val as $enc ) {
$enclosure = explode( "n", $enc );
$pung[] = trim( $enclosure[0] );
}
}
/**
* Filters the list of enclosures already enclosed for the given post.
*
* @since 2.0.0
*
* @param string[] $pung Array of enclosures for the given post.
* @param int $post_id Post ID.
*/
return apply_filters( 'get_enclosed', $pung, $post_id );
}
function get_enclosed( $post_id ) { $custom_fields = get_post_custom( $post_id ); $pung = array(); if ( ! is_array( $custom_fields ) ) { return $pung; } foreach ( $custom_fields as $key => $val ) { if ( 'enclosure' !== $key || ! is_array( $val ) ) { continue; } foreach ( $val as $enc ) { $enclosure = explode( "n", $enc ); $pung[] = trim( $enclosure[0] ); } } /** * Filters the list of enclosures already enclosed for the given post. * * @since 2.0.0 * * @param string[] $pung Array of enclosures for the given post. * @param int $post_id Post ID. */ return apply_filters( 'get_enclosed', $pung, $post_id ); }
function get_enclosed( $post_id ) {
	$custom_fields = get_post_custom( $post_id );
	$pung          = array();
	if ( ! is_array( $custom_fields ) ) {
		return $pung;
	}

	foreach ( $custom_fields as $key => $val ) {
		if ( 'enclosure' !== $key || ! is_array( $val ) ) {
			continue;
		}
		foreach ( $val as $enc ) {
			$enclosure = explode( "n", $enc );
			$pung[]    = trim( $enclosure[0] );
		}
	}

	/**
	 * Filters the list of enclosures already enclosed for the given post.
	 *
	 * @since 2.0.0
	 *
	 * @param string[] $pung    Array of enclosures for the given post.
	 * @param int      $post_id Post ID.
	 */
	return apply_filters( 'get_enclosed', $pung, $post_id );
}

常見問題

FAQs
檢視更多 >