API / Minn\Media / FileTypes

FileTypes final class

Minn\Media\FileTypes · public/minn/src/Minn/Media/FileTypes.php · 75 lines

File types as WordPress knows them (data/mime.json): every extension's MIME type, the ones a user may upload, the kind each extension is (image, audio, document...), and the type a file name's extension says, each list through the filter plugins hook.

Constants and properties

privatestatic ?array $table

Public

statictable(): array#

The table: mime (extensions => type), allowed (the ones uploads take by default) and ext2type (kind => extensions).

@return array<string, mixed>
staticall(): mixed#

Every extension's MIME type (wp_get_mime_types), as mime_types leaves them.

staticallowed(mixed $user = NULL): mixed#

The types a user (the request's, unless one is given) may upload (get_allowed_mime_types): HTML and JavaScript too for one with unfiltered_html; then upload_mimes.

staticcheck(mixed $filename, mixed $mimes = NULL): array#

The extension and type a file name has among the types given (the allowed ones by default), false for each when none matches (wp_check_filetype).

@return array{ext: string|false, type: mixed}
statickinds(): mixed#

The extensions of each kind (wp_get_ext_types), as ext2type leaves them.

statickindOf(mixed $ext): mixed#

The kind an extension is (wp_ext2type), or null.