函数原型
get_enclosed( int $post_id ): string[]
函数描述
Retrieves enclosures already enclosed for a post.
是否弃用
未弃用
函数参数
-
$post_id
int
Required - Post ID.
函数返回值
string[] Array of enclosures for the given post.
函数位置
File: wp-includes/post.php.
函数源码
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

