default_language_code = $default_language;
$this->source_language_code = $source_language;
$this->element_id = $element_id;
parent::__construct( $sitepress );
}
function add_translation_of_selector_to_page( $trid, $current_language, $selected_language, $untranslated_ids ) {
$default_language = $this->default_language_code;
$source_language = $this->source_language_code;
?>
get_var (
$wpdb->prepare (
" SELECT t.name
FROM {$wpdb->terms} t
JOIN {$wpdb->term_taxonomy} tt
ON t.term_id = tt.term_id
WHERE tt.term_taxonomy_id = %d
LIMIT 1",
$ttid
)
);
}
/**
* @param int $trid
* @return null|object
*/
private function get_original_name_by_trid( $trid ) {
global $wpdb;
$src_snippet = $this->source_language_code ? $wpdb->prepare (
" AND language_code = %s LIMIT 1",
$this->source_language_code
) : '';
$all_translations = $wpdb->get_results (
$wpdb->prepare (
" SELECT t.name, i.element_id as ttid, i.language_code
FROM {$wpdb->terms} t
JOIN {$wpdb->term_taxonomy} tt
ON t.term_id = tt.term_id
JOIN {$wpdb->prefix}icl_translations i
ON i.element_type = CONCAT('tax_', tt.taxonomy)
AND i.element_id = tt.term_taxonomy_id
WHERE i.trid = %d
AND i.element_id != %d
{$src_snippet}",
$trid,
$this->element_id
)
);
$res = null;
foreach ( $all_translations as $translation ) {
$res = $res === null ? $translation : $res;
if ( $translation->language_code === $this->default_language_code ) {
$res = $translation;
break;
}
}
return $res;
}
}