/**
  * Filters taxonomy updates by language for Bulk Edit during Add New Media
  * and the Media/Edit Media screen
  *
  * @since 2.11
  *
  * @param	integer	ID of the current post
  */
 public static function edit_attachment($post_id)
 {
     static $already_updating = 0;
     MLACore::mla_debug_add(__LINE__ . " MLA_WPML::edit_attachment( {$post_id} ) _REQUEST = " . var_export($_REQUEST, true), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE);
     /*
      * mla_update_single_item may call this action again, and
      * nothing should happen while updating duplicate items
      */
     if ($already_updating == $post_id || self::$updating_duplicates) {
         return;
     } else {
         $already_updating = $post_id;
     }
     /*
      * Check for Bulk Edit during Add New Media
      */
     if (!empty($_REQUEST['mlaAddNewBulkEditFormString'])) {
         if (!empty(self::$bulk_edit_request['tax_input'])) {
             $tax_inputs = self::$bulk_edit_request['tax_input'];
             if ('checked' == MLACore::mla_get_option('term_assignment', false, false, MLA_WPML::$mla_language_option_definitions)) {
                 self::_build_tax_input($post_id, $tax_inputs, self::$bulk_edit_request['tax_action']);
                 $tax_inputs = self::_apply_tax_input($post_id);
             }
         } else {
             $tax_inputs = NULL;
         }
         $updates = MLA::mla_prepare_bulk_edits($post_id, self::$bulk_edit_request, self::$bulk_edit_map);
         unset($updates['tax_input']);
         unset($updates['tax_action']);
         MLAData::mla_update_single_item($post_id, $updates, $tax_inputs);
         return;
     }
     // Upload New Media Bulk Edit
     /*
      * For the Bulk Edit action on the Media/Assistant screen, only synchronization is needed
      */
     if (!(isset($_REQUEST['bulk_action']) && 'bulk_edit' == $_REQUEST['bulk_action'])) {
         /*
          * This is the Media/Edit Media screen.
          * The category taxonomy (edit screens) is a special case because 
          * post_categories_meta_box() changes the input name
          */
         if (isset($_REQUEST['tax_input'])) {
             $tax_inputs = $_REQUEST['tax_input'];
         } else {
             $tax_inputs = array();
         }
         if (isset($_REQUEST['post_category'])) {
             $tax_inputs['category'] = $_REQUEST['post_category'];
         }
         if (isset($_REQUEST['tax_action'])) {
             $tax_actions = $_REQUEST['tax_action'];
         } else {
             $tax_actions = NULL;
         }
         if (!empty($tax_inputs) && 'checked' == MLACore::mla_get_option('term_assignment', false, false, MLA_WPML::$mla_language_option_definitions)) {
             self::_build_tax_input($post_id, $tax_inputs, $tax_actions);
             $tax_inputs = self::_apply_tax_input($post_id);
         }
         if (!empty($tax_inputs)) {
             MLAData::mla_update_single_item($post_id, array(), $tax_inputs);
         }
     }
     // Media/Edit Media screen, NOT Bulk Edit
 }
 /**
  * Filters taxonomy updates by language for Bulk Edit during Add New Media
  * and the Media/Edit Media screen
  *
  * @since 2.11
  *
  * @param	integer	ID of the current post
  */
 public static function edit_attachment($post_id)
 {
     static $already_updating = 0;
     /*
      * mla_update_single_item eventually calls this action again
      */
     if ($already_updating == $post_id) {
         return;
     } else {
         $already_updating = $post_id;
     }
     /*
      * Check for Bulk Edit during Add New Media
      */
     if (is_array(self::$upload_bulk_edit_args)) {
         if (!empty(self::$upload_bulk_edit_args['tax_input'])) {
             $tax_inputs = self::$upload_bulk_edit_args['tax_input'];
             if ('checked' == MLAOptions::mla_get_option('term_assignment', false, false, MLA_WPML::$mla_language_option_definitions)) {
                 self::_build_tax_input($post_id, $tax_inputs, self::$upload_bulk_edit_args['tax_action']);
                 $tax_inputs = self::_apply_tax_input($post_id);
             }
         } else {
             $tax_inputs = NULL;
         }
         $updates = MLA::mla_prepare_bulk_edits($post_id, self::$upload_bulk_edit_args, self::$upload_bulk_edit_map);
         unset($updates['tax_input']);
         unset($updates['tax_action']);
         MLAData::mla_update_single_item($post_id, $updates, $tax_inputs);
         /*
          * Synchronize the changes to all other translations - NOT NEEDED
          */
         if (false && 'checked' == MLAOptions::mla_get_option('term_synchronization', false, false, MLA_WPML::$mla_language_option_definitions)) {
             foreach (self::$tax_input as $language => $tax_inputs) {
                 /*
                  * Skip 'tax_input_post_id' and the language we've already updated
                  */
                 if (!isset(self::$existing_terms[$language]) || self::$existing_terms['language_code'] == $language) {
                     continue;
                 }
                 // Other translations have no existing terms, so we don't need _apply_synch_input()
                 $translation = self::$existing_terms[$language];
                 $tax_inputs = self::_apply_tax_input($translation['element_id'], $language);
                 $already_updating = $translation['element_id'];
                 // prevent recursion
                 MLAData::mla_update_single_item($translation['element_id'], $updates, $tax_inputs);
                 $already_updating = $post_id;
             }
             // translation
         }
         // do synchronization
         return;
     }
     // Upload New Media Bulk Edit
     /*
      * For the Bulk Edit action on the Media/Assistant screen, only synchronization is needed
      */
     if (!(isset($_REQUEST['bulk_action']) && 'bulk_edit' == $_REQUEST['bulk_action'])) {
         /*
          * The category taxonomy (edit screens) is a special case because 
          * post_categories_meta_box() changes the input name
          */
         if (isset($_REQUEST['tax_input'])) {
             $tax_inputs = $_REQUEST['tax_input'];
         } else {
             $tax_inputs = array();
         }
         if (isset($_REQUEST['post_category'])) {
             $tax_inputs['category'] = $_REQUEST['post_category'];
         }
         if (isset($_REQUEST['tax_action'])) {
             $tax_actions = $_REQUEST['tax_action'];
         } else {
             $tax_actions = NULL;
         }
         if (!empty($tax_inputs) && 'checked' == MLAOptions::mla_get_option('term_assignment', false, false, MLA_WPML::$mla_language_option_definitions)) {
             self::_build_tax_input($post_id, $tax_inputs, $tax_actions);
             $tax_inputs = self::_apply_tax_input($post_id);
         }
         if (!empty($tax_inputs)) {
             MLAData::mla_update_single_item($post_id, array(), $tax_inputs);
         }
     }
     // NOT Bulk Edit
     /*
      * Synchronize the changes to all other translations
      */
     if ('checked' == MLAOptions::mla_get_option('term_synchronization', false, false, MLA_WPML::$mla_language_option_definitions)) {
         /*
          * Update terms because they have changed
          */
         $terms_before = self::_update_existing_terms($post_id);
         // $tax_input is a convenient source of language codes; ignore $tax_inputs
         foreach (self::$tax_input as $language => $tax_inputs) {
             /*
              * Skip 'tax_input_post_id' and the language we've already updated
              */
             if (!isset(self::$existing_terms[$language]) || self::$existing_terms['language_code'] == $language) {
                 continue;
             }
             $tax_inputs = self::_apply_synch_input($language);
             if (!empty($tax_inputs)) {
                 $translation = self::$existing_terms[$language]['element_id'];
                 $already_updating = $translation;
                 // prevent recursion
                 MLAData::mla_update_single_item($translation, array(), $tax_inputs);
                 $already_updating = $post_id;
             }
         }
         // translation
     }
     // do synchronization
 }