<?php

$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_blog_section', array(
    'title'		=> 	esc_html__('Blog Section','construction-arc'),
    'panel'		=> 'constructionarc_frontpage_settings',
    'priority'  => constructionarc_themes_get_section_position('constructionarc_blog_section'),
    'hiding_control' => 'constructionarc_blog_disable'
)));

//ENABLE/DISABLE BLOG SECTION
$wp_customize->add_setting('constructionarc_blog_disable', array(
	'default' => 'enable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_blog_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_blog_section',
	'switch_label' => array(
		'enable' => esc_html__('Enable', 'construction-arc'),
		'disable' => esc_html__('Disable', 'construction-arc'),
	),
	'class' => 'switch-section',
    'priority' => -1,
)));

    $wp_customize->add_setting('constructionarc_blog_section_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post',
    ));

    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_blog_section_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_blog_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_blog_super_title',
                    'constructionarc_blog_title',
                    'constructionarc_blog_title_align',
                    'constructionarc_blog_title_style_heading',
                    'constructionarc_blog_title_style',
                    'constructionarc_home_blog_alignment',
                    'constructionarc_blog_display_style',
                    'constructionarc_posts_num',
                    'constructionarc_blog_categories',
                    'constructionarc_home_post_author_options',
                    'constructionarc_home_post_date_options',
                    'constructionarc_home_post_reading_time',
                    'constructionarc_blog_excerpt_length',
                    'constructionarc_blog_home_btn',
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_blog_bg_type',
                    'constructionarc_blog_bg_color',
                    'constructionarc_blog_bg_image',
                    'constructionarc_blog_overlay_color',
                    'constructionarc_blog_padding',
                    'constructionarc_blog_cs_seperator',
                ),
            ),
        ),
    )));
    
    $wp_customize->add_setting('constructionarc_blog_super_title', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_blog_super_title', array(
        'label'	   => esc_html__('Super Title','construction-arc'),
        'section'  => 'constructionarc_blog_section',
        'type'	   => 'text',
    ));

    $wp_customize->add_setting('constructionarc_blog_title', array(
        'transport' => 'postMessage',
        'sanitize_callback'	=> 'sanitize_text_field'		
    ));
    $wp_customize->add_control('constructionarc_blog_title', array(
        'label'	   => esc_html__('Title','construction-arc'),
        'section'  => 'constructionarc_blog_section',
        'type'	   => 'text',
    ));
    
    $wp_customize->add_setting('constructionarc_blog_title_align', array(
        'default' => 'text-center',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(
        new constructionarc_Custom_Control_Buttonset( $wp_customize, 'constructionarc_blog_title_align',
            array(
                'choices'  => array(
                    'text-left' => esc_html__('Left', 'construction-arc'),
                    'text-center' => esc_html__('Center', 'construction-arc'),
                    'text-right' => esc_html__('Right', 'construction-arc'),
                ),
                'label'    => esc_html__( 'Alignment', 'construction-arc' ),
                'section'  => 'constructionarc_blog_section',
                'settings' => 'constructionarc_blog_title_align',
            )
        )
    );

    $wp_customize->add_setting('constructionarc_blog_title_style_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_blog_title_style_heading', array(
        'section' => 'constructionarc_blog_section',
        'label' => esc_html__('Section Title Style', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_blog_title_style', array(
        'default' => 'style1',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_blog_title_style', array(
        'section' => 'constructionarc_blog_section',
        'type'    => 'select',
        'choices' => array(
            'style1' => esc_html__('Style 1','construction-arc'),
            'style2' => esc_html__('Style 2','construction-arc'),			
            'style3' => esc_html__('Style 3','construction-arc'),		
        )
    ));

    $wp_customize->add_setting('constructionarc_blog_categories', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'sanitize_text_field',    
    ));
    $wp_customize->add_control(new constructionarc_Multiple_Check_Control($wp_customize, 'constructionarc_blog_categories', array(
        'section'  => 'constructionarc_blog_section',
        'choices'  => $blog_cat,
        'label' => esc_html__('Select Categories', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_home_blog_alignment',array(
        'default' => 'text-center',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Buttonset($wp_customize,'constructionarc_home_blog_alignment', array(
        'choices'  => array(
            'text-left' => esc_html__('Left', 'construction-arc'),
            'text-center' => esc_html__('Center', 'construction-arc'),
            'text-right' => esc_html__('Right', 'construction-arc'),
        ),
        'label'    => esc_html__( 'Content Alignment', 'construction-arc' ),
        'section'  => 'constructionarc_blog_section',
    )));

    $wp_customize->add_setting('constructionarc_blog_display_style', array(
        'default' => 'grid',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_blog_display_style', array(
        'section' => 'constructionarc_blog_section',
        'type'    => 'select',
        'label' => esc_html__('Display Style', 'construction-arc'),
        'choices' => array(
            'grid' => esc_html__('Grid','construction-arc'),
            'slide' => esc_html__('Slide','construction-arc'),			
        )
    ));
    
    $wp_customize->add_setting('constructionarc_posts_num', array(
        'sanitize_callback' => 'absint',
        'default' => 6,
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_posts_num', array(
        'section' => 'constructionarc_blog_section',
        'label' => esc_html__('Display Number of Item', 'construction-arc'),
        'input_attrs' => array(
            'min' => 1,
            'max' => 12,
            'step' => 1,
        )
    )));

    $wp_customize->add_setting('constructionarc_home_post_date_options', array(
        'transport' => 'postMessage',
        'default' => 'enable',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',     
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_home_post_date_options', array(
        'label' => esc_html__('Post Date', 'construction-arc'),
        'settings' => 'constructionarc_home_post_date_options',
        'section' => 'constructionarc_blog_section',
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting('constructionarc_home_post_author_options', array(
        'transport' => 'postMessage',
        'default' => 'enable',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_home_post_author_options', array(
        'label' => esc_html__('Author', 'construction-arc'),
        'settings' => 'constructionarc_home_post_author_options',
        'section' => 'constructionarc_blog_section',
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting('constructionarc_home_post_reading_time', array(
        'transport' => 'postMessage',
        'default' => 'enable',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_home_post_reading_time', array(
        'label' => esc_html__('Reading Time', 'construction-arc'),
        'settings' => 'constructionarc_home_post_reading_time',
        'section' => 'constructionarc_blog_section',
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        ),
    )));

    $wp_customize->add_setting( 'constructionarc_blog_excerpt_length', array(
        'default'    => 20,
        'sanitize_callback' => 'absint'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_blog_excerpt_length', array(
        'section' => 'constructionarc_blog_section',
        'label' => esc_html__('Excerpt Length (words number)', 'construction-arc'),
        'input_attrs' => array(
            'min' => 10,
            'max' => 100,
            'step' => 5
        )
    )));

    $wp_customize->add_setting( 'constructionarc_blog_home_btn', array(
        'transport' => 'postMessage',
        'default'  => esc_html__( 'Read More','construction-arc' ),
        'sanitize_callback' => 'sanitize_text_field',		
    ));
    $wp_customize->add_control('constructionarc_blog_home_btn', array(
        'label' => esc_html__( 'Button Text', 'construction-arc' ),
        'section' => 'constructionarc_blog_section',
        'type'  => 'text',
    ));

    $wp_customize->add_setting('constructionarc_pro_blog', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_blog', array(
        'section' => 'constructionarc_blog_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('(3+) Different Layout & Settings', 'construction-arc'),
            esc_html__('Configure Column & Space(Gap)', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', 'construction-arc'),
            esc_html__('Control Excerpt Character', 'construction-arc'),
            esc_html__('On/Off Date, Author & Comment', 'construction-arc'),
            esc_html__('Title, sub title & text color options', 'construction-arc'),
			esc_html__('4+ Different Background Options( Color/Video/Gradient/Image ) ', 'construction-arc'),
			esc_html__('More Than 35+ Top & Bottom Separator Shape Illustrator with Color & Height Option', 'construction-arc'),
        ),
        'priority' => 250,
    )));

$wp_customize->selective_refresh->add_partial( "constructionarc_home_blog_section_refresh", array (
    'settings' => array( 
        'constructionarc_blog_disable',
        'constructionarc_blog_display_style',
        'constructionarc_blog_categories',
        'constructionarc_posts_num',	
        'constructionarc_blog_excerpt_length',
    ),
    'selector' => "#blog-section",
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section-blog' );
    }
));