Class MLA (Media Library Assistant) Options manages the plugin option settings and provides functions to get and put them from/to WordPress option variables

Separated from class MLASettings in version 1.00

package Media Library Assistant
since 1.00

 Methods

Initialization function, similar to __construct()

initialize() : void

since 1.00

Set $add_attachment_id to just-inserted attachment

mla_add_attachment_action(integer $post_ID) : void

All of the actual processing is done later, in mla_update_attachment_metadata_filter.

since 1.00

Parameters

$post_ID

integer

ID of just-inserted attachment

Render and manage Attachment Display Settings options; alignment, link type and size

mla_attachment_display_settings_option_handler(string $action, string $key, array $value, array $args) : string

since 1.71
uses \global\MLASettings::$page_template_array

Parameters

$action

string

'render', 'update', 'delete', or 'reset'

$key

string

option name, e.g., 'image_default_align'

$value

array

option parameters

$args

array

Optional. null (default) for 'render' else option data, e.g., $_REQUEST

Returns

stringHTML table row markup for 'render' else message(s) reflecting the results of the operation.

Render and manage custom field mapping options

mla_custom_field_option_handler(string $action, string $key, array $value, array $args) : string

since 1.10
uses \global\$mla_option_templates

Parameters

$action

string

'render', 'update', 'delete', or 'reset'

$key

string

option name, e.g., 'custom_field_mapping'

$value

array

option parameters

$args

array

Optional. null (default) for 'render' else option data, e.g., $_REQUEST

Returns

stringHTML table row markup for 'render' else message(s) reflecting the results of the operation.

Fetch custom field option value given a slug

mla_custom_field_option_value(string $slug) : array

since 1.10

Parameters

$slug

string

slug, e.g., 'c_File Size' for the 'File Size' field

Returns

arrayoption value, e.g., array( 'name' => 'File Size', ... )

Evaluate file information for custom field mapping

mla_custom_field_support(string $support_type) : array

since 1.10

Parameters

$support_type

string

array format; 'default_columns' (default), 'default_hidden_columns', 'default_sortable_columns', 'quick_edit' or 'bulk_edit'

Returns

arraydefault, hidden, sortable quick_edit or bulk_edit colums in appropriate format

Delete the stored value of a defined MLA option

mla_delete_option(string $option, array $option_table) : boolean

since 0.1

Parameters

$option

string

Name of the desired option

$option_table

array

Custom option definitions

Returns

booleanTrue if the option was deleted, otherwise false

Evaluate custom field mapping updates for a post

mla_evaluate_custom_field_mapping(integer $post_id, string $category, array $settings, array $attachment_metadata) : array

since 1.10

Parameters

$post_id

integer

post ID to be evaluated

$category

string

category/scope to evaluate against: custom_field_mapping or single_attachment_mapping

$settings

array

(optional) custom_field_mapping values, default NULL (use current option value)

$attachment_metadata

array

(optional) attachment_metadata, default NULL (use current postmeta database value)

Returns

arrayUpdates suitable for MLAData::mla_update_single_item, if any

Evaluate IPTC/EXIF mapping updates for a post

mla_evaluate_iptc_exif_mapping(object $post, string $category, array $settings, array $attachment_metadata, boolean $is_upload) : array

since 1.00

Parameters

$post

object

post object with current values

$category

string

category to evaluate against, e.g., iptc_exif_standard_mapping or iptc_exif_mapping

$settings

array

(optional) iptc_exif_mapping values, default - current option value

$attachment_metadata

array

(optional) _wp_attachment_metadata, for MLAOptions::mla_update_attachment_metadata_filter

$is_upload

boolean

(optional) true if uploading a new item else false (default)

Returns

arrayUpdates suitable for MLAData::mla_update_single_item, if any

Get IPTC/EXIF or custom field mapping data source

mla_get_data_source(integer $post_id, string $category, array $data_value, array $attachment_metadata) : string | array

Defined as public so MLA Mapping Hooks clients can call it. Isolates clients from changes to _evaluate_data_source().

since 1.70

Parameters

$post_id

integer

post->ID of attachment

$category

string

category/scope to evaluate against: custom_field_mapping or single_attachment_mapping

$data_value

