wp_get_ext_types example

/** * Retrieves the file type based on the extension name. * * @since 2.5.0 * * @param string $ext The extension to search. * @return string|void The file type, example: audio, video, document, spreadsheet, etc. */
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;
        }
    }
}

/** * Returns first matched extension for the mime-type, * as mapped from wp_get_mime_types(). * * @since 5.8.1 * * @param string $mime_type * * @return string|false */
'archive'     => array(
            _x( 'Archives', 'file type group' ),
            __( 'Manage Archives' ),
            /* translators: %s: Number of archives. */
            _n_noop(
                'Archive <span class="count">(%s)</span>',
                'Archives <span class="count">(%s)</span>'
            ),
        ),
    );

    $ext_types  = wp_get_ext_types();
    $mime_types = wp_get_mime_types();

    foreach ( $post_mime_types as $group => $labels ) {
        if ( in_array( $group, array( 'image', 'audio', 'video' ), true ) ) {
            continue;
        }

        if ( ! isset( $ext_types[ $group ] ) ) {
            unset( $post_mime_types[ $group ] );
            continue;
        }

        
Home | Imprint | This part of the site doesn't use cookies.