Class MLA (Media Library Assistant) WPML provides support for the WPML Multilingual CMS family of plugins, including WPML Media

package Media Library Assistant
since 2.11

 Methods

Add the plugin's admin-mode filter/action handlers

admin_init() : void

since 2.11

Captures "before update" term assignments from the Media/Edit Media screen

attachment_fields_to_save(\WP_Post $post, array $attachment) 

since 2.13

Parameters

$post

\WP_Post

The WP_Post object.

$attachment

array

An array of attachment metadata.

Filters taxonomy updates by language for Bulk Edit during Add New Media and the Media/Edit Media screen

edit_attachment(integer $post_id) 

since 2.11

Parameters

$post_id

integer

ID of the current post

Initialization function, similar to __construct()

initialize() : void

This function contains add_action and add_filter calls.

since 2.11

Force "All languages" mode for IPTC/EXIF mapping, which uses mla_get_shortcode_attachments

mla_begin_mapping(string $source, mixed $post_id) 

since 2.20

Parameters

$source

string

what kind of mapping action is starting: single_custom, single_iptc_exif, bulk_custom, bulk_iptc_exif, create_metadata, update_metadata, custom_fields, custom_rule, iptc_exif_standard, iptc_exif_taxonomy, iptc_exif_custom, iptc_exif_custom_rule

$post_id

mixed

Attachment ID or NULL, depending on scope

Remove "All languages" filter

mla_end_mapping() : void

since 2.20

Adds the "Language" tab to the Settings/Media Library Assistant list

mla_get_options_tablist(array | false $results, array $mla_tablist, string | NULL $tab) : array

since 2.11

Parameters

$results

arrayfalse

The entire tablist ( $tab = NULL ), a single tab entry or false if not found/not allowed.

$mla_tablist

array

The entire default tablist

$tab

stringNULL

tab slug for single-element return or NULL to return entire tablist

Returns

arrayupdated tablist or single tab element

MLA Tag Cloud Query Clauses

mla_get_terms_clauses(array $clauses) : array

Adds language-specific clauses to filter the cloud terms.

since 2.11

Parameters

$clauses

array

SQL clauses ( 'fields', 'join', 'where', 'order', 'orderby', 'limits' )

Returns

arrayupdated SQL clauses

MLA Tag Cloud Query Arguments

mla_get_terms_query_arguments(array $all_query_parameters) : array

Saves [mla_tag_cloud] query parameters for use in MLA_WPML::mla_get_terms_clauses.

since 2.11
uses \global\MLA_WPML::$all_query_parameters

Parameters

$all_query_parameters

array

shortcode arguments merged with attachment selection defaults, so every possible parameter is present

Returns

arrayupdated attachment query arguments

Captures the Bulk Edit, "Upload New Media" parameters

mla_list_table_bulk_action_initial_request(array $request, string $bulk_action, array $custom_field_map) : array

since 2.11

Parameters

$request

array

bulk action request parameters, including ['mla_bulk_action_do_cleanup'].

$bulk_action

string

the requested action.

$custom_field_map

array

[ slug => field_name ]

Returns

arrayupdated bulk action request parameters

Converts Bulk Edit taxonomy inputs to language-specific values

mla_list_table_bulk_action_item_request(array $request, string $bulk_action, integer $post_id, array $custom_field_map) : array

since 2.11

Parameters

$request

array

bulk action request parameters, including ['mla_bulk_action_do_cleanup'].

$bulk_action

string

the requested action.

$post_id

integer

the affected attachment.

$custom_field_map

array

[ slug => field_name ]

Returns

arrayupdated bulk action request parameters

Add a duplicate translation for an item, then redirect to the Media/Edit Media screen

mla_list_table_custom_admin_action(string $mla_admin_action, integer $mla_item_ID) 

since 2.11

Parameters

$mla_admin_action

string

the requested action.

$mla_item_ID

integer

zero (0), or the affected attachment.

Captures the Quick Edit "before update" term assignments

mla_list_table_inline_action(array $item_content, integer $post_id) : object

since 2.11

Parameters

$item_content

array

NULL, to indicate no handler.

$post_id

integer

the affected attachment.

Returns

objectupdated $item_content. NULL if no handler, otherwise ( 'message' => error or status message(s), 'body' => '', 'prevent_default' => true to bypass the MLA handler )

