odd_row = false; $this->current_document_words_count = 0; $this->current_shown_item = isset( $_GET[ 'sm' ] ) ? $_GET[ 'sm' ] : 'dashboard'; $this->base_target_url = dirname( __FILE__ ); } public function display_main() { $this->render_main(); } private function render_main() { ?>

implode_messages(); $this->build_tab_items(); $this->render_items(); ?>
messages) { echo implode('', $this->messages); } } private function build_tab_item_target_url($target) { return $this->base_target_url . $target; } private function build_tab_items() { $this->tab_items = array(); $this->build_dashboard_item(); $this->build_translators_item(); $this->build_basket_item(); $this->build_translation_jobs_item(); $this->build_mcs_item(); $this->build_translation_notifications_item(); $this->build_tp_com_log_item(); $this->tab_items = apply_filters('wpml_tm_tab_items', $this->tab_items); } /** * @param int $basket_items_count * * @return string|void */ private function build_basket_item_caption( $basket_items_count = 0 ) { if ( isset( $_GET[ 'clear_basket' ] ) && $_GET[ 'clear_basket' ] ) { $basket_items_count = 0; } else { if (! is_numeric( $basket_items_count )) { $basket_items_count = TranslationProxy_Basket::get_basket_items_count( true ); } if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'delete' && isset( $_GET[ 'id' ] ) && $_GET[ 'id' ] ) { $basket_items_count -= 1; } } $basket_items_count_caption = __('Translation Basket', 'wpml-translation-management'); if ($basket_items_count > 0) { $basket_item_count_badge = '' . $basket_items_count . ''; $basket_items_count_caption .= $basket_item_count_badge; } return $basket_items_count_caption; } /** * @return bool */ private function can_display_translation_services() { global $sitepress; return ( defined( 'WPML_BYPASS_TS_CHECK' ) && WPML_BYPASS_TS_CHECK ) || ! $sitepress->get_setting( 'translation_service_plugin_activated' ); } private function build_translation_notifications_item() { $this->tab_items['notifications']['caption'] = __('Translation Notifications', 'wpml-translation-management'); //$this->tab_items['notifications']['target'] = $this->build_tab_item_target_url('/sub/notifications.php'); $this->tab_items['notifications']['callback'] = array($this, 'build_content_translation_notifications'); } private function build_mcs_item() { $this->tab_items['mcsetup']['caption'] = __('Multilingual Content Setup', 'wpml-translation-management'); //$this->tab_items['mcsetup']['target'] = $this->build_tab_item_target_url('/sub/mcsetup.php'); $this->tab_items['mcsetup']['callback'] = array($this, 'build_content_mcs'); } private function build_translation_jobs_item() { $this->tab_items['jobs']['caption'] = __('Translation Jobs', 'wpml-translation-management'); //$this->tab_items['jobs']['target'] = $this->build_tab_item_target_url('/sub/jobs.php'); $this->tab_items['jobs']['callback'] = array($this, 'build_content_translation_jobs'); } private function build_basket_item() { $basket_items_count = TranslationProxy_Basket::get_basket_items_count( true ); if ( $basket_items_count > 0 ) { $this->tab_items['basket']['caption'] = $this->build_basket_item_caption( $basket_items_count ); //$this->tab_items['basket']['target'] = $this->build_tab_item_target_url( '/sub/basket.php' ); $this->tab_items['basket']['callback'] = array($this, 'build_content_basket'); } } private function build_translators_item() { $this->tab_items['translators']['caption'] = __('Translators', 'wpml-translation-management'); $this->tab_items['translators']['current_user_can'] = 'list_users'; //$this->tab_items['translators']['target'] = $this->build_tab_item_target_url('/sub/translators.php'); $this->tab_items['translators']['callback'] = array($this, 'build_content_translators'); } private function build_dashboard_item() { $this->tab_items['dashboard']['caption'] = __('Translation Dashboard', 'wpml-translation-management'); $this->tab_items['dashboard']['callback'] = array($this, 'build_content_dashboard'); } /** * @return string */ private function get_current_shown_item() { return $this->current_shown_item; } /** * @return array */ private function build_tabs() { $tm_sub_menu = $this->get_current_shown_item(); foreach ($this->tab_items as $id => $tab_item) { if (!isset($tab_item['caption'])) { continue; } if (!isset($tab_item['target']) && !isset($tab_item['callback'])) { continue; } $caption = $tab_item['caption']; $current_user_can = isset($tab_item['current_user_can']) ? $tab_item['current_user_can'] : false; if ($current_user_can && !current_user_can($current_user_can)) { continue; } $classes = array( 'nav-tab' ); if ($tm_sub_menu == $id) { $classes[] = 'nav-tab-active'; } $class = implode(' ', $classes); $href = 'admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=' . $id; ?> get_current_shown_item(); foreach ($this->tab_items as $id => $tab_item) { if (!isset($tab_item['caption'])) { continue; } if (!isset($tab_item['target']) && !isset($tab_item['callback'])) { continue; } if ($tm_sub_menu == $id) { if (isset($tab_item['target'])) { $target = $tab_item['target']; /** @noinspection PhpIncludeInspection */ include $this->build_tab_item_target_url($target); } if (isset($tab_item['callback'])) { $callback = $tab_item['callback']; call_user_func($callback); } } } do_action('icl_tm_menu_' . $tm_sub_menu); } public function build_content_dashboard() { /** @var SitePress $sitepress */ global $sitepress; $this->active_languages = $sitepress->get_active_languages(); $this->translatable_types = $sitepress->get_translatable_documents(); $this->build_dashboard_data(); $this->build_content_dashboard_filter(); $this->build_content_dashboard_results(); $this->build_content_dashboard_remote_translations_controls(); } public function build_content_translators() { global $iclTranslationManagement, $wpdb, $sitepress; require_once 'wpml-translator-settings.class.php'; $translator_settings = new WPML_Translator_Settings( $wpdb, $sitepress, $iclTranslationManagement ); $translator_settings->build_header_content(); ?>   

build_content_translators(); if ( !defined( 'ICL_HIDE_TRANSLATION_SERVICES' ) || !ICL_HIDE_TRANSLATION_SERVICES ) { ?>

can_display_translation_services() ) { if ( $this->site_key_exist() || $this->is_any_translation_service_active() ) { $translator_settings->build_content_translation_services(); } else { echo $this->build_link_to_register_plugin(); } } } } private function site_key_exist(){ if(class_exists('WP_Installer')){ $repository_id = 'wpml'; $site_key = WP_Installer()->get_site_key($repository_id); } return $does_exist = ($site_key !== false ? true : false ); } private function is_any_translation_service_active(){ $is_active = TranslationProxy::get_current_service(); return $feedback = ( $is_active !== false ? true : false ); } private function build_link_to_register_plugin(){ $link = sprintf( '' . __( 'Please register WPML to enable the professional translation option', 'wpml-translation-management') . '', admin_url('plugin-install.php?tab=commercial#repository-wpml') ); return $link; } public function build_content_basket() { $basket_table = new SitePress_Table_Basket(); $basket_table->prepare_items(); $action_url = esc_attr( 'admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=' . $_GET[ 'sm' ] ); ?>

1.

display(); ?>
build_translation_options(); } private function build_translation_options() { global $sitepress, $wpdb; $basket_items_number = TranslationProxy_Basket::get_basket_items_count(true); $basket_name_max_length = TranslationProxy::get_current_service_batch_name_max_length(); if ( $basket_items_number > 0 ) { $source_language = TranslationProxy_Basket::get_source_language(); $basket_name_placeholder = sprintf( __( "%s|WPML|%s", 'wpml-translation-management' ), get_option( 'blogname' ), $source_language ); $basket = new WPML_Translation_Basket( $wpdb ); $basket_name_placeholder = esc_attr( $basket->get_unique_basket_name( $basket_name_placeholder, $basket_name_max_length ) ); ?>

2.

 
get_active_languages(); foreach ( $target_languages as $key => $lang ) { if ( ! in_array( $lang[ 'code' ], $basket_languages ) ) { unset( $target_languages[ $key ] ); } } foreach ( $target_languages as $lang ) { if ( $lang[ 'code' ] === TranslationProxy_Basket::get_source_language() ) { continue; } ?>
TranslationProxy_Basket::get_source_language(), 'to' => $lang[ 'code' ], 'name' => 'translator[' . $lang[ 'code' ] . ']', 'selected' => $selected_translator, 'services' => array( 'local', TranslationProxy::get_current_service_id() ) ); $blog_translators = wpml_tm_load_blog_translators(); $translators_dropdown = new WPML_TM_Translators_Dropdown( $blog_translators ); $translators_dropdown->render( $args ); ?>

settings['doc_translation_method']) ? intval($iclTranslationManagement->settings['doc_translation_method']) : ICL_TM_TMETHOD_MANUAL; ?>

build_content_dashboard_fetch_translations_box(); ?>
build_content_mcs_custom_fields(); include ICL_PLUGIN_PATH . '/menu/_custom_types_translation.php'; ?> admin_texts_to_translate) && function_exists('icl_register_string')): //available only with the String Translation plugin ?>

