Inpsyde\MultilingualPress\API\WPDBContentRelations::get_existing_translation_ids PHP Method

get_existing_translation_ids() public method

Return the existing translation IDs according to the given parameters.
public get_existing_translation_ids ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : array
$source_site_id integer Source blog ID.
$target_site_id integer Target blog ID.
$source_content_id integer Source post ID or term taxonomy ID.
$target_content_id integer Target post ID or term taxonomy ID.
$type string Content type.
return array
    public function get_existing_translation_ids($source_site_id, $target_site_id, $source_content_id, $target_content_id, $type)
    {
        $sql = "\nSELECT DISTINCT ml_source_blogid, ml_source_elementid\nFROM {$this->table}\nWHERE (\n\t\t( ml_blogid = %d AND ml_elementid = %d )\n\t\tOR ( ml_blogid = %d AND ml_elementid = %d )\n\t)\n\tAND ml_type = %s";
        $query = $this->db->prepare($sql, $source_site_id, $source_content_id, $target_site_id, $target_content_id, $type);
        $result = $this->db->get_results($query, ARRAY_A);
        if (!$result) {
            return [];
        }
        foreach ($result as $key => $data) {
            $result[$key] = array_map('intval', $data);
        }
        return $result;
    }