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

relate_all_terms() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same term taxonomy IDs. Furthermore, the current site is assumed to be either the source site or the destination site.
Since: 3.0.0
public relate_all_terms ( integer $source_site_id, integer $destination_site_id ) : integer
$source_site_id integer Source site ID.
$destination_site_id integer Destination site ID.
return integer The number of relations inserted.
    public function relate_all_terms($source_site_id, $destination_site_id)
    {
        $inserted = 0;
        $query = "\nINSERT INTO {$this->table} (\n\tml_source_blogid,\n\tml_source_elementid,\n\tml_blogid,\n\tml_elementid,\n\tml_type\n)\nSELECT %d, term_taxonomy_id, %d, term_taxonomy_id, 'term'\nFROM {$this->db->term_taxonomy}";
        foreach ([$source_site_id, $destination_site_id] as $site_id) {
            $inserted += (int) $this->db->query($this->db->prepare($query, $source_site_id, $site_id));
        }
        return $inserted;
    }