Localize $mla_language_option_definitions array

mla_localize_language_option_definitions() : void

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

since 2.11

Manages the creation of new taxonomy terms from metadata values

mla_mapping_new_text(mixed $new_text, string $setting_key, integer $post_id, string $category, array $attachment_metadata) : array

since 2.20

Parameters

$new_text

mixed

string or array value returned by the rule

$setting_key

string

field name or taxonomy name

$post_id

integer

post ID to be evaluated

$category

string

category/scope to evaluate against: iptc_exif_standard_mapping, iptc_exif_taxonomy_mapping or iptc_exif_custom_mapping

$attachment_metadata

array

attachment_metadata, default NULL

Returns

arrayupdated rule EXIF/Template value

Saves the current mapping rule for term creation

mla_mapping_rule(array $setting_value, integer $post_id, string $category, array $attachment_metadata) 

since 2.20

Parameters

$setting_value

array

mapping rule

$post_id

integer

post ID to be evaluated

$category

string

category/scope to evaluate against: iptc_exif_standard_mapping, iptc_exif_taxonomy_mapping or iptc_exif_custom_mapping

$attachment_metadata

array

attachment_metadata, default NULL

Captures the existing term assignments before the Media Manager Modal Window ATTACHMENT DETAILS taxonomy meta boxes updates

mla_media_modal_begin_update_compat_fields(object $post) 

since 2.11

Parameters

$post

object

the current post

Applies Term Synchronization after the Media Manager Modal Window taxonomy updates

mla_media_modal_end_update_compat_fields(string $results, array $taxonomies, object $post) 

since 2.11

Parameters

$results

string

HTML markup for the taxonomy meta box elements

$taxonomies

array

supported taxonomy objects

$post

object

current post object

Applies Term Assignment to the terms assigned to one Media Manager Modal Window ATTACHMENT DETAILS taxonomy

mla_media_modal_update_compat_fields_terms(array $terms, string $key, object $value, integer $post_id) 

since 2.11

Parameters

$terms

array

assigned term id/name values

$key

string

taxonomy slug

$value

object

taxonomy object

$post_id

integer

current post ID

Renders the Settings/Media Library Assistant "Language" tab

mla_render_language_tab() : array

since 2.11

Returns

array( 'message' => '', 'body' => '' )

Applies Term Synchronization after item updates

mla_updated_single_item(integer $post_id, integer $result) 

since 2.15

Parameters

$post_id

integer

ID of the item that was updated.

$result

integer

Zero if the update failed else ID of the item that was updated.

Modify and extend the substitution values used for the Bulk Edit on Upload form.

mla_upload_bulk_edit_form_values(array $page_values) 

since 2.20

Parameters

$page_values

array

[ parameter_name => parameter_value ] pairs

Adds translation update message for display at the top of the Edit Media screen

post_updated_messages(array $messages) : array

since 2.11

Parameters

$messages

array

messages for the Edit screen

Returns

arrayupdated messages

Force "All languages" mode for IPTC/EXIF mapping, which uses mla_get_shortcode_attachments

pre_wpml_is_translated_post_type_filter(boolean $translated, string $type) 

since 2.20

Parameters

$translated

boolean

true if the post_type is language-specific

$type

string

the post type

Copies taxonomy terms from the source item to the new translated item

wpml_media_create_duplicate_attachment(integer $attachment_id, integer $duplicated_attachment_id) 

since 2.11

Parameters

$attachment_id

integer

ID of the source item

$duplicated_attachment_id

integer

ID of the new item

Adds a term and its translations to $relevant_terms

_add_relevant_term(object $term, object $translations, boolean $skip_cache) 

since 2.11
uses \global\MLA_WPML::$relevant_terms

Parameters

$term

object

WordPress term object

$translations

object

Sitepress translations object; optional

$skip_cache

boolean

Ignore the Sitepress terms cache; optional

Compute Term Synchronization replacement $tax_inputs

_apply_synch_input(string $language) : array

Assumes the "current post" in $existing_terms is the source and $existing_terms contains the target translation

since 2.11
uses \global\MLA_WPML::$existing_terms

Parameters

$language

string

the target translation code

Returns

