\MLA_WPML

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

Summary

Methods
Properties
Constants
initialize()
mla_get_terms_query_arguments()
mla_get_terms_clauses()
admin_init()
mla_media_modal_begin_update_compat_fields()
mla_media_modal_update_compat_fields_terms()
mla_media_modal_end_update_compat_fields()
mla_list_table_inline_action()
mla_list_table_bulk_action_initial_request()
mla_list_table_bulk_action_item_request()
mla_list_table_custom_admin_action()
post_updated_messages()
pre_wpml_is_translated_post_type_filter()
mla_begin_mapping()
mla_mapping_rule()
mla_mapping_new_text()
mla_end_mapping()
mla_updated_single_item()
wpml_media_create_duplicate_attachment()
attachment_fields_to_save()
mla_update_attachment_metadata_postfilter()
edit_attachment()
mla_upload_bulk_edit_form_values()
mla_get_options_tablist()
mla_localize_language_option_definitions()
mla_render_language_tab()
$mla_language_option_definitions
No constants found
No protected methods found
No protected properties found
N/A
_add_relevant_term()
_get_relevant_term()
_build_existing_terms()
_update_existing_terms()
_build_tax_input()
_apply_tax_input()
_apply_synch_input()
_apply_term_synchronization()
_save_language_settings()
_reset_language_settings()
$all_query_parameters
$bulk_edit_map
$bulk_edit_request
$current_mapping_rule
$relevant_terms
$existing_terms
$tax_input
$wpml_content_defaults
$duplicate_attachments
$updating_duplicates
N/A

Properties

$mla_language_option_definitions

$mla_language_option_definitions : 

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

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

Type

$all_query_parameters

$all_query_parameters : array

Save the query arguments

Type

array

$bulk_edit_map

$bulk_edit_map : array

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

Type

array — [ id ] => field name

$bulk_edit_request

$bulk_edit_request : array

Bulk Edit parameters during "Upload New Media"

Type

array — [ field ] => new value

$current_mapping_rule

$current_mapping_rule : array

Current mapping rule for term creation

Type

array — mapping rule

$relevant_terms

$relevant_terms : array

Taxonomy terms and translations

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

Type

array — [ $term_taxonomy_id ] => array( $term, $details, $translations )

$existing_terms

$existing_terms : array

Taxonomy terms for the current item translation in the database

Type

array — ['element_id'] => $post_id; [ 'language_code' ] => WPML item language or default language, e.g., 'en' [ 'slug' ] => Polylang item language or default language, e.g., 'en' [ $language ][ translation_details ] [ $language ][ $taxonomy ][ $term_taxonomy_id ] => $term

$tax_input

$tax_input : array

Replacement tax_input values in all languages

Type

array — ['tax_input_post_id'] => $post_id; [ $language ][ $taxonomy ] => array of integer term_ids (hierarchical) [ $language ][ $taxonomy ] => comma-delimited string of term names (flat)

$wpml_content_defaults

$wpml_content_defaults : array

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

Type

array — NULL or ( always_translate_media, duplicate_media, duplicate_featured )

$duplicate_attachments

$duplicate_attachments : array

Duplicates created during media upload

Type

array — [ $post_id ] => $language;

$updating_duplicates

$updating_duplicates : boolean

True while fixing and mapping duplicates

Type

boolean

Methods

initialize()

initialize() : void

Initialization function, similar to __construct()

This function contains add_action and add_filter calls.

mla_get_terms_query_arguments()

mla_get_terms_query_arguments(  $all_query_parameters) : array

MLA Tag Cloud Query Arguments

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

Parameters

$all_query_parameters

Returns

array —

updated attachment query arguments

mla_get_terms_clauses()

mla_get_terms_clauses(  $clauses) : array

MLA Tag Cloud Query Clauses

Adds language-specific clauses to filter the cloud terms.

Parameters

$clauses

Returns

array —

updated SQL clauses

admin_init()

admin_init() : void

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

mla_media_modal_begin_update_compat_fields()

mla_media_modal_begin_update_compat_fields(  $post) 

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

Parameters

$post

mla_media_modal_update_compat_fields_terms()

mla_media_modal_update_compat_fields_terms(  $terms,   $key,   $value,   $post_id) 

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

Parameters

$terms
$key
$value
$post_id

mla_media_modal_end_update_compat_fields()

mla_media_modal_end_update_compat_fields(  $results,   $taxonomies,   $post) 

Applies Term Synchronization after the Media Manager Modal Window taxonomy updates

Parameters

$results
$taxonomies
$post

mla_list_table_inline_action()

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

Captures the Quick Edit "before update" term assignments

Parameters

array $item_content

NULL, to indicate no handler.

integer $post_id

the affected attachment.

Returns

object —

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

mla_list_table_bulk_action_initial_request()

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

Captures the Bulk Edit, "Upload New Media" parameters

Parameters

array $request

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

string $bulk_action

the requested action.

array $custom_field_map

[ slug => field_name ]

Returns

array —

updated bulk action request parameters

mla_list_table_bulk_action_item_request()

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

Converts Bulk Edit taxonomy inputs to language-specific values

Parameters