array

data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )

$attachment_metadata

array

(optional) _wp_attachment_metadata, default NULL (use current postmeta database value)

Returns

stringarraydata source value

Get ALL markup templates from $mla_templates, including 'default'

mla_get_markup_templates() : array | null

since 0.80

Returns

arraynullname => value for all markup templates or null if no templates

Return the stored value or default value of a defined MLA option

mla_get_option(string $option, boolean $get_default, boolean $get_stored, array $option_table) : mixed

since 0.1

Parameters

$option

string

Name of the desired option

$get_default

boolean

True to ignore current setting and return default values

$get_stored

boolean

True to ignore default values and return only stored values

$option_table

array

Custom option definitions

Returns

mixedValue(s) for the option or false if the option is not a defined MLA option

Get ALL style templates from $mla_templates, including 'default'

mla_get_style_templates() : array | null

since 0.80

Returns

arraynullname => value for all style templates or null if no templates

Initialize "tax_checked_on_top" => "checked" default for all supported taxonomies

mla_initialize_tax_checked_on_top() : void

Called after all taxonomies are registered, e.g., in MLAObjects::_build_taxonomies.

since 2.02

Render and manage iptc/exif support options

mla_iptc_exif_option_handler(string $action, string $key, array $value, array $args) : string

since 1.00
uses \global\$mla_option_templates

Parameters

$action

string

'render', 'update', 'delete', or 'reset'

$key

string

option name, e.g., 'iptc_exif_mapping'

$value

array

option parameters

$args

array

Optional. null (default) for 'render' else option data, e.g., $_REQUEST

Returns

stringHTML table row markup for 'render' else message(s) reflecting the results of the operation.

Identify custom field mapping data source

mla_is_data_source(string $candidate_name) : boolean

Determines whether a name matches any of the element-level data source dropdown options, i.e., excludes "template:" and "meta:" values.

since 1.80

Parameters

$candidate_name

string

candidate data source name

Returns

booleantrue if candidate name matches a data source

Localize $mla_option_definitions array

mla_localize_option_definitions_array() : void

Localization must be done at runtime, and these calls cannot be placed in the "public static" array definition itself.

since 1.70

Put user-defined markup templates to $mla_templates and database

mla_put_markup_templates(array $templates) : boolean

since 0.80

Parameters

$templates

array

name => value for all user-defined markup templates

Returns

booleantrue if success, false if failure

Put user-defined style templates to $mla_templates and database

mla_put_style_templates(array $templates) : boolean

since 0.80

Parameters

$templates

array

name => value for all user-defined style templates

Returns

booleantrue if success, false if failure

Render and manage Search box options, e.g., connector and search fields

mla_search_option_handler(string $action, string $key, array $value, array $args) : string

since 1.90
uses \global\$mla_option_templates

Parameters

$action

string

'render', 'update', 'delete', or 'reset'

$key

string

option name; 'search_connector' or 'search_fields'

$value

array

option parameters

$args

array

Optional. null (default) for 'render' else option data, e.g., $_REQUEST

Returns

stringHTML table row markup for 'render' else message(s) reflecting the results of the operation.

Returns an array of taxonomy names assigned to $support_type

mla_supported_taxonomies(string $support_type) : array

since 1.90

Parameters

$support_type

string

Optional. 'support' (default), 'quick-edit', 'flat-checklist', 'term-search' or 'filter'

Returns

arraytaxonomies assigned to $support_type; can be empty.

Render and manage taxonomy support options, e.g., Categories and Post Tags

mla_taxonomy_option_handler(string $action, string $key, array $value, array $args) : string

since 0.30
uses \global\$mla_option_templates

Parameters

$action

string

'render', 'update', 'delete', or 'reset'

$key

string

option name, e.g., 'tax_support', or 'tax_flat_checklist'

$value

array

option parameters

$args

array

Optional. null (default) for 'render' else option data, e.g., $_REQUEST

Returns

stringHTML table row markup for 'render' else message(s) reflecting the results of the operation.

Determine MLA support for a taxonomy, handling the special case where the settings are being updated or reset.

mla_taxonomy_support(string $tax_name, string $support_type) : boolean | string

since 0.30

Parameters

$tax_name

