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

Perform ITC/EXIF mapping on just-inserted attachment

mla_add_attachment_action(integer $post_id) : void

since 1.00

Parameters

$post_id

integer

ID of just-inserted attachment

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) : boolean

since 0.1

Parameters

$option

string

Name of the desired option

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

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

Returns

arrayUpdates suitable for MLAData::mla_update_single_item, if any

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) : mixed

since 0.1

Parameters

$option

string

Name of the desired option

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

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.

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 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., 'taxonomy_support'

$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) : boolean

since 0.1

Parameters

$option

string

Name of the desired option

$newvalue

mixed

New value for the desired option

Returns

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

Compose a Custom Field Options list with current selection

_compose_custom_field_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 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 custom field mapping data source

_evaluate_data_source(integer $post_id, string $category, string $data_source, string $format, array $attachment_metadata) : string

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_source

string

data source name

$format

string

desired results format, default 'native'

$attachment_metadata

array

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

Returns

stringdata 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, 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

since 1.00

Returns

arrayCustom field names from the postmeta table

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 iptc_exif_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 

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
   

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 a database tuning option

MLA_INSERTED_IN_TUNING 

 

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 toolbar Taxonomy Terms option

MLA_MEDIA_MODAL_TERMS 

 

Provides a unique name for the Media Manager toolbar option

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 current version option

MLA_VERSION_OPTION