<?php
/**
 * Theme Footer Panel Customizer
 *
 * @package news
*/

function mediapulse_theme_front_customizer ( $wp_customize ) {
	
	/* GLOBAL SETTINGS */        
    $wp_customize->add_panel('news_front_sections',
        array(
            'priority'      => 5,
            'capability'    => 'edit_theme_options',
            'title'         => esc_html__('Front Page','mediapulse')
        )
    );

    $wp_customize->add_section('news_slider1',
        array(
            'title'         => esc_html__('Slider 1', 'mediapulse' ),
			'panel'     =>  'news_front_sections',
            'priority'      => 4
        )
    );
	
	// enable/disable banner
    $wp_customize->add_setting('slider1_enable',
        array(
			'type'				=> 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'mediapulse_sanitize_checkbox'
        )
    );
    $wp_customize->add_control(new mediapulse_Toggle_Control( $wp_customize, 'slider1_enable',
        array(
            'label'     =>  esc_html__( 'Slider 1 Enable/Disable', 'mediapulse'),
            'section'   =>  'news_slider1',
            'settings'   =>  'slider1_enable',
            'type'      =>  'toggle',
            'priority'  =>  1
        )
    ));
	
	/* LEFT BANNER */
    // select the banner left category
    $wp_customize->add_setting( 'slider1_category',
        array(
            'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'slider1_category',
        array(
            'label'             =>  esc_html__( 'Select Category', 'mediapulse' ),
            'section'           =>  'news_slider1',
            'settings'           =>  'slider1_category',
            'priority'          =>  2
        )
    ) );

	// banner 
	    $wp_customize->add_section('news_banner',
        array(
            'title'         => esc_html__('Banner slider', 'mediapulse' ),
			'panel'     =>  'news_front_sections',
            'priority'      => 4
        )
    );
	
	// enable/disable banner
    $wp_customize->add_setting('enable_banner',
        array(
			'type'				=> 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'mediapulse_sanitize_checkbox'
        )
    );
    $wp_customize->add_control(new mediapulse_Toggle_Control( $wp_customize, 'enable_banner',
        array(
            'label'     =>  esc_html__( 'Banner Slider Enable/Disable', 'mediapulse'),
            'section'   =>  'news_banner',
            'settings'   =>  'enable_banner',
            'type'      =>  'toggle',
            'priority'  =>  1
        )
    ));
	
	/* LEFT BANNER */
    // select the banner left category
    $wp_customize->add_setting( 'banner_category',
        array(
            'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'banner_category',
        array(
            'label'             =>  esc_html__( 'Select Category for Banner slider', 'mediapulse' ),
            'section'           =>  'news_banner',
            'settings'           =>  'banner_category',
            'priority'          =>  2
        )
    ) );
	
		// enable/disable banner
    $wp_customize->add_setting('enable_banner_category',
        array(
			'type'				=> 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'mediapulse_sanitize_checkbox'
        )
    );
    $wp_customize->add_control(new mediapulse_Toggle_Control( $wp_customize, 'enable_banner_category',
        array(
            'label'     =>  esc_html__( 'Enable/Disable Category area', 'mediapulse'),
            'section'   =>  'news_banner',
            'settings'   =>  'enable_banner_category',
            'type'      =>  'toggle',
            'priority'  =>  1
        )
    ));
	
	for($i=0;$i<4;$i++) {
	$wp_customize->add_setting( 'right_category_'.$i,
        array(
            //'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'right_category_'.$i,
        array(
            'label'             =>  esc_html__( 'Select Category for Right Side', 'mediapulse' ),
            'section'           =>  'news_banner',
            'settings'           =>  'right_category_'.$i,
        )
    ) );
	}

	// feature product 
	$wp_customize->add_section('featured_news',
        array(
            'title'         => esc_html__('Featured posts', 'mediapulse' ),
			'panel'     =>  'news_front_sections',
            'priority'      => 4
        )
    );
	
	// enable/disable banner
    $wp_customize->add_setting('featured_enable',
        array(
			'type'				=> 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'mediapulse_sanitize_checkbox'
        )
    );
    $wp_customize->add_control(new mediapulse_Toggle_Control( $wp_customize, 'featured_enable',
        array(
            'label'     =>  esc_html__( 'Featured Posts Enable/Disable', 'mediapulse'),
            'section'   =>  'featured_news',
            'settings'   =>  'featured_enable',
            'type'      =>  'toggle',
            'priority'  =>  1
        )
    ));
	
	$wp_customize->add_setting( 'featured_category',
        array(
            'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'featured_category',
        array(
            'label'             =>  esc_html__( 'Select Category ', 'mediapulse' ),
            'section'           =>  'featured_news',
            'settings'           =>  'featured_category',
            'priority'          =>  2
        )
    ) );
	
	// category slider // 
	$wp_customize->add_section('category_section',
        array(
            'title'         => esc_html__('Category Section', 'mediapulse' ),
			'panel'     =>  'news_front_sections',
            'priority'      => 4
        )
    );
	
	// enable/disable banner
    $wp_customize->add_setting('category_enable',
        array(
			'type'				=> 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'mediapulse_sanitize_checkbox'
        )
    );
    $wp_customize->add_control(new mediapulse_Toggle_Control( $wp_customize, 'category_enable',
        array(
            'label'     =>  esc_html__( 'Category Section Enable/Disable', 'mediapulse'),
            'section'   =>  'category_section',
            'settings'   =>  'category_enable',
            'type'      =>  'toggle',
            'priority'  =>  1
        )
    ));
	
	$wp_customize->add_setting( 'category_left_side',
        array(
            'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'category_left_side',
        array(
            'label'             =>  esc_html__( 'Select Category for Left slider', 'mediapulse' ),
            'section'           =>  'category_section',
            'settings'           =>  'category_left_side',
            'priority'          =>  2
        )
    ) );
	
	$wp_customize->add_setting( 'category_right_side',
        array(
            'default'           =>  0,
            'sanitize_callback' =>  'absint'
        )
    );
    $wp_customize->add_control( new mediapulse_Dropdown_Category_Control( $wp_customize, 'category_right_side',
        array(
            'label'             =>  esc_html__( 'Select Category for Right slider', 'mediapulse' ),
            'section'           =>  'category_section',
            'settings'           =>  'category_right_side',
            'priority'          =>  2
        )
    ) );
	
	$wp_customize->add_section('front_page_order_section',
    array(
        'title' => esc_html__('Reorder sections', 'mediapulse'),
        'panel' => 'news_front_sections',
        'priority' => 5
    ));
	
	$default = array( 'slider1_enable', 'enable_banner', 'featured_enable', 'category_enable' );
	$choices = array(
            'slider1_enable' => esc_html__( 'Slider One', 'mediapulse'),
            'enable_banner' => esc_html__('Banner Slider', 'mediapulse'),
            'featured_enable' => esc_html__('Featured Category', 'mediapulse'),
            'category_enable' => esc_html__( 'Category Section', 'mediapulse' ),
        );
	
	$wp_customize->add_setting( 'front_page_content_sort',
    array(
        'capability'  => 'edit_theme_options',
        'sanitize_callback' => 'mediapulse_sanitize_array',
        'default'     => $default
    ) );

    $wp_customize->add_control( new mediapulse_Control_Sortable( $wp_customize, 'front_page_content_sort',
    array(
        'label' => esc_html__( 'Drag And Drop to Rearrange', 'mediapulse' ),
        'section' => 'front_page_order_section',
        'settings' => 'front_page_content_sort',
        'type'=> 'sortable',
        'choices'     => $choices
    ) ) );
}
add_action( 'customize_register', 'mediapulse_theme_front_customizer' );