function __construct() { global $cms_nav_ie_ver, $sitepress; if (!isset($sitepress)) { $sitepress = new SitePress(); $sitepress->initialize_cache(); } $sitepress_settings = $sitepress->get_settings(); $this->settings = $sitepress_settings['modules']['cms-navigation']; $cms_nav_user_agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('#MSIE ([0-9]+)\\.[0-9]#', $cms_nav_user_agent, $matches)) { $cms_nav_ie_ver = $matches[1]; } add_action('icl_navigation_breadcrumb', array($this, 'cms_navigation_breadcrumb')); add_action('icl_navigation_menu', array($this, 'cms_navigation_menu_nav')); add_action('icl_navigation_sidebar', array($this, 'cms_navigation_page_navigation')); add_action('save_post', array($this, 'cms_navigation_update_post_settings')); add_action('admin_head', array($this, 'cms_navigation_page_edit_options')); add_action('admin_head', array($this, 'cms_navigation_js')); add_action('init', array($this, 'cms_navigation_css')); add_action('plugins_loaded', array($this, 'sidebar_navigation_widget_init')); add_filter('page_link', array($this, 'rewrite_page_link'), 15, 2); add_action('parse_query', array($this, 'redirect_offsite_urls')); add_filter('permalink_structure_changed', array($this, 'clear_cache')); add_filter('update_option_show_on_front', array($this, 'clear_cache')); add_filter('update_option_page_on_front', array($this, 'clear_cache')); add_filter('update_option_page_for_posts', array($this, 'clear_cache')); add_action('delete_post', array($this, 'clear_cache')); add_action('delete_category', array($this, 'clear_cache')); add_action('create_category', array($this, 'clear_cache')); add_action('edited_category', array($this, 'clear_cache')); // not needed - save_post handles this //add_action('trashed_post', array($this,'clear_cache')); //add_action('untrashed_post', array($this,'clear_cache')); }
public function set_language($domain, $lang) { $this->language_of_domain[$domain] = $lang; $string_settings = $this->sitepress->get_setting('st'); $string_settings['lang_of_domain'] = $this->language_of_domain; $this->sitepress->set_setting('st', $string_settings, true); }
private function estimate_custom_field_word_count() { $sitepress_settings = $this->sitepress->get_settings(); if (!isset($this->language_code) || !isset($this->id) || !$this->is_registered_type()) { return 0; } $words = 0; $post_id = $this->id; if (!empty($sitepress_settings['translation-management']['custom_fields_translation']) && is_array($sitepress_settings['translation-management']['custom_fields_translation'])) { $custom_fields = array(); foreach ($sitepress_settings['translation-management']['custom_fields_translation'] as $cf => $op) { if (WPML_TRANSLATE_CUSTOM_FIELD === (int) $op) { $custom_fields[] = $cf; } } foreach ($custom_fields as $cf) { $custom_fields_value = get_post_meta($post_id, $cf); if ($custom_fields_value && is_scalar($custom_fields_value)) { // only support scalar values fo rnow $words += $this->get_string_words_count($this->language_code, $custom_fields_value); } else { foreach ($custom_fields_value as $custom_fields_value_item) { if ($custom_fields_value_item && is_scalar($custom_fields_value_item)) { // only support scalar values fo rnow $words += $this->get_string_words_count($this->language_code, $custom_fields_value_item); } } } } } return (int) $words; }
/** * @param SitePress $sitepress * @param WPML_Query_Filter $query_filter */ public function __construct(&$sitepress, &$query_filter) { $wpdb = $sitepress->wpdb(); $post_translation = $sitepress->post_translations(); $term_translation = $sitepress->term_translations(); parent::__construct($sitepress, $wpdb, $post_translation, $term_translation); $this->query_filter =& $query_filter; }
public function load_icl_migration() { if (!$this->sitepress || (bool) $this->sitepress->get_setting('wpml_icl_migration_completed') === false) { require_once WPML_ICLM_PATH . '/menu/wpml-icl-migration-menu.class.php'; $migration_menu = new WPML_ICL_Migration_Display(); $migration_menu->init(); } }
function language_selector_widget_init() { if ($this->sitepress->get_setting('setup_complete')) { register_widget('ICL_Language_Switcher'); } add_action('template_redirect', 'icl_lang_sel_nav_ob_start', 0); add_action('wp_head', 'icl_lang_sel_nav_ob_end'); }
/** * WPML_TM_Translation_Status_Display constructor. * * @param wpdb $wpdb * @param SitePress $sitepress * @param WPML_Post_Status $status_helper * @param WPML_Translation_Job_Factory $job_factory * @param WPML_TM_API $tm_api */ public function __construct(&$wpdb, &$sitepress, &$status_helper, &$job_factory, &$tm_api) { $post_translation = $sitepress->post_translations(); parent::__construct($wpdb, $sitepress, $post_translation); $this->status_helper =& $status_helper; $this->job_factory =& $job_factory; $this->tm_api =& $tm_api; }
/** * @param $name * @param $domain * * @return string */ public function get_source_lang($name, $domain) { $domain_lang = $this->lang_of_domain->get_language($domain); if (!$domain_lang) { $flag = 0 === strpos($domain, 'admin_texts_') || 'Tagline' === $name || 'Blog Title' === $name; $domain_lang = $flag ? $this->sitepress->get_user_admin_language(get_current_user_id()) : 'en'; } return $domain_lang; }
/** * @param SitePress $sitepress * @param WPML_Terms_Translations $term_utils * @param string $taxonomy */ public function __construct(&$sitepress, &$term_utils, $taxonomy) { $wpdb = $sitepress->wpdb(); parent::__construct($wpdb, $sitepress); $this->term_utils = $term_utils; $this->taxonomy = $taxonomy; $this->data = $this->set_affected_ids(); $this->prepare_missing_terms_data(); }
/** * WPML_Translations_Queue_Jobs_Model constructor. * * @param SitePress $sitepress * @param TranslationManagement $tm_instance * @param WPML_TM_API $tm_api * @param WPML_TM_Post_Link_Factory $post_link_factory * @param array $translation_jobs */ public function __construct($sitepress, &$tm_instance, &$tm_api, &$post_link_factory, array $translation_jobs) { parent::__construct($tm_instance); $this->translation_jobs = $translation_jobs; $this->tm_api =& $tm_api; $this->post_link_factory =& $post_link_factory; $this->post_types = $sitepress->get_translatable_documents(true); $this->post_types = apply_filters('wpml_get_translatable_types', $this->post_types); }
public function __construct($id, &$sitepress, &$wpdb) { parent::__construct($id); $this->wpdb =& $wpdb; $this->sitepress =& $sitepress; $this->wp_post = get_post($id); $this->element_type = 'post_' . $this->wp_post->post_type; $this->language_code = $this->sitepress->get_language_for_element($id, $this->element_type); }
/** * get current language */ public static function get_current_lang() { self::validate_wpml_exists(); $wpml = new SitePress(); if (is_admin()) { $lang = $wpml->get_default_language(); } else { $lang = self::get_current_lang_code(); } return $lang; }
/** * @return array containing strings displayed in the translation service polling status box */ public function get_status_array() { $data = $this->filter_obsolete($this->project->jobs()); $button_text = __('Get completed translations', 'sitepress'); if (($job_in_progress = $this->in_progress_count($data)) == 1) { $jobs_in_progress_text = __('1 job has been sent to the translation service.', 'sitepress'); } else { $jobs_in_progress_text = sprintf(__('%d jobs have been sent to the translation service.', 'sitepress'), $job_in_progress); } $last_picked_up = $this->sitepress->get_setting('last_picked_up'); $last_time_picked_up = !empty($last_picked_up) ? date_i18n('Y, F jS @g:i a', $last_picked_up) : __('never', 'sitepress'); $last_pickup_text = sprintf(__('Last time translations were picked up: %s', 'sitepress'), $last_time_picked_up); return array('jobs_in_progress_text' => $jobs_in_progress_text, 'button_text' => $button_text, 'last_pickup_text' => $last_pickup_text, 'polling_data' => $this->filter_known_pending($data)); }
private function init_metabox_data() { $this->metabox_data = array(); $this->active_languages = $this->sitepress->get_active_languages(); $this->default_language = $this->sitepress->get_default_language(); $this->metabox_data['title'] = __('WPML Translation', 'wpml-string-translation'); $this->metabox_data['package_language_title'] = sprintf(__('Language of this %s is %s', 'wpml-string-translation'), $this->package->kind, $this->active_languages[$this->default_language]['display_name']); $this->metabox_data['translate_title'] = sprintf(__('Send %s to translation', 'wpml-string-translation'), $this->package->kind); if ($this->got_package()) { $this->metabox_data['statuses_title'] = __('Translation status:', 'wpml-string-translation'); $this->init_translation_statuses(); } else { $this->metabox_data['statuses_title'] = __('There is nothing to translate.', 'wpml-string-translation'); } }
/** * get flag url */ public static function getFlagUrl($code) { self::validateWpmlExists(); $wpml = new SitePress(); if (empty($code) || $code == "all") { $url = ICL_PLUGIN_URL . '/res/img/icon16.png'; } else { $url = $wpml->get_flag_url($code); } //default: show all if (empty($url)) { $url = ICL_PLUGIN_URL . '/res/img/icon16.png'; } return $url; }
public static function get_job_id_from_request() { /** * @var TranslationManagement $iclTranslationManagement * @var WPML_Post_Translation $wpml_post_translations */ global $iclTranslationManagement, $wpml_post_translations, $wpml_translation_job_factory, $sitepress, $wpdb; $job_id = filter_input(INPUT_GET, 'job_id', FILTER_SANITIZE_NUMBER_INT); $trid = filter_input(INPUT_GET, 'trid', FILTER_SANITIZE_NUMBER_INT); $language_code = filter_input(INPUT_GET, 'language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $source_language_code = filter_input(INPUT_GET, 'source_language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if (!$job_id && $trid && $language_code) { $job_id = $iclTranslationManagement->get_translation_job_id($trid, $language_code); if (!$job_id) { if (!$source_language_code) { $post_id = SitePress::get_original_element_id_by_trid($trid); } else { $posts_in_trid = $wpml_post_translations->get_element_translations(false, $trid); $post_id = isset($posts_in_trid[$source_language_code]) ? $posts_in_trid[$source_language_code] : false; } $blog_translators = wpml_tm_load_blog_translators(); $args = array('lang_from' => $source_language_code, 'lang_to' => $language_code, 'job_id' => $job_id); if ($post_id && $blog_translators->is_translator($sitepress->get_current_user()->ID, $args)) { $job_id = $wpml_translation_job_factory->create_local_post_job($post_id, $language_code); } } } return $job_id; }
/** * @param string $class */ private function mark_command_as_executed($class) { $id = call_user_func(array($class, 'get_command_id')); $this->string_settings[$id . '_has_run'] = true; $this->sitepress->set_setting('st', $this->string_settings, true); wp_cache_flush(); }
public static function get_job_id_from_request() { /** * @var TranslationManagement $iclTranslationManagement * @var WPML_Post_Translation $wpml_post_translations */ global $iclTranslationManagement, $wpml_post_translations, $wpml_translation_job_factory; $job_id = filter_input(INPUT_GET, 'job_id', FILTER_SANITIZE_NUMBER_INT); $trid = filter_input(INPUT_GET, 'trid', FILTER_SANITIZE_NUMBER_INT); $language_code = filter_input(INPUT_GET, 'language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $source_language_code = filter_input(INPUT_GET, 'source_language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if (!$job_id && $trid && $language_code) { $job_id = $iclTranslationManagement->get_translation_job_id($trid, $language_code); if (!$job_id) { if (!$source_language_code) { $post_id = SitePress::get_original_element_id_by_trid($trid); } else { $posts_in_trid = $wpml_post_translations->get_element_translations(false, $trid); $post_id = isset($posts_in_trid[$source_language_code]) ? $posts_in_trid[$source_language_code] : false; } if ($post_id && current_user_can('manage_options', $post_id)) { $job_id = $wpml_translation_job_factory->create_local_post_job($post_id, $language_code); } } } return $job_id; }
static function _st_warnings() { if (!class_exists('ICL_AdminNotifier')) { return; } global $sitepress, $sitepress_settings; if (!isset($sitepress)) { return; } if (method_exists($sitepress, 'check_settings_integrity') && !SitePress::check_settings_integrity()) { return; } if (!isset($sitepress_settings['st']['strings_language'])) { $sitepress_settings = $sitepress->get_settings(); } if (isset($sitepress_settings['st']['strings_language'])) { if ($sitepress->get_default_language() != $sitepress_settings['st']['strings_language']) { self::_st_default_language_warning(); } elseif ($sitepress_settings['st']['strings_language'] != 'en') { self::_st_default_and_st_language_warning(); } else { ICL_AdminNotifier::removeMessage('_st_default_and_st_language_warning'); ICL_AdminNotifier::removeMessage('_st_default_language_warning'); } } }
/** * @return array */ private function init_rtl_settings() { $this->rtl_original = $this->sitepress->is_rtl($this->job->source_language_code); $this->rtl_translation = $this->sitepress->is_rtl($this->job->language_code); $this->rtl_original_attribute_object = $this->rtl_original ? ' dir="rtl"' : ' dir="ltr"'; $this->rtl_translation_attribute = $this->rtl_translation ? ' dir="rtl"' : ' dir="ltr"'; return array($this->rtl_original, $this->rtl_translation); }
/** * @return array containing strings displayed in the translation service polling status box * * @throws Exception in case communication with Translation Proxy fails */ public function get_status_array() { try { $data = $this->filter_obsolete($this->project->jobs()); } catch (Exception $e) { throw new Exception('Got the following error when trying to load status data from Translation Proxy via polling: ' . $e->getMessage(), 0, $e); } $button_text = __('Get completed translations', 'wpml-translation-management'); if (($job_in_progress = $this->in_progress_count($data)) == 1) { $jobs_in_progress_text = __('1 job has been sent to the translation service.', 'wpml-translation-management'); } else { $jobs_in_progress_text = sprintf(__('%d jobs have been sent to the translation service.', 'wpml-translation-management'), $job_in_progress); } $last_picked_up = $this->sitepress->get_setting('last_picked_up'); $last_time_picked_up = !empty($last_picked_up) ? date_i18n('Y, F jS @g:i a', $last_picked_up) : __('never', 'wpml-translation-management'); $last_pickup_text = sprintf(__('Last time translations were picked up: %s', 'wpml-translation-management'), $last_time_picked_up); return array('jobs_in_progress_text' => $jobs_in_progress_text, 'button_text' => $button_text, 'last_pickup_text' => $last_pickup_text, 'polling_data' => $this->filter_known_pending($data)); }
public static function em_ml_admin_original_event_link($link) { global $EM_Event; if (empty($EM_Event->event_id) && !empty($_REQUEST['trid'])) { $post_id = SitePress::get_original_element_id_by_trid($_REQUEST['trid']); $original_event_link = em_get_event($post_id, 'post_id')->get_edit_url(); } return $link; }
/** * Conditionally set some default values for event related custom fields translation. * * @return bool `false` if defaults were already set, `true` otherwise. */ public function set_defaults() { // make this check again has the action is triggered many times in a request lifecycle if ($this->has_set_defaults()) { return false; } $fields = $this->get_default_copy_fields(); foreach ($fields as $field) { $this->sitepress->core_tm()->settings['custom_fields_translation'][$field] = WPML_COPY_CUSTOM_FIELD; } // remove the method to avoid infinite loops remove_action('icl_save_settings', array($this, 'set_defaults')); // the Translation Management plugin might not be active on this // installation, save this option only if Translation Management is active. $translation_management = $this->sitepress->core_tm(); $tm_is_active = !empty($translation_management) && is_a($translation_management, 'TranslationManagement'); if ($tm_is_active) { $translation_management->save_settings(); Tribe__Settings_Manager::set_option($this->defaults_option_name, true); return true; } return false; }
private function get_strings_summary($source_language) { $strings_query = "\n\t\t\t\tSELECT\n\t\t\t\t s.id, s.context as domain, s.gettext_context as context, s.name, s.value,\n\t\t\t\t (SELECT count(*)\n\t\t\t\t \tFROM {$this->wpdb->prefix}icl_string_translations t\n\t\t\t\t \tWHERE t.string_id = s.id AND t.language<>s.language) as translations\n\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\n\t\t\t\tWHERE s.language = %s\n\t\t\t\tORDER BY s.context, s.domain_name_context_md5;\n\t\t\t\t"; $strings_prepared = $this->wpdb->prepare($strings_query, $source_language); $strings = $this->wpdb->get_results($strings_prepared); $active_languages = $this->sitepress->get_active_languages(); $active_languages_count = count($active_languages); foreach ($strings as $string) { $wpml_string = new WPML_String($string->id, $this->sitepress, $this->wpdb); if (!isset($this->report['strings'])) { $this->init_strings_report($wpml_string); } $type = 'strings'; $this->report[$type]['count']['total']++; if ($string->translations < $active_languages_count) { $this->report[$type]['count']['untranslated'] += $active_languages_count - $string->translations - 1; } $element_attributes = array('element_id' => $string->id, 'element_type' => 'string', 'post_type' => 'string'); $words_count = $wpml_string->get_words_count(); $words_count = apply_filters('wpml_element_words_count', $words_count, $element_attributes); $this->report[$type]['words']['total'] += $words_count; $this->report[$type]['words']['untranslated'] = $this->report[$type]['words']['total'] * $this->report[$type]['count']['untranslated']; } }
public static function wpml_get_table_taxonomies(SitePress $sitepress) { $taxonomies = $sitepress->get_wp_api()->get_taxonomies(array(), 'objects'); $result = array("taxonomies" => array(), "activeLanguages" => array(), "allLanguages" => array()); $sitepress->set_admin_language(); $active_langs = $sitepress->get_active_languages(); $default_lang = $sitepress->get_default_language(); $result["activeLanguages"][$default_lang] = array("label" => $active_langs[$default_lang]['display_name'], "flag" => $sitepress->get_flag_url($default_lang)); foreach ($active_langs as $code => $lang) { if ($code !== $default_lang) { $result["activeLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } } $all_languages = $sitepress->get_languages(); foreach ($all_languages as $code => $lang) { $result["allLanguages"][$code] = array("label" => $lang['display_name'], "flag" => $sitepress->get_flag_url($code)); } foreach ($taxonomies as $key => $tax) { if ($sitepress->is_translated_taxonomy($key)) { $result["taxonomies"][$key] = array("label" => $tax->label, "singularLabel" => $tax->labels->singular_name, "hierarchical" => $tax->hierarchical, "name" => $key); } } return $result; }
function reset_pro_translation_configuration() { $translation_service_name = $this->TranslationProxy->get_current_service_name(); $this->sitepress->set_setting('content_translation_languages_setup', false); $this->sitepress->set_setting('content_translation_setup_complete', false); $this->sitepress->set_setting('content_translation_setup_wizard_step', false); $this->sitepress->set_setting('translator_choice', false); $this->sitepress->set_setting('icl_lang_status', false); $this->sitepress->set_setting('icl_balance', false); $this->sitepress->set_setting('icl_support_ticket_id', false); $this->sitepress->set_setting('icl_current_session', false); $this->sitepress->set_setting('last_get_translator_status_call', false); $this->sitepress->set_setting('last_icl_reminder_fetch', false); $this->sitepress->set_setting('icl_account_email', false); $this->sitepress->set_setting('translators_management_info', false); $this->sitepress->set_setting('site_id', false); $this->sitepress->set_setting('access_key', false); $this->sitepress->set_setting('ts_site_id', false); $this->sitepress->set_setting('ts_access_key', false); if (class_exists('TranslationProxy_Basket')) { //Cleaning the basket TranslationProxy_Basket::delete_all_items_from_basket(); } $sql_for_remote_rids = $this->wpdb->prepare("FROM {$this->wpdb->prefix}icl_translation_status\n\t\t\t\t\t\t\t\t \t\t\t\tWHERE translation_service != 'local'\n\t\t\t\t\t\t\t\t \t\t\t\t\tAND translation_service != 0\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND status IN ( %d, %d )", ICL_TM_WAITING_FOR_TRANSLATOR, ICL_TM_IN_PROGRESS); //Delete all translation service jobs with status "waiting for translator" or "in progress" $this->wpdb->query("DELETE FROM {$this->wpdb->prefix}icl_translate_job WHERE rid IN (SELECT rid {$sql_for_remote_rids})"); //Delete all translation statuses with status "waiting for translator" or "in progress" $this->wpdb->query("DELETE {$sql_for_remote_rids}"); //Cleaning up Translation Proxy settings $this->sitepress->set_setting('icl_html_status', false); $this->sitepress->set_setting('language_pairs', false); if (!$this->TranslationProxy->has_preferred_translation_service()) { $this->sitepress->set_setting('translation_service', false); $this->sitepress->set_setting('icl_translation_projects', false); } $this->sitepress->save_settings(); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_core_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_content_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_string_status"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_node"); $this->wpdb->query("TRUNCATE TABLE {$this->wpdb->prefix}icl_reminders"); if ($this->TranslationProxy->has_preferred_translation_service() && $translation_service_name) { $confirm_message = 'The translation process with %1$s was reset.'; } elseif ($translation_service_name) { $confirm_message = 'Your site was successfully disconnected from %1$s. Go to the translators tab to connect a new %1$s account or use a different translation service.'; } else { $confirm_message = 'PRO translation has been reset.'; } $response = sprintf(__($confirm_message, 'wpml-translation-management'), $translation_service_name); return $response; }
function post_type_link_filter($post_link, $post, $leavename, $sample) { if (!$this->sitepress->is_translated_post_type($post->post_type) || !($ld = $this->sitepress->get_element_language_details($post->ID, 'post_' . $post->post_type))) { return $post_link; } if (isset($this->post_link_cache[$post->ID][$leavename . '#' . $sample])) { $post_link = $this->post_link_cache[$post->ID][$leavename . '#' . $sample]; } else { $st_settings = $this->sitepress->get_setting('st'); $strings_language = !empty($st_settings['strings_language']) ? $st_settings['strings_language'] : 'en'; // fix permalink when object is not in the current language if ($ld->language_code != $strings_language) { $slug_settings = $this->sitepress->get_setting('posts_slug_translation'); $slug_settings = !empty($slug_settings['types'][$post->post_type]) ? $slug_settings['types'][$post->post_type] : null; if ((bool) $slug_settings === true) { $slug_this = $this->get_slug_by_type($post->post_type); $slug_real = $this->get_translated_slug($slug_this, $ld->language_code); if (empty($slug_real)) { return $post_link; } global $wp_rewrite; if (isset($wp_rewrite->extra_permastructs[$post->post_type])) { $struct_original = $wp_rewrite->extra_permastructs[$post->post_type]['struct']; $lslash = false !== strpos($struct_original, '/' . $slug_this) ? '/' : ''; $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = preg_replace('@' . $lslash . $slug_this . '/@', $lslash . $slug_real . '/', $struct_original); remove_filter('post_type_link', array($this, 'post_type_link_filter'), 1); // high priority $post_link = get_post_permalink($post->ID, $leavename, $sample); add_filter('post_type_link', array($this, 'post_type_link_filter'), 1, 4); // high priority $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = $struct_original; } else { $post_link = str_replace($slug_this . '=', $slug_real . '=', $post_link); } } $this->post_link_cache[$post->ID][$leavename . '#' . $sample] = $post_link; } } return $post_link; }
/** * Uses the data retrieved from the database and saves information about, * in need of fixing terms to this object. * * @return array */ private function prepare_missing_terms_data() { $default_lang = $this->sitepress->get_default_language(); $data = $this->data; $missing = array(); foreach ($data as $ttid => $data_item) { if (empty($data_item['plangs']) && empty($data_item['tlang'])) { $missing[$ttid][$default_lang] = -1; } else { $affected_languages = array_diff($data_item['plangs'], $data_item['tlang']); if (!empty($affected_languages)) { foreach ($data_item['plangs'] as $post_id => $lang) { if (!isset($missing[$ttid][$lang])) { $missing[$ttid][$lang] = array($post_id); } else { $missing[$ttid][$lang][] = $post_id; } } } } } $this->missing_terms = $missing; }
public function maybe_migrate_string_name() { global $wpdb; $slug_settings = $this->sitepress->get_setting('posts_slug_translation'); if (!isset($slug_settings['string_name_migrated'])) { $queryable_post_types = get_post_types(array('publicly_queryable' => true)); foreach ($queryable_post_types as $type) { $post_type_obj = get_post_type_object($type); $slug = trim($post_type_obj->rewrite['slug'], '/'); if ($slug) { // First check if we should migrate from the old format URL slug: slug $string_id = $wpdb->get_var($wpdb->prepare("SELECT id\r\r\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_strings\r\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE name = %s AND value = %s", 'URL slug: ' . $slug, $slug)); if ($string_id) { // migrate it to URL slug: post_type $st_update['name'] = 'URL slug: ' . $type; $wpdb->update($wpdb->prefix . 'icl_strings', $st_update, array('id' => $string_id)); } } } $slug_settings['string_name_migrated'] = true; $this->sitepress->set_setting('posts_slug_translation', $slug_settings, true); } }
/** * Print the Single Taxonomy Metabox * * @author Andrea Grillo <*****@*****.**> * @since 1.0.0 * * @param $taxonomy string Taxonomy Name * @param $taxonomy_box string Taxonomy Box * * @return void */ public function single_taxonomy_meta_box($taxonomy, $taxonomy_box) { $taxonomy_label = YITH_Vendors()->get_vendors_taxonomy_label(); $vendor = yith_get_vendor('current', 'product'); $vendor_id = 0; $wpml_vendor = null; /* WPML Support */ global $sitepress, $pagenow; if ($vendor->is_valid()) { if (isset($sitepress)) { $vendor_id = yit_wpml_object_id($vendor->id, YITH_Vendors()->get_taxonomy_name(), true); $wpml_vendor = get_term_by('id', $vendor_id, $vendor->term->taxonomy); $vendor_id = $wpml_vendor->term_id; } else { $vendor_id = $vendor->id; } } elseif (isset($sitepress) && $vendor->is_super_user() && 'post-new.php' == $pagenow && !empty($_GET['trid'])) { $original_product_id = SitePress::get_original_element_id_by_trid($_GET['trid']); $original_vendor = yith_get_vendor($original_product_id, 'product'); if ($original_vendor->is_valid()) { $vendor_id = yit_wpml_object_id($original_vendor->id, YITH_Vendors()->get_taxonomy_name(), true); $wpml_vendor = get_term_by('id', $vendor_id, $original_vendor->term->taxonomy); $vendor_id = $wpml_vendor->term_id; } } $args = array('id' => 'tax-input-yith_shop_vendor', 'name' => 'tax_input[yith_shop_vendor]', 'taxonomy' => $this->_taxonomy_name, 'show_option_none' => !$vendor->is_super_user() ? '' : sprintf(__('No %s'), strtolower($taxonomy_label['singular_name'])), 'hide_empty' => !$vendor->is_super_user(), 'selected' => $vendor_id, 'walker' => YITH_Walker_CategoryDropdown(), 'option_none_value' => ''); $vendor = yith_get_vendor('current', 'user'); if ($vendor->is_valid() && $vendor->has_limited_access() && $vendor->is_user_admin()) { echo is_null($wpml_vendor) ? $vendor->name : $wpml_vendor->name; } else { wp_dropdown_categories($args); } }