1. 首页
  2. WordPress钩子手册

get_enclosed

apply_filters( ‘get_enclosed’, string[] $pung, int $post_id )

过滤器::过滤给定post已包含的附件列表。
Filter Hook: Filters the list of enclosures already enclosed for the given post.

目录锚点:#参数#源码


参数(Parameters)

参数 类型 说明
$pung (string[]) 给定柱的外壳阵列。
$post_id (int) 邮政编码。

源码(Source)

/**
 * Retrieve enclosures already enclosed for a post.
 *
 * @since 1.5.0
 *
 * @param int $post_id Post ID.
 * @return array List of enclosures.
 */
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( "
", $enc );
			$pung[] = trim( $enclosure[ 0 ] );
		}
	}

	/**
	 * Filter the list of enclosures already enclosed for the given post.
	 *
	 * @since 2.0.0
	 *
	 * @param array $pung    Array of enclosures for the given post.
	 * @param int   $post_id Post ID.
	 */
	return apply_filters( 'get_enclosed', $pung, $post_id );
}
更新版本 源码位置 使用 被使用
2.0.0 wp-includes/post.php:4776 1 0

get_enclosed 为WP2原创文章,链接:https://www.wp2.cn/hook/get_enclosed-2/

发表评论

您的电子邮箱地址不会被公开。