admin_texts_to_translate as $option_name => $option_value) { $iclTranslationManagement->render_option_writes($option_name, $option_value); } ?>

get_translation_setting_name( 'custom_fields' ); $custom_fields_readonly_settings_name = $iclTranslationManagement->get_readonly_translation_setting_name( 'custom_fields' ); $custom_fields_readonly_custom_settings_name = $iclTranslationManagement->get_custom_readonly_translation_setting_name( 'custom_fields' ); $custom_fields_settings = $iclTranslationManagement->settings[ $custom_fields_settings_name ]; $custom_fields_settings = isset( $custom_fields_settings ) ? $custom_fields_settings : array(); $custom_fields_readonly_settings = $iclTranslationManagement->settings[ $custom_fields_readonly_settings_name ]; $custom_fields_readonly_settings = isset( $custom_fields_readonly_settings ) ? $custom_fields_readonly_settings : array(); $custom_fields_readonly_custom_settings = $iclTranslationManagement->settings[ $custom_fields_readonly_custom_settings_name ]; $custom_fields_readonly_custom_settings = isset( $custom_fields_readonly_custom_settings ) ? $custom_fields_readonly_custom_settings : array(); $custom_fields_keys = $wpdb->get_col( "SELECT DISTINCT meta_key FROM $wpdb->postmeta" ); $custom_fields_keys = array_unique( array_merge( $custom_fields_keys, $custom_fields_readonly_settings ) ); $custom_fields_keys = array_unique( array_merge( $custom_fields_keys, $custom_fields_readonly_custom_settings ) ); if ( $custom_fields_keys ) { natcasesort( $custom_fields_keys ); } ?>

