<?php
/**
 * About Section Settings
 *
 * @package Feminine_Lifestyle_Blog
 */
if ( ! function_exists( 'feminine_lifestyle_blog_about_settings' ) ) :

function feminine_lifestyle_blog_about_settings( $wp_customize ) {
    
    /** About Section Settings */
    $wp_customize->add_section(
        'about_section',
        array(
            'title'    => __( 'About Section', 'feminine-lifestyle-blog' ),
            'priority' => 15,
            'panel'    => 'homepage_settings',
        )
    );

    /** Enable About Section */
    $wp_customize->add_setting( 
        'ed_about_section', 
        array(
            'default'           => false,
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_checkbox'
        ) 
    );
    
    $wp_customize->add_control(
        new Feminine_Lifestyle_Blog_Toggle_Control( 
            $wp_customize,
            'ed_about_section',
            array(
                'section'     => 'about_section',
                'label'       => __( 'Enable About Section', 'feminine-lifestyle-blog' ),
            )
        )
    );

    /** Title Text */
    $wp_customize->add_setting( 
        'about_title', 
        array(
            'default'           => esc_html__( 'About Me', 'feminine-lifestyle-blog' ), 
            'sanitize_callback' => 'sanitize_text_field',
            'transport'         => 'postMessage'
        ) 
    );
    
    $wp_customize->add_control(
        'about_title',
        array(
            'section'         => 'about_section',
            'label'           => __( 'Section Title', 'feminine-lifestyle-blog' ),
            'type'            => 'text',
        )   
    );

    $wp_customize->selective_refresh->add_partial( 'about_title', array(
        'selector'          => '.about-section .about-section-wrapper .about-grid .content-box h2.about-section-title',
        'render_callback'   => 'feminine_lifestyle_blog_get_about_title',
    ) );

    /** Content Text */
    $wp_customize->add_setting( 
        'about_content', 
        array(
            'default'           => '', 
            'sanitize_callback' => 'wp_kses_post',
            'transport'         => 'postMessage'
        ) 
    );
    
    $wp_customize->add_control(
        'about_content',
        array(
            'section'         => 'about_section',
            'label'           => __( 'Section Content', 'feminine-lifestyle-blog' ),
            'type'            => 'textarea',
        )   
    );

    $wp_customize->selective_refresh->add_partial( 'about_content', array(
        'selector'          => '.about-section .about-section-wrapper .about-grid .content-box .about_content',
        'render_callback'   => 'feminine_lifestyle_blog_get_about_content',
    ) );

    $wp_customize->add_setting(
        'about_btn_label',
        array(
            'default'           => '',
            'sanitize_callback' => 'sanitize_text_field',
            'transport'         => 'postMessage'
        )
    );
    
    $wp_customize->add_control(
        'about_btn_label',
        array(
            'type'            => 'text',
            'section'         => 'about_section',
            'label'           => __( 'Button Label', 'feminine-lifestyle-blog' ),

        )
    );

    $wp_customize->selective_refresh->add_partial( 'about_btn_label', array(
        'selector'          => '.about-section .about-section-wrapper .about-grid .content-box .primary-btn',
        'render_callback'   => 'feminine_lifestyle_blog_get_about_btn_label',
    ) );

    /** Notification Button Link */
    $wp_customize->add_setting(
        'about_btn_url',
        array(
            'default'           => '',
            'sanitize_callback' => 'esc_url_raw' 
        )
    );
    
    $wp_customize->add_control(
        'about_btn_url',
        array(
            'type'            => 'text',
            'section'         => 'about_section',
            'label'           => __( 'Button Link', 'feminine-lifestyle-blog' ),

        )
    );

    $wp_customize->add_setting(
        'abt_signature_image',
        array(
            'default'           => '',
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Media_Control(
            $wp_customize,
            'abt_signature_image',
            array(
                'label'           => __( 'Upload Signature Image', 'feminine-lifestyle-blog' ),
                'section'         => 'about_section',
                'mime_type'       => 'image',
            )
        )
    );

    $wp_customize->add_setting(
        'abt_image',
        array(
            'default'           => '',
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_number_absint',
        )
    );
    
    $wp_customize->add_control(
        new WP_Customize_Media_Control(
            $wp_customize,
            'abt_image',
            array(
                'label'           => __( 'Upload About Image', 'feminine-lifestyle-blog' ),
                'section'         => 'about_section',
                'mime_type'       => 'image',
            )
        )
    );

    /** About Image Caption */
    $wp_customize->add_setting(
        'about_image_align',
        array(
            'default'           => 'left-align',
            'sanitize_callback' => 'feminine_lifestyle_blog_sanitize_radio',
        )
    );
    
    $wp_customize->add_control( 
        new Feminine_Lifestyle_Blog_Radio_Buttonset_Control( 
            $wp_customize,
            'about_image_align',
            array(
                'label'   => esc_html__( 'Image Alignment', 'feminine-lifestyle-blog' ),
                'section' => 'about_section',
                'choices' => array(
                    'left-align'  => esc_html__( 'Left', 'feminine-lifestyle-blog' ),
                    'right-align' => esc_html__( 'Right', 'feminine-lifestyle-blog' )
                ),
            )
        )
    );

}
endif;
add_action( 'customize_register', 'feminine_lifestyle_blog_about_settings' );