wpcf7_convert_mime_to_ext()CF7 1.0

Converts a MIME type string to an array of corresponding file extensions.

Хуков нет.

Возвращает

Массив. Corresponding file extensions.

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

wpcf7_convert_mime_to_ext( $mime );
$mime(строка) (обязательный)
MIME type. Wildcard (*) is available for the subtype part.

Код wpcf7_convert_mime_to_ext() CF7 5.9.3

function wpcf7_convert_mime_to_ext( $mime ) {
	static $mime_types = array();

	$mime_types = wp_get_mime_types();

	$results = array();

	if ( preg_match( '%^([a-z]+)/([*]|[a-z0-9.+-]+)$%i', $mime, $matches ) ) {
		foreach ( $mime_types as $key => $val ) {
			if ( '*' === $matches[2] and str_starts_with( $val, $matches[1] . '/' )
		 	or $val === $matches[0] ) {
				$results = array_merge( $results, explode( '|', $key ) );
			}
		}
	}

	$results = array_unique( $results );
	$results = array_filter( $results );
	$results = array_values( $results );

	return $results;
}