# MLAMime

Class MLA (Media Library Assistant) MIME filters WordPress MIME Type functions and supports the Views and Uploads Settings tabs

package | Media Library Assistant
since | 1.40

### Methods

## Execute an Optional Upload MIME Types query

    _execute_optional_upload_items_query( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

query results; array of MLA Optional Upload MIME Type objects

## Execute an Upload MIME Types query

    _execute_upload_items_query( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

query results; array of MLA Upload MIME Type objects

## Add filters, run query, remove filters

    _execute_view_items_query( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

query results; array of MLA post_mime_type objects

## Assemble the list of icon types without MLA filtering

    _get_core_icon_types() : boolean

static

since | 1.40

### Response

`boolean`

Success (true) or failure (false) of the operation

## Assemble the list of icon types with MLA filtering

    _get_current_icon_types() : boolean

static

since | 1.40

### Response

`boolean`

Success (true) or failure (false) of the operation

## Assemble the in-memory representation of the (read-only) Optional Upload MIME Types

    _get_optional_upload_mime_templates() : boolean

static

since | 1.40

### Response

`boolean`

Success (true) or failure (false) of the operation

## Assemble the in-memory representation of the Post MIME Types

    _get_post_mime_templates( $force_refresh = false) : boolean

static

since | 1.40

### Arguments

#### $force_refresh

``

### Response

`boolean`

Success (true) or failure (false) of the operation

## Return the names and display values of the sortable columns

    _get_sortable_upload_columns() : array

static

since | 1.40

### Response

`array`

name => array( orderby value, heading ) for sortable columns

## Return the names and display values of the sortable columns

    _get_sortable_upload_optional_columns() : array

static

since | 1.40

### Response

`array`

name => array( orderby value, heading ) for sortable columns

## Return the names and display values of the sortable columns

    _get_sortable_view_columns() : array

static

since | 1.40

### Response

`array`

name => array( orderby value, heading ) for sortable columns

## Assemble the in-memory representation of the Upload MIME Types

    _get_upload_mime_templates( $force_refresh = false) : boolean

static

since | 1.40

### Arguments

#### $force_refresh

``

### Response

`boolean`

Success (true) or failure (false) of the operation

## Builds the $default_upload_columns array with translated source texts.

    _localize_default_upload_columns() : void

static

since | 1.71

## Builds the $default_upload_optional_columns array with translated source texts.

    _localize_default_upload_optional_columns() : void

static

since | 1.71

## Builds the $default_view_columns array with translated source texts.

    _localize_default_view_columns() : void

static

since | 1.71

## Sanitize and expand Optional Upload MIME Type query arguments from request variables

    _prepare_optional_upload_items_query( $raw_request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $raw_request

``

#### $offset

``

#### $count

``

### Response

`array`

revised arguments suitable for query

## Sanitize and expand Upload MIME Type query arguments from request variables

    _prepare_upload_items_query( $raw_request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $raw_request

``

#### $offset

``

#### $count

``

### Response

`array`

revised arguments suitable for query

## Sanitize and expand query arguments from request variables

    _prepare_view_items_query( $raw_request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $raw_request

``

#### $offset

``

#### $count

``

### Response

`array`

revised arguments suitable for query

## Store the custom entries of the Post MIME Types

    _put_post_mime_templates() : boolean

static

since | 1.40

### Response

`boolean`

Success (true) or failure (false) of the operation

## Store the options portion of the Upload MIME Types

    _put_upload_mime_templates() : boolean

static

since | 1.40

### Response

`boolean`

Success (true) or failure (false) of the operation

## Initialization function, similar to __construct()

    initialize() : void

static

since | 1.40

## Add an MLA post_mime_type object

    mla_add_post_mime_type( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

Message(s) reflecting the results of the operation

## Add an MLA Upload MIME Type object

    mla_add_upload_mime( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

Message(s) reflecting the results of the operation

## Get the total number of MLA Upload MIME Type objects

    mla_count_optional_upload_items( $request) : integer

static

since | 1.40

### Arguments

#### $request

``

### Response

`integer`

Number of MLA Upload MIME Type objects

## Get the total number of MLA Upload MIME Type objects

    mla_count_upload_items( $request) : integer

static

since | 1.40

### Arguments

#### $request

``

### Response

`integer`

Number of MLA Upload MIME Type objects

## Get the total number of MLA post_mime_type objects

    mla_count_view_items( $request) : integer

static

since | 1.40

### Arguments

#### $request

``

### Response

`integer`

Number of MLA post_mime_type objects

## Delete an MLA post_mime_type object

    mla_delete_post_mime_type( $slug) : array

static

since | 1.40

### Arguments

#### $slug

``

### Response

`array`

Message(s) reflecting the results of the operation

## Delete an MLA Upload MIME Type object

    mla_delete_upload_mime( $slug) : array

static

since | 1.40

### Arguments

#### $slug

``

### Response

`array`

Message(s) reflecting the results of the operation

## Update the file extension to icon type (e.g., xls => spreadsheet, doc => document) array

    mla_ext2type_filter( $standard_types) : array

static

Note that the calling function, wp_ext2type, takes an extension and returns an icon type. This filter updates the array of possible matches to support the calling function.

Called from /wp-includes/functions.php, function wp_ext2type(). That function is called from /wp-admin/includes/ajax-actions.php, function wp_ajax_send_link_to_editor(), /wp-admin/includes/media.php, function wp_media_upload_handler(), and /wp-includes/post.php, function wp_mime_type_icon(). The first two calls look for "audio" and "video" files to call the appropriate filter. The third call assigns the appropriate icon to the file for display purposes.

Defined as public because it's a filter.

since | 1.40

### Arguments

#### $standard_types

``

### Response

`array`

The updated associations array.

## Retrieve a standard icon type, i.e., without MLA filtering

    mla_get_core_icon_type( $extension) : string

static

since | 1.40

### Arguments

#### $extension

``

### Response

`string`

icon type for the requested extension; 'default' if extension not found

## Get an array of current Icon Type names

    mla_get_current_icon_types() : array

static

since | 1.40

### Response

`array`

( icon_type ) or false on failure.

## Get an HTML img element representing an attachment icon

    mla_get_icon_type_image( $icon_type,  $size = NULL) : string

static

since | 1.40

### Arguments

#### $icon_type

``

#### $size

``

### Response

`string`

HTML img element or empty string on failure.

## Get an attachment icon height and width

    mla_get_icon_type_size( $icon_type) : array

static

since | 2.14

### Arguments

#### $icon_type

``

### Response

`array`

( width, height )

## Retrieve an MLA Optional Upload MIME Type given an ID

    mla_get_optional_upload_mime( $ID) : mixed

static

since | 1.40

### Arguments

#### $ID

``

### Response

`mixed`

the requested object; false if object not found

## Retrieve an MLA post_mime_type object

    mla_get_post_mime_type( $slug) : mixed

static

since | 1.40

### Arguments

#### $slug

``

### Response

`mixed`

Array of elements, including slug, for the requested object; false if object not found

## Retrieve an MLA post_mime_type slug given a post_ID

    mla_get_post_mime_type_slug( $post_ID) : mixed

static

since | 1.40

### Arguments

#### $post_ID

``

### Response

`mixed`

string with slug of the requested object; false if object not found

## Retrieve an MLA Upload MIME Type object

    mla_get_upload_mime( $slug) : mixed

static

since | 1.40

### Arguments

#### $slug

``

### Response

`mixed`

Array of elements, including slug, for the requested object; false if object not found

## Retrieve an MLA Upload MIME Type slug given a post_ID

    mla_get_upload_mime_slug( $post_ID) : mixed

static

since | 1.40

### Arguments

#### $post_ID

``

### Response

`mixed`

string with slug of the requested object; false if object not found

## Filters the list mapping image mime types to their respective extensions.

    mla_getimagesize_mimes_to_exts_filter(array $mime_to_ext)

static

Mitigates a bug in WP 4.6.x and 4.7.x that prevents uploading SVG files.

since | 2.50

### Arguments

#### $mime_to_ext

`array`

Array of image mime types and their matching extensions.

## Retrieve the icon directory for a MIME type

    mla_icon_dir_filter( $path) : string

static

Called from /wp-includes/deprecated.php, function get_attachment_icon_src(). Called from /wp-includes/media.php, function wp_get_attachment_image_src(). Called from /wp-includes/post.php, function wp_mime_type_icon(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $path

``

### Response

`string`

Updated path to the icon directory, no trailing slash

## Retrieve the icon directory URL for a MIME type

    mla_icon_dir_uri_filter( $uri) : string

static

Called from /wp-includes/post.php, function wp_mime_type_icon(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $uri

``

### Response

`string`

Updated path to the icon directory URL, no trailing slash

## Retrieve the icon (directory => URI) array for a MIME type

    mla_icon_dirs_filter( $path_uri_array) : array

static

Called from /wp-includes/post.php, function wp_mime_type_icon(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $path_uri_array

``

### Response

`array`

Updated (path => URI) array

## Retrieve list of MIME types and file extensions; use this filter to add types

    mla_mime_types_filter( $mime_types) : array

static

Called from /wp-includes/functions.php, function wp_get_mime_types(). That function is called from /wp-includes/class-wp-image-editor.php functions get_mime_type() and get_extension(), and from /wp-includes/functions.php, functions do_enclose() and get_allowed_mime_types().

Defined as public because it's a filter.

since | 1.40

### Arguments

#### $mime_types

``

### Response

`array`

Updated MIME types

## Analyze a Library View/Post MIME Type specification, returning an array of the placeholders it contains

    mla_parse_view_specification( $specification) : array

static

Compatibility shim for MLACore::mla_parse_view_specification

since | 1.40

### Arguments

#### $specification

``

### Response

`array`

( ['prefix'] => string, ['name'] => string, ['value'] => string, ['option'] => string, optional ['error'] => string )

## Retrieve views eligible for Media/Assistant table display

    mla_pluck_table_views() : array

static

since | 1.40

### Response

`array`

table views array ( specification => Plural Label )

## Get default Post MIME Types

    mla_post_mime_types_filter( $post_mime_types) : array

static

Called from /wp-includes/post.php, function get_post_mime_types(). That function is called from: /wp-admin/includes/media.php function get_media_item(), to validate the type of an attachment when it is edited, /wp-admin/includes/post.php, function wp_edit_attachments_query() to count the number of attachments of each type, and /wp-includes/media.php function wp_enqueue_media(), to populate the the Media Manager/Add Media "media items" drop down list.

Defined as public because it's a filter.

since | 1.40

### Arguments

#### $post_mime_types

``

### Response

`array`

Updated allowed MIME types

## Convert a Library View/Post MIME Type specification to WP_Query parameters

    mla_prepare_view_query( $slug,  $specification) : array

static

Compatibility shim for MLACore::mla_prepare_view_query

since | 1.40

### Arguments

#### $slug

``

#### $specification

``

### Response

`array`

post_mime_type specification or custom field query

## Retrieve MLA Upload MIME Type objects for list table display

    mla_query_optional_upload_items( $request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $request

``

#### $offset

``

#### $count

``

### Response

`array`

MLA Upload MIME Type objects

## Retrieve MLA Upload MIME Type objects for list table display

    mla_query_upload_items( $request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $request

``

#### $offset

``

#### $count

``

### Response

`array`

MLA Upload MIME Type objects

## Retrieve MLA post_mime_type objects for list table display

    mla_query_view_items( $request,  $offset,  $count) : array

static

since | 1.40

### Arguments

#### $request

``

#### $offset

``

#### $count

``

### Response

`array`

MLA post_mime_type objects

## Sanitize a MIME type

    mla_sanitize_mime_type_filter( $sanitized_mime_type,  $raw_mime_type) : string

static

Called from /wp-includes/formatting.php, function sanitize_mime_type(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $sanitized_mime_type

``

#### $raw_mime_type

``

### Response

`string`

Updated sanitized MIME type

## Tabulate MLA Upload MIME Type objects by view for list table display

    mla_tabulate_upload_items( $s = '') : array

static

since | 1.40

### Arguments

#### $s

``

### Response

`array`

( 'singular' label, 'plural' label, 'count' of items )

## Update an MLA post_mime_type object

    mla_update_post_mime_type( $request) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

Message(s) reflecting the results of the operation

## Update an MLA Upload MIME Type object

    mla_update_upload_mime( $request = NULL) : array

static

since | 1.40

### Arguments

#### $request

``

### Response

`array`

Message(s) reflecting the results of the operation

## Retrieve list of allowed MIME types and file extensions; use this filter to remove types

    mla_upload_mimes_filter( $mime_types,  $user = NULL) : array

static

Called from /wp-includes/functions.php, function get_allowed_mime_types(). That function is called from /wp-includes/formatting.php function sanitize_file_name() and from /wp-includes/functions.php, function wp_check_filetype(). wp_check_filetype returns only one MIME type for a given file extension, so the file extension should/must be a unique key.

This filter is also hooked by /wp-includes/ms-functions.php and processed in function check_upload_mimes(), which "is used to filter that list against the filetype whitelist provided by Multisite Super Admins at wp-admin/network/settings.php." Multisite installs must respect this restriction, so any list we produce will be passed thru that function if it exists.

Defined as public because it's a filter.

since | 1.40

### Arguments

#### $mime_types

``

#### $user

``

### Response

`array`

Updated allowed MIME types

## Attempts to determine the real file type of a file

    mla_wp_check_filetype_and_ext_filter( $validate,  $file,  $filename,  $mimes) : array

static

Called from /wp-includes/functions.php, function wp_check_filetype_and_ext(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $validate

``

#### $file

``

#### $filename

``

#### $mimes

``

### Response

`array`

Updated array( ext, type, proper_filename (string or false) )

## Retrieve the icon for a MIME type

    mla_wp_mime_type_icon_filter( $icon,  $mime,  $post_id) : array

static

Called from /wp-includes/post.php, function wp_mime_type_icon(). Defined as public because it's a filter.

since | 1.40

### Arguments

#### $icon

``

#### $mime

``

#### $post_id

``

### Response

`array`

Updated URI to the MIME type icon

### Properties

## Disable MIME filtering during option initialization

    disable_mla_filtering : boolean

static

since |
var |

### Type(s)

`boolean`

## In-memory representation of the Icon Type => file extension(s) associations

    mla_icon_type_associations : array

static

since |
var | slug => ( singular, plural, specification, post_mime_type, table_view, menu_order, description )

### Type(s)

`array`

## Table column definitions, Settings/Uploads tab table

    default_upload_columns : array

static

This array defines table columns and titles where the key is the column slug (and class) and the value is the column's title text.

All of the columns are added to this array by MLAMime::_localize_default_upload_columns.

since |
var |

### Type(s)

`array`

## Sortable column definitions, Settings/Uploads tab table

    default_sortable_upload_columns : array

static

This array defines the table columns that can be sorted. The array key is the column slug that needs to be sortable, and the value is database column to sort by. Often, the key and value will be the same, but this is not always the case (as the value is a column name from the database, not the list table).

The array value also contains a boolean which is 'true' if the initial sort order for the column is DESC/Descending.

since |
var |

### Type(s)

`array`

## Table column definitions

    default_upload_optional_columns : array

static

This array defines table columns and titles where the key is the column slug (and class) and the value is the column's title text.

All of the columns are added to this array by MLAMime::_localize_default_upload_optional_columns.

since |
var |

### Type(s)

`array`

## Sortable column definitions

    default_upload_optional_sortable_columns : array

static

This array defines the table columns that can be sorted. The array key is the column slug that needs to be sortable, and the value is database column to sort by. Often, the key and value will be the same, but this is not always the case (as the value is a column name from the database, not the list table).

The array value also contains a boolean which is 'true' if the initial sort order for the column is DESC/Descending.

since |
var |

### Type(s)

`array`

## Table column definitions, Settings/Views tab table

    default_view_columns : array

static

This array defines table columns and titles where the key is the column slug (and class) and the value is the column's title text.

All of the columns are added to this array by MLAMime::_localize_default_view_columns.

since |
var |

### Type(s)

`array`

## Sortable column definitions, Settings/Views tab table

    default_sortable_view_columns : array

static

This array defines the table columns that can be sorted. The array key is the column slug that needs to be sortable, and the value is database column to sort by. Often, the key and value will be the same, but this is not always the case (as the value is a column name from the database, not the list table).

The array value also contains a boolean which is 'true' if the initial sort order for the column is DESC/Descending.

since |
var |

### Type(s)

`array`

## In-memory representation of the Post MIME Types

    mla_post_mime_templates : array

static

since |
var | slug => ( singular, plural, specification, post_mime_type, table_view, menu_order, description )

### Type(s)

`array`

## Highest existing Post MIME Type ID value

    mla_post_mime_highest_ID : integer

static

since |
var |

### Type(s)

`integer`

## Icon types without MLA filtering

    mla_core_icon_types : array

static

since |
var | extension => ( core_icon_type )

### Type(s)

`array`

## Icon types with MLA filtering - basenames of files in the current icon directory

    mla_current_icon_types : array

static

since |
var | ( icon_type => icon_image_uri )

### Type(s)

`array`

## In-memory representation of the Upload MIME Types

    mla_upload_mime_templates : array

static

since |
var | extension => ( post_ID, mime_type, core_type, mla_type, source, standard_source, disabled, description, icon_type, wp_icon_type, mla_icon_type, core_icon_type )

### Type(s)

`array`

## In-memory cache of the default Upload MIME Type descriptions

    mla_upload_mime_descriptions : array

static

since |
var | extension => description

### Type(s)

`array`

## Highest existing Upload MIME Type ID value

    mla_upload_mime_highest_ID : integer

static

since |
var |

### Type(s)

`integer`

## In-memory representation of the (read-only) Optional Upload MIME Types

    mla_optional_upload_mime_templates : array

static

since |
var | ( ID, slug, mime_type, core_type, mla_type, description )

### Type(s)

`array`