public function set_relation($source_site_id, $target_site_id, $source_content_id, $target_content_id, $type = 'post')
{
$translation_ids = $this->get_translation_ids($source_site_id, $target_site_id, $source_content_id, $target_content_id, $type);
$existing = $this->get_relations($source_site_id, $source_content_id, $type);
if (isset($existing[$target_site_id])) {
if ($existing[$target_site_id] === $target_content_id) {
return true;
}
$this->delete_relation($translation_ids['ml_source_blogid'], $target_site_id, $translation_ids['ml_source_elementid'], 0, $type);
}
$result = (bool) $this->insert_row($translation_ids['ml_source_blogid'], $target_site_id, $translation_ids['ml_source_elementid'], $target_content_id, $type);
$cache_key = $this->get_cache_key($source_site_id, $source_content_id, $type);
wp_cache_delete($cache_key, $this->cache_group);
\Inpsyde\MultilingualPress\debug(current_filter() . '/' . __METHOD__ . '/' . __LINE__ . " - {$this->db->last_query}");
return $result;
}