string

Taxonomy name, e.g., attachment_category

$support_type

string

Optional. 'support' (default), 'quick-edit' or 'filter'

Returns

booleanstringtrue if the taxonomy is supported in this way else false. string if $tax_name is '' and $support_type is 'filter', returns the taxonomy to filter by.

Add or update the stored value of a defined MLA option

mla_update_option(string $option, mixed $newvalue, array $option_table) : boolean

since 0.1

Parameters

$option

string

Name of the desired option

$newvalue

mixed

New value for the desired option

$option_table

array

Custom option definitions

Returns

booleanTrue if the value was changed or false if the update failed

Called once for each file uploaded

mla_wp_handle_upload_filter(array $file) : array

since 1.70

Parameters

$file

array

file parameters ( 'name' )

Returns

arrayupdated file parameters

Examine or alter the filename before the file is made permanent

mla_wp_handle_upload_prefilter_filter(array $file) : array

since 1.70

Parameters

$file

array

file parameters ( 'name' )

Returns

arrayupdated file parameters

Compose a Custom Field Options list with current selection

_compose_custom_field_option_list(string $selection, array $blacklist) : string

since 1.10
uses \global\$mla_option_templates

Parameters

$selection

string

current selection or 'none' (default)

$blacklist

array

optional list of terms to exclude from the list

Returns

stringHTML markup with select field options

Compose a (Custom Field) Data Source Options list with current selection

_compose_data_source_option_list(string $selection) : string

since 1.10
uses \global\$mla_option_templates

Parameters

$selection

string

current selection or 'none' (default)

Returns

stringHTML markup with select field options

Compose an IPTC Options list with current selection

_compose_iptc_option_list(string $selection) : string

since 1.00
uses \global\$mla_option_templates

Parameters

$selection

string

current selection or 'none' (default)

Returns

stringHTML markup with select field options

Compose an hierarchical taxonomy Parent options list with current selection

_compose_parent_option_list(string $taxonomy, integer $selection) : string

since 1.00
uses \global\$mla_option_templates

Parameters

$taxonomy

string

taxonomy slug

$selection

integer

current selection or 0 (zero, default)

Returns

stringHTML markup with select field options

Evaluate post information for custom field mapping

_evaluate_array_result(array $value, string $option, boolean $keep_existing) : mixed

since 1.40

Parameters

$value

array

field value(s)

$option

string

format option text|single|export|array|multi

$keep_existing

boolean

keep existing value(s) - for 'multi' option

Returns

mixedarray for option = array|multi else string

Evaluate custom field mapping data source

_evaluate_data_source(integer $post_id, string $category, array $data_value, array $attachment_metadata) : string | array

since 1.10

Parameters

$post_id

integer

post->ID of attachment

$category

string

category/scope to evaluate against: custom_field_mapping or single_attachment_mapping

$data_value

array

data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )

$attachment_metadata

array

(optional) _wp_attachment_metadata, default NULL (use current postmeta database value)

Returns

stringarraydata source value

Evaluate file information for custom field mapping

_evaluate_file_information(string $upload_dir, array $wp_attached_files, array $wp_attachment_metadata, integer $post_id) : array

since 1.10

Parameters

$upload_dir

string

absolute path the the uploads base directory

$wp_attached_files

array

_wp_attached_file meta_value array, indexed by post_id

$wp_attachment_metadata

array

_wp_attachment_metadata meta_value array, indexed by post_id

$post_id

integer

post->ID of attachment

Returns

arrayabsolute_path_raw, absolute_path, absolute_file_name_raw, absolute_file_name, absolute_file, base_file, path, file_name, extension, dimensions, width, height, hwstring_small, array of intermediate sizes

Generate a list of all (post) Custom Field names

_get_custom_field_names() : array

The list will include any Custom Field and IPTC/EXIF rules that haven't been mapped to any attachments, yet.

since 1.00

Returns

arrayCustom field names from the postmeta table and MLA rules

Build and search a cache of taxonomy and term name to term ID mappings

_get_term_id(string $term_name, integer $term_parent, string $taxonomy, array $post_terms) : integer

since 2.01

Parameters

$term_name

string

term name (not slug)

$term_parent

integer

