$sanitized[ $allowed_var ] = (bool) $vars[ $allowed_var ]; break; case 'mixed': $sanitized[ $allowed_var ] = $vars[ $allowed_var ]; break; } } } return $sanitized; } /** * @param array $lang * @param WPML_LS_Slot $slot * * @return array */ private function add_backward_compatibility_to_languages( $lang, $slot ) { if ( $this->needs_backward_compatibility() ) { $is_current_language = isset( $lang['is_current'] ) && $lang['is_current']; if ( $slot->is_menu() ) { if ( $is_current_language ) { array_unshift( $lang['css_classes'], 'menu-item-language-current' ); } array_unshift( $lang['css_classes'], 'menu-item-language' ); } if ( $slot->is_sidebar() || $slot->is_shortcode_actions() ) { if ( $this->is_legacy_template( $slot->template(), 'list-vertical' ) || $this->is_legacy_template( $slot->template(), 'list-horizontal' ) ){ array_unshift( $lang['css_classes'], 'icl-' . $lang['code'] ); $lang['backward_compatibility']['css_classes_a'] = $is_current_language ? 'lang_sel_sel' : 'lang_sel_other'; } if ( $this->is_legacy_template( $slot->template(), 'dropdown' ) || $this->is_legacy_template( $slot->template(), 'dropdown-click' ) ){ if ( $is_current_language ) { $lang['backward_compatibility']['css_classes_a'] = 'lang_sel_sel icl-' . $lang['code']; } else { array_unshift( $lang['css_classes'], 'icl-' . $lang['code'] ); } } } } return $lang; } /** * @param array $vars * @param WPML_LS_Slot $slot * * @return mixed */ private function add_backward_compatibility_to_wrapper( $vars, $slot ) { if ( $this->needs_backward_compatibility() ) { if ( $slot->is_sidebar() || $slot->is_shortcode_actions() ) { if ( $this->is_legacy_template( $slot->template(), 'list-vertical' ) || $this->is_legacy_template( $slot->template(), 'list-horizontal' ) ){ $vars['backward_compatibility']['css_id'] = 'lang_sel_list'; if ( $this->is_legacy_template( $slot->template(), 'list-horizontal' ) ) { $vars['css_classes'] = 'lang_sel_list_horizontal ' . $vars['css_classes']; } else { $vars['css_classes'] = 'lang_sel_list_vertical ' . $vars['css_classes']; } } if ( $this->is_legacy_template( $slot->template(), 'dropdown' ) ) { $vars['backward_compatibility']['css_id'] = 'lang_sel'; } if ( $this->is_legacy_template( $slot->template(), 'dropdown-click' ) ) { $vars['backward_compatibility']['css_id'] = 'lang_sel_click'; } } if ( $slot->is_post_translations() ) { $vars['css_classes'] = 'icl_post_in_other_langs ' . $vars['css_classes']; } if ( $slot->is_footer() ) { $vars['backward_compatibility']['css_id'] = 'lang_sel_footer'; } $vars['backward_compatibility']['css_classes_flag'] = 'iclflag'; $vars['backward_compatibility']['css_classes_native'] = 'icl_lang_sel_native'; $vars['backward_compatibility']['css_classes_display'] = 'icl_lang_sel_translated'; $vars['backward_compatibility']['css_classes_bracket'] = 'icl_lang_sel_bracket'; } return $vars; } /** * @param $template_slug * @param mixed|string|null $type * * @return bool */ private function is_legacy_template( $template_slug, $type = null ) { $templates = $this->settings->get_core_templates(); $ret = in_array( $template_slug, $templates, true); if ( $ret && array_key_exists( $type, $templates ) ) { $ret = $templates[ $type ] === $template_slug; } return $ret; } }