<?php
function logingpower_languageswitcher(){

		// language switcher background color
		if ( !empty(get_option('logingpower_settings')['logingpower_languageswitcher_background_color_show'] ) ){
			$logingpower_style= 'body.login div.language-switcher  {
				background-color:'.esc_attr( (get_option('logingpower_settings')['logingpower_languageswitcher_background_color'] )??'#c7ccd1' ).'!important;	 
			}';
		wp_add_inline_style('login',$logingpower_style);
		}
		// language switcher border width , border radius ,  padding, 
		$logingpower_style= 'body.login div.language-switcher  {
			width:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_width'])??'100').'%!important;
			border:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_style'])??'none').' '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_width'])??'0').'px'.' '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_color'])??'#2271b1').'!important;
			border-radius:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_radius_topleft'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_radius_topright'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_radius_bottomright'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_border_radius_bottomleft'])??'0').'px !important;
			padding:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_padding_top'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_padding_right'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_padding_bottom'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_padding_left'])??'0').'px !important;
			opacity:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_opacity'])??'1').' !important;
		}';
		wp_add_inline_style('login',$logingpower_style);

		//language switcher backgrund image 
		$languageswitcher_background_img='none';
		$languageswitcher_background_repeat='no-repeat';
		$languageswitcher_background_imgsize_style='auto';
		if ( !empty(get_option('logingpower_settings')['logingpower_languageswitcher_background_show'] ) )
		$languageswitcher_background_img=sanitize_text_field (get_option('logingpower_settings')['logingpower_languageswitcher_background_img'] ??plugins_url( 'imgs/laptop.JPG', __FILE__ ));
		$languageswitcher_background_repeat=sanitize_text_field(  get_option('logingpower_settings')[ 'logingpower_languageswitcher_background_repeat' ]??'no-repeat');
		$languageswitcher_background_imgsize=sanitize_text_field( get_option('logingpower_settings')['logingpower_languageswitcher_background_imgsize']??'auto');
			$languageswitcher_background_imgsize_style='auto';
		switch ($languageswitcher_background_imgsize) {
			case 'auto':
			 	$languageswitcher_background_imgsize_style='auto';
				break;
			case 'width':
			 $languageswitcher_background_imgsize_style='100%  auto';
				break;
			case 'height':
				$languageswitcher_background_imgsize_style='auto 100%';
				break;
			case 'both':
			 $languageswitcher_background_imgsize_style='100%  100%';
				break;
			default:
				$languageswitcher_background_imgsize_style='auto';
				break;
		}
		
		$logingpower_style= 'body.login div.language-switcher  {
			background-image:url('.esc_attr($languageswitcher_background_img ).');
				background-size:'. esc_attr( $languageswitcher_background_imgsize_style).'!important;
				background-repeat: ' .esc_attr($languageswitcher_background_repeat). '!important;
		}';
		wp_add_inline_style('login',$logingpower_style);

		$logingpower_style= 'body.login div.language-switcher form input {
			width:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_width'])??'65').'px !important;
			height:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_height'])??'30').'px !important;
			font-size:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_fontsize'])??'13').'px !important;
			background-color:'.esc_attr( (get_option('logingpower_settings')['logingpower_languageswitcher_change_background_color'] )??'#f6f7f7' ).'!important;	
			border:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_style'])??'solid').' '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_width'])??'1').'px '.' '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_color'])??'#2271b1').'!important;
			border-radius:'.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_radius_topleft'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_radius_topright'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_radius_bottomright'])??'0').'px'.' 
			   '.esc_attr((get_option('logingpower_settings')['logingpower_languageswitcher_change_border_radius_bottomleft'])??'0').'px !important;
			color:'.esc_attr( (get_option('logingpower_settings')['logingpower_languageswitcher_change_label_color'] )??'#2271b1' ).'!important;
			cursor:'.esc_attr( (get_option('logingpower_settings')['logingpower_languageswitcher_change_cursor'] )??'pointer' ).'!important;}';
		wp_add_inline_style('login',$logingpower_style);
		$logingpower_style= 'body.login div.language-switcher form input:hover{
			background-color:'.esc_attr( (get_option('logingpower_settings')['logingpower_languageswitcher_change_hover_color'] )??'#f6f7f7' ).'!important;}';
		wp_add_inline_style('login',$logingpower_style);
		     function logingpower_languageswitcher_label( $translated_text, $text, $domain ) {
		         if ($text === 'Change') {
		    	$translated_text=  sanitize_text_field(get_option('logingpower_settings')['logingpower_languageswitcher_change_label'] ??'Change');
		         }
		        return $translated_text;
		    }
		    add_filter( 'gettext', 'logingpower_languageswitcher_label', 20, 3 );
	}//add_action( 'login_head', 'logingpower_languageswitcher') ;
	 add_action( 'login_enqueue_scripts', 'logingpower_languageswitcher') ;