<?php
namespace Elementor;

class headeruser extends Widget_Base {
	
	public function get_name() {
		return 'headeruser';
	}
	
	public function get_title() {
		return 'حساب کاربری و سبد خرید';
	}
	
	    public function get_icon() {
		return 'eicon eicon-header';
    }
    
    public function get_categories() {
        return [ 'farnam' ];
    }
	
	protected function register_controls() {


		$this->start_controls_section(
			'section_title',
			[
				'label' => __( 'Content', 'elementor' ),
			]
		);
		
		$this->add_control(
			'posts_per_page',
			[
				'label' => __( 'عنوان', 'elementor' ),
				'label_block' => true,
				'type' => Controls_Manager::TEXT,
				'placeholder' => __( 'یک عنوان وارد کنید', 'elementor' ),
			]
		);
		
		
		        $this->end_controls_section();

				       $this->start_controls_section(
            'farnam_product_style_1',
            [
                'label' => esc_html__( 'تنظیمات فعال سازی', 'woolentor' ),
            ]
        );
		$this->add_control(
			'farnamoneshow1',
			[
				'label' => __( 'نمایش حساب کاربری', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		
       $this->add_control(
			'farnamoneshow2',
			[
				'label' => __( 'نمایش سبد خرید', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
  
        $this->end_controls_section();



		 $this->start_controls_section(
            'farnam_product_style_2',
            [
                'label' => esc_html__( 'تنظیمات استایل و ظاهر', 'woolentor' ),
            ]
        );
             

		   

		   $this->add_control(
'color_farnam_3',
			[
				'label' => __( 'رنگ پس زمینه کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
				
				'selectors' => [
					'{{WRAPPER}} #user-403-farvardin' => 'background: {{VALUE}} !important',
				],
			]
           );

		   $this->add_control(
'color_farnam_4',
			[
				'label' => __( 'رنگ کادر کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #user-403-farvardin' => 'border-color: {{VALUE}} !important',
				],
			]
           );
		     $this->add_control(
'color_farnam_421',
			[
				'label' => __( 'رنگ عنوان کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mot-donya-fiveuser-403-farvardin-title' => 'color: {{VALUE}} !important',
				],
			]
           );

		   	 	   $this->add_control(
'color_farnam_6',
			[
				'label' => __( 'رنگ فلش کنار حساب کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #user-403-farvardin::before' => 'color: {{VALUE}} !important',
				],
			]
           );  
		   
		   $this->add_control(
'color_farnam_6we1',
			[
				'label' => __( 'رنگ ایکون کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mot-donya-fiveuser-403-farvardin svg path' => 'stroke: {{VALUE}} !important',
				],
			]
           );  
		   
		    $this->add_control(
'color_farnam_6we2',
			[
				'label' => __( 'رنگ دوم ایکون کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mot-donya-fiveuser-403-farvardin svg circle' => 'stroke: {{VALUE}} !important',
				],
			]
           ); 
		       $this->add_control(
'color_farnam_6we65556',
			[
				'label' => __( 'رنگ گردی داخل ایکون کاربری', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mot-donya-fiveuser-403-farvardin svg circle' => 'fill: {{VALUE}} !important',
				],
			]
           );
		 	   $this->add_control(
'color_farnam_5',
			[
				'label' => __( 'رنگ پس زمینه دکمه خروج', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .ittyn2' => 'background: {{VALUE}} !important',
				],
			]
           );  
		   
		   	   	 	   $this->add_control(
'color_farnam_7',
			[
				'label' => __( 'رنگ متن دکمه خروج', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .ittyn2 .khorooj-sistem' => 'color: {{VALUE}} !important',
				],
			]
           );  
		   
		      	   	 
		   	   	 	   $this->add_control(
'color_farnam_754',
			[
				'label' => __( 'رنگ هاور دکمه ها', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .user-meta .dsfgdsf444444 a:hover' => 'color: {{VALUE}} !important',
				],
			]
           );  
		   
		   		   		      	   	 	   $this->add_control(
'color_farnam_9sabad-1',
			[
				'label' => __( 'رنگ پس زمینه سبد خرید', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #sabad-farvardin-403' => 'background: {{VALUE}} !important',
				],
			]
           );  
		   		      	   	 	   $this->add_control(
'color_farnam_9',
			[
				'label' => __( 'رنگ ایکون سبد خرید', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #sabad-farvardin-403 svg circle' => 'stroke: {{VALUE}} !important',
					'{{WRAPPER}} #sabad-farvardin-403 svg path' => 'stroke: {{VALUE}} !important',
				],
			]
           );  
		   
		   		   
		   		      	   	 	   $this->add_control(
'color_farnam_10',
			[
				'label' => __( 'رنگ پس زمینه شمارنده', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #sabad-farvardin-403 .sabadnumbercolor' => 'background: {{VALUE}} !important',
				],
			]
           );  
		   
		         	   	 	   $this->add_control(
'color_farnam_11',
			[
				'label' => __( 'رنگ متن شمارنده', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} #sabad-farvardin-403 .sabadnumbercolor' => 'color: {{VALUE}} !important',
				],
			]
           );  
		   
		   
		          	   	 	   $this->add_control(
'color_farnam_12',
			[
				'label' => __( 'رنگ پس زمینه حذف محصولات', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mini-cart-3 .remove.remove_from_cart_button' => 'background: {{VALUE}} !important',
				],
			]
           );  
		   
		   
		   	          	   	 	
     
		   
		   
		   
		      	   	 	   $this->add_control(
'color_farnam_148',
			[
				'label' => __( 'رنگ متن حذف محصولات', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mini-cart-3 .remove.remove_from_cart_button' => 'color: {{VALUE}} !important;',
				],
			]
           );  
		   
		   
		    
		      	   	 	   $this->add_control(
'color_farnam_185',
			[
				'label' => __( 'رنگ پس زمینه دکمه تسویه حساب', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart__buttons .button:nth-child(2)' => 'background: {{VALUE}} !important',
				],
			]
           );  
		   
		      	   	 	   $this->add_control(
'color_farnam_1r85',
			[
				'label' => __( 'رنگ متن دکمه تسویه حساب', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart__buttons .button:nth-child(2)' => 'color: {{VALUE}} !important',
				],
			]
           );  
	
	
	
	 $this->add_responsive_control(
                        'farnamborde54r1we11',
                        [
                            'label' => esc_html__( 'گردی حساب کاربری', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} #user-403-farvardin' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
						 $this->add_responsive_control(
                        'farnamborde54r1we12',
                        [
                            'label' => esc_html__( 'گردی سبد خرید', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} #sabad-farvardin-403' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
 $this->add_responsive_control(
                        'farnamborde54r1',
                        [
                            'label' => esc_html__( 'گردی باکس بازشونده حساب کاربری', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .left-rr-user.mk-402-2.bazshomik980.mik983343242 .user-meta' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
  $this->add_responsive_control(
                        'farnamborder2',
                        [
                            'label' => esc_html__( 'گردی تصویر کاربری', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .intrr1' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
				  $this->add_responsive_control(
                        'farnamborder3',
                        [
                            'label' => esc_html__( 'گردی دکمه خروج', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .ittyn2' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
								  $this->add_responsive_control(
                        'farnamborder4',
                        [
                            'label' => esc_html__( 'گردی شمارنده سبد خرید', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} #sabad-farvardin-403 .sabadnumbercolor' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );	
									  $this->add_responsive_control(
                        'farnamborder5',
                        [
                            'label' => esc_html__( 'گردی باکس بازشونده سبد خرید', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .left-sabad.min-car-6.gtr-654.sabadcolortitle.cartnimshe-422-1400 .mini-cart-3' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                                '{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart-item.mini_cart_item' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );	
					
						  $this->add_responsive_control(
                        'farnamborder4453',
                        [
                            'label' => esc_html__( 'گردی دکمه های سبد خرید', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart__total.total' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                                '{{WRAPPER}} .ss-nn-xx-11 .left-sabad span' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                                '{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart__buttons .button' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                                '{{WRAPPER}} .mini-cart-3 .woocommerce-mini-cart__buttons .button:nth-child(2)' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );	
					


        $this->end_controls_section();
	}
	
	protected function render() {
		$settings = $this->get_settings_for_display();
		

		?>

<div class="left-header-box header-one-one-4 ss-nn-xx-11">



 <?php if ( 'yes' === $settings['farnamoneshow1'] ) { ?>
<?php if ( is_user_logged_in() ) { ?>


<div class="left-rr-user mk-402-2 bazshomik980 mik983343242" id="user-403-farvardin">

<div class="mot-donya-fiveuser-403-farvardin">
<div class="mot-donya-fiveuser-403-farvardin-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 24 24" fill="none" stroke="#1b1b1d" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg></div>

<div class="mot-donya-fiveuser-403-farvardin-title">

حساب کاربری</div></div>


<div class="user-meta">
   <div class="user-avatar45">
		<div class="intrr1"><?php

// Get current user id
$user_id = get_current_user_id();

// Get attachment id
$attachment_id = get_user_meta( $user_id, 'avatar', true );

// Get default avatar URL
$default_avatar = wp_get_attachment_image_src(get_option('avatar_default'), '100');

// True
if ( $attachment_id ) {

  // Get image url
  $image_url = wp_get_attachment_url( $attachment_id );

  // Display image
  if ( $image_url ) {
    echo wp_get_attachment_image( $attachment_id, '100' );
  } else {
    // Display default avatar
    echo '<img src="' . esc_url($default_avatar[0]) . '" alt="اواتار" width="100" height="100">';
  }
} else {

  // Display default avatar
  echo '<img src="' . get_template_directory_uri() . '/img/user.jpg' . '" alt="اواتار پیشفرض" width="100" height="100">';
}
?></div>
       <div class="ittyn2">
<a class="khorooj-sistem" href="<?php echo home_url() ?>/my-account/customer-logout/">خروج از سایت</a>

</div>
        
    
    </div>
	<div class="dsfgdsf444444">
<a href="<?php echo home_url() ?>/my-account/"><i class="mdi mdi-view-dashboard-outline"></i>پنل کاربری </a>
<a href="<?php echo home_url() ?>/my-account/edit-account/"><i class="mdi mdi-account-outline"></i>ویرایش حساب کاربری </a>
<a href="<?php echo home_url() ?>/my-account/orders/"><i class="mdi mdi-card-bulleted-outline"></i> سفارش های شما </a>
<a href="<?php echo home_url() ?>/my-account/mywishlist/"><i class="mdi mdi-heart"></i> علاقه مندی های شما </a>

<div class="log-111">

<a  href="<?php echo home_url() ?>/my-account/customer-logout/"> <i class="mdi mdi-account-arrow-left-outline"></i>خروج از سایت </a>

</div></div>
</div>
</div>


 <?php } 
 else { ?>
 <a href="<?php echo home_url() ?>/my-account/" class="left-rr-user mk-402-2" id="user-403-farvardin">

<div class="mot-donya-fiveuser-403-farvardin">
<div class="mot-donya-fiveuser-403-farvardin-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 24 24" fill="none" stroke="#1b1b1d" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg></div>

<div class="mot-donya-fiveuser-403-farvardin-title">

ورود و عضویت</div></div>


</a>
 <?php } ?>
  <?php } ?>
  
 <?php if ( 'yes' === $settings['farnamoneshow2'] ) { ?>

 <span  class="left-sabad min-car-6 gtr-654 sabadcolortitle cartnimshe-422-1400 mk-402-3" id="sabad-farvardin-403">
<div class="sabad-icon-403-farvardin"> <svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 24 24" fill="none" stroke="#1b1b1d" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shopping-cart"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg></div>



<span class="sabadnumbercolor"><div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div></span>
<div class="mini-cart-3">

<div class="widget_shopping_cart_content"><?php woocommerce_mini_cart(); ?></div> </div>
</span>
 <?php } ?>





</div>




 

  


		<?php
	}
	
	protected function _content_template() {

    }
	
	
}