wp_ext2type()WP 2.5.0

Retrieves the file type based on the extension name.

Хуков нет.

Возвращает

Строку|null. The file type, example: audio, video, document, spreadsheet, etc.

Использование

wp_ext2type( $ext );
$ext(строка) (обязательный)
The extension to search.

Список изменений

С версии 2.5.0 Введена.

Код wp_ext2type() WP 6.5.2

function wp_ext2type( $ext ) {
	$ext = strtolower( $ext );

	$ext2type = wp_get_ext_types();
	foreach ( $ext2type as $type => $exts ) {
		if ( in_array( $ext, $exts, true ) ) {
			return $type;
		}
	}
}