/** * @param int $post_ID * @param string $post_type * @param string $post_language_code * @param int|bool $trid * * @throws \InvalidArgumentException * @throws \UnexpectedValueException */ private function set_post_language($post_ID, $post_type, $post_language_code, $trid = false) { if ($post_language_code && $this->sitepress->is_translated_post_type($post_type)) { $wpml_translations = new WPML_Translations($this->sitepress); $post_element = new WPML_Post_Element($post_ID, $this->sitepress); if ($post_language_code) { $wpml_translations->set_language_code($post_element, $post_language_code); } if ($trid) { $wpml_translations->set_trid($post_element, $trid); } } }