<?php
/**
 * Feminine Mentor Theme Customizer
 *
 * @package Feminine Mentor
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function feminine_mentor_customize_register( $wp_customize ) {
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';

	$feminine_mentor_options = feminine_mentor_theme_options();

	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial(
			'blogname',
			array(
				'selector'        => '.site-title a',
				'render_callback' => 'feminine_mentor_customize_partial_blogname',
			)
		);
		$wp_customize->selective_refresh->add_partial(
			'blogdescription',
			array(
				'selector'        => '.site-description',
				'render_callback' => 'feminine_mentor_customize_partial_blogdescription',
			)
		);
	}

	$wp_customize->add_panel(
        'theme_options',
        array(
            'title' => esc_html__('Theme Options', 'feminine-mentor'),
            'priority' => 2,
        )
    );



//Social Links
    $wp_customize->add_section(
    'social_section',
	    array(
	        'title' => esc_html__( 'Social Links','feminine-mentor' ),
		     'description' => esc_html__( 'More Social Links are available in Premium Version','feminine-mentor' ),
	        'panel'=>'theme_options',
	        'capability'=>'edit_theme_options',
	    )
	);
	$wp_customize->add_setting('feminine_mentor_theme_options[fb_url]',
	    array(
	        'type' => 'option',
	        'default' => $feminine_mentor_options['fb_url'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_url',
	    )
	);
	$wp_customize->add_control('feminine_mentor_theme_options[fb_url]',
	    array(
	        'label' => esc_html__('Facebook Link', 'feminine-mentor'),
	        'type' => 'text',
	        'section' => 'social_section',
	        'settings' => 'feminine_mentor_theme_options[fb_url]',
	    )
	);
		$wp_customize->add_setting('feminine_mentor_theme_options[insta_url]',
	    array(
	        'type' => 'option',
	        'default' => $feminine_mentor_options['insta_url'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_url',
	    )
	);
	$wp_customize->add_control('feminine_mentor_theme_options[insta_url]',
	    array(
	        'label' => esc_html__('Instagram Link', 'feminine-mentor'),
	        'type' => 'text',
	        'section' => 'social_section',
	        'settings' => 'feminine_mentor_theme_options[insta_url]',
	    )
	);
		$wp_customize->add_setting('feminine_mentor_theme_options[twitter_url]',
	    array(
	        'type' => 'option',
	        'default' => $feminine_mentor_options['twitter_url'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_url',
	    )
	);
	$wp_customize->add_control('feminine_mentor_theme_options[twitter_url]',
	    array(
	        'label' => esc_html__('Twiiter X Link', 'feminine-mentor'),
	        'type' => 'text',
	        'section' => 'social_section',
	        'settings' => 'feminine_mentor_theme_options[twitter_url]',
	    )
	);


    $wp_customize->add_section(
    'article_section',
	    array(
	        'title' => esc_html__( 'Single Article/Blog Page','feminine-mentor' ),
	        'panel'=>'theme_options',
	        'capability'=>'edit_theme_options',
	    )
	);

	$wp_customize->add_setting('feminine_mentor_theme_options[sidebar_show]',
	    array(
	        'type' => 'option',
	        'default'        => true,
	        'default' => $feminine_mentor_options['sidebar_show'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_checkbox',
	    )
	);

	$wp_customize->add_control('feminine_mentor_theme_options[sidebar_show]',
	    array(
	        'label' => esc_html__('Show Sidebar in Single Article?', 'feminine-mentor'),
	        'type' => 'Checkbox',
	        'section' => 'article_section',

	    )
	);



//Header Section
    $wp_customize->add_section(
    'header_section',
	    array(
	        'title' => esc_html__( 'Header Section','feminine-mentor' ),
	        'panel'=>'theme_options',
	        'capability'=>'edit_theme_options',
	    )
	);


       $wp_customize->add_setting( 'feminine_mentor_theme_options[header_layout]', array(
          'capability' => 'edit_theme_options',
          'default' => 'header1',
          'sanitize_callback' => 'feminine_mentor_sanitize_radio',
          'type' => 'option',
    ) );

    $wp_customize->add_control( 'feminine_mentor_theme_options[header_layout]', array(
          'type' => 'radio',
          'section' => 'header_section', // Add a default or your own section
          'label' => esc_attr( __('Choose Header Layout', 'feminine-mentor') ),
          'choices' => array(
            'header1' => esc_attr( __('Default Header', 'feminine-mentor') ),
            'header2' => esc_attr( __('Centered Layout', 'feminine-mentor') ),
            'header3' => esc_attr( __('Bottom Menu Layout', 'feminine-mentor') ),
          ),
    ) );


	$wp_customize->add_setting('feminine_mentor_theme_options[dark_header]',
	    array(
	        'type' => 'option',
	        'default'        => true,
	        'default' => $feminine_mentor_options['dark_header'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_checkbox',
	    )
	);

	$wp_customize->add_control('feminine_mentor_theme_options[dark_header]',
	    array(
	        'label' => esc_html__('Dark Header?', 'feminine-mentor'),
	        'type' => 'Checkbox',
	        'section' => 'header_section',

	    )
	);

	$wp_customize->add_setting('feminine_mentor_theme_options[header_full_width]',
	    array(
	        'type' => 'option',
	        'default'        => true,
	        'default' => $feminine_mentor_options['header_full_width'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_checkbox',
	    )
	);

	$wp_customize->add_control('feminine_mentor_theme_options[header_full_width]',
	    array(
	        'label' => esc_html__('Full Width?', 'feminine-mentor'),
	        'type' => 'Checkbox',
	        'section' => 'header_section',

	    )
	);

	$wp_customize->add_section(
    'footer_section',
	    array(
	        'title' => esc_html__( 'Footer Option','feminine-mentor' ),
	       	'description' => esc_html__( 'Copyright text can be changed in Premium Version','feminine-mentor' ),
	        'panel'=>'theme_options',
	        'capability'=>'edit_theme_options',
	    )
	);

	$wp_customize->add_setting('feminine_mentor_theme_options[show_widgets]',
	    array(
	        'type' => 'option',
	        'default'        => true,
	        'default' => $feminine_mentor_options['show_widgets'],
	        'sanitize_callback' => 'feminine_mentor_sanitize_checkbox',
	    )
	);

	$wp_customize->add_control('feminine_mentor_theme_options[show_widgets]',
	    array(
	        'label' => esc_html__('Show Widgets', 'feminine-mentor'),
	        'type' => 'Checkbox',
	        'priority' => 1,
	        'section' => 'footer_section',

	    )
	);


}
add_action( 'customize_register', 'feminine_mentor_customize_register' );

/**
 * Render the site title for the selective refresh partial.
 *
 * @return void
 */
function feminine_mentor_customize_partial_blogname() {
	bloginfo( 'name' );
}

/**
 * Render the site tagline for the selective refresh partial.
 *
 * @return void
 */
function feminine_mentor_customize_partial_blogdescription() {
	bloginfo( 'description' );
}

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function feminine_mentor_customize_preview_js() {
	wp_enqueue_script( 'feminine-mentor-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), _S_VERSION, true );
}
add_action( 'customize_preview_init', 'feminine_mentor_customize_preview_js' );
