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

duplicate_relations() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same content IDs.
Since: 3.0.0
public duplicate_relations ( integer $source_site_id, integer $destination_site_id, string $type = '' ) : integer
$source_site_id integer Source site ID.
$destination_site_id integer Destination site ID.
$type string Optional. Content type. Defaults to empty string.
return integer The number of relations duplicated.
    public function duplicate_relations($source_site_id, $destination_site_id, $type = '')
    {
        $args = [$destination_site_id, $source_site_id];
        $query = "\nINSERT INTO {$this->table} (\n\tml_source_blogid,\n\tml_source_elementid,\n\tml_blogid,\n\tml_elementid,\n\tml_type\n)\nSELECT ml_source_blogid, ml_source_elementid, %d, ml_elementid, ml_type\nFROM {$this->table}\nWHERE ml_blogid = %d";
        if ($type) {
            $query .= ' AND ml_type = %s';
            $args[] = $type;
        }
        return (int) $this->db->query($this->db->prepare($query, $args));
    }