get_media_items()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_media_items( int $post_id, array $errors ): string
Описание
Полученная HTML-разметка создаётся для индикатора прогресса компонента SWF Upload. Также создаётся ссылка для показа и скрытия формы изменения изображения-вложения.
Оригинал (английский)
The HTML markup retrieved will be created for the progress of SWF Upload component. Will also create link for showing and hiding the form to modify the image attachment.
Параметры
$post_id
int
обязательный
$errors
array
обязательный
Возвращаемое значение
string
Исходный код
wp-admin/includes/media.php:1546
function get_media_items( $post_id, $errors ) {
$attachments = array();
if ( $post_id ) {
$post = get_post( $post_id );
if ( $post && 'attachment' === $post->post_type ) {
$attachments = array( $post->ID => $post );
} else {
$attachments = get_children(
array(
'post_parent' => $post_id,
'post_type' => 'attachment',
'orderby' => 'menu_order ASC, ID',
'order' => 'DESC',
)
);
}
} else {
if ( is_array( $GLOBALS['wp_the_query']->posts ) ) {
foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) {
$attachments[ $attachment->ID ] = $attachment;
}
}
}
$output = '';
foreach ( (array) $attachments as $id => $attachment ) {
if ( 'trash' === $attachment->post_status ) {
continue;
}
$item = get_media_item( $id, array( 'errors' => $errors[ $id ] ?? null ) );
if ( $item ) {
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
}
}
return $output;
}
История изменений
| Версия | Описание |
|---|---|
| 2.5.0 | Introduced. |

