array( 'font-current-normal' => '#222222', 'font-current-hover' => '#000000', 'background-current-normal' => '#eeeeee', 'background-current-hover' => '#eeeeee', 'font-other-normal' => '#222222', 'font-other-hover' => '#000000', 'background-other-normal' => '#e5e5e5', 'background-other-hover' => '#eeeeee', 'border' => '#cdcdcd', 'background' => '#e5e5e5' ), 'White' => array( 'font-current-normal' => '#444444', 'font-current-hover' => '#000000', 'background-current-normal' => '#ffffff', 'background-current-hover' => '#eeeeee', 'font-other-normal' => '#444444', 'font-other-hover' => '#000000', 'background-other-normal' => '#ffffff', 'background-other-hover' => '#eeeeee', 'border' => '#cdcdcd', 'background' => '#ffffff' ), 'Blue' => array( 'font-current-normal' => '#ffffff', 'font-current-hover' => '#000000', 'background-current-normal' => '#95bedd', 'background-current-hover' => '#95bedd', 'font-other-normal' => '#000000', 'font-other-hover' => '#ffffff', 'background-other-normal' => '#cbddeb', 'background-other-hover' => '#95bedd', 'border' => '#0099cc', 'background' => '#cbddeb' ) ); function __construct(){ $this->widget_css_defaults = $this->color_schemes['White']; $this->footer_css_defaults = $this->color_schemes['White']; add_action('plugins_loaded',array(&$this,'init')); } function init(){ global $sitepress_settings; $this->settings = $sitepress_settings; if ($this->settings['icl_lang_sel_footer']){ add_action('wp_head', array(&$this, 'language_selector_footer_style'),19); add_action('wp_footer', array(&$this, 'language_selector_footer'),19); } if (is_admin()) { add_action('icl_language_switcher_options',array(&$this,'admin'),1); } else if ($this->settings['icl_post_availability']) { icl_register_string('WPML', 'Text for alternative languages for posts', $this->settings['icl_post_availability_text']); add_filter('the_content', array(&$this, 'post_availability')); } // the language selector widget $this->language_selector_widget_init(); if(is_admin() && $_GET['page'] == ICL_PLUGIN_FOLDER . '/menu/languages.php'){ add_action('admin_head', 'icl_lang_sel_nav_css', 1, 1, true); add_action('admin_head', array(&$this, 'custom_language_switcher_style')); } if(!is_admin()){ add_action('wp_head', array(&$this, 'custom_language_switcher_style')); } } function language_selector_widget_init(){ wp_register_sidebar_widget( 'icl_lang_selector_sidebar', __('Language Selector', 'sitepress'), 'language_selector_widget', 'icl_languages_selector'); wp_register_widget_control( 'icl_lang_selector_wiget', __('Language Selector', 'sitepress'), array(&$this, 'set_widget') ); add_action('template_redirect','icl_lang_sel_nav_ob_start'); add_action('wp_head','icl_lang_sel_nav_ob_end'); } function set_widget(){ global $sitepress, $sitepress_settings; if (isset($_POST['icl_widget_update'])){ $sitepress_settings['icl_widget_title_show'] = (isset($_POST['icl_widget_title_show'])) ? 1 : 0; $sitepress->save_settings($sitepress_settings); } echo ''; echo '
'; } function post_availability($content){ $out = ''; if(is_singular()){ $languages = icl_get_languages('skip_missing=true'); if(1 < count($languages)){ //$out .= $this->settings['post_available_before'] ? $this->settings['post_available_before'] : ''; foreach($languages as $l){ if(!$l['active']) $langs[] = ''.$l['translated_name'].''; } $out .= join(', ', $langs); //$out .= $this->settings['post_available_after'] ? $this->settings['post_available_after'] : ''; $out = '

' . sprintf(icl_t('WPML', 'Text for alternative languages for posts', $this->settings['icl_post_availability_text']), $out) . '

'; } } if ($this->settings['icl_post_availability_position'] == 'above') return $out . $content; else return $content . $out; } function language_selector_footer_style(){ $add = false; foreach($this->footer_css_defaults as $key=>$d){ if (isset($this->settings['icl_lang_sel_footer_config'][$key]) && $this->settings['icl_lang_sel_footer_config'][$key] != $d){ $this->settings['icl_lang_sel_footer_config'][$key] . "\n"; $add = true; break; } } if($add){ echo "\n\n"; } } function language_selector_footer() { $languages = icl_get_languages('orderby=id&order=asc&skip_missing=0'); if(!empty($languages)){ echo ' '; } } function admin(){ foreach($this->color_schemes as $key=>$val): ?> widget_css_defaults as $k=>$v): ?>
 
 
  • color_schemes as $key=>$val): ?> footer_css_defaults as $k=>$v): ?> settings['icl_lang_sel_footer']) echo 'style="display:none;" '; ?>>
  • settings['icl_lang_sel_type'] || $this->settings['icl_lang_sel_type'] == 'dropdown') echo ' style="display:none;"';?>>
    widget_css_defaults = $this->widget_css_defaults; $add = false; foreach($this->widget_css_defaults as $key=>$d){ if(isset($this->settings['icl_lang_sel_config'][$key]) && $this->settings['icl_lang_sel_config'][$key] != $d){ $this->settings['icl_lang_sel_config'][$key] . "\n"; $add = true; break; } } if($add){ $list = ($this->settings['icl_lang_sel_type'] == 'list') ? true : false; echo "\n\n"; } if (isset($this->settings['icl_additional_css']) && !empty($this->settings['icl_additional_css'])) { echo "\r\n"; } } } // end class // language switcher functions function language_selector_widget($args){ global $sitepress, $sitepress_settings; extract($args, EXTR_SKIP); echo $before_widget; if ($sitepress_settings['icl_widget_title_show']) { echo $args['before_title']; echo icl_t('WPML', 'Widget title', __('Languages','sitepress')); echo $args['after_title']; } $sitepress->language_selector(); echo $after_widget; } function icl_lang_sel_nav_ob_start(){ if(is_feed()) return; ob_start('icl_lang_sel_nav_prepend_css'); } function icl_lang_sel_nav_ob_end(){ ob_end_flush();} function icl_lang_sel_nav_prepend_css($buf){ if(defined('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS') && ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS){ return $buf; } return preg_replace('##i','' . PHP_EOL . PHP_EOL . icl_lang_sel_nav_css(false), $buf); } function icl_lang_sel_nav_css($show = true){ if(defined('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS') && ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS){ return ''; } $link_tag = ''; if(!$show && (!isset($_GET['page']) || $_GET['page'] != ICL_PLUGIN_FOLDER . '/menu/languages.php')){ return $link_tag; }else{ echo $link_tag; } } global $icl_language_switcher; $icl_language_switcher = new SitePressLanguageSwitcher;