array $request

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

string $bulk_action

the requested action.

integer $post_id

the affected attachment.

array $custom_field_map

[ slug => field_name ]

Returns

array —

updated bulk action request parameters

mla_list_table_custom_admin_action()

mla_list_table_custom_admin_action(string  $mla_admin_action, integer  $mla_item_ID) 

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

Parameters

string $mla_admin_action

the requested action.

integer $mla_item_ID

zero (0), or the affected attachment.

post_updated_messages()

post_updated_messages(  $messages) : array

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

Parameters

$messages

Returns

array —

updated messages

pre_wpml_is_translated_post_type_filter()

pre_wpml_is_translated_post_type_filter(  $translated,   $type) 

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

Parameters

$translated
$type

mla_begin_mapping()

mla_begin_mapping(  $source,   $post_id = NULL) 

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

Parameters

$source
$post_id

mla_mapping_rule()

mla_mapping_rule(  $setting_value,   $post_id,   $category,   $attachment_metadata) 

Saves the current mapping rule for term creation

Parameters

$setting_value
$post_id
$category
$attachment_metadata

mla_mapping_new_text()

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

Manages the creation of new taxonomy terms from metadata values

Parameters

$new_text
$setting_key
$post_id
$category
$attachment_metadata

Returns

array —

updated rule EXIF/Template value

mla_end_mapping()

mla_end_mapping() : void

Remove "All languages" filter

mla_updated_single_item()

mla_updated_single_item(integer  $post_id, integer  $result) 

Applies Term Synchronization after item updates

Parameters

integer $post_id

ID of the item that was updated.

integer $result

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

wpml_media_create_duplicate_attachment()

wpml_media_create_duplicate_attachment(  $attachment_id,   $duplicated_attachment_id) 

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

Parameters

$attachment_id
$duplicated_attachment_id

attachment_fields_to_save()

attachment_fields_to_save(\WP_Post  $post, array  $attachment) 

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

Parameters

\WP_Post $post

The WP_Post object.

array $attachment

An array of attachment metadata.

mla_update_attachment_metadata_postfilter()

mla_update_attachment_metadata_postfilter(  $data,   $post_id,   $options) : array

Copy attachment metadata to duplicated items

This filter is called AFTER MLA mapping rules are applied during wp_update_attachment_metadata() processing. The postfilter gives you an opportunity to record or update the metadata after the mapping.

Parameters

$data
$post_id
$options

Returns

array —

updated attachment metadata

edit_attachment()

edit_attachment(  $post_id) 

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

Parameters

$post_id

mla_upload_bulk_edit_form_values()

mla_upload_bulk_edit_form_values(array  $page_values) 

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

Parameters

array $page_values

[ parameter_name => parameter_value ] pairs

mla_get_options_tablist()

mla_get_options_tablist(  $results,   $mla_tablist,   $tab) : array

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

Parameters

$results
$mla_tablist
$tab

Returns

array —

updated tablist or single tab element

mla_localize_language_option_definitions()

mla_localize_language_option_definitions() : void

Localize $mla_language_option_definitions array

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

mla_render_language_tab()

mla_render_language_tab() : array

Renders the Settings/Media Library Assistant "Language" tab

Returns

array —

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

_add_relevant_term()

_add_relevant_term(  $term,   $translations = NULL,   $skip_cache = false) 

Adds a term and its translations to $relevant_terms

Parameters

$term
$translations
$skip_cache

_get_relevant_term()

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

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

Parameters

string $field

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

mixed $value

to search for; integer, string or integer

string $taxonomy

to search in; slug

string $language

code; string; optional

boolean $test_only

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

$skip_cache

_build_existing_terms()

_build_existing_terms(integer  $post_id) 

Build the $existing_terms array

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.

Parameters

integer $post_id

ID of the current post

_update_existing_terms()

_update_existing_terms(integer  $post_id) : array

Update the $existing_terms 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.

Parameters

integer $post_id

ID of the current post

Returns

array —

( taxonomy => term assignments ) before the update

_build_tax_input()

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

Build the $tax_input array

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.

Parameters

integer $post_id

ID of the current post

array $tax_inputs

'tax_input' request parameter

array $tax_actions

'tax_action' request parameter

_apply_tax_input()

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

Filter the $tax_input array to a specific language

Parameters

integer $post_id

ID of the post to be updated

string $post_language

explicit language_code; optional

Returns

array —

language-specific $tax_inputs

_apply_synch_input()

_apply_synch_input(string  $language) : array

Compute Term Synchronization replacement $tax_inputs

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

Parameters

string $language

the target translation code

Returns

array —

$tax_inputs for Term Synchronization

_apply_term_synchronization()

_apply_term_synchronization(integer  $post_id) : array

Apply Term Synchronization

Parameters

integer $post_id

the item we're synchronizing to

Returns

array —

$tax_inputs for Term Synchronization

_save_language_settings()

_save_language_settings() : array

Save Language settings to the options table

Returns

array —

Message(s) reflecting the results of the operation

_reset_language_settings()

_reset_language_settings() : array

Delete saved settings, restoring default values

Returns

array —

Message(s) reflecting the results of the operation