$cf_key ): ?>
"> checked /> "> checked /> "> checked />

settings['notification']; ?>

  • checked="checked" />
  • checked="checked" />

  • checked="checked" />
  • checked="checked" />

  • checked="checked" />
  • checked="checked" />

tab_items) { ?>

build_tabs(); ?>

build_content(); ?>
current_language = $sitepress->get_current_language(); $this->source_language = TranslationProxy_Basket::get_source_language(); if ( isset( $_SESSION[ 'translation_dashboard_filter' ] ) ) { $this->translation_filter = $_SESSION[ 'translation_dashboard_filter' ]; } if ( $this->source_language || ! isset( $this->translation_filter[ 'from_lang' ] ) ) { if ( $this->source_language ) { $this->translation_filter[ 'from_lang' ] = $this->source_language; } else { $this->translation_filter[ 'from_lang' ] = isset( $_GET[ 'lang' ] ) ? $_GET[ 'lang' ] : $this->current_language; } } if (!isset($this->translation_filter['to_lang'])) { $this->translation_filter['to_lang'] = isset($_GET['to_lang']) ? $_GET['to_lang'] : ''; } if ($this->translation_filter['to_lang'] == $this->translation_filter['from_lang']) { $this->translation_filter['to_lang'] = false; } if (!isset($this->translation_filter['tstatus'])) { $this->translation_filter['tstatus'] = isset($_GET['tstatus']) ? $_GET['tstatus'] : -1; // -1 == All documents } if (!isset($this->translation_filter['sort_by']) || !$this->translation_filter['sort_by']) { $this->translation_filter['sort_by'] = 'date'; } if (!isset($this->translation_filter['sort_order']) || !$this->translation_filter['sort_order']) { $this->translation_filter['sort_order'] = 'DESC'; } $sort_order_next = $this->translation_filter['sort_order'] == 'ASC' ? 'DESC' : 'ASC'; $this->dashboard_title_sort_link = 'admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=dashboard&icl_tm_action=sort&sort_by=title&sort_order=' . $sort_order_next; $this->dashboard_date_sort_link = 'admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=dashboard&icl_tm_action=sort&sort_by=date&sort_order=' . $sort_order_next; $this->post_statuses = array( 'publish' => __('Published', 'wpml-translation-management'), 'draft' => __('Draft', 'wpml-translation-management'), 'pending' => __('Pending Review', 'wpml-translation-management'), 'future' => __('Scheduled', 'wpml-translation-management'), 'private' => __('Private', 'wpml-translation-management') ); $this->post_statuses = apply_filters('wpml_tm_dashboard_post_statuses', $this->post_statuses); // Get the document types that we can translate $this->post_types = $sitepress->get_translatable_documents(); $this->post_types = apply_filters('wpml_tm_dashboard_translatable_types', $this->post_types); $this->build_external_types(); $this->translation_filter['limit_no'] = isset($_GET['show_all']) && $_GET['show_all'] ? 10000 : ICL_TM_DOCS_PER_PAGE; if (!isset($this->translation_filter['parent_type'])) { $this->translation_filter['parent_type'] = 'any'; } $this->selected_languages = array(); if (!empty($iclTranslationManagement->dashboard_select)) { $this->selected_posts = $iclTranslationManagement->dashboard_select['post']; $this->selected_languages = $iclTranslationManagement->dashboard_select['translate_to']; } if (isset($this->translation_filter['icl_selected_posts'])) { parse_str($this->translation_filter['icl_selected_posts'], $this->selected_posts); } $this->filter_post_status = isset($this->translation_filter['status']) ? $this->translation_filter['status'] : false; if ( isset( $_GET[ 'type' ] ) ) { $this->translation_filter[ 'type' ] = $_GET[ 'type' ]; } $this->filter_translation_type = isset( $this->translation_filter[ 'type' ] ) ? $this->translation_filter[ 'type' ] : false; } private function build_content_dashboard_documents_sorting_link( $url, $label, $filter_argument ) { $caption = $label; if ( $this->translation_filter[ 'sort_by' ] == $filter_argument ) { $caption .= ' '; $caption .= $this->translation_filter[ 'sort_order' ] == 'ASC' ? '↑' : '↓'; } ?> /> build_content_dashboard_documents_sorting_link( $this->dashboard_title_sort_link, $dashboard_title_sort_caption, 'p.post_title' ); ?> build_content_dashboard_documents_sorting_link( $this->dashboard_date_sort_link, $dashboard_date_sort_label, 'p.post_date' ); ?> note get_active_languages()); if ($lang_count > 10) { $lang_col_width = "30%"; } else { $lang_col_width = $lang_count*17 . "px"; } ?> translation_filter[ 'to_lang' ] ) { ?> <?php echo $this->translation_filter[ 'to_lang' ] ?> get_active_languages() as $lang ) { if ( $lang[ 'code' ] == $this->translation_filter[ 'from_lang' ] ) { continue; } ?> <?php echo $lang[ 'code' ] ?> build_content_dashboard_documents_head_footer_cells(); ?> build_content_dashboard_documents_head_footer_cells(); ?> build_content_dashboard_documents_body(); ?>
documents) > ICL_TM_DOCS_PER_PAGE) { echo '' . sprintf(__('Show %d documents per page', 'wpml-translation-management'), ICL_TM_DOCS_PER_PAGE) . ''; } // pagination $paged = (int)filter_input(INPUT_GET, 'paged', FILTER_SANITIZE_NUMBER_INT); $paged = $paged ? $paged : 1; $page_links = paginate_links(array( 'base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => '«', 'next_text' => '»', 'total' => $wp_query->max_num_pages, 'current' => $paged, 'add_args' => isset($this->translation_filter) ? $this->translation_filter : array() )); ?>
0' ) ?> ' ); ?>
found_posts > ICL_TM_DOCS_PER_PAGE ) { echo '' . __( 'show all', 'wpml-translation-management' ) . ''; } $page_links_parts[ 'from' ] = number_format_i18n( ( $paged - 1 ) * $wp_query->query_vars[ 'posts_per_page' ] + 1 ); $page_links_parts[ 'to' ] = number_format_i18n( min( $paged * $wp_query->query_vars[ 'posts_per_page' ], $wp_query->found_posts ) ); $page_links_parts[ 'total' ] = number_format_i18n( $wp_query->found_posts ); ?> ', $page_links_parts[ 'from' ], $page_links_parts[ 'to' ], $page_links_parts[ 'total' ] ); ?>


