<?php
/*
 * Elementor eCommerce Addon Client Widget
 * Author & Copyright: NicheAddon
*/

namespace Elementor;

if (!isset(get_option( 'naeca_bw_settings' )['naeca_client'])) { // enable & disable

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Vinson_Client extends Widget_Base{

	/**
	 * Retrieve the widget name.
	*/
	public function get_name(){
		return 'naecommerce_basic_client';
	}

	/**
	 * Retrieve the widget title.
	*/
	public function get_title(){
		return esc_html__( 'Client', 'ecommerce-addon' );
	}

	/**
	 * Retrieve the widget icon.
	*/
	public function get_icon() {
		return 'eicon-logo';
	}

	/**
	 * Retrieve the list of categories the widget belongs to.
	*/
	public function get_categories() {
		return ['naecommerce-basic-category'];
	}

	/**
	 * Register eCommerce Addon Client widget controls.
	 * Adds different input fields to allow the user to change and customize the widget settings.
	*/
	protected function register_controls(){

		$this->start_controls_section(
			'section_client',
			[
				'label' => esc_html__( 'Client Options', 'ecommerce-addon' ),
			]
		);
		$this->add_control(
			'client_style',
			[
				'label' => esc_html__( 'Client Logos Style', 'ecommerce-addon' ),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'style-one' => esc_html__( 'Style One (Slider)', 'ecommerce-addon' ),
					'style-two' => esc_html__( 'Style Two (Static)', 'ecommerce-addon' ),
				],
				'default' => 'style-one',
				'description' => esc_html__( 'Select your client style.', 'ecommerce-addon' ),
			]
		);
		$this->add_control(
			'client_column',
			[
				'label' => esc_html__( 'Client Column', 'ecommerce-addon' ),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'two' => esc_html__( 'Two Column', 'ecommerce-addon' ),
					'three' => esc_html__( 'Three Column', 'ecommerce-addon' ),
					'four' => esc_html__( 'Four Column', 'ecommerce-addon' ),
				],
				'default' => 'four',
				'condition' => [
					'client_style' => 'style-two',
				],
				'description' => esc_html__( 'Select your client column.', 'ecommerce-addon' ),
			]
		);

		$repeater = new Repeater();
		$repeater->add_control(
			'client_logo_title',
			[
				'label' => esc_html__( 'Logo title', 'ecommerce-addon' ),
				'type' => Controls_Manager::TEXT,
				'label_block' => true,
				'placeholder' => esc_html__( 'Type item title here', 'ecommerce-addon' ),
			]
		);
		$repeater->add_control(
			'client_logo',
			[
				'label' => esc_html__( 'Logo Image', 'ecommerce-addon' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],

			]
		);
		$repeater->add_control(
			'client_link',
			[
				'label' => esc_html__( 'Link', 'ecommerce-addon' ),
				'type' => Controls_Manager::URL,
				'placeholder' => __( 'https://your-link.com', 'ecommerce-addon' ),
				'label_block' => true,
				'show_external' => true,
				'default' => [
					'url' => '',
					'is_external' => true,
					'nofollow' => true,
				],
			]
		);
		$this->add_control(
			'clientLogos_groups',
			[
				'label' => esc_html__( 'Client Logos', 'ecommerce-addon' ),
				'type' => Controls_Manager::REPEATER,
				'default' => [
					[
						'client_logo_title' => esc_html__( 'Client', 'ecommerce-addon' ),
					],

				],
				'fields' =>  $repeater->get_controls(),
				'title_field' => '{{{ client_logo_title }}}',
			]
		);
		$this->add_control(
			'retina_img',
			[
				'label' => esc_html__( 'Retina Image?', 'ecommerce-addon' ),
				'type' => Controls_Manager::SWITCHER,
				'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
				'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
				'return_value' => 'true',
				'description' => esc_html__( 'If you want to resize your retina image, enable it.', 'ecommerce-addon' ),
			]
		);
		$this->end_controls_section();// end: Section

		// Carousel Options
			$this->start_controls_section(
				'section_carousel',
				[
					'label' => esc_html__( 'Carousel Options', 'ecommerce-addon' ),
				]
			);
			$this->add_responsive_control(
				'carousel_items',
				[
					'label' => esc_html__( 'How many items?', 'ecommerce-addon' ),
					'type' => Controls_Manager::NUMBER,
					'min' => 1,
					'max' => 100,
					'step' => 1,
					'default' => 1,
					'description' => esc_html__( 'Enter the number of items to show.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_margin',
				[
					'label' => __( 'Space Between Items', 'ecommerce-addon' ),
					'type' => Controls_Manager::SLIDER,
					'default' => [
						'size' =>30,
					],
					'label_block' => true,
				]
			);
			$this->add_control(
				'carousel_autoplay_timeout',
				[
					'label' => __( 'Auto Play Timeout', 'ecommerce-addon' ),
					'type' => Controls_Manager::NUMBER,
					'default' => 5000,
				]
			);
			$this->add_control(
				'carousel_autoplay',
				[
					'label' => esc_html__( 'Need Autoplay?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'If you want to start Carousel automatically, enable it.', 'ecommerce-addon' ),
					'default' => 'true',
				]
			);
			$this->add_control(
				'carousel_animatein',
				[
					'label' => esc_html__( 'Animate In', 'ecommerce-addon' ),
					'type' => Controls_Manager::SELECT,
					'options' => [
						'false' => esc_html__( 'None', 'ecommerce-addon' ),
						'fadeIn' => esc_html__( 'fadeIn', 'ecommerce-addon' ),
						'fadeOut' => esc_html__( 'fadeOut', 'ecommerce-addon' ),
					],
					'default' => 'false',
					'description' => esc_html__( 'Select your style.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_animateout',
				[
					'label' => esc_html__( 'Animate Out', 'ecommerce-addon' ),
					'type' => Controls_Manager::SELECT,
					'options' => [
						'false' => esc_html__( 'None', 'ecommerce-addon' ),
						'fadeIn' => esc_html__( 'fadeIn', 'ecommerce-addon' ),
						'fadeOut' => esc_html__( 'fadeOut', 'ecommerce-addon' ),
					],
					'default' => 'false',
					'description' => esc_html__( 'Select your style.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_loop',
				[
					'label' => esc_html__( 'Need Loop?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'Continuously moving carousel, if enabled.', 'ecommerce-addon' ),
					'default' => 'true',
				]
			);
			$this->add_control(
				'carousel_dots',
				[
					'label' => esc_html__( 'Need Dots?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'If you want Carousel Dots, enable it.', 'ecommerce-addon' ),
					'default' => 'true',
				]
			);
			$this->add_control(
				'carousel_nav',
				[
					'label' => esc_html__( 'Need Navigation?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'If you want Carousel Navigation, enable it.', 'ecommerce-addon' ),
					'default' => 'true',
				]
			);			
			$this->add_control(
				'carousel_mousedrag',
				[
					'label' => esc_html__( 'Need Mouse Drag?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'If you want to disable Mouse Drag, check it.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_autowidth',
				[
					'label' => esc_html__( 'Need Auto Width?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'Adjust Auto Width automatically for each carousel items.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_autoheight',
				[
					'label' => esc_html__( 'Need Auto Height?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'Adjust Auto Height automatically for each carousel items.', 'ecommerce-addon' ),
				]
			);
			$this->add_control(
				'carousel_center',
				[
					'label' => esc_html__( 'Need Center?', 'ecommerce-addon' ),
					'type' => Controls_Manager::SWITCHER,
					'label_on' => esc_html__( 'Yes', 'ecommerce-addon' ),
					'label_off' => esc_html__( 'No', 'ecommerce-addon' ),
					'return_value' => 'true',
					'description' => esc_html__( 'Center carousel items.', 'ecommerce-addon' ),
				]
			);
			$this->end_controls_section();// end: Section

		// Section
			$this->start_controls_section(
				'sectn_style',
				[
					'label' => esc_html__( 'Section', 'ecommerce-addon' ),
					'tab' => Controls_Manager::TAB_STYLE,
				]
			);
			$this->add_responsive_control(
				'section_padding',
				[
					'label' => __( 'Padding', 'ecommerce-addon' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .client-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					],
				]
			);
			$this->add_control(
				'secn_bg_color',
				[
					'label' => esc_html__( 'Background Color', 'ecommerce-addon' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .client-item' => 'background-color: {{VALUE}};',
					],
				]
			);			
			$this->add_group_control(
				Group_Control_Border::get_type(),
				[
					'name' => 'secn_border',
					'label' => esc_html__( 'Border', 'ecommerce-addon' ),
					'selector' => '{{WRAPPER}} .client-item',
				]
			);
			$this->add_group_control(
				Group_Control_Box_Shadow::get_type(),
				[
					'name' => 'secn_box_shadow',
					'label' => esc_html__( 'Section Box Shadow', 'ecommerce-addon' ),
					'selector' => '{{WRAPPER}} .client-item',
				]
			);
			$this->add_control(
				'secn_border_radius',
				[
					'label' => __( 'Border Radius', 'ecommerce-addon' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .client-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					],
				]
			);
			$this->end_controls_section();// end: Section

		// Image
			$this->start_controls_section(
				'section_image_style',
				[
					'label' => esc_html__( 'Image', 'ecommerce-addon' ),
					'tab' => Controls_Manager::TAB_STYLE,
				]
			);
			$this->add_responsive_control(
				'image_margin',
				[
					'label' => __( 'Margin', 'ecommerce-addon' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .client-item .naeca-image' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					],
				]
			);
			$this->add_group_control(
				Group_Control_Border::get_type(),
				[
					'name' => 'image_border',
					'label' => esc_html__( 'Border', 'ecommerce-addon' ),
					'selector' => '{{WRAPPER}} .client-item .naeca-image',
				]
			);
			$this->add_control(
				'image_border_radius',
				[
					'label' => __( 'Border Radius', 'ecommerce-addon' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .client-item .naeca-image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					],
				]
			);
			$this->add_group_control(
				Group_Control_Box_Shadow::get_type(),
				[
					'name' => 'image_box_shadow',
					'label' => esc_html__( 'Box Shadow', 'ecommerce-addon' ),
					'selector' => '{{WRAPPER}} .client-item .naeca-image',
				]
			);
			$this->add_control(
				'image_width',
				[
					'label' => esc_html__( 'Image width', 'ecommerce-addon' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => 0,
							'max' => 500,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .naeca-clients .item img' => 'max-width: {{SIZE}}{{UNIT}};',
					],
				]
			);
			$this->end_controls_section();// end: Section

		// Navigation
			$this->start_controls_section(
				'section_navigation_style',
				[
					'label' => esc_html__( 'Navigation', 'ecommerce-addon' ),
					'tab' => Controls_Manager::TAB_STYLE,
					'condition' => [
						'carousel_nav' => 'true',
					],
					'frontend_available' => true,
				]
			);
			$this->add_responsive_control(
				'arrow_size',
				[
					'label' => esc_html__( 'Size', 'ecommerce-addon' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => 42,
							'max' => 1000,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
					],
				]
			);
			$this->start_controls_tabs( 'nav_arrow_style' );
				$this->start_controls_tab(
					'nav_arrow_normal',
					[
						'label' => esc_html__( 'Normal', 'ecommerce-addon' ),
					]
				);
				$this->add_control(
					'nav_arrow_color',
					[
						'label' => esc_html__( 'Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev:before, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next:before' => 'color: {{VALUE}};',
						],
					]
				);
				$this->add_control(
					'nav_arrow_bg_color',
					[
						'label' => esc_html__( 'Background Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next' => 'background-color: {{VALUE}};',
						],
					]
				);
				$this->add_group_control(
					Group_Control_Border::get_type(),
					[
						'name' => 'nav_border',
						'label' => esc_html__( 'Border', 'ecommerce-addon' ),
						'selector' => '{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next',
					]
				);
				$this->end_controls_tab();  // end:Normal tab

				$this->start_controls_tab(
					'nav_arrow_hover',
					[
						'label' => esc_html__( 'Hover', 'ecommerce-addon' ),
					]
				);
				$this->add_control(
					'nav_arrow_hov_color',
					[
						'label' => esc_html__( 'Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev:hover:before, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next:hover:before' => 'color: {{VALUE}};',
						],
					]
				);
				$this->add_control(
					'nav_arrow_bg_hover_color',
					[
						'label' => esc_html__( 'Background Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev:hover, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next:hover' => 'background-color: {{VALUE}};',
						],
					]
				);
				$this->add_group_control(
					Group_Control_Border::get_type(),
					[
						'name' => 'nav_active_border',
						'label' => esc_html__( 'Border', 'ecommerce-addon' ),
						'selector' => '{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev:hover, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next:hover',
					]
				);
				$this->end_controls_tab();  // end:Hover tab

			$this->end_controls_tabs(); // end tabs
			$this->end_controls_section();// end: Section

		// Dots
			$this->start_controls_section(
				'section_dots_style',
				[
					'label' => esc_html__( 'Dots', 'ecommerce-addon' ),
					'tab' => Controls_Manager::TAB_STYLE,
					'condition' => [
						'carousel_dots' => 'true',
					],
					'frontend_available' => true,
				]
			);
			$this->add_responsive_control(
				'dots_size',
				[
					'label' => esc_html__( 'Size', 'ecommerce-addon' ),
					'type' => Controls_Manager::SLIDER,
					'range' => [
						'px' => [
							'min' => 0,
							'max' => 1000,
							'step' => 1,
						],
					],
					'size_units' => [ 'px' ],
					'selectors' => [
						'{{WRAPPER}} .owl-carousel .owl-dot' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}}',
					],
				]
			);
			$this->add_responsive_control(
				'dots_margin',
				[
					'label' => __( 'Margin', 'ecommerce-addon' ),
					'type' => Controls_Manager::DIMENSIONS,
					'size_units' => [ 'px', '%', 'em' ],
					'selectors' => [
						'{{WRAPPER}} .owl-carousel .owl-dot' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					],
				]
			);
			$this->start_controls_tabs( 'dots_style' );
				$this->start_controls_tab(
					'dots_normal',
					[
						'label' => esc_html__( 'Normal', 'ecommerce-addon' ),
					]
				);
				$this->add_control(
					'dots_color',
					[
						'label' => esc_html__( 'Background Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-dot' => 'background: {{VALUE}};',
						],
					]
				);
				$this->add_group_control(
					Group_Control_Border::get_type(),
					[
						'name' => 'dots_border',
						'label' => esc_html__( 'Border', 'ecommerce-addon' ),
						'selector' => '{{WRAPPER}} .owl-carousel .owl-dot',
					]
				);
				$this->end_controls_tab();  // end:Normal tab

				$this->start_controls_tab(
					'dots_active',
					[
						'label' => esc_html__( 'Active', 'ecommerce-addon' ),
					]
				);
				$this->add_responsive_control(
					'active_dots_size',
					[
						'label' => esc_html__( 'Active Height', 'ecommerce-addon' ),
						'type' => Controls_Manager::SLIDER,
						'range' => [
							'px' => [
								'min' => 0,
								'max' => 1000,
								'step' => 1,
							],
						],
						'size_units' => [ 'px' ],
						'selectors' => [
							'{{WRAPPER}} .owl-carousel button.owl-dot.active' => 'height: {{SIZE}}{{UNIT}}',
						],
					]
				);
				$this->add_control(
					'dots_active_color',
					[
						'label' => esc_html__( 'Background Color', 'ecommerce-addon' ),
						'type' => Controls_Manager::COLOR,
						'selectors' => [
							'{{WRAPPER}} .owl-carousel .owl-dot.active' => 'background: {{VALUE}};',
						],
					]
				);
				$this->add_group_control(
					Group_Control_Border::get_type(),
					[
						'name' => 'dots_active_border',
						'label' => esc_html__( 'Border', 'ecommerce-addon' ),
						'selector' => '{{WRAPPER}} .owl-carousel .owl-dot.active',
					]
				);
				$this->end_controls_tab();  // end:Active tab
			$this->end_controls_tabs(); // end tabs
			$this->end_controls_section();// end: Section

	}

	/**
	 * Render Client widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	*/
	protected function render() {
		$settings = $this->get_settings_for_display();
		$client_style = !empty( $settings['client_style'] ) ? $settings['client_style'] : '';
		$client_column = !empty( $settings['client_column'] ) ? $settings['client_column'] : '';
		$retina_img = !empty( $settings['retina_img'] ) ? $settings['retina_img'] : '';
		$clientLogos_groups = !empty( $settings['clientLogos_groups'] ) ? $settings['clientLogos_groups'] : [];

		// Carousel
			$carousel_items = !empty( $settings['carousel_items'] ) ? $settings['carousel_items'] : '';
			$carousel_items_tablet = !empty( $settings['carousel_items_tablet'] ) ? $settings['carousel_items_tablet'] : '';
			$carousel_items_mobile = !empty( $settings['carousel_items_mobile'] ) ? $settings['carousel_items_mobile'] : '';
			$carousel_margin = !empty( $settings['carousel_margin']['size'] ) ? $settings['carousel_margin']['size'] : '';
			$carousel_autoplay_timeout = !empty( $settings['carousel_autoplay_timeout'] ) ? $settings['carousel_autoplay_timeout'] : '';
			$carousel_autoplay  = ( isset( $settings['carousel_autoplay'] ) && ( 'true' == $settings['carousel_autoplay'] ) ) ? true : false;
			$carousel_animatein = !empty( $settings['carousel_animatein'] ) ? $settings['carousel_animatein'] : '';
			$carousel_animateout = !empty( $settings['carousel_animateout'] ) ? $settings['carousel_animateout'] : '';
			$carousel_loop  = ( isset( $settings['carousel_loop'] ) && ( 'true' == $settings['carousel_loop'] ) ) ? true : false;
			$carousel_dots  = ( isset( $settings['carousel_dots'] ) && ( 'true' == $settings['carousel_dots'] ) ) ? true : false;
			$carousel_nav  = ( isset( $settings['carousel_nav'] ) && ( 'true' == $settings['carousel_nav'] ) ) ? true : false;
			$carousel_mousedrag  = ( isset( $settings['carousel_mousedrag'] ) && ( 'true' == $settings['carousel_mousedrag'] ) ) ? $settings['carousel_mousedrag'] : 'false';
			$carousel_autowidth  = ( isset( $settings['carousel_autowidth'] ) && ( 'true' == $settings['carousel_autowidth'] ) ) ? true : false;
			$carousel_autoheight  = ( isset( $settings['carousel_autoheight'] ) && ( 'true' == $settings['carousel_autoheight'] ) ) ? true : false;
			$carousel_center  = ( isset( $settings['carousel_center'] ) && ( 'true' == $settings['carousel_center'] ) ) ? true : false;

		// Carousel Data's
			$carousel_items = $carousel_items ? ' data-items="'. $carousel_items .'"' : ' data-items="1"';
			$carousel_tablet = $carousel_items_tablet ? ' data-items-tablet="'. $carousel_items_tablet .'"' : ' data-items-tablet="1"';
			$carousel_mobile = $carousel_items_mobile ? ' data-items-mobile-landscape="'. $carousel_items_mobile .'"' : ' data-items-mobile-landscape="1"';
			$carousel_small_mobile = $carousel_items_mobile ? ' data-items-mobile-portrait="'. $carousel_items_mobile .'"' : ' data-items-mobile-portrait="1"';
			$carousel_margin = $carousel_margin ? ' data-margin="'. $carousel_margin .'"' : ' data-margin="0"';
			$carousel_autoplay_timeout = $carousel_autoplay_timeout ? ' data-autoplay-timeout="'. $carousel_autoplay_timeout .'"' : '';
			$carousel_autoplay = ('true' == $carousel_autoplay) ? ' data-autoplay="true"' : ' data-autoplay="false"';
			$carousel_animatein = $carousel_animatein ? ' data-animatein="'. $carousel_animatein .'"' : '';
			$carousel_animateout = $carousel_animateout ? ' data-animateout="'. $carousel_animateout .'"' : '';
			$carousel_loop = ('true' == $carousel_loop) ? ' data-loop="true"' : ' data-loop="false"';
			$carousel_dots = ('true' == $carousel_dots) ? ' data-dots="true"' : ' data-dots="false"';
			$carousel_nav = ('true' == $carousel_nav) ? ' data-nav="true"' : ' data-nav="false"';
			$carousel_mousedrag = ('true' == $carousel_mousedrag) ? ' data-mouse-drag="true"' : ' data-mouse-drag="false"';
			$carousel_autowidth = ('true' == $carousel_autowidth) ? ' data-auto-width="true"' : ' data-auto-width="false"';
			$carousel_autoheight = ('true' == $carousel_autoheight) ? ' data-auto-height="true"' : ' data-auto-height="false"';
			$carousel_center = ('true' == $carousel_center) ? ' data-center="true"' : ' data-center="false"';

		if($client_style === 'style-two') {
		  $style_cls = ' clients-style-two';		  
		  if($client_column === 'two') {
		  	$item_div = '<div class="nich-col-md-6">';
		  	$item_cdiv = '</div>';
			} elseif($client_column === 'three') {
				$item_div = '<div class="nich-col-lg-4 nich-col-md-6">';
		  	$item_cdiv = '</div>';
			} else {
				$item_div = '<div class="nich-col-lg-3 nich-col-md-6">';
		  	$item_cdiv = '</div>';
			}
		} else {
		  $style_cls = '';
		  $item_div = '<div class="item">';
		  $item_cdiv = '</div>';
		  $col_cls = '';
		}

		$output = '<div class="naeca-clients'.$style_cls.'">';
		if($client_style === 'style-one') {
			$output .= '<div class="owl-carousel" '. $carousel_items . $carousel_tablet . $carousel_mobile . $carousel_small_mobile . $carousel_margin . $carousel_autoplay_timeout . $carousel_loop . $carousel_dots . $carousel_nav . $carousel_autoplay . $carousel_mousedrag . $carousel_autowidth . $carousel_autoheight .'>';
		} else {
			$output .= '<div class="nich-row nich-justify-content-center">';
		}
		// Group Param Output
		if( is_array( $clientLogos_groups ) && !empty( $clientLogos_groups ) ) {
			foreach ( $clientLogos_groups as $each_logo ) {
				$client_logo_title = !empty( $each_logo['client_logo_title'] ) ? $each_logo['client_logo_title'] : '';
				$image_url = wp_get_attachment_url( $each_logo['client_logo']['id'] );
				$image_link = !empty( $each_logo['client_link']['url'] ) ? $each_logo['client_link']['url'] : '';
				$image_link_external = !empty( $each_logo['client_link']['is_external'] ) ? 'target="_blank"' : '';
				$image_link_nofollow = !empty( $each_logo['client_link']['nofollow'] ) ? 'rel="nofollow"' : '';
				$image_link_attr = !empty( $image_link ) ?  $image_link_external.' '.$image_link_nofollow : '';

				if($image_url){
		      list($width, $height, $type, $attr) = getimagesize($image_url);
		    } else {
		      $width = '';
		      $height = '';
		    }
				if($retina_img) {
		      $logo_width = $width/2;
		      $logo_height = $height/2;
		    } else {
		      $logo_width = '';
		      $logo_height = '';
		    }
		    $logo_width = $logo_width ? 'width: '.naecommerce_core_check_px($logo_width).';' : '';
				$logo_height = $logo_height ? 'height: '.naecommerce_core_check_px($logo_height).';' : '';

			  if (!empty($each_logo['client_link']['url'])) {
				$output .= $item_div.'<div class="client-item"><div class="naeca-image"><a href="'. $each_logo['client_link']['url'] .'" '. $image_link_attr .'><img src="'. $image_url .'" alt="'.esc_attr($client_logo_title).'" style="'.esc_attr($logo_width).' '.esc_attr($logo_height).'"></a></div></div>'.$item_cdiv;
			  } else {
				$output .= $item_div.'<div class="client-item"><div class="naeca-image"><img src="'. $image_url .'" alt="'.esc_attr($client_logo_title).'" style="'.esc_attr($logo_width).' '.esc_attr($logo_height).'"></div></div>'.$item_cdiv;
			  }
			}
		}
		$output .= '</div></div>';

		echo $output;

		if ( Plugin::$instance->editor->is_edit_mode() ) : ?>
		<script type="text/javascript">
	    jQuery(document).ready(function($) {
				$('.owl-carousel').each( function() {
			    var $carousel = $(this);
			    var $items = ($carousel.data('items') !== undefined) ? $carousel.data('items') : 1;
			    var $items_tablet = ($carousel.data('items') !== undefined) ? $carousel.data('items-tablet') : 1;
			    var $items_mobile_landscape = ($carousel.data('items-mobile-landscape') !== undefined) ? $carousel.data('items-mobile-landscape') : 1;
			    var $items_mobile_portrait = ($carousel.data('items-mobile-portrait') !== undefined) ? $carousel.data('items-mobile-portrait') : 1;
			    var $stagep_tablet = ($carousel.data('stagep-tablet') !== undefined) ? $carousel.data('stagep-tablet') : 1;
			    var $stagep_desktop = ($carousel.data('stagep-desktop') !== undefined) ? $carousel.data('stagep-desktop') : 1;
			    $carousel.owlCarousel ({
			      loop : ($carousel.data('loop') !== undefined) ? $carousel.data('loop') : true,
			      items : $carousel.data('items'),
			      margin : ($carousel.data('margin') !== undefined) ? $carousel.data('margin') : 0,
			      stagePadding : ($carousel.data('stagepadding') !== undefined) ? $carousel.data('stagepadding') : 0,
			      dots : ($carousel.data('dots') !== undefined) ? $carousel.data('dots') : true,
			      nav : ($carousel.data('nav') !== undefined) ? $carousel.data('nav') : false,
			      navText : ["<div class='slider-no-current'><span class='current-no'></span><span class='total-no'></span></div><span class='current-monials'></span>", "<div class='slider-no-next'></div><span class='next-monials'></span>"],
			      autoplay : ($carousel.data('autoplay') !== undefined) ? $carousel.data('autoplay') : false,
			      autoplayTimeout : ($carousel.data('autoplay-timeout') !== undefined) ? $carousel.data('autoplay-timeout') : 5000,
			      animateIn : ($carousel.data('animatein') !== undefined) ? $carousel.data('animatein') : false,
			      animateOut : ($carousel.data('animateout') !== undefined) ? $carousel.data('animateout') : false,
			      mouseDrag : ($carousel.data('mouse-drag') !== undefined) ? $carousel.data('mouse-drag') : true,
			      autoWidth : ($carousel.data('auto-width') !== undefined) ? $carousel.data('auto-width') : false,
			      autoHeight : ($carousel.data('auto-height') !== undefined) ? $carousel.data('auto-height') : false,
			      center : ($carousel.data('center') !== undefined) ? $carousel.data('center') : false,
			      responsiveClass: true,
			      dotsEachNumber: true,
			      smartSpeed: 600,
			      autoplayHoverPause: true,
			      responsive : {
			        0 : {
			          items : $items_mobile_portrait,
			        },
			        480 : {
			          items : $items_mobile_landscape,
			        },
			        768 : {
			          items : $items_tablet,
			          stagePadding: $stagep_tablet,
			        },
			        1200 : {
			          items : $items,
			          stagePadding: $stagep_desktop,
			        }
			      }
			    });
			    var totLength = $('.owl-dot', $carousel).length;
			    $('.total-no', $carousel).html(totLength);
			    $('.current-no', $carousel).html(totLength);
			    $carousel.owlCarousel();
			    $('.current-no', $carousel).html(1);
			    $carousel.on('changed.owl.carousel', function(event) {
			      var total_items = event.page.count;
			      var currentNum = event.page.index + 1;
			      $('.total-no', $carousel ).html(total_items);
			      $('.current-no', $carousel).html(currentNum);
			    });
			  });
		  });
		</script>
		<?php endif;

	}

	/**
	 * Render Client widget output in the editor.
	 * Written as a Backbone JavaScript template and used to generate the live preview.
	*/

	//protected function _content_template(){}

}
Plugin::instance()->widgets_manager->register_widget_type( new Vinson_Client() );

} // enable & disable
