コード例 #1
0
ファイル: Events.php プロジェクト: benjaminmedia/wp-trapp
 /**
  * Save languages from the returned row.
  *
  * @return void.
  */
 public function saveLanguages()
 {
     $translations = pll_get_post_translations($this->post->ID);
     foreach ($this->rowTranslations as $locale => $translation) {
         // Polylang is using the slug to set post languages
         $languageSlug = current(explode('_', $locale));
         if (!array_key_exists($languageSlug, $translations)) {
             $translations[$languageSlug] = $this->saveLanguagesPost($languageSlug);
         }
         // Update the meta key
         update_post_meta($translations[$languageSlug], Post\Events::TRAPP_META_KEY, $translation['id']);
         update_post_meta($translations[$languageSlug], Post\Events::TRAPP_META_LINK, $translation['edit_uri']);
     }
     pll_save_post_translations($translations);
 }
コード例 #2
0
ファイル: Events.php プロジェクト: benjaminmedia/wp-trapp
 public function getPostTranslations()
 {
     $language = pll_get_post_language($this->postId);
     $translations = pll_get_post_translations($this->postId);
     if (array_key_exists($language, $translations)) {
         unset($translations[$language]);
     }
     return $translations;
 }