private function get_status_data($post_id, $lang)
 {
     global $wpml_post_translations;
     $status_helper = wpml_get_post_status_helper();
     $trid = $wpml_post_translations->get_element_trid($post_id);
     $status = $status_helper->get_status(false, $trid, $lang);
     $source_language_code = $wpml_post_translations->get_element_lang_code($post_id);
     $correct_id = $wpml_post_translations->element_id_in($post_id, $lang);
     list($icon, $text, $link) = $status && $correct_id ? $this->generate_edit_allowed_data($correct_id, $status_helper->needs_update($correct_id)) : $this->generate_add_data($trid, $lang, $source_language_code, $post_id);
     return array($icon, $text, $link, $trid);
 }
function wpml_tm_load_status_display_filter()
{
    global $wpml_tm_status_display_filter, $wpml_post_translations, $iclTranslationManagement, $sitepress, $wpdb;
    $blog_translators = wpml_tm_load_blog_translators();
    $tm_api = new WPML_TM_API($blog_translators, $iclTranslationManagement);
    $tm_api->init_hooks();
    if (!isset($wpml_tm_status_display_filter)) {
        $status_helper = wpml_get_post_status_helper();
        $job_factory = wpml_tm_load_job_factory();
        $wpml_tm_status_display_filter = new WPML_TM_Translation_Status_Display($wpdb, $sitepress, $wpml_post_translations, $status_helper, $job_factory, $tm_api);
    }
    $wpml_tm_status_display_filter->init();
}
 private function run_wpml_actions($master_post, $trid, $lang, $id, $post_array)
 {
     $master_post_id = $master_post->ID;
     $this->sitepress->set_element_language_details($id, 'post_' . $master_post->post_type, $trid, $lang);
     $this->sync_duplicate_password($master_post_id, $id);
     $this->sync_page_template($master_post_id, $id);
     $this->duplicate_fix_children($master_post_id, $lang);
     // make sure post name is copied
     $this->wpdb->update($this->wpdb->posts, array('post_name' => $master_post->post_name), array('ID' => $id));
     update_post_meta($id, '_icl_lang_duplicate_of', $master_post->ID);
     if ($this->sitepress->get_option('sync_post_taxonomies')) {
         $this->duplicate_taxonomies($master_post_id, $lang);
     }
     $this->duplicate_custom_fields($master_post_id, $lang);
     // Duplicate post format after the taxonomies because post format is stored
     // as a taxonomy by WP.
     if ($this->sitepress->get_setting('sync_post_format')) {
         $_wp_post_format = get_post_format($master_post_id);
         set_post_format($id, $_wp_post_format);
     }
     if ($this->sitepress->get_setting('sync_comments_on_duplicates')) {
         $this->duplicate_comments($master_post_id, $id);
     }
     $status_helper = wpml_get_post_status_helper();
     $status_helper->set_status($id, ICL_TM_DUPLICATE);
     $status_helper->set_update_status($id, false);
     do_action('icl_make_duplicate', $master_post_id, $lang, $post_array, $id);
     clean_post_cache($id);
     return $id;
 }
 private function get_status_in_lang($language_code)
 {
     $status_helper = wpml_get_post_status_helper();
     return $status_helper->get_status(false, $this->data->trid, $language_code);
 }
     foreach ($duplicated_posts as $original_post_id) {
         $element_type = 'post_' . get_post_type($original_post_id);
         $trid = $sitepress->get_element_trid($original_post_id, $element_type);
         $element_language_details = $sitepress->get_element_translations($trid, $element_type);
         $item_updated = false;
         foreach ($active_languages as $code => $active_language) {
             if (!isset($element_language_details[$code])) {
                 continue;
             }
             $element_translation = $element_language_details[$code];
             if (!isset($element_translation) || $element_translation->original) {
                 continue;
             }
             $translation = $iclTranslationManagement->get_element_translation($element_translation->element_id, $code, $element_type);
             if (!$translation) {
                 $status_helper = wpml_get_post_status_helper();
                 $status_helper->set_status($element_translation->element_id, ICL_TM_DUPLICATE);
                 $item_updated = true;
             }
         }
         if ($item_updated) {
             $updated_items++;
         }
         if ($updated_items >= 20) {
             break;
         }
     }
     echo json_encode(array('updated' => $updated_items));
     exit;
 case 'icl_ts_add_missing_language':
     global $iclTranslationManagement;
 private function is_in_basket($trid, $lang)
 {
     $status_helper = wpml_get_post_status_helper();
     return $status_helper->get_status(false, $trid, $lang) === ICL_TM_IN_BASKET;
 }
Esempio n. 7
0
 function get_translation_statuses($product_translations, $active_languages, $slang = false, $trid = false, $job_language = false)
 {
     global $wpdb, $sitepress, $wpml_post_translations;
     foreach ($active_languages as $language) {
         if ($job_language && $language['code'] != $job_language) {
             continue;
         } elseif (isset($product_translations[$language['code']]) && $product_translations[$language['code']]->original) {
             $alt = __('Original language', 'woocommerce-multilingual');
             echo '<i title="' . $alt . '" class="stat_img icon-minus"></i>';
         } elseif ($slang != $language['code'] && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && $_POST['translation_status_lang'] == $language['code'] || $_POST['translation_status_lang'] == ''))) {
             $status_helper = wpml_get_post_status_helper();
             $status = $status_helper->get_status(false, $trid, $language['code']);
             if (!$status) {
                 $alt = __('Not translated', 'woocommerce-multilingual');
                 echo '<i title="' . $alt . '" class="stat_img icon-warning-sign"></i>';
             } elseif ($status == ICL_TM_NEEDS_UPDATE) {
                 $alt = __('Not translated - needs update', 'woocommerce-multilingual');
                 echo '<i title="' . $alt . '" class="stat_img icon-repeat"></i>';
             } elseif ($status != ICL_TM_COMPLETE && $status != ICL_TM_DUPLICATE) {
                 $alt = __('In progress', 'woocommerce-multilingual');
                 echo '<i title="' . $alt . '" class="stat_img icon-spinner"></i>';
             } elseif ($status == ICL_TM_COMPLETE || $status == ICL_TM_DUPLICATE) {
                 $alt = __('Complete', 'woocommerce-multilingual');
                 echo '<i title="' . $alt . '" class="stat_img icon-ok"></i>';
             }
         }
     }
 }