<?php
/**
 * Theme Customizer Controls
 *
 * @package somalite
 */


if ( ! function_exists( 'somalite_customizer_general_settings_register' ) ) :
function somalite_customizer_general_settings_register( $wp_customize ) {
     
    // General Settings
    $wp_customize->add_section(
        'soma_general_settings',
        array (
            'priority'      => 25,
            'capability'    => 'edit_theme_options',
            'theme_supports'=> '',
            'title'         => esc_html__( 'General Settings', 'somalite' )
        )
    );

    // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_disable_title', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_disable_title', 
        array(
            'label'       => esc_html__( 'Disable / Enable Section', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_disable_title',
        ) 
    ));


    // Parallax Scroll for background image 
    $wp_customize->add_setting(
        'sm_home_section_disable',
        array(
            'type' => 'theme_mod',
            'default'           => false,
            'sanitize_callback' => 'somalite_sanitize_checkbox'
        )
    );

    $wp_customize->add_control( 
        new Somalite_Toggle_Control( $wp_customize, 'sm_home_section_disable', 
        array(
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-toggle',
            'settings'    => 'sm_home_section_disable',
            'label'         => esc_html__( 'Disable Home Background Section', 'somalite' ),
            'description'   => esc_html__( 'Choose whether to show or hide the Home Background Section', 'somalite' ),
        ) 
    ));


    // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_bg_title', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_bg_title', 
        array(
            'label'       => esc_html__( 'Home Section Background Image', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_bg_title',
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Home Background Image 
    $wp_customize->add_setting(
        'sm_theme_home_bg',
        array(
            'type' => 'theme_mod',
            'sanitize_callback' => 'somalite_sanitize_image'
        )
    );

    $wp_customize->add_control(
      new WP_Customize_Image_Control(
          $wp_customize,
          'sm_theme_home_bg',
          array(
              'settings'      => 'sm_theme_home_bg',
              'section'       => 'soma_general_settings',
              'label'         => esc_html__( 'Home Background Image', 'somalite' ),
              'description'   => esc_html__( 'Upload background image for your home section', 'somalite' ),
              'active_callback' => 'somalite_home_background_section_disable',
          )
      )
    );

    // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_content_title', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_content_title', 
        array(
            'label'       => esc_html__( 'Home Section Content', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_content_title',
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Home Section Heading text 
    $wp_customize->add_setting(
        'sm_home_heading_text',
        array(            
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field',
            'transport' => 'postMessage',
        )
    );

    $wp_customize->add_control(
        'sm_home_heading_text',
        array(
            'settings'      => 'sm_home_heading_text',
            'section'       => 'soma_general_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Heading Text', 'somalite' ),
            'description'   => esc_html__( 'heading for the home section', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );

    $wp_customize->selective_refresh->add_partial( 'sm_home_heading_text', array(
        'selector'            => '.promo-section h1',   
        'settings'            => 'sm_home_heading_text',     
        'render_callback'     => 'somalite_home_heading_text_render_callback',
        'fallback_refresh'    => false, 
    ));

    // Home Section SubHeading text
    $wp_customize->add_setting(
        'sm_home_subheading_text',
        array(            
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field',
            'transport' => 'postMessage',
        )
    );

    $wp_customize->add_control(
        'sm_home_subheading_text',
        array(
            'settings'      => 'sm_home_subheading_text',
            'section'       => 'soma_general_settings',
            'type'          => 'textarea',
            'label'         => esc_html__( 'SubHeading Text', 'somalite' ),
            'description'   => esc_html__( 'Subheading for the home section', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );

    $wp_customize->selective_refresh->add_partial( 'sm_home_subheading_text', array(
        'selector'            => '.promo-section p',   
        'settings'            => 'sm_home_subheading_text',     
        'render_callback'     => 'somalite_home_subheading_text_render_callback',
        'fallback_refresh'    => false, 
    ));


    // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_buttons_title', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_buttons_title', 
        array(
            'label'       => esc_html__( 'Home Section Buttons', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_buttons_title',
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Home Section Button text 
    $wp_customize->add_setting(
        'sm_home_button_text',
        array( 
            'type' => 'theme_mod',           
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field',
            
        )
    );

    $wp_customize->add_control(
        'sm_home_button_text',
        array(
            'settings'      => 'sm_home_button_text',
            'section'       => 'soma_general_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Button Text', 'somalite' ),
            'description'   => esc_html__( 'Button text for the home section', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );  


    // Home Section Button url 
    $wp_customize->add_setting(
        'sm_home_button_url',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_url'
        )
    );

    $wp_customize->add_control(
        'sm_home_button_url',
        array(
            'settings'      => 'sm_home_button_url',
            'section'       => 'soma_general_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Button URL', 'somalite' ),
            'description'   => esc_html__( 'Button URL for the home section, you can paste youtube or vimeo video url also', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );


    // Home Section Button2 text
    $wp_customize->add_setting(
        'sm_home_button2_text',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'sm_home_button2_text',
        array(
            'settings'      => 'sm_home_button2_text',
            'section'       => 'soma_general_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Button 2 Text', 'somalite' ),
            'description'   => esc_html__( 'Button 2 text for the home section', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );


    // Home Section Button2 url 
    $wp_customize->add_setting(
        'sm_home_button2_url',
        array(
            'type' => 'theme_mod',
            'default'           => '',
            'sanitize_callback' => 'somalite_sanitize_url'
        )
    );

    $wp_customize->add_control(
        'sm_home_button2_url',
        array(
            'settings'      => 'sm_home_button2_url',
            'section'       => 'soma_general_settings',
            'type'          => 'textbox',
            'label'         => esc_html__( 'Button 2 URL', 'somalite' ),
            'description'   => esc_html__( 'Button 2 URL for the home section, you can paste youtube or vimeo video url also', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        )
    );

     // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_parallax', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_parallax', 
        array(
            'label'       => esc_html__( 'Parallax Settings', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_parallax',
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Parallax Scroll for background image 
    $wp_customize->add_setting(
        'sm_home_parallax',
        array(
            'type' => 'theme_mod',
            'default'           => true,
            'sanitize_callback' => 'somalite_sanitize_checkbox'
        )
    );

    $wp_customize->add_control( 
        new Somalite_Toggle_Control( $wp_customize, 'sm_home_parallax', 
        array(
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-toggle',
            'settings'    => 'sm_home_parallax',
            'label'         => esc_html__( 'Enable Parallax scroll:', 'somalite' ),
            'description'   => esc_html__( 'Choose whether to show a parallax scroll feature for the Home Background image', 'somalite' ),
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Title label
    $wp_customize->add_setting( 
        'somalite_label_home_section_extra', 
        array(
            'sanitize_callback' => 'somalite_sanitize_title',
        ) 
    );

    $wp_customize->add_control( 
        new Somalite_Title_Info_Control( $wp_customize, 'somalite_label_home_section_extra', 
        array(
            'label'       => esc_html__( 'Extra Settings', 'somalite' ),
            'section'     => 'soma_general_settings',
            'type'        => 'somalite-title',
            'settings'    => 'somalite_label_home_section_extra',
            'active_callback' => 'somalite_home_background_section_disable',
        ) 
    ));

    // Image over background
    $wp_customize->add_setting(
        'sm_home_image_over_bg',
        array(
            'type' => 'theme_mod',
            'sanitize_callback' => 'somalite_sanitize_image'
        )
    );

    $wp_customize->add_control(
      new WP_Customize_Image_Control(
          $wp_customize,
          'sm_home_image_over_bg',
          array(
              'settings'      => 'sm_home_image_over_bg',
              'section'       => 'soma_general_settings',
              'label'         => esc_html__( 'Add Image over Home Background', 'somalite' ),
              'description'   => esc_html__( 'Upload image just above the text for your home section', 'somalite' ),
              'active_callback' => 'somalite_home_background_section_disable',
          )
      )
    );

}
endif;

add_action( 'customize_register', 'somalite_customizer_general_settings_register' );