function user_can_translate_product($trid, $language_code) { global $wpdb, $iclTranslationManagement, $sitepress; $current_translator = $iclTranslationManagement->get_current_translator(); $job_id = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT tj.job_id FROM {$wpdb->prefix}icl_translate_job tj\n\t\t\t\tJOIN {$wpdb->prefix}icl_translation_status ts ON tj.rid = ts.rid\n\t\t\t\tJOIN {$wpdb->prefix}icl_translations t ON ts.translation_id = t.translation_id\n\t\t\t\tWHERE t.trid = %d AND t.language_code='%s'\n\t\t\t\tORDER BY tj.job_id DESC LIMIT 1\n\t\t", $trid, $language_code)); if ($job_id && wpml_check_user_is_translator($sitepress->get_source_language_by_trid($trid), $language_code)) { return true; } return false; }
</th> <th scope="col" width="20%"><?php _e('Product', 'wpml-wcml'); ?> </th> <th scope="col" width="73%"><?php echo $woocommerce_wpml->products->get_translation_flags($active_languages, $default_language, isset($_GET['slang']) && $_GET['slang'] != "all" ? $_GET['slang'] : false); ?> </th> </tr> </thead> <tbody> <?php $lang_codes = array(); foreach ($active_languages as $language) { if ($default_language == $language['code'] || current_user_can('wpml_manage_woocommerce_multilingual') || wpml_check_user_is_translator($default_language, $language['code']) && !current_user_can('wpml_manage_woocommerce_multilingual')) { if (!isset($_GET['slang']) || isset($_GET['slang']) && ($_GET['slang'] == $language['code'] || $default_language == $language['code'] || $_GET['slang'] == 'all')) { $lang_codes[$language['code']] = $language['display_name']; } } } $default_language_display_name = $lang_codes[$default_language]; unset($lang_codes[$default_language]); $lang_codes = array($default_language => $default_language_display_name) + $lang_codes; ?> <?php if (empty($products)) { ?> <tr><td colspan="4"><h3 class="wcml_no_found_text"><?php _e('No products found', 'wpml-wcml'); ?>
/** * Check user is translator * * @since 1.3 * @package WPML * @subpackage WPML API * * @param int $post_id Post ID * @param $cred_form_id * @param bool|string $current_language (optional) current language * * @internal param int $form_id Form ID * @return bool (true if translator) */ function wpml_generate_controls($post_id, $cred_form_id, $current_language = false) { global $sitepress, $sitepress_settings; if (!$current_language) { $current_language = $sitepress->get_default_language(); } if ($current_language != $sitepress->get_language_for_element($post_id, 'post_' . get_post_type($post_id))) { $current_language = $sitepress->get_language_for_element($post_id, 'post_' . get_post_type($post_id)); } $controls = array(); $trid = $sitepress->get_element_trid($post_id, 'post_' . get_post_type($post_id)); $translations = $sitepress->get_element_translations($trid, 'post_' . get_post_type($post_id)); foreach ($sitepress->get_active_languages() as $active_language) { if ($current_language == $active_language['code'] || !wpml_check_user_is_translator($current_language, $active_language['code'])) { continue; } if (array_key_exists($active_language['code'], $translations)) { //edit translation $controls[$active_language['code']]['action'] = 'edit'; $post_url = get_permalink($translations[$active_language['code']]->element_id); if (false === strpos($post_url, '?') || false === strpos($post_url, '?') && $sitepress_settings['language_negotiation_type'] != '3') { $controls[$active_language['code']]['url'] = $post_url . '?action=edit_translation&cred-edit-form=' . $cred_form_id; //CRED edit form ID } else { $controls[$active_language['code']]['url'] = $post_url . '&action=edit_translation&cred-edit-form=' . $cred_form_id; //CRED edit form ID } } else { //add translation $controls[$active_language['code']]['action'] = 'create'; $post_url = get_permalink($post_id); if (false === strpos($post_url, '?') || false === strpos($post_url, '?') && $sitepress_settings['language_negotiation_type'] != '3') { $controls[$active_language['code']]['url'] = get_permalink($post_id) . '?action=create_translation&trid=' . $trid . '&to_lang=' . $active_language['code'] . '&source_lang=' . $current_language . '&cred-edit-form=' . $cred_form_id; //CRED new form ID } else { $controls[$active_language['code']]['url'] = get_permalink($post_id) . '&action=create_translation&trid=' . $trid . '&to_lang=' . $active_language['code'] . '&source_lang=' . $current_language . '&cred-edit-form=' . $cred_form_id; //CRED new form ID } } $controls[$active_language['code']]['language'] = $sitepress->get_display_language_name($active_language['code'], $current_language); $controls[$active_language['code']]['flag'] = $sitepress->get_flag_url($active_language['code']); } return $controls; }
function cred_wpml_generate_translation_link($post_id, $exist_translation, $to_lang) { global $sitepress; $current_language = $sitepress->get_language_for_element($post_id, 'post_' . get_post_type($post_id)); if (!wpml_check_user_is_translator($current_language, $to_lang)) { return false; } $forms = $this->cred_wpml_glue_get_translation_forms(); if (!empty($forms)) { foreach ($forms as $key => $form_post_type) { if (get_post_type($post_id) == $form_post_type) { $form_id = $key; break; } } } if (!isset($form_id)) { return false; } if ($exist_translation) { $transl_post_id = icl_object_id($post_id, get_post_type($post_id), false, $to_lang); if ($transl_post_id) { return get_permalink($transl_post_id) . '?action=edit_translation&cred-edit-form=' . $form_id; } } else { $trid = $sitepress->get_element_trid($post_id, 'post_' . get_post_type($post_id)); return get_permalink($post_id) . '?action=create_translation&trid=' . $trid . '&to_lang=' . $to_lang . '&source_lang=' . $current_language . '&cred-edit-form=' . $form_id; } }
function get_translation_statuses($product_translations, $active_languages, $default_language, $slang = false) { global $wpdb; foreach ($active_languages as $language) { if ($default_language != $language['code'] && ($slang && $slang == $language['code'] || !$slang) && (current_user_can('wpml_operate_woocommerce_multilingual') || wpml_check_user_is_translator($default_language, $language['code'])) && (!isset($_POST['translation_status_lang']) || (isset($_POST['translation_status_lang']) && $_POST['translation_status_lang'] == $language['code'] || $_POST['translation_status_lang'] == ''))) { if (isset($product_translations[$language['code']])) { $tr_status = $wpdb->get_row($wpdb->prepare("SELECT status,needs_update FROM " . $wpdb->prefix . "icl_translation_status WHERE translation_id = %d", $product_translations[$language['code']]->translation_id)); if (!$tr_status) { $alt = __('Not translated', 'wpml-wcml'); echo '<i title="' . $alt . '" class="stat_img icon-warning-sign"></i>'; } elseif ($tr_status->needs_update) { $alt = __('Not translated - needs update', 'wpml-wcml'); echo '<i title="' . $alt . '" class="stat_img icon-repeat"></i>'; } elseif ($tr_status->status != ICL_TM_COMPLETE && $tr_status->status != ICL_TM_DUPLICATE) { $alt = __('In progress', 'wpml-wcml'); echo '<i title="' . $alt . '" class="stat_img icon-spinner"></i>'; } elseif ($tr_status->status == ICL_TM_COMPLETE || $tr_status->status == ICL_TM_DUPLICATE) { $alt = __('Complete', 'wpml-wcml'); echo '<i title="' . $alt . '" class="stat_img icon-ok"></i>'; } } else { $alt = __('Not translated', 'wpml-wcml'); echo '<i title="' . $alt . '" class="stat_img icon-warning-sign"></i>'; } } } }