/**
 * Ajax handler for type assignment fix troubleshoot action
 */
function icl_repair_broken_type_and_language_assignments()
{
    global $sitepress;
    $lang_setter = new WPML_Fix_Type_Assignments($sitepress);
    $rows_fixed = $lang_setter->run();
    wp_send_json_success($rows_fixed);
}
 /**
  * Checks if a duplicate element_id already exists with a different than the input type.
  * This only applies to posts and taxonomy terms.
  *
  * @param string $el_type
  * @param int    $el_id
  *
  * @return null|string null if no duplicate icl translations entry is found
  * having a different than the input element type, the element type if a
  * duplicate row is found.
  */
 private function check_duplicate($el_type, $el_id)
 {
     $res = false;
     $exp = explode('_', $el_type);
     $_type = $exp[0];
     if (in_array($_type, array('post', 'tax'))) {
         $res = $this->duplicate_from_db($el_id, $el_type, $_type);
         if ($res) {
             $fix_assignments = new WPML_Fix_Type_Assignments($this->sitepress);
             $fix_assignments->run();
             $res = $this->duplicate_from_db($el_id, $el_type, $_type);
         }
     }
     return $res;
 }