<?php
/**
 * Gallery Section
*/
$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_recentwork_section', array(
	'title'		=> 	esc_html__('Gallery Section','construction-arc'),
	'panel'		=> 'constructionarc_frontpage_settings',
	'priority'  => constructionarc_themes_get_section_position('constructionarc_recentwork_section'),
	'hiding_control' => 'constructionarc_portfolio_disable'
)));

//ENABLE/DISABLE GALLERY SECTION
$wp_customize->add_setting('constructionarc_portfolio_disable', array(
	'default' => 'enable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_portfolio_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_recentwork_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_recentwork_nav', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'wp_kses_post',
	));
	$wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_recentwork_nav', array(
		'type' => 'tab',
		'section' => 'constructionarc_recentwork_section',
		'priority' => 1,
		'buttons' => array(
			array(
				'name' => esc_html__('Content', 'construction-arc'),
				'fields' => array(
					'constructionarc_recentwork_title_align',
					'constructionarc_recentwork_super_title',
					'constructionarc_recentwork_title',
					'constructionarc_recentwork_title_style_heading',
					'constructionarc_recentwork_title_style',
					'constructionarc_recentwork_gallery',
					'constructionarc_gallery_default_text',
					'constructionarc_gallery_tab_align',
					'constructionarc_gallery_display_layout',
					'constructionarc_gallery_caption_disable',
					'constructionarc_gallery_zoom_icon_disable',
					'constructionarc_recentwork_block_space',
				),
				'active' => true,
			),
			array(
				'name' => esc_html__('Style', 'construction-arc'),
				'fields' => array(
				),
			),
			array(
				'name' => esc_html__('Advanced', 'construction-arc'),
				'fields' => array(
					'constructionarc_recentwork_bg_type',
					'constructionarc_recentwork_bg_color',
					'constructionarc_recentwork_bg_image',
					'constructionarc_recentwork_overlay_color',
					'constructionarc_recentwork_padding',
					'constructionarc_recentwork_cs_seperator',
				),
			),
		),
	)));

		
	$wp_customize->add_setting( 'constructionarc_recentwork_super_title', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'sanitize_text_field', 	 
	));
	$wp_customize->add_control('constructionarc_recentwork_super_title', array(
		'label'		=> esc_html__( 'Super Title', 'construction-arc' ),
		'section'	=> 'constructionarc_recentwork_section',
		'type'      => 'text'
	));
	
	$wp_customize->add_setting( 'constructionarc_recentwork_title', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'sanitize_text_field', 	 
	));
	$wp_customize->add_control('constructionarc_recentwork_title', array(
		'label'		=> esc_html__( 'Title', 'construction-arc' ),
		'section'	=> 'constructionarc_recentwork_section',
		'type'      => 'text'
	));
	
	$wp_customize->add_setting('constructionarc_recentwork_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_recentwork_title_align',
		array(
			'choices'  => array(
				'text-left' => esc_html__('Left', 'construction-arc'),
				'text-right' => esc_html__('Right', 'construction-arc'),
				'text-center' => esc_html__('Center', 'construction-arc'),
			),
			'label'    => esc_html__( 'Alignment', 'construction-arc' ),
			'section'  => 'constructionarc_recentwork_section',
			'settings' => 'constructionarc_recentwork_title_align',
		)
	));

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


	$wp_customize->add_setting('constructionarc_recentwork_title_style', array(
		'default' => 'style1',
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
	));
	$wp_customize->add_control('constructionarc_recentwork_title_style', array(
		'section' => 'constructionarc_recentwork_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'),			
		)
	));

	/** Advance */
	$wp_customize->add_setting('constructionarc_recentwork_gallery', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		//done
		'default' => json_encode(array(
			array(
				'title'      => '',
				'gallery'    => '',
			)
		))
	));
	$wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize,'constructionarc_recentwork_gallery', 
		array(
			'label' 	   => esc_html__('Advance Gallery Image', 'construction-arc'),
			'section' 	   => 'constructionarc_recentwork_section',
			'settings' 	   => 'constructionarc_recentwork_gallery',
			'box_label' => esc_html__('Gallery Item', 'construction-arc'),
			'add_label' => esc_html__('Add New', 'construction-arc'),
			'limit' => 5,
		),
		array(
			'title' => array(
				'type' => 'text',
				'label' => __("Title", 'construction-arc'),
			),
			'gallery' => array(
				'type' => 'gallery',
				'label' => __("Upload Image", 'construction-arc'),
			),
		)
	));

	$wp_customize->add_setting( 'constructionarc_gallery_default_text', array(
		'transport' => 'postMessage',
		'sanitize_callback' => 'sanitize_text_field', 
		'default' => '',	 
	));
	$wp_customize->add_control('constructionarc_gallery_default_text', array(
		'label'		=> esc_html__( 'Default Text', 'construction-arc' ),
		'section'	=> 'constructionarc_recentwork_section',
		'type'      => 'text'
	));

	$wp_customize->add_setting('constructionarc_gallery_tab_align', array(
		'default' => 'stretch',
		'sanitize_callback' => 'constructionarc_themes_sanitize_select',
		'transport' => 'postMessage'
	));
	$wp_customize->add_control( new constructionarc_Custom_Control_Buttonset( $wp_customize, 'constructionarc_gallery_tab_align',
		array(
			'choices'  => array(
				'start' => esc_html__('Left', 'construction-arc'),
				'center' => esc_html__('Center', 'construction-arc'),
				'end' => esc_html__('Right', 'construction-arc'),
				'stretch' => esc_html__('Stretch', 'construction-arc'),
			),
			'label'    => esc_html__( 'Tab Alignment', 'construction-arc' ),
			'section'  => 'constructionarc_recentwork_section',
		)
	));

	$wp_customize->add_setting('constructionarc_gallery_display_layout', 
		array( 
			'sanitize_callback' => 'sanitize_text_field',
			'default' => 'style6',
			'transport' => 'postMessage'
		)
	);
	$wp_customize->add_control(new constructionarc_Selector($wp_customize, 'constructionarc_gallery_display_layout', array(
		'section' => 'constructionarc_recentwork_section',
		'label' => esc_html__('Gallery Display Layout', 'construction-arc'),
		'options' => array(
			'style1' => get_template_directory_uri() . '/inc/customizer/images/gallery-style1.webp',
			'style2' => get_template_directory_uri() . '/inc/customizer/images/gallery-style2.webp',
			'style3' => get_template_directory_uri() . '/inc/customizer/images/gallery-style3.webp',
			'style6' => get_template_directory_uri() . '/inc/customizer/images/gallery-style6.webp',
		)
	)));

	$wp_customize->add_setting('constructionarc_gallery_caption_disable', array(
		'default' => 'enable',
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
	));
	$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_gallery_caption_disable', array(
		'label' => esc_html__('Gallery Caption', 'construction-arc'),
		'section' => 'constructionarc_recentwork_section',
		'switch_label' => array(
			'enable' => esc_html__('Enable', 'construction-arc'),
			'disable' => esc_html__('Disable', 'construction-arc'),
		)
	)));

	$wp_customize->add_setting('constructionarc_gallery_zoom_icon_disable', array(
		'default' => 'enable',
		'transport' => 'postMessage',
		'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
	));
	$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_gallery_zoom_icon_disable', array(
		'label' => esc_html__('Zoom Button', 'construction-arc'),
		'section' => 'constructionarc_recentwork_section',
		'switch_label' => array(
			'enable' => esc_html__('Enable', 'construction-arc'),
			'disable' => esc_html__('Disable', 'construction-arc'),
		)
	)));

	$wp_customize->add_setting('constructionarc_recentwork_block_space', array(
		'sanitize_callback' => 'absint',
		'default' => 1,
		'transport' => 'postMessage'
	));
	$wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_recentwork_block_space', array(
		'section' => 'constructionarc_recentwork_section',
		'label' => esc_html__('Block Space', 'construction-arc'),
		'input_attrs' => array(
			'min' => 0,
			'max' => 3,
			'step' => 1,
		)
	)));

	$wp_customize->add_setting('constructionarc_pro_recentwork', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_recentwork', array(
        'section' => 'constructionarc_recentwork_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('(4+) Different Layout ( Tabs Included )', 'construction-arc'),
            esc_html__('Add Unlimited Gallery Items', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', 'construction-arc'),
            esc_html__('Advanced Gallery Layout & Settings', 'construction-arc'),
            esc_html__('Able to specify Gallery Description', '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_portfolio_section_refresh", array (
	'settings' => array( 
		'constructionarc_portfolio_disable',
		'constructionarc_gallery_default_text',
		'constructionarc_recentwork_gallery',
		'constructionarc_gallery_display_layout',
		'constructionarc_recentwork_block_space',
	),
	'selector' => "#recentwork-section",
	'fallback_refresh' => true,
	'container_inclusive' => true,
	'render_callback' => function () {
		return get_template_part( 'section/section-recentwork' );
	}
));