/** * @param string[] $allowed_langs * @param int $element_id * @param string $element_type_prefix * * @return string[] */ public function filter_target_langs($allowed_langs, $element_id, $element_type_prefix) { if (TranslationProxy_Basket::anywhere_in_basket($element_id, $element_type_prefix)) { $allowed_langs = array(); } elseif ($element_type_prefix === 'post') { if ((bool) $this->post_translations->get_element_lang_code($element_id) === true) { $allowed_langs = array_fill_keys($allowed_langs, 1); $translations = $this->tm_records->icl_translations_by_element_id_and_type_prefix($element_id, 'post')->translations(); foreach ($translations as $lang_code => $element) { if (isset($allowed_langs[$lang_code]) && ($element->element_id() && !$element->source_language_code() || $this->tm_status->is_in_active_job($element_id, $lang_code, 'post'))) { unset($allowed_langs[$lang_code]); } } $allowed_langs = array_keys($allowed_langs); } } return $allowed_langs; }
function tm_after_load() { require WPML_TM_PATH . '/inc/actions/wpml-tm-action-helper.class.php'; require WPML_TM_PATH . '/inc/translation-jobs/collections/wpml-abstract-job-collection.class.php'; require WPML_TM_PATH . '/inc/translation-proxy/wpml-translation-basket.class.php'; require WPML_TM_PATH . '/inc/translation-proxy/interfaces/TranslationProxy_Interface.php'; require WPML_TM_PATH . '/inc/translation-proxy/translationproxy.class.php'; require WPML_TM_PATH . '/inc/ajax.php'; global $wpml_translation_job_factory, $wpdb, $wpml_tm_translation_status; $wpml_translation_job_factory = new WPML_Translation_Job_Factory($wpdb); wpml_tm_init_mail_notifications(); wpml_tm_load_element_translations(); require WPML_TM_PATH . '/inc/filters/wpml-tm-translation-status.class.php'; require WPML_TM_PATH . '/inc/filters/wpml-tm-translation-status-display.class.php'; $wpml_tm_translation_status = new WPML_TM_Translation_Status(); $wpml_tm_translation_status->init(); add_action('wpml_pre_status_icon_display', 'wpml_tm_load_status_display_filter'); require WPML_TM_PATH . '/inc/wpml-private-actions.php'; }
function tm_after_load() { global $wpml_tm_translation_status, $wpdb; if (!isset($wpml_tm_translation_status)) { require WPML_TM_PATH . '/inc/actions/wpml-tm-action-helper.class.php'; require WPML_TM_PATH . '/inc/translation-jobs/collections/wpml-abstract-job-collection.class.php'; require WPML_TM_PATH . '/inc/translation-proxy/wpml-translation-basket.class.php'; require WPML_TM_PATH . '/inc/translation-jobs/wpml-translation-batch.class.php'; require WPML_TM_PATH . '/inc/translation-proxy/translationproxy.class.php'; require WPML_TM_PATH . '/inc/ajax.php'; wpml_tm_load_job_factory(); wpml_tm_init_mail_notifications(); wpml_tm_load_element_translations(); $tm_records = new WPML_TM_Records($wpdb); $wpml_tm_translation_status = new WPML_TM_Translation_Status($tm_records); $wpml_tm_translation_status->init(); add_action('wpml_pre_status_icon_display', 'wpml_tm_load_status_display_filter'); require WPML_TM_PATH . '/inc/wpml-private-actions.php'; } }