zero or term's parent term_id

$taxonomy

string

taxonomy slug

$post_terms

array

term objects currently assigned to the item

Returns

integerterm_id for the term name

Load style and markup templates to $mla_templates

_load_option_templates() : void

since 0.80

Update custom field mappings

_update_custom_field_mapping(array $current_values, array $new_values) : array

since 1.10

Parameters

$current_values

array

current custom_field_mapping values

$new_values

array

new values

Returns

array( 'message' => HTML message(s) reflecting results, 'values' => updated custom_field_mapping values, 'changed' => true if any changes detected else false )

Update Custom field portion of IPTC/EXIF mappings

_update_iptc_exif_custom_mapping(array $current_values, array $new_values) : array

since 1.00

Parameters

$current_values

array

current iptc_exif_mapping values

$new_values

array

new values

Returns

array( 'message' => HTML message(s) reflecting results, 'values' => updated iptc_exif_mapping values, 'changed' => true if any changes detected else false )

Update Standard field portion of IPTC/EXIF mappings

_update_iptc_exif_standard_mapping(array $current_values, array $new_values) : array

since 1.00

Parameters

$current_values

array

current iptc_exif_mapping values

$new_values

array

new values

Returns

array( 'message' => HTML message(s) reflecting results, 'values' => updated iptc_exif_mapping values, 'changed' => true if any changes detected else false )

Update Taxonomy term portion of IPTC/EXIF mappings

_update_iptc_exif_taxonomy_mapping(array $current_values, array $new_values) : array

since 1.00

Parameters

$current_values

array

current iptc_exif_mapping values

$new_values

array

new values

Returns

array( 'message' => HTML message(s) reflecting results, 'values' => updated iptc_exif_mapping values, 'changed' => true if any changes detected else false )

 Properties

 

$mla_option_definitions defines the database options and admin page areas for setting/updating them

$mla_option_definitions 

The array must be populated at runtime in MLAOptions::mla_localize_option_definitions_array(), because Localization calls cannot be placed in the "public static" array definition itself.

Each option is defined by an array with the following elements:

array key => HTML id/name attribute and option database key (OMIT MLA_OPTION_PREFIX)

tab => Settings page tab id for the option name => admin page label or heading text type => 'checkbox', 'header', 'radio', 'select', 'text', 'textarea', 'custom', 'hidden' std => default value help => help text size => text size, default 40 cols => textbox columns, default 90 rows => textbox rows, default 5 options => array of radio or select option values texts => array of radio or select option display texts render => rendering function for 'custom' options. Usage: $options_list .= ['render']( 'render', $key, $value ); update => update function for 'custom' options; returns nothing. Usage: $message = ['update']( 'update', $key, $value, $_REQUEST ); delete => delete function for 'custom' options; returns nothing. Usage: $message = ['delete']( 'delete', $key, $value, $_REQUEST ); reset => reset function for 'custom' options; returns nothing. Usage: $message = ['reset']( 'reset', $key, $value, $_REQUEST );

     

Option setting for "Inserted in" reporting

$process_inserted_in : boolean

This setting is false if the "Inserted in" database access setting is "disabled", else true.

since 1.00
   

Attachment ID passed from mla_add_attachment_action to mla_update_attachment_metadata_filter

$add_attachment_id : integer

Ensures that IPTC/EXIF and Custom Field mapping is only performed when the attachment is first added to the Media Library.

since 1.70
 

Array of Data Source names for custom field mapping

$custom_field_data_sources : array

since 1.10
 

Style and Markup templates

$mla_option_templates : array

since 0.80

 Constants

 

Provides a unique name for the Media/Add New bulk edit option

MLA_ADD_NEW_BULK_EDIT 

 

Provides a unique name for the Bulk Update and Map All chunk size option

MLA_BULK_CHUNK_SIZE 

 

Provides a unique name for the taxonomy count Attachments option

MLA_COUNT_TERM_ATTACHMENTS 

 

Provides a unique name for the default order option

MLA_DEFAULT_ORDER 

 

Provides a unique name for the default orderby option

MLA_DEFAULT_ORDERBY 

 

Provides a unique name for the Edit Media additional meta boxes option

MLA_EDIT_MEDIA_META_BOXES 

 