post_types = apply_filters( 'wpml_get_translatable_types', $this->post_types ); foreach ( $this->post_types as $id => $type_info ) { if ( isset( $type_info->prefix ) ) { // this is an external type returned by wpml_get_translatable_types $new_type = new stdClass(); $new_type->labels = new stdClass(); $new_type->labels->singular_name = isset( $type_info->labels->singular_name ) ? $type_info->labels->singular_name : $type_info->label; $new_type->labels->name = isset( $type_info->labels->name ) ? $type_info->labels->name : $type_info->label; $new_type->prefix = $type_info->prefix; $new_type->external_type = 1; $this->post_types[ $id ] = $new_type; } } } private function build_content_dashboard_filter() { require WPML_TM_PATH . '/menu/dashboard/wpml-tm-dashboard-display-filter.class.php'; $dashboard_filter = new WPML_TM_Dashboard_Display_Filter( $this->active_languages, $this->source_language, $this->translation_filter, $this->post_types, $this->post_statuses ); $dashboard_filter->display(); } private function build_content_dashboard_results() { ?>
build_content_dashboard_documents(); $this->build_content_dashboard_documents_options(); ?>

service_activation_incomplete(); return $result; } private function build_content_dashboard_documents_options() { $translate_checked = 'checked="checked"'; $duplicate_checked = ''; $do_nothing_checked = ''; if( $this->is_translation_locked() ) { $translate_checked = 'disabled="disabled"'; $do_nothing_checked = 'checked="checked"'; } ?>
active_languages as $lang ): ?> translation_filter[ 'from_lang' ] ) { continue; } $radio_prefix_html = '
/> /> />

