<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Typography;
Use Elementor\Core\Schemes\Typography;
use Elementor\Group_Control_Border;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;

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

class Widgetkit_Pro_Woo_Single_Product_Title extends Widget_Base
{

    public function get_name()
    {
        return 'widgetkit-pro-woo-single-product-title';
    }

    public function get_title()
    {
        return __('Title', 'widgetkit-pro');
    }

    public function get_icon()
    {
        return 'eicon-woocommerce';
    }

    public function get_categories()
    {
        return ['widgetkit_pro_woo_single_product'];
    }

    /**
	 * A list of style that the widgets is depended in
	 **/
	public function get_style_depends() {
        return [
            'widgetkit_bs',
            'widgetkit_pro_default',
        ];
    }
	/**
	 * A list of scripts that the widgets is depended in
	 **/
	public function get_script_depends() {
		return [ 
			// 'layout',
		 ];
	}

    protected function register_controls()
    {
        
        /**
         * all cat
         */
        $specific_cats = array();
        $terms = get_terms( array(
            'taxonomy' => 'product_cat',
            'hide_empty' => false,
        ) );
        if(wkp_check_dependent_plugin('woocommerce', 'woocommerce.php') && $terms):
            foreach( $terms as $t ):
                $specific_cats[$t->term_id] = $t->name;
            endforeach;
        endif;


// # region style tab

    // #region single product title style
        $this->start_controls_section(
            'section_style_header',
            [
                'label' => __( 'Title', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'single_product_title_color',
            [
                'label' => __( 'Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'default' => '#3d3d3d',
                'selectors' => [
                    '{{WRAPPER}} .woo-single-product-title  h2.single-product-title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'single_product_title_typography',
                'selector' => '{{WRAPPER}} .woo-single-product-title  h2.single-product-title',
            ]
        );
        $this->add_responsive_control(
            'single_product_title_alignment',
            [
                'label' => __( 'Alignment', 'widgetkit-pro' ),
                'type' => Controls_Manager::CHOOSE,
                'default' => 'left',
                'options' => [
                    'left'    => [
                        'title' => __( 'Left', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => __( 'Center', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => __( 'Right', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-right',
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .woo-single-product-title  h2.single-product-title' => 'text-align: {{VALUE}};',
                ],
            ]
        );
        
        $this->end_controls_section();
    // #endregion

// #endregion

    }


    protected function render()
    {
        $settings = $this->get_settings();
        ?>

        <div id="woo-single-product-title<?php echo $this->get_id(); ?>" class="woo-single-product-title woo-single-product-title-<?php echo $this->get_id() ?>">

            <?php 
            include( plugin_dir_path( __FILE__ ) . '../layout/woo/single-product/title.php'); 
            ?>
        </div>
        <script>
            jQuery(function($){
                if(!$('body').hasClass('wkpro-woo-single-product-title')){
                    $('body').addClass('wkpro-woo-single-product-title');
                }
            });
        </script>

    <?php
    }
    protected function _content_template()
    {
    }
}
