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

get_element_for_site() public method

Return the term taxonomy ID of the given target site for the given source term.
public get_element_for_site ( integer $source_site_id, integer $target_site_id, integer $source_content_id, string $type ) : integer
$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.
$type string Content type.
return integer
    public function get_element_for_site($source_site_id, $target_site_id, $source_content_id, $type);

Usage Example

 /**
  * Return the current term taxonomy ID for the given site and the given term ID in the current site.
  *
  * @param int $site_id Blog ID.
  * @param int $term_id Term ID of the currently edited term.
  *
  * @return int
  */
 public function get_current_term($site_id, $term_id)
 {
     $term = $this->get_term_from_site($term_id);
     if (!isset($term->term_taxonomy_id)) {
         return 0;
     }
     if (!isset($this->site_terms[$term->term_taxonomy_id][$site_id])) {
         $term_taxonomy_id = $this->content_relations->get_element_for_site($this->current_site_id, $site_id, $term->term_taxonomy_id, 'term');
         if ($term_taxonomy_id) {
             $this->site_terms[$term->term_taxonomy_id][$site_id] = $term_taxonomy_id;
         }
     }
     if (empty($this->site_terms[$term->term_taxonomy_id][$site_id])) {
         return 0;
     }
     return $this->site_terms[$term->term_taxonomy_id][$site_id];
 }