<?php
/**
 * Blog Settings
 *
 * @package Chic Lifestyle
 */

add_action( 'customize_register', 'chic_lifestyle_customize_register_blog_post' );

function chic_lifestyle_customize_register_blog_post( $wp_customize ) {
	$wp_customize->add_section( 'chic_lifestyle_blog_sections', array(
	    'title'          => esc_html__( 'Blog Section', 'chic-lifestyle' ),
	    'description'    => esc_html__( 'Blog Section slider', 'chic-lifestyle' ),
	    'panel'          => 'chic_lifestyle_homepage_panel',
	    'priority'       => 5,
	) );

    $wp_customize->add_setting( 'chic_lifestyle_blog_section_display_option', array(
      'sanitize_callback'     =>  'chic_lifestyle_sanitize_checkbox',
      'default'               =>  true
    ) );

    $wp_customize->add_control( new Chic_Lifestyle_Toggle_Control( $wp_customize, 'chic_lifestyle_blog_section_display_option', array(
      'label' => esc_html__( 'Hide / Show','chic-lifestyle' ),
      'section' => 'chic_lifestyle_blog_sections',
      'settings' => 'chic_lifestyle_blog_section_display_option',
      'type'=> 'toggle',
    ) ) );
    
    $wp_customize->selective_refresh->add_partial( 'chic_lifestyle_blog_section_display_option', array(
        'selector' => '#chic_lifestyle_blog_sections > .container',
    ) );

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

    $wp_customize->add_control( 'chic_lifestyle_blog_section_title', array(
        'label' => esc_html__( 'Title', 'chic-lifestyle' ),
        'section' => 'chic_lifestyle_blog_sections',
        'settings' => 'chic_lifestyle_blog_section_title',
        'type'=> 'text',
    ) );

    $wp_customize->add_setting( 'chic_lifestyle_blog_section_category', array(
        'capability'  => 'edit_theme_options',        
        'sanitize_callback' => 'sanitize_text_field',
        'default'     => '',
    ) );

    $wp_customize->add_control( new Chic_Lifestyle_Customize_Dropdown_Taxonomies_Control(
        $wp_customize, 'chic_lifestyle_blog_section_category', array(
            'label' => esc_html__( 'Choose Category', 'chic-lifestyle' ),
            'section' => 'chic_lifestyle_blog_sections',
            'settings' => 'chic_lifestyle_blog_section_category',
            'type'=> 'dropdown-taxonomies',
            'taxonomy'  =>  'category'
    ) ) );

    $wp_customize->add_setting( 'chic_lifestyle_blog_section_number_of_posts', array(
        'sanitize_callback'     =>  'sanitize_text_field',
        'default'               =>  4
    ) );

    $wp_customize->add_control( 'chic_lifestyle_blog_section_number_of_posts', array(
        'label' => esc_html__( 'Number of posts', 'chic-lifestyle' ),
        'section' => 'chic_lifestyle_blog_sections',
        'settings' => 'chic_lifestyle_blog_section_number_of_posts',
        'type'=> 'text',
        'description'   =>  'put -1 for unlimited'
    ) );

}