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.

Delete the stored value of a defined MLA option

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

Compatibility shim for MLACore::mla_delete_option

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; WP_ADMIN mode

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

Compatibility shim for MLAData_Source::mla_get_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

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

Compatibility shim for MLACore::mla_get_option

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

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; WP_ADMIN mode

mla_is_data_source(string $candidate_name) : boolean

Compatibility shim for MLAData_Source::mla_is_data_source.

since 1.80

Parameters

$candidate_name

string

candidate data source name

Returns

booleantrue if candidate name matches a data source

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

Compatibility shim for MLACore::mla_taxonomy_support

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

Compatibility shim for MLACore::mla_taxonomy_support

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

Compatibility shim for MLACore::mla_update_option

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

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 option settings templates to $mla_option_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

 

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
 

Option Setting 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 Media/Add New bulk edit "on top" option

MLA_ADD_NEW_BULK_EDIT_ON_TOP 

 

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 Debug display limit option

MLA_DEBUG_DISPLAY_LIMIT 

 

Provides a unique name for the Debug alternate log file option

MLA_DEBUG_FILE 

 

Provides a unique name for the Debug replace MLA_DEBUG_LEVEL option

MLA_DEBUG_REPLACE_LEVEL 

 

Provides a unique name for the Debug replace PHP log file option

MLA_DEBUG_REPLACE_PHP_LOG 

 

Provides a unique name for the Debug replace PHP error_reporting option

MLA_DEBUG_REPLACE_PHP_REPORTING 

 

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