Provides a unique name for the "searchable taxonomies" option

MLA_EDIT_MEDIA_SEARCH_TAXONOMY 

 

Provides a unique name for the Enable MLA Icons option

MLA_ENABLE_MLA_ICONS 

 

Provides a unique name for the Enable Post MIME Types option

MLA_ENABLE_POST_MIME_TYPES 

 

Provides a unique name for the Enable Upload MIME Types option

MLA_ENABLE_UPLOAD_MIMES 

 

Provides a unique name for the exclude revisions option

MLA_EXCLUDE_REVISIONS 

 

Provides a "size" attribute value for the EXIF/Template Value field

MLA_EXIF_SIZE 

     

Provides a unique name for a database tuning option

MLA_INSERTED_IN_TUNING 

 

Provides a unique name for the Media Grid toolbar option, which also controls the ATTACHMENT DETAILS enhancements

MLA_MEDIA_GRID_TOOLBAR 

 

Provides a unique name for the Media Manager Attachment Details auto-fill option

MLA_MEDIA_MODAL_DETAILS_AUTOFILL 

 

Provides a unique name for the Media Manager Attachment Details searchable taxonomy option This option is for hierarchical taxonomies, e.g., "Att.

MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX 

Categories".

 

Provides a unique name for the Media Manager Attachment Details searchable taxonomy option This option is for flat taxonomies, e.g., "Att.

MLA_MEDIA_MODAL_DETAILS_TAG_METABOX 

Tags".

 

Provides a unique name for the Media Manager toolbar MIME Types option

MLA_MEDIA_MODAL_MIMETYPES 

 

Provides a unique name for the Media Manager toolbar Month and Year option

MLA_MEDIA_MODAL_MONTHS 

 

Provides a unique name for the Media Manager order option

MLA_MEDIA_MODAL_ORDER 

 

Provides a unique name for the Media Manager orderby option

MLA_MEDIA_MODAL_ORDERBY 

   

Provides a unique name for the Media Manager toolbar Search Box Controls option

MLA_MEDIA_MODAL_SEARCHBOX_CONTROLS 

 

Provides a unique name for the Media Manager toolbar Taxonomy Terms option

MLA_MEDIA_MODAL_TERMS 

   

Provides a unique name for the Media Manager toolbar option, which also controls the ATTACHMENT DETAILS enhancements

MLA_MEDIA_MODAL_TOOLBAR 

   

Provides a unique name for the Custom Field "new field" key

MLA_NEW_CUSTOM_FIELD 

 

Provides a unique name for the Custom Field "new rule" key

MLA_NEW_CUSTOM_RULE 

 

Provides a unique name for the Post MIME Types option

MLA_POST_MIME_TYPES 

 

Provides a unique name for the admin screen remove Media/Library option

MLA_SCREEN_DISPLAY_LIBRARY 

 

Provides a unique name for the admin screen menu title option

MLA_SCREEN_MENU_TITLE 

 

Provides a unique name for the admin screen menu order option

MLA_SCREEN_ORDER 

 

Provides a unique name for the admin screen page title option

MLA_SCREEN_PAGE_TITLE 

 

Provides a unique name for the display Search Media controls option

MLA_SEARCH_MEDIA_FILTER_DEFAULTS 

 

Provides a unique name for the display Search Media controls option

MLA_SEARCH_MEDIA_FILTER_SHOW_CONTROLS 

 

Provides a unique name for the Media/Assistant submenu table thumbnail/icon size option

MLA_TABLE_ICON_SIZE 

 

Provides a unique name for the Media/Assistant submenu table views width option

MLA_TABLE_VIEWS_WIDTH 

 

Provides a unique name for the taxonomy filter maximum depth option

MLA_TAXONOMY_FILTER_DEPTH 

 

Provides a unique name for the taxonomy filter maximum depth option

MLA_TAXONOMY_FILTER_INCLUDE_CHILDREN 

 

Provides a unique name for the taxonomy support option

MLA_TAXONOMY_SUPPORT 

 

Provides a unique name for the Upload MIME Types option

MLA_UPLOAD_MIMES 

 

Provides a unique name for the current version option

MLA_VERSION_OPTION