/**
  * Echos the HTML that serves as an entry point for the taxonomy translation
  * screen and enqueues necessary js.
  */
 public function render()
 {
     WPML_Taxonomy_Translation_Table_Display::enqueue_taxonomy_table_js($this->sitepress);
     $output = '<div class="wrap">';
     if ($this->taxonomy) {
         $output .= '<input type="hidden" id="tax-preselected" value="' . $this->taxonomy . '">';
     }
     if (!$this->tax_selector) {
         $output .= '<input type="hidden" id="tax-selector-hidden" value="1"/>';
     }
     if ($this->tax_selector) {
         $output .= '<h1>' . __('Taxonomy Translation', 'sitepress') . '</h1>';
         $output .= '<br/>';
     }
     $output .= '<div id="wpml_tt_taxonomy_translation_wrap" data-items_per_page="' . $this->get_items_per_page() . '">';
     $output .= '<div class="loading-content"><span class="spinner" style="visibility: visible"></span></div>';
     $output .= '</div>';
     do_action('icl_menu_footer');
     echo $output . '</div>';
 }
 public function render()
 {
     WPML_Taxonomy_Translation_Table_Display::enqueue_taxonomy_table_js();
     $output = '<div class="wrap">';
     if ($this->taxonomy) {
         $output .= '<input type="hidden" id="tax-preselected" value="' . $this->taxonomy . '">';
     }
     if (!$this->tax_selector) {
         $output .= '<input type="hidden" id="tax-selector-hidden" value="1"/>';
     }
     $output .= '<div id="icon-wpml" class="icon32" style="clear:both"><br/></div>';
     if ($this->tax_selector) {
         $output .= '<h1>' . __('Taxonomy Translation', 'sitepress') . '</h1>';
         $output .= '<br/>';
     }
     $output .= '<div id="wpml_tt_taxonomy_translation_wrap">';
     $output .= '<div class="loading-content"><span class="spinner" style="visibility: visible"></span></div>';
     $output .= '</div>';
     do_action('icl_menu_footer');
     $output .= apply_filters('wpml_taxonomy_translation_bottom', $html = '', $this->taxonomy, $this->taxonomy_obj);
     echo $output;
     echo '</div>';
 }
 function js_load()
 {
     if (is_admin() && !defined('DOING_AJAX')) {
         if (isset($_GET['page'])) {
             $page = basename($_GET['page']);
             $page_basename = str_replace('.php', '', $page);
         } else {
             $page_basename = false;
         }
         if (isset($_SERVER['SCRIPT_NAME']) && (strpos($_SERVER['SCRIPT_NAME'], 'post-new.php') || strpos($_SERVER['SCRIPT_NAME'], 'post.php'))) {
             wp_register_script('sitepress-post-edit-tags', ICL_PLUGIN_URL . '/res/js/post-edit-terms.js', array('jquery', 'underscore'));
             $post_edit_messages = array('switch_language_title' => __('You are about to change the language of {post_name}.', 'sitepress'), 'switch_language_alert' => __('All categories and tags will be translated if possible.', 'sitepress'), 'connection_loss_alert' => __('The following terms do not have a translation in the chosen language and will be disconnected from this post:', 'sitepress'), 'loading' => __('Loading Language Data for {post_name}', 'sitepress'), 'switch_language_message' => __('Please make sure that you\'ve saved all the changes. We will have to reload the page.', 'sitepress'), 'switch_language_confirm' => __('Do you want to continue?', 'sitepress'));
             wp_localize_script('sitepress-post-edit-tags', 'icl_post_edit_messages', $post_edit_messages);
             wp_enqueue_script('sitepress-post-edit-tags');
         }
         if (isset($_SERVER['SCRIPT_NAME']) && strpos($_SERVER['SCRIPT_NAME'], 'edit.php')) {
             wp_register_script('sitepress-post-list-quickedit', ICL_PLUGIN_URL . '/res/js/post-list-quickedit.js', array('jquery'));
             wp_enqueue_script('sitepress-post-list-quickedit');
         }
         wp_enqueue_script('sitepress-scripts', ICL_PLUGIN_URL . '/res/js/scripts.js', array('jquery'), ICL_SITEPRESS_VERSION);
         if (isset($page_basename) && file_exists(ICL_PLUGIN_PATH . '/res/js/' . $page_basename . '.js')) {
             $dependencies = array();
             $localization = false;
             switch ($page_basename) {
                 case 'languages':
                     $dependencies[] = 'colorpicker';
                     break;
                 case 'troubleshooting':
                     $dependencies[] = 'jquery-ui-dialog';
                     $localization = array('object_name' => 'troubleshooting_strings', 'strings' => array('success_1' => __("Post type and source language assignment have been fixed for ", 'sitepress'), 'success_2' => __(" elements", 'sitepress'), 'no_problems' => __("No errors were found in the assignment of post types."), 'suffixesRemoved' => __("Language suffixes were removed from the selected terms.")));
                     wp_enqueue_style("wp-jquery-ui-dialog");
                     break;
             }
             $handle = 'sitepress-' . $page_basename;
             wp_register_script($handle, ICL_PLUGIN_URL . '/res/js/' . $page_basename . '.js', $dependencies, ICL_SITEPRESS_VERSION);
             if ($localization) {
                 wp_localize_script($handle, $localization['object_name'], $localization['strings']);
             }
             wp_enqueue_script($handle);
         } else {
             WPML_Taxonomy_Translation_Table_Display::enqueue_taxonomy_table_js();
         }
         if (!wp_style_is('toolset-font-awesome', 'registered')) {
             // check if styles are already registered
             wp_register_style('toolset-font-awesome', ICL_PLUGIN_URL . '/res/css/font-awesome.min.css', null, ICL_SITEPRESS_VERSION);
             // register if not
         }
         wp_enqueue_style('toolset-font-awesome');
         // enqueue styles
     }
 }
 /**
  * Ajax handler for saving label translations from the WPML Taxonomy Translations menu.
  */
 public static function save_labels_translation()
 {
     $general = isset($_POST['plural']) ? $_POST['plural'] : false;
     $singular = isset($_POST['singular']) ? $_POST['singular'] : false;
     $taxonomy = isset($_POST['taxonomy']) ? $_POST['taxonomy'] : false;
     $language = isset($_POST['taxonomy_language_code']) ? $_POST['taxonomy_language_code'] : false;
     if ($singular && $general && $taxonomy && $language) {
         $tax_label_data = WPML_Taxonomy_Translation_Table_Display::get_label_translations($taxonomy);
         if (isset($tax_label_data['id_singular']) && $tax_label_data['id_singular'] && isset($tax_label_data['id_general']) && $tax_label_data['id_general']) {
             $original_id_singular = $tax_label_data['id_singular'];
             $original_id_plural = $tax_label_data['id_general'];
             icl_add_string_translation($original_id_singular, $language, $singular, ICL_STRING_TRANSLATION_COMPLETE);
             $singular_result = (string) icl_get_string_by_id($original_id_singular, $language);
             icl_add_string_translation($original_id_plural, $language, $general, ICL_STRING_TRANSLATION_COMPLETE);
             $plural_result = (string) icl_get_string_by_id($original_id_plural, $language);
             if ($singular_result && $plural_result) {
                 $result = array('singular' => $singular_result, 'general' => $plural_result, 'lang' => $language);
                 wp_send_json_success($result);
             }
         }
     }
     wp_send_json_error();
 }