array$tax_inputs for Term Synchronization

Filter the $tax_input array to a specific language

_apply_tax_input(integer $post_id, string $post_language) : array

since 2.11
uses \global\MLA_WPML::$tax_input
uses \global\MLA_WPML::$existing_terms

Parameters

$post_id

integer

ID of the post to be updated

$post_language

string

explicit language_code; optional

Returns

arraylanguage-specific $tax_inputs

Apply Term Synchronization

_apply_term_synchronization(integer $post_id) : array

since 2.15
uses \global\MLA_WPML::$existing_terms

Parameters

$post_id

integer

the item we're synchronizing to

Returns

array$tax_inputs for Term Synchronization

Build the $existing_terms array

_build_existing_terms(integer $post_id) 

Takes each translatable taxonomy and builds an array of language-specific term_id to term_id/term_name mappings for terms already assigned to the item translation.

since 2.11
uses \global\MLA_WPML::$existing_terms
uses \global\MLA_WPML::$relevant_terms

Parameters

$post_id

integer

ID of the current post

Build the $tax_input array

_build_tax_input(integer $post_id, array $tax_inputs, array $tax_actions) 

Takes each term from the $tax_inputs parameter and builds an array of language-specific term_id to term_id/term_name mappings for all languages.

since 2.11
uses \global\MLA_WPML::$tax_input
uses \global\MLA_WPML::$existing_terms

Parameters

$post_id

integer

ID of the current post

$tax_inputs

array

'tax_input' request parameter

$tax_actions

array

'tax_action' request parameter

Finds a $relevant_term (if defined) given a key and (optional) a language

_get_relevant_term(string $field, mixed $value, string $taxonomy, string $language, boolean $test_only, boolean $skip_cache) 

since 2.11
uses \global\MLA_WPML::$relevant_terms

Parameters

$field

string

to search in; 'id', 'name', or 'term_taxonomy_id'

$value

mixed

to search for; integer, string or integer

$taxonomy

string

to search in; slug

$language

string

code; string; optional

$test_only

boolean

false (default) to add missing term, true to leave term out

$skip_cache

boolean

Ignore the Sitepress terms cache; optional

Delete saved settings, restoring default values

_reset_language_settings() : array

since 2.11

Returns

arrayMessage(s) reflecting the results of the operation

Save Language settings to the options table

_save_language_settings() : array

since 2.11
uses \global\$_REQUEST

Returns

arrayMessage(s) reflecting the results of the operation

Update the $existing_terms array

_update_existing_terms(integer $post_id) : array

Takes each translatable taxonomy and rebuilds the array of language-specific term_id to term_id/term_name mappings for the "current translation" represented by the $post_id.

since 2.11
uses \global\MLA_WPML::$existing_terms
uses \global\MLA_WPML::$relevant_terms

Parameters

$post_id

integer

ID of the current post

Returns

array( taxonomy => term assignments ) before the update

 Properties

 

$mla_language_option_definitions defines the language-specific database options and admin page areas for setting/updating them

$mla_language_option_definitions 

The array must be populated at runtime in MLA_WPML::mla_localize_language_option_definitions(), because localization calls cannot be placed in the "public static" array definition itself.

Each option is defined by an array with the elements documented in class-mla-options.php

 

Save the query arguments

$all_query_parameters : array

since 2.11
 

Custom Field Map during Bulk Edit, "Upload New Media"

$bulk_edit_map : array

since 2.11
 

Bulk Edit parameters during "Upload New Media"

$bulk_edit_request : array

since 2.11
 

Current mapping rule for term creation

$current_mapping_rule : array

since 2.20
 

Duplicates created during media upload

$duplicate_attachments : array

since 2.11
 

Taxonomy terms for the current item translation in the database

$existing_terms : array

since 2.11
 

Taxonomy terms and translations

$relevant_terms : array

NOTE: WPML uses term_taxonomy_id as the "element_id" in its translations; Polylang uses term_id as the "element_id".

since 2.11
 

Replacement tax_input values in all languages

$tax_input : array

since 2.11
 

True while fixing and mapping duplicates

$updating_duplicates : boolean

since 2.20
 

WPML Option settings to restore when always_translate_media is changed in Bulk Edit on Upload area

$wpml_content_defaults : array

since 2.20