WP_Widget_Media::is_attachment_with_mime_type()
Determine if the supplied attachment is for a valid attachment post with the specified MIME type.
Метод класса: WP_Widget_Media{}
Хуков нет.
Возвращает
true|false
. Is matching MIME type.
Использование
$WP_Widget_Media = new WP_Widget_Media(); $WP_Widget_Media->is_attachment_with_mime_type( $attachment, $mime_type );
- $attachment(int|WP_Post) (обязательный)
- Attachment post ID or object.
- $mime_type(строка) (обязательный)
- MIME type.
Список изменений
С версии 4.8.0 | Введена. |
Код WP_Widget_Media::is_attachment_with_mime_type() WP Widget Media::is attachment with mime type WP 6.7.2
public function is_attachment_with_mime_type( $attachment, $mime_type ) { if ( empty( $attachment ) ) { return false; } $attachment = get_post( $attachment ); if ( ! $attachment ) { return false; } if ( 'attachment' !== $attachment->post_type ) { return false; } return wp_attachment_is( $mime_type, $attachment ); }