<?php

function kindrex_cta( $wp_customize ) {
	$wp_customize->add_section(
		'kindrex-cta-section',
		array(
			'title'       => esc_html__( 'Callout Blocks', 'kindrex' ),
			'description' => esc_html__( 'Options for two callout blocks.', 'kindrex' ),
			'priority'    => '83',
		)
	);

	$wp_customize->add_setting(
		'kindrex-cta-display',
		array(
			'default'           => esc_html__( 'No', 'kindrex' ),
			'sanitize_callback' => 'kindrex_sanitize_html',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'kindrex-cta-display-control',
			array(
				'label'    => esc_html__( 'Display Callout Block 1?', 'kindrex' ),
				'section'  => 'kindrex-cta-section',
				'settings' => 'kindrex-cta-display',
				'type'     => 'select',
				'choices'  => array(
					'No'  => esc_html__( 'No', 'kindrex' ),
					'Yes' => esc_html__( 'Yes', 'kindrex' ),
				),
			)
		)
	);

	$wp_customize->add_setting(
		'kindrex-cta-image',
		array(
			'sanitize_callback' => 'kindrex_sanitize_html',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Cropped_Image_Control(
			$wp_customize,
			'kindrex-cta-image-control',
			array(
				'label'    => esc_html__( 'Image', 'kindrex' ),
				'section'  => 'kindrex-cta-section',
				'settings' => 'kindrex-cta-image',
				'height'   => 500,
				'width'    => 750,
			)
		)
	);

	$wp_customize->add_setting(
		'kindrex-cta-headline',
		array(
			'default'           => esc_html__( 'Example Headline Text!', 'kindrex' ),
			'sanitize_callback' => 'kindrex_sanitize_html',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'kindrex-cta-headline-control',
			array(
				'label'    => esc_html__( 'Headline', 'kindrex' ),
				'section'  => 'kindrex-cta-section',
				'settings' => 'kindrex-cta-headline',
			)
		)
	);

	$wp_customize->add_setting(
		'kindrex-cta-text',
		array(
			'default'           => esc_html__( 'Example Paragraph Text!', 'kindrex' ),
			'sanitize_callback' => 'kindrex_sanitize_html',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'kindrex-cta-text-control',
			array(
				'label'    => esc_html__( 'Text', 'kindrex' ),
				'section'  => 'kindrex-cta-section',
				'settings' => 'kindrex-cta-text',
				'type'     => 'textarea',
			)
		)
	);

	$wp_customize->add_setting(
		'kindrex-cta-link',
		array(
			'sanitize_callback' => 'kindrex_sanitize_html',
		)
	);

	$wp_customize->add_control(
		new WP_Customize_Control(
			$wp_customize,
			'kindrex-cta-link-control', 
			array(
				'label'    => esc_html__( 'Link', 'kindrex' ),
				'section'  => 'kindrex-cta-section',
				'settings' => 'kindrex-cta-link',
				'type'     => 'dropdown-pages',
			)
		)
	);

	/*
	CTA 2
	*/

	$wp_customize->add_control(
		'labels1',
		array(
			'type'        => 'button',
			'settings'    => array(),
			'label'       => __( 'Display Callout Block 2?', 'kindrex' ),
			'priority'    => 10,
			'section'     => 'kindrex-cta-section',
			'input_attrs' => array(
				'value'   => __( 'Get pro for this feature!', 'kindrex' ),
				'class'   => 'button-secondary',
				'onclick' => "window.open('https://www.designwicked.com/store/premium-kindrex', '_blank')",
			),
		)
	);

}

add_action( 'customize_register', 'kindrex_cta' );
