function wpml_sanitize_hex_color_array($input, $default_if_invalid = '', $bypass_non_strings = true, $recursive = false)
{
    $result = $input;
    if (is_array($input)) {
        $result = array();
        foreach ($input as $key => $value) {
            if (is_array($value) && $recursive) {
                $result[$key] = wpml_sanitize_hex_color_array($value, $default_if_invalid, $recursive);
            } elseif (is_string($value)) {
                $result[$key] = wpml_sanitize_hex_color($value, $default_if_invalid);
            } elseif ($bypass_non_strings) {
                $result[$key] = $value;
            }
        }
    }
    return $result;
}
示例#2
0
     $this->save_settings($iclsettings);
     echo '1|';
     break;
 case 'icl_save_language_switcher_options':
     $_POST = stripslashes_deep($_POST);
     $ls_options = filter_input_array(INPUT_POST, array_fill_keys(array('icl_lso_link_empty', 'icl_lso_flags', 'icl_lso_native_lang', 'icl_lso_display_lang'), array('filter' => FILTER_SANITIZE_NUMBER_INT, 'flags' => FILTER_NULL_ON_FAILURE)));
     if (!$this->get_setting('setup_complete')) {
         if (isset($iclsettings['setup_reset'])) {
             unset($iclsettings['setup_reset']);
         }
     }
     if (isset($_POST['icl_lang_sel_config'])) {
         $iclsettings['icl_lang_sel_config'] = wpml_sanitize_hex_color_array($_POST['icl_lang_sel_config'], '', true, false);
     }
     if (isset($_POST['icl_lang_sel_footer_config'])) {
         $iclsettings['icl_lang_sel_footer_config'] = wpml_sanitize_hex_color_array($_POST['icl_lang_sel_footer_config'], '', true, false);
     }
     if (isset($_POST['icl_lang_sel_type'])) {
         $iclsettings['icl_lang_sel_type'] = $_POST['icl_lang_sel_type'];
     }
     if (isset($_POST['icl_lang_sel_stype'])) {
         $iclsettings['icl_lang_sel_stype'] = $_POST['icl_lang_sel_stype'];
     }
     $iclsettings['icl_lang_sel_orientation'] = $_POST['icl_lang_sel_orientation'];
     if (isset($_POST['icl_lang_sel_footer'])) {
         $iclsettings['icl_lang_sel_footer'] = 1;
     } else {
         $iclsettings['icl_lang_sel_footer'] = 0;
     }
     if (isset($_POST['icl_post_availability'])) {
         $iclsettings['icl_post_availability'] = 1;
示例#3
0
 function custom_language_switcher_style()
 {
     if (defined('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS') && ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS) {
         return;
     }
     $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) {
             $add = true;
             break;
         }
     }
     if ($add) {
         $list = $this->settings['icl_lang_sel_type'] == 'list' ? true : false;
         echo "\n<style type=\"text/css\">";
         foreach ($this->settings['icl_lang_sel_config'] as $k => $v) {
             switch ($k) {
                 case 'font-current-normal':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list a.lang_sel_sel, #lang_sel_list a.lang_sel_sel:visited{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel a, #lang_sel a.lang_sel_sel{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'font-current-hover':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list a:hover, #lang_sel_list a.lang_sel_sel:hover{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel a:hover, #lang_sel a.lang_sel_sel:hover{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'background-current-normal':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list a.lang_sel_sel, #lang_sel_list a.lang_sel_sel:visited{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel a.lang_sel_sel, #lang_sel a.lang_sel_sel:visited{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'background-current-hover':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list a.lang_sel_sel:hover{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel a.lang_sel_sel:hover{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'font-other-normal':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list ul a.lang_sel_other, #lang_sel_list ul a.lang_sel_other:visited{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel li ul a, #lang_sel li ul a:visited{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'font-other-hover':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list ul a.lang_sel_other:hover{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel li ul a:hover{color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'background-other-normal':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list ul a.lang_sel_other, #lang_sel li ul a:link, #lang_sel_list ul a.lang_sel_other:visited{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel li ul a, #lang_sel li ul a:link, #lang_sel li ul a:visited{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'background-other-hover':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list ul a.lang_sel_other:hover{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel li ul a:hover{background-color:' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
                 case 'border':
                     //if($v != $this->widget_css_defaults[$k])
                     if ($list) {
                         echo '#lang_sel_list a, #lang_sel_list a:visited{border-color:' . sanitize_text_field($v) . ';} #lang_sel_list  ul{border-top:1px solid ' . wpml_sanitize_hex_color_array($v) . ';}';
                     } else {
                         echo '#lang_sel a, #lang_sel a:visited{border-color:' . sanitize_text_field($v) . ';} #lang_sel ul ul{border-top:1px solid ' . wpml_sanitize_hex_color_array($v) . ';}';
                     }
                     break;
             }
         }
         echo "</style>\n";
     }
     if (isset($this->settings['icl_additional_css']) && !empty($this->settings['icl_additional_css'])) {
         echo "\r\n<style type=\"text/css\">";
         //echo implode("\r\n", $this->settings['icl_additional_css']);
         echo $this->settings['icl_additional_css'];
         echo "\r\n</style>";
     }
 }