<?php
/**
 * Offer Section
 *
 * @package lawyer_consultant_firm
 */

$wp_customize->add_section(
	'lawyer_consultant_firm_offer_section',
	array(
		'panel'    => 'lawyer_consultant_firm_front_page_options',
		'title'    => esc_html__( 'Offer Section', 'lawyer-consultant-firm' ),
		'priority' => 10,
	)
);

// Offer Section - Enable Section.
$wp_customize->add_setting(
	'lawyer_consultant_firm_enable_offer_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'lawyer_consultant_firm_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Lawyer_Consultant_Firm_Toggle_Switch_Custom_Control(
		$wp_customize,
		'lawyer_consultant_firm_enable_offer_section',
		array(
			'label'    => esc_html__( 'Enable Offer Section', 'lawyer-consultant-firm' ),
			'section'  => 'lawyer_consultant_firm_offer_section',
			'settings' => 'lawyer_consultant_firm_enable_offer_section',
		)
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'lawyer_consultant_firm_enable_offer_section',
		array(
			'selector' => '#lawyer_consultant_firm_offer_section .section-link',
			'settings' => 'lawyer_consultant_firm_enable_offer_section',
		)
	);
}


for ( $lawyer_consultant_firm_i = 1; $lawyer_consultant_firm_i <= 6; $lawyer_consultant_firm_i++ ) {

	// Icon setting
	$wp_customize->add_setting(
		"lawyer_consultant_firm_offer_icon_{$lawyer_consultant_firm_i}",
		array(
			'default'           => 'fas fa-balance-scale',
			'sanitize_callback' => 'sanitize_text_field',
			'capability'        => 'edit_theme_options',
		)
	);

	$wp_customize->add_control(
		new Lawyer_Consultant_Firm_Change_Icon_Control(
			$wp_customize,
			"lawyer_consultant_firm_offer_icon_{$lawyer_consultant_firm_i}",
			array(
				/* translators: %d: Offer item number */
				'label'    => sprintf( __( 'Offer Icon %d', 'lawyer-consultant-firm' ), $lawyer_consultant_firm_i ),
				'section'  => 'lawyer_consultant_firm_offer_section',
				'iconset'  => 'fb',
                'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
			)
		)
	);

	// Heading setting
	$wp_customize->add_setting(
		"lawyer_consultant_firm_offer_heading_{$lawyer_consultant_firm_i}",
		array(
			'default'           => '',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		"lawyer_consultant_firm_offer_heading_{$lawyer_consultant_firm_i}",
		array(
			/* translators: %d: Offer item number */
			'label'    => sprintf( __( 'Offer Heading %d', 'lawyer-consultant-firm' ), $lawyer_consultant_firm_i ),
			'section'  => 'lawyer_consultant_firm_offer_section',
			'type'     => 'text',
            'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
		)
	);

	// Link setting
	$wp_customize->add_setting(
		"lawyer_consultant_firm_offer_link_{$lawyer_consultant_firm_i}",
		array(
			'default'           => '',
			'sanitize_callback' => 'esc_url_raw',
		)
	);

	$wp_customize->add_control(
		"lawyer_consultant_firm_offer_link_{$lawyer_consultant_firm_i}",
		array(
			/* translators: %d: Offer item number */
			'label'    => sprintf( __( 'Offer Link %d', 'lawyer-consultant-firm' ), $lawyer_consultant_firm_i ),
			'section'  => 'lawyer_consultant_firm_offer_section',
			'type'     => 'url',
            'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
		)
	);
}

// Offer Section - Sub Heading
$wp_customize->add_setting(
	'lawyer_consultant_firm_offer_sub_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'lawyer_consultant_firm_offer_sub_heading',
	array(
		'label'           => esc_html__( 'Offer Sub Heading', 'lawyer-consultant-firm' ),
		'section'         => 'lawyer_consultant_firm_offer_section',
		'settings'        => 'lawyer_consultant_firm_offer_sub_heading',
		'type'            => 'text',
		'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
	)
);

// Offer Section - Offer Text
$wp_customize->add_setting(
	'lawyer_consultant_firm_offer_text',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'lawyer_consultant_firm_offer_text',
	array(
		'label'           => esc_html__( 'Offer Text', 'lawyer-consultant-firm' ),
		'section'         => 'lawyer_consultant_firm_offer_section',
		'settings'        => 'lawyer_consultant_firm_offer_text',
		'type'            => 'text',
		'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
	)
);

// Offer Section - Offer Heading.
$wp_customize->add_setting(
	'lawyer_consultant_firm_offer_section_heading',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'lawyer_consultant_firm_offer_section_heading',
	array(
		'label'           => sprintf( esc_html__( 'Offer Heading', 'lawyer-consultant-firm' )),
		'section'         => 'lawyer_consultant_firm_offer_section',
		'settings'        => 'lawyer_consultant_firm_offer_section_heading',
		'type'            => 'text',
		'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
	)
);

// Offer Section - OfferContent.
$wp_customize->add_setting(
	'lawyer_consultant_firm_offer_section_content',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'lawyer_consultant_firm_offer_section_content',
	array(
		'label'           => sprintf( esc_html__( 'Offer Content', 'lawyer-consultant-firm' )),
		'section'         => 'lawyer_consultant_firm_offer_section',
		'settings'        => 'lawyer_consultant_firm_offer_section_content',
		'type'            => 'text',
		'active_callback' => 'lawyer_consultant_firm_is_offer_section_enabled',
	)
);

$wp_customize->add_setting( 
	'lawyer_consultant_firm_offer_settings_upgraded_features',
	array(
		'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control(
	'lawyer_consultant_firm_offer_settings_upgraded_features', 
	array(
		'type'=> 'hidden',
		'description' => "
			<div class='customizer-upgraded-features'>
				<i class='fas fa-info-circle'></i>
				<span class='pro-text'>
					Unlock Premium <strong>Features</strong> ?<br>
					<a target='_blank' href='". esc_url(LAWYER_CONSULTANT_FIRM_PREMIUM_PAGE) ." '>Upgrade Pro</a>
				</div>
			</div>
		",
		'section' => 'lawyer_consultant_firm_offer_section'
	)
);