<?php

/**
 * Who we are Settings
 *
 * @package relax_spa
 */

add_action('customize_register', 'relax_spa_customize_who_we_are_option');

function relax_spa_customize_who_we_are_option($wp_customize)
{

    $wp_customize->add_section('relax_spa_who_we_are_section', array(
        'title'         => esc_html__('Who we are Section', 'relax-spa'),
        'panel'         => 'relax_spa_homepage_panel'
    ));

    $wp_customize->add_setting('bs_who_we_are_display_option', array(
        'sanitize_callback' => 'relax_spa_sanitize_checkbox',
        'default' => true
    ));

    $wp_customize->add_control(new Relax_Spa_Toggle_Control($wp_customize, 'bs_who_we_are_display_option', array(
        'label' => esc_html__('Hide / Show', 'relax-spa'),
        'section' => 'relax_spa_who_we_are_section',
        'type' => 'relax-spa-toggle',
    )));

    $wp_customize->selective_refresh->add_partial('bs_who_we_are_display_option', array(
        'selector' => '#about .main-title .title', // You can also select a css class
    ));

    $wp_customize->add_setting('bs_heading_for_who_we_are', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
        'default' => ''
    ));

    $wp_customize->add_control('bs_heading_for_who_we_are', array(
        'label' => esc_html__('Enter Heading', 'relax-spa'),
        'section' => 'relax_spa_who_we_are_section',
        'type' => 'text',
    ));


    $wp_customize->add_setting('bs_who_we_are_pages', array(
        'sanitize_callback' => 'relax_spa_sanitize_select',
        'default' => ''
    ));
    $page_query = get_pages();
    $pages = array();
    $pages[''] = esc_attr__("-- Select --", 'relax-spa');
    foreach ($page_query as $page) {
        $pages[$page->post_name] = $page->post_title;
    }

    $wp_customize->add_control(new Relax_Spa_Select_Control($wp_customize, 'bs_who_we_are_pages', array(
        'label' => esc_html__('Select Page For Who we are Section :', 'relax-spa'),
        'section' => 'relax_spa_who_we_are_section',
        'settings' => 'bs_who_we_are_pages',
        'type' => 'relax-spa-select',
        'choices' => $pages,
    )));

    $wp_customize->add_setting('bs_button_name', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => esc_html__( 'Learn More', 'relax-spa' )
    ));

    $wp_customize->add_control('bs_button_name', array(
        'label' => esc_html__('Enter Button Label', 'relax-spa'),
        'section' => 'relax_spa_who_we_are_section',
        'type' => 'text',
    ));

    $wp_customize->selective_refresh->add_partial('bs_who_we_are_display_option', array(
        'selector' => '.about > .container',
    ));

    $wp_customize->add_setting( 'rs_who_we_are_image', array(
        'sanitize_callback'     =>  'relax_spa_sanitize_image',
        'default-image'      => get_template_directory_uri() . '/images/testimonial.webp',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control(
        $wp_customize, 'rs_who_we_are_image', array(
            'label'      => esc_html__( 'Image', 'relax-spa' ),
            'section'    => 'relax_spa_who_we_are_section',
            'settings'   => 'rs_who_we_are_image',
        )
    ) );
}
