<?php

/**
 * WooCommerce - Single - Module - Social Share & Follow - Customizer Settings
 */


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

if( !class_exists( 'HouseFix_Shop_Customizer_Single_Social_Share_And_Follow' ) ) {

    class HouseFix_Shop_Customizer_Single_Social_Share_And_Follow {

        private static $_instance = null;

        public static function instance() {

            if ( is_null( self::$_instance ) ) {
                self::$_instance = new self();
            }

            return self::$_instance;

        }

        function __construct() {

            add_filter( 'housefix_woo_single_page_settings', array( $this, 'single_page_settings' ), 10, 1 );
            add_action( 'customize_register', array( $this, 'register' ), 15);

        }

        function single_page_settings( $settings ) {

            $product_show_sharer_facebook                = housefix_customizer_settings('wdt-single-product-show-sharer-facebook' );
            $settings['product_show_sharer_facebook']    = $product_show_sharer_facebook;

            $product_show_sharer_delicious               = housefix_customizer_settings('wdt-single-product-show-sharer-delicious' );
            $settings['product_show_sharer_delicious']   = $product_show_sharer_delicious;

            $product_show_sharer_digg                    = housefix_customizer_settings('wdt-single-product-show-sharer-digg' );
            $settings['product_show_sharer_digg']        = $product_show_sharer_digg;

            $product_show_sharer_twitter                 = housefix_customizer_settings('wdt-single-product-show-sharer-twitter' );
            $settings['product_show_sharer_twitter']     = $product_show_sharer_twitter;

            $product_show_sharer_linkedin                = housefix_customizer_settings('wdt-single-product-show-sharer-linkedin' );
            $settings['product_show_sharer_linkedin']    = $product_show_sharer_linkedin;

            $product_show_sharer_pinterest               = housefix_customizer_settings('wdt-single-product-show-sharer-pinterest' );
            $settings['product_show_sharer_pinterest']   = $product_show_sharer_pinterest;

            return $settings;

        }

        function register( $wp_customize ) {

            /**
            * Share
            */

                /**
                * Option : Sharer Description
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-description]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-description]', array(
                                'type'        => 'wdt-description',
                                'label'       => esc_html__( 'Note: ', 'housefix-pro'),
                                'section'     => 'woocommerce-single-page-sociable-share-section',
                                'description' => esc_html__( 'This option is applicable only for WooCommerce "Custom Template".', 'housefix-pro')
                            )
                        )
                    );

                /**
                * Option : Show Facebook Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-facebook]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-facebook]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show Facebook Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

                /**
                * Option : Show Delicious Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-delicious]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-delicious]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show Delicious Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

                /**
                * Option : Show Digg Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-digg]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-digg]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show Digg Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

                /**
                * Option : Show Twitter Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-twitter]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-twitter]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show Twitter Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

                /**
                * Option : Show LinkedIn Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-linkedin]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-linkedin]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show LinkedIn Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

                /**
                * Option : Show Pinterest Sharer
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-pinterest]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-sharer-pinterest]', array(
                                'type'    => 'wdt-switch',
                                'label'   => esc_html__( 'Show Pinterest Sharer', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-share-section',
                                'choices' => array(
                                    'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                    'off' => esc_attr__( 'No', 'housefix-pro' )
                                )
                            )
                        )
                    );

            /**
            * Follow
            */

                /**
                * Option : Follow Description
                */
                    $wp_customize->add_setting(
                        HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-follow-description]', array(
                            'type' => 'option'
                        )
                    );

                    $wp_customize->add_control(
                        new HouseFix_Customize_Control_Switch(
                            $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-follow-description]', array(
                                'type'    => 'wdt-description',
                                'label'   => esc_html__( 'Note :', 'housefix-pro'),
                                'section' => 'woocommerce-single-page-sociable-follow-section',
                                'description'   => esc_html__( 'This option is applicable only for WooCommerce "Custom Template".', 'housefix-pro'),
                            )
                        )
                    );

                    $social_follow = array (
                        'delicious'   => esc_html__('Delicious', 'housefix-pro'),
                        'deviantart'  => esc_html__('Deviantart', 'housefix-pro'),
                        'digg'        => esc_html__('Digg', 'housefix-pro'),
                        'dribbble'    => esc_html__('Dribbble', 'housefix-pro'),
                        'envelope'    => esc_html__('Envelope', 'housefix-pro'),
                        'facebook'    => esc_html__('Facebook', 'housefix-pro'),
                        'flickr'      => esc_html__('Flickr', 'housefix-pro'),
                        'google-plus' => esc_html__('Google Plus', 'housefix-pro'),
                        'instagram'   => esc_html__('Instagram', 'housefix-pro'),
                        'lastfm'      => esc_html__('Lastfm', 'housefix-pro'),
                        'linkedin'    => esc_html__('Linkedin', 'housefix-pro'),
                        'myspace'     => esc_html__('Myspace', 'housefix-pro'),
                        'pinterest'   => esc_html__('Pinterest', 'housefix-pro'),
                        'reddit'      => esc_html__('Reddit', 'housefix-pro'),
                        'rss'         => esc_html__('RSS', 'housefix-pro'),
                        'skype'       => esc_html__('Skype', 'housefix-pro'),
                        'stumbleupon' => esc_html__('Stumbleupon', 'housefix-pro'),
                        'tumblr'      => esc_html__('Tumblr', 'housefix-pro'),
                        'twitter'     => esc_html__('Twitter', 'housefix-pro'),
                        'viadeo'      => esc_html__('Viadeo', 'housefix-pro'),
                        'vimeo'       => esc_html__('Vimeo', 'housefix-pro'),
                        'yahoo'       => esc_html__('Yahoo', 'housefix-pro'),
                        'youtube'     => esc_html__('Youtube', 'housefix-pro')
                    );

                    foreach($social_follow as $socialfollow_key => $socialfollow) {

                        $wp_customize->add_setting(
                            HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-follow-'.$socialfollow_key.']', array(
                                'type' => 'option'
                            )
                        );

                        $wp_customize->add_control(
                            new HouseFix_Customize_Control_Switch(
                                $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-show-follow-'.$socialfollow_key.']', array(
                                    'type'    => 'wdt-switch',
                                    'label'   => sprintf(esc_html__('Show %1$s Follow', 'housefix-pro'), $socialfollow),
                                    'section' => 'woocommerce-single-page-sociable-follow-section',
                                    'choices' => array(
                                        'on'  => esc_attr__( 'Yes', 'housefix-pro' ),
                                        'off' => esc_attr__( 'No', 'housefix-pro' )
                                    )
                                )
                            )
                        );

                        $wp_customize->add_setting(
                            HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-follow-'.$socialfollow_key.'-link]', array(
                                'type' => 'option'
                            )
                        );

                        $wp_customize->add_control(
                            new HouseFix_Customize_Control(
                                $wp_customize, HOUSEFIX_CUSTOMISER_VAL . '[wdt-single-product-follow-'.$socialfollow_key.'-link]', array(
                                    'type'       => 'text',
                                    'section'    => 'woocommerce-single-page-sociable-follow-section',
                                    'input_attrs' => array(
                                        'placeholder' => sprintf(esc_html__('%1$s Link', 'housefix-pro'), $socialfollow)
                                    ),
                                    'dependency' => array ( 'wdt-single-product-show-follow-'.$socialfollow_key, '==', '1' )
                                )
                            )
                        );

                    }

        }

    }

}


if( !function_exists('housefix_shop_customizer_single_social_share_and_follow') ) {
	function housefix_shop_customizer_single_social_share_and_follow() {
		return HouseFix_Shop_Customizer_Single_Social_Share_And_Follow::instance();
	}
}

housefix_shop_customizer_single_social_share_and_follow();