/** * @param int $site_id * @param int $term_id // currently edited term * @return int */ public function get_current_term($site_id, $term_id) { if (!isset($this->site_terms[$term_id])) { $this->site_terms[$term_id] = $this->content_relations->get_relations($this->current_site_id, $term_id, 'term'); } if (empty($this->site_terms[$term_id][$site_id])) { return 0; } return $this->site_terms[$term_id][$site_id]; }
/** * Handle term edits. * * @param int $term_taxonomy_id Term taxonomy ID. * * @return bool */ public function edit_term($term_taxonomy_id) { $success = FALSE; $existing = $this->content_relations->get_relations($this->current_site_id, $term_taxonomy_id, 'term'); foreach ($this->post_data as $target_site_id => $target_term_taxonomy_id) { $result = $this->update_terms($existing, $term_taxonomy_id, $target_site_id, (int) $target_term_taxonomy_id); if ($result) { $success = TRUE; } } return $success; }
/** * Gets the relevant multisite post id from singlesite post. * * @param $post * @param $blog * * @return int */ public function get_multisite_id($post, $blog) { $rel = $this->content_relations->get_relations(Wpml2mlp_Helper::get_default_blog(), Wpml2mlp_Helper::get_default_post_ID($post), $post->post_type); $blog_id = (int) $blog['blog_id']; $multisite_id = -1; foreach ($rel as $key => $value) { if ($key == $blog_id) { $multisite_id = $value; break; } } return $multisite_id; }
/** * Returns an array with site ID as keys and content ID as values. * * @param int $site_id * @param int $content_id * @param string $type * @return array */ public function get_related_content_ids($site_id, $content_id, $type) { return $this->content_relations->get_relations($site_id, $content_id, $type); }