public function __construct($language, $term_language = null)
 {
     // build the object from all properties stored as an array
     if (empty($term_language)) {
         foreach ($language as $prop => $value) {
             $this->{$prop} = $value;
         }
     } else {
         foreach ($language as $prop => $value) {
             $this->{$prop} = in_array($prop, array('term_id', 'term_taxonomy_id', 'count')) ? (int) $language->{$prop} : $language->{$prop};
         }
         // although it would be convenient here, don't assume the term is shared between taxonomies as it may not be the case in future
         // http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/
         $this->tl_term_id = (int) $term_language->term_id;
         $this->tl_term_taxonomy_id = (int) $term_language->term_taxonomy_id;
         $this->tl_count = (int) $term_language->count;
         $description = maybe_unserialize($language->description);
         $this->locale = $description['locale'];
         $this->is_rtl = $description['rtl'];
         $this->description =& $this->locale;
         // backward compatibility with Polylang < 1.2
         $this->mo_id = PLL_MO::get_id($this);
         $this->set_flag();
     }
 }
Beispiel #2
0
 /**
  * Upgrades if the previous version is < 2.1
  * Moves strings translations from polylang_mo post_content to post meta _pll_strings_translations
  *
  * @since 2.0.8
  */
 protected function upgrade_2_1()
 {
     foreach (get_terms('language', array('hide_empty' => 0)) as $lang) {
         $mo_id = PLL_MO::get_id($lang);
         $meta = get_post_meta($mo_id, '_pll_strings_translations', true);
         if (empty($meta)) {
             $post = get_post($mo_id, OBJECT);
             $strings = unserialize($post->post_content);
             if (is_array($strings)) {
                 update_post_meta($mo_id, '_pll_strings_translations', $strings);
             }
         }
     }
 }