функция
since 1.5.0
get_enclosed()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_enclosed( int $post_id ): string[]
Описание
Возвращает enclosures, уже добавленные к записи.
Параметры
$post_id
int
обязательный
Идентификатор записи.
Возвращаемое значение
string[]
Исходный код
wp-includes/post.php:5977
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 );
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

