/**
  * Creates the categories from the language
  *
  * @param $blog
  *
  */
 public function create_categories_from_lng($blog)
 {
     global $sitepress;
     $current_language = $sitepress->get_current_language();
     $blog_language = get_blog_language($blog['blog_id'], TRUE);
     $sitepress->switch_lang($blog_language);
     $get_cat_args = array("hide_empty" => 0);
     $categories = get_categories($get_cat_args);
     $sitepress->switch_lang($current_language);
     switch_to_blog((int) $blog['blog_id']);
     foreach ($categories as $current_categorie) {
         if (!term_exists($current_categorie->name, 'category')) {
             $mlp_categorie_id = self::add_categorie($current_categorie);
         }
     }
     restore_current_blog();
 }
Пример #2
0
 /**
  * Gets blog relevant for provided post.
  *
  * @param $post
  *
  * @return blog
  */
 private function get_relevant_blog($post)
 {
     if (!$this->blog_cache) {
         $this->blog_cache = wp_get_sites();
     }
     $pst_lng = Wpml2mlp_Helper::get_language_info($post->ID);
     foreach ($this->blog_cache as $ab) {
         if (get_blog_language($ab['blog_id'], TRUE) == $pst_lng) {
             return $ab;
         }
     }
     return FALSE;
 }