예제 #1
0
 /**
  * Returns the equivalent post_type in the specified language.
  *
  * @param string $post_type A post_type to return in a given language
  * @param string $lang_code The language code for the required language 
  * @return string The equivalent post_type name, or given post_type if it doesn't exist
  **/
 public function get_post_type_in_lang($post_type, $lang_code)
 {
     $base_post_type = $this->get_base_post_type($post_type);
     if (bbl_get_default_lang_code() == $lang_code) {
         return $base_post_type;
     }
     // Some post types are untranslated…
     if (!bbl_is_translated_post_type($post_type)) {
         return $post_type;
     }
     // Return the original post type if we couldn't find it in our array
     if (!isset($this->lang_map2[$lang_code][$base_post_type])) {
         return $post_type;
     }
     return $this->lang_map2[$lang_code][$base_post_type];
 }
 public function save_post($post_id, WP_Post $post)
 {
     if ($this->no_recursion) {
         return;
     }
     if (!bbl_is_translated_post_type($post->post_type)) {
         return;
     }
     $nonce = isset($_POST['_bbl_ready_for_translation']) ? $_POST['_bbl_ready_for_translation'] : false;
     if (!$nonce) {
         return;
     }
     if (!wp_verify_nonce($nonce, "bbl_ready_for_translation-{$post->ID}")) {
         return;
     }
     if (!isset($_POST['babble_ready_for_translation'])) {
         return;
     }
     # @TODO individual language selection when marking post as translation ready
     $langs = bbl_get_active_langs();
     $lang_codes = wp_list_pluck($langs, 'code');
     $this->create_post_jobs($post->ID, $lang_codes);
 }