selected_languages ) && empty( $this->selected_posts ), true, false); $tm_jobs_submit_caption = __( 'Add to translation basket', 'wpml-translation-management' ); ?> />
build_content_dashboard_fetch_translations_box(); $active_service = icl_do_not_promote() ? false : TranslationProxy::get_current_service(); $service_dashboard_info = TranslationProxy::get_service_dashboard_info(); if ( $active_service && $service_dashboard_info ) { ?>

name . ' ' . __( 'account status', 'wpml-translation-management' ) ?>

translatable_types; $filtered_types = array(); foreach ( $types as $type ) { $filtered_types[ ] = 'post_' . $type->name; } $ext_types = $this->post_types; foreach ( $ext_types as $key => $type ) { if ( isset( $type->prefix ) ) { $filtered_types[ ] = $type->prefix . '_' . $key; } } $tm_dashboard = new WPML_TM_Dashboard( $wpdb, $this->active_languages, $filtered_types ); $this->documents = $tm_dashboard->get_documents( $this->translation_filter ); } private function build_dashboard_data() { $this->build_dashboard_filter_arguments(); $this->build_dashboard_documents(); } private function build_content_dashboard_documents_body() { global $sitepress, $wpdb; $this->current_document_words_count = 0; if ( !$this->documents ) { $colspan = 6 + ( $this->translation_filter[ 'to_lang' ] ? 1 : count( $sitepress->get_active_languages() ) - 1 ); ?> odd_row = false; wp_nonce_field( 'save_translator_note_nonce', '_icl_nonce_stn_' ); require WPML_TM_PATH . '/menu/dashboard/wpml-tm-dashboard-document-row.class.php'; $odd_row = true; $active_languages = $this->translation_filter[ 'to_lang' ] ? array( $this->translation_filter[ 'to_lang' ] => $this->active_languages[ $this->translation_filter[ 'to_lang' ] ] ) : $this->active_languages; foreach ( $this->documents as $doc ) { $selected = is_array( $this->selected_posts ) && in_array( $doc->ID, $this->selected_posts ); $doc_row = new WPML_TM_Dashboard_Document_Row( $doc, $this->translation_filter, $this->post_types, $this->post_statuses, $active_languages, $selected, $sitepress, $wpdb ); $doc_row->display( $odd_row ); $odd_row = !$odd_row; } } } private function build_tp_com_log_item( ) { if ( isset( $_GET[ 'sm' ] ) && $_GET[ 'sm' ] == 'com-log' ) { $this->tab_items['com-log']['caption'] = __('Communication Log', 'wpml-translation-management'); $this->tab_items['com-log']['callback'] = array($this, 'build_tp_com_log'); } } public function build_tp_com_log( ) { require_once WPML_TM_PATH . '/inc/translation-proxy/translationproxy-com-log.class.php'; if ( isset( $_POST[ 'tp-com-clear-log' ] ) ) { TranslationProxy_Com_Log::clear_log( ); } if ( isset( $_POST[ 'tp-com-disable-log' ] ) ) { TranslationProxy_Com_Log::set_logging_state( false ); } if ( isset( $_POST[ 'tp-com-enable-log' ] ) ) { TranslationProxy_Com_Log::set_logging_state( true ); } $action_url = esc_attr( 'admin.php?page=' . WPML_TM_FOLDER . '/menu/main.php&sm=' . $_GET[ 'sm' ] ); $com_log = TranslationProxy_Com_Log::get_log( ); ?>