<?php
/**
 * Advertisement Section
 *
 * @package Majestic Blog
 */

$wp_customize->add_section(
	'majestic_blog_advertisement_section',
	array(
		'panel' => 'majestic_blog_front_page_options',
		'title' => esc_html__( 'Advertisement Section', 'majestic-blog' ),
	)
);

// Advertisement Section - Enable Section.
$wp_customize->add_setting(
	'majestic_blog_enable_advertisement_section',
	array(
		'default'           => false,
		'sanitize_callback' => 'majestic_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Majestic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'majestic_blog_enable_advertisement_section',
		array(
			'label'    => esc_html__( 'Enable Advertisement Section', 'majestic-blog' ),
			'section'  => 'majestic_blog_advertisement_section',
			'settings' => 'majestic_blog_enable_advertisement_section',
		)
	)
);

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

// Advertisement Section - Set Advertisement Image.
$wp_customize->add_setting(
	'majestic_blog_advertisement_image',
	array(
		'default'           => '',
		'sanitize_callback' => 'majestic_blog_sanitize_image',
	)
);

$wp_customize->add_control(
	new WP_Customize_Image_Control(
		$wp_customize,
		'majestic_blog_advertisement_image',
		array(
			'label'           => esc_html__( 'Advertisement Image', 'majestic-blog' ),
			'section'         => 'majestic_blog_advertisement_section',
			'settings'        => 'majestic_blog_advertisement_image',
			'active_callback' => 'majestic_blog_is_advertisement_section_enabled',
		)
	)
);

// Advertisement Section - Set Advertisement Image URL.
$wp_customize->add_setting(
	'majestic_blog_advertisement_image_url',
	array(
		'default'           => '',
		'sanitize_callback' => 'esc_url_raw',
	)
);

$wp_customize->add_control(
	'majestic_blog_advertisement_image_url',
	array(
		'label'           => esc_html__( 'Advertisement Image URL', 'majestic-blog' ),
		'section'         => 'majestic_blog_advertisement_section',
		'settings'        => 'majestic_blog_advertisement_image_url',
		'active_callback' => 'majestic_blog_is_advertisement_section_enabled',
		'type'            => 'url',
	)
);
