<?php
if (!defined('ABSPATH')) {
    exit;
}
if (!class_exists('Bikys_Customize')) {

    class Bikys_Customize {


        public function __construct() {
            add_action('customize_register', array($this, 'customize_register'));
        }

        /**
         * @param $wp_customize WP_Customize_Manager
         */
        public function customize_register($wp_customize) {

            /**
             * Theme options.
             */
            require_once get_theme_file_path('inc/customize-control/editor.php');
            $this->init_bikys_blog($wp_customize);

            $this->init_bikys_social($wp_customize);

            if (bikys_is_woocommerce_activated()) {
                $this->init_woocommerce($wp_customize);
            }

            do_action('bikys_customize_register', $wp_customize);
        }


        /**
         * @param $wp_customize WP_Customize_Manager
         *
         * @return void
         */
        public function init_bikys_blog($wp_customize) {

            $wp_customize->add_section('bikys_blog_archive', array(
                'title' => esc_html__('Blog', 'bikys'),
            ));

            // =========================================
            // Select Style
            // =========================================

            $wp_customize->add_setting('bikys_options_blog_style', array(
                'type'              => 'option',
                'default'           => 'standard',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_blog_style', array(
                'section' => 'bikys_blog_archive',
                'label'   => esc_html__('Blog style', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'standard' => esc_html__('Blog Standard', 'bikys'),
                    //====start_premium
                    'style-1'  => esc_html__('Blog Grid', 'bikys'),
                    'list'     => esc_html__('Blog List', 'bikys'),
                    'modern'   => esc_html__('Blog modern', 'bikys'),
                    //====end_premium
                ),
            ));

            $wp_customize->add_setting('bikys_options_blog_columns', array(
                'type'              => 'option',
                'default'           => 1,
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_blog_columns', array(
                'section' => 'bikys_blog_archive',
                'label'   => esc_html__('Colunms', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    1 => esc_html__('1', 'bikys'),
                    2 => esc_html__('2', 'bikys'),
                    3 => esc_html__('3', 'bikys'),
                    4 => esc_html__('4', 'bikys'),
                ),
            ));

            $wp_customize->add_setting('bikys_options_blog_archive_sidebar', array(
                'type'              => 'option',
                'default'           => 'right',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_blog_archive_sidebar', array(
                'section' => 'bikys_blog_archive',
                'label'   => esc_html__('Sidebar Position', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'left'  => esc_html__('Left', 'bikys'),
                    'right' => esc_html__('Right', 'bikys'),
                ),
            ));
        }

        /**
         * @param $wp_customize WP_Customize_Manager
         *
         * @return void
         */
        public function init_bikys_social($wp_customize) {

            $wp_customize->add_section('bikys_social', array(
                'title' => esc_html__('Socials', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Show Social Share', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share_facebook', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_facebook', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Facebook', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share_twitter', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_twitter', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Twitter', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share_linkedin', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_linkedin', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Linkedin', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share_google-plus', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_google-plus', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Google+', 'bikys'),
            ));

            $wp_customize->add_setting('bikys_options_social_share_pinterest', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_pinterest', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Pinterest', 'bikys'),
            ));
            $wp_customize->add_setting('bikys_options_social_share_email', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_social_share_email', array(
                'type'    => 'checkbox',
                'section' => 'bikys_social',
                'label'   => esc_html__('Share on Email', 'bikys'),
            ));
        }

        /**
         * @param $wp_customize WP_Customize_Manager
         *
         * @return void
         */
        public function init_woocommerce($wp_customize) {

            $wp_customize->add_panel('woocommerce', array(
                'title' => esc_html__('Woocommerce', 'bikys'),
            ));

            $wp_customize->add_section('bikys_woocommerce_archive', array(
                'title'      => esc_html__('Archive', 'bikys'),
                'capability' => 'edit_theme_options',
                'panel'      => 'woocommerce',
                'priority'   => 1,
            ));

            $wp_customize->add_setting('bikys_options_woocommerce_archive_layout', array(
                'type'              => 'option',
                'default'           => 'default',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_woocommerce_archive_layout', array(
                'section' => 'bikys_woocommerce_archive',
                'label'   => esc_html__('Layout Style', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'default' => esc_html__('Sidebar', 'bikys'),
                    //====start_premium
                    'canvas'  => esc_html__('Canvas Filter', 'bikys'),
                    'menu'    => esc_html__('Menu Filter', 'bikys'),
                    //====end_premium
                ),
            ));

            $wp_customize->add_setting('bikys_options_woocommerce_archive_width', array(
                'type'              => 'option',
                'default'           => 'default',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_woocommerce_archive_width', array(
                'section' => 'bikys_woocommerce_archive',
                'label'   => esc_html__('Layout Width', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'default' => esc_html__('Default', 'bikys'),
                    'wide'    => esc_html__('Wide', 'bikys'),
                ),
            ));

            $wp_customize->add_setting('bikys_options_woocommerce_archive_sidebar', array(
                'type'              => 'option',
                'default'           => 'left',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_woocommerce_archive_sidebar', array(
                'section' => 'bikys_woocommerce_archive',
                'label'   => esc_html__('Sidebar Position', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'left'  => esc_html__('Left', 'bikys'),
                    'right' => esc_html__('Right', 'bikys'),

                ),
            ));

            $wp_customize->add_setting('bikys_options_woocommerce_shop_pagination', array(
                'type'              => 'option',
                'default'           => 'default',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_shop_pagination', array(
                'section' => 'bikys_woocommerce_archive',
                'label'   => esc_html__('Products pagination', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'default'  => esc_html__('Pagination', 'bikys'),
                    'more-btn' => esc_html__('Load More', 'bikys'),
                    'infinit'  => esc_html__('Infinit Scroll', 'bikys'),

                ),
            ));

            // =========================================
            // Single Product
            // =========================================

            $wp_customize->add_section('bikys_woocommerce_single', array(
                'title'      => esc_html__('Single Product', 'bikys'),
                'capability' => 'edit_theme_options',
                'panel'      => 'woocommerce',
            ));

            $wp_customize->add_setting('bikys_options_single_product_gallery_layout', array(
                'type'              => 'option',
                'default'           => 'horizontal',
                'transport'         => 'refresh',
                'sanitize_callback' => 'sanitize_text_field',
            ));
            $wp_customize->add_control('bikys_options_single_product_gallery_layout', array(
                'section' => 'bikys_woocommerce_single',
                'label'   => esc_html__('Style', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'horizontal' => esc_html__('Horizontal', 'bikys'),
                    //====start_premium
                    'vertical'   => esc_html__('Vertical', 'bikys'),
                    'gallery'    => esc_html__('Gallery', 'bikys'),
                    'slider'     => esc_html__('Slider', 'bikys'),
                    'sticky'     => esc_html__('Sticky', 'bikys'),
                    //====end_premium
                ),
            ));

            $wp_customize->add_setting('bikys_options_single_product_content_meta', array(
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'sanitize_callback' => 'bikys_sanitize_editor',
            ));

            $wp_customize->add_control(new Bikys_Customize_Control_Editor($wp_customize, 'bikys_options_single_product_content_meta', array(
                'section' => 'bikys_woocommerce_single',
                'label'   => esc_html__('Single extra description', 'bikys'),
            )));


            // =========================================
            // Product
            // =========================================


            $wp_customize->add_section('bikys_woocommerce_product', array(
                'title'      => esc_html__('Product Block', 'bikys'),
                'capability' => 'edit_theme_options',
                'panel'      => 'woocommerce',
            ));
            $attribute_array      = [
                '' => esc_html__('None', 'bikys')
            ];
            $attribute_taxonomies = wc_get_attribute_taxonomies();

            if (!empty($attribute_taxonomies)) {
                foreach ($attribute_taxonomies as $tax) {
                    if (taxonomy_exists(wc_attribute_taxonomy_name($tax->attribute_name))) {
                        $attribute_array[$tax->attribute_name] = $tax->attribute_label;
                    }
                }
            }

            $wp_customize->add_setting('bikys_options_wocommerce_attribute', array(
                'type'              => 'option',
                'default'           => '',
                'transport'         => 'refresh',
                'sanitize_callback' => 'sanitize_text_field',
            ));
            $wp_customize->add_control('bikys_options_wocommerce_attribute', array(
                'section' => 'bikys_woocommerce_product',
                'label'   => esc_html__('Attributes Swatches Image', 'bikys'),
                'type'    => 'select',
                'choices' => $attribute_array,
            ));

            $wp_customize->add_setting('bikys_options_wocommerce_block_style', array(
                'type'              => 'option',
                'default'           => '',
                'transport'         => 'refresh',
                'sanitize_callback' => 'sanitize_text_field',
            ));
            $wp_customize->add_control('bikys_options_wocommerce_block_style', array(
                'section' => 'bikys_woocommerce_product',
                'label'   => esc_html__('Style', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    '' => esc_html__('Style 1', 'bikys'),
                ),
            ));

            $wp_customize->add_setting('bikys_options_wocommerce_grid_list_layout', array(
                'type'              => 'option',
                'default'           => '',
                'transport'         => 'refresh',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_wocommerce_grid_list_layout', array(
                'section' => 'bikys_woocommerce_product',
                'label'   => esc_html__('Grid - List Layout', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    ''     => esc_html__('Grid', 'bikys'),
                    'list' => esc_html__('List', 'bikys'),
                ),
            ));

            $wp_customize->add_setting('bikys_options_woocommerce_product_hover', array(
                'type'              => 'option',
                'default'           => 'none',
                'transport'         => 'refresh',
                'sanitize_callback' => 'sanitize_text_field',
            ));
            $wp_customize->add_control('bikys_options_woocommerce_product_hover', array(
                'section' => 'bikys_woocommerce_product',
                'label'   => esc_html__('Animation Image Hover', 'bikys'),
                'type'    => 'select',
                'choices' => array(
                    'none'          => esc_html__('None', 'bikys'),
                    'bottom-to-top' => esc_html__('Bottom to Top', 'bikys'),
                    'top-to-bottom' => esc_html__('Top to Bottom', 'bikys'),
                    'right-to-left' => esc_html__('Right to Left', 'bikys'),
                    'left-to-right' => esc_html__('Left to Right', 'bikys'),
                    'swap'          => esc_html__('Swap', 'bikys'),
                    'fade'          => esc_html__('Fade', 'bikys'),
                    'zoom-in'       => esc_html__('Zoom In', 'bikys'),
                    'zoom-out'      => esc_html__('Zoom Out', 'bikys'),
                ),
            ));

            $wp_customize->add_setting('bikys_options_wocommerce_row_laptop', array(
                'type'              => 'option',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_wocommerce_row_laptop', array(
                'section' => 'woocommerce_product_catalog',
                'label'   => esc_html__('Products per row Laptop', 'bikys'),
                'type'    => 'number',
            ));

            $wp_customize->add_setting('bikys_options_wocommerce_row_tablet', array(
                'type'              => 'option',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_wocommerce_row_tablet', array(
                'section' => 'woocommerce_product_catalog',
                'label'   => esc_html__('Products per row tablet', 'bikys'),
                'type'    => 'number',
            ));

            $wp_customize->add_setting('bikys_options_wocommerce_row_mobile', array(
                'type'              => 'option',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
            ));

            $wp_customize->add_control('bikys_options_wocommerce_row_mobile', array(
                'section' => 'woocommerce_product_catalog',
                'label'   => esc_html__('Products per row mobile', 'bikys'),
                'type'    => 'number',
            ));
        }
    }
}
return new Bikys_Customize();
