Inpsyde\MultilingualPress\API\ContentRelations::relate_all_posts PHP Method

relate_all_posts() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same post IDs. Furthermore, the current site is assumed to be either the source site or the destination site.
Since: 3.0.0
public relate_all_posts ( 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_posts($source_site_id, $destination_site_id);

Usage Example

 /**
  * Sets up content relations between the source site and the new site.
  *
  * @param int $source_site_id      The ID of the source site.
  * @param int $destination_site_id The ID of the new site.
  *
  * @return void
  */
 private function handle_content_relations($source_site_id, $destination_site_id)
 {
     if ($this->content_relations->has_site_relations($source_site_id)) {
         $this->content_relations->duplicate_relations($source_site_id, $destination_site_id);
         return;
     }
     $this->content_relations->relate_all_posts($source_site_id, $destination_site_id);
     $this->content_relations->relate_all_terms($source_site_id, $destination_site_id);
 }