/** * Copies taxonomy terms from the source item to the new translated item * * @since 2.11 * * @param integer ID of the new item * @param object post object of the new item * @param array an associative array of translations with language code as key and translation id as value */ public static function pll_translate_media($duplicated_attachment_id, $duplicated_attachment_object, $translations) { global $polylang; static $already_adding = 0; MLA::mla_debug_add(__LINE__ . " MLA_Polylang::pll_translate_media( {$duplicated_attachment_id} ) translations = " . var_export($translations, true), MLA::MLA_DEBUG_CATEGORY_LANGUAGE); if ($already_adding == $duplicated_attachment_id) { return; } else { $already_adding = $duplicated_attachment_id; } $attachment_id = absint(isset($_REQUEST['from_media']) ? $_REQUEST['from_media'] : $duplicated_attachment_id); $language_code = array_search($duplicated_attachment_id, $translations); self::$duplicate_attachments[$duplicated_attachment_id] = $language_code; if (isset($_REQUEST['action']) && 'translate_media' == $_REQUEST['action']) { if ('checked' == MLAOptions::mla_get_option('term_synchronization', false, false, MLA_Polylang::$mla_language_option_definitions)) { // Clone the existing common terms to the new translation self::_build_existing_terms($attachment_id); self::_build_tax_input($attachment_id); $tax_inputs = self::_apply_tax_input(0, $language_code); } else { $tax_inputs = NULL; } if (!empty($tax_inputs)) { MLAData::mla_update_single_item($duplicated_attachment_id, array(), $tax_inputs); } self::$existing_terms = array('element_id' => 0); self::$relevant_terms = array(); } // translate_media }