<?php
//Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;


function real_estate_vital_setup() {
	/**
	* Add image size for slider
	*/
	add_image_size( 'real-estate-vital-slider', 1440, 700, true );
}
add_action( 'after_setup_theme', 'real_estate_vital_setup' );

//Enque styles and scripts
function real_estate_vital_enqueue_styles() {
	$parenthandle = 'real-estate-salient-style';
	 $theme = wp_get_theme();   
    //Load Parent theme style.css
    wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', 
        array(),  // if the parent theme code has a dependency, copy it to here
        $theme->parent()->get('Version')
    );
	// Swiper CSS
	wp_enqueue_style( 'real-estate-vital-swiper', get_stylesheet_directory_uri() . '/css/swiper-bundle.min.css' );
	// Custom property CSS
	wp_enqueue_style( 'real-estate-vital-custom-property', get_stylesheet_directory_uri(). '/css/customproperty.css', array());
	// Font Awesome 6
	wp_enqueue_style( 'real-estate-vital-font-awesome', get_stylesheet_directory_uri(). '/css/fontawesomeall.min.css', array());
	//Load child theme style.css
    wp_enqueue_style( 'real-estate-vital', get_stylesheet_uri(),
        array( $parenthandle ),
        $theme->get('Version') // this only works if you have Version in the style header
    );

	// Load Swiper
	wp_enqueue_script( 'real-estate-vital-swiper', get_stylesheet_directory_uri() . '/js/swiper-bundle.min.js', array( 'jquery' ) );
	wp_enqueue_script( 'real-estate-vital-sidr', get_stylesheet_directory_uri() . '/js/jquery.sidr.min.js', array( 'jquery' ) );
	// Custom JS File
	wp_enqueue_script( 'real-estate-vital', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'real_estate_vital_enqueue_styles', 10 );


/**
 * Load Google Font
 */
function real_estate_vital_enque_google_font() {
	// Include the file.
	require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );

	// Load the webfont.
	wp_enqueue_style( 'real-estate-vital-poppins', wptt_get_webfont_url( 'https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap' ), array(), '1.0');
}
add_action( 'wp_enqueue_scripts', 'real_estate_vital_enque_google_font' );

/**
 * Customizer settings for Mobile on top bar
 */
function real_estate_vital_customize($wp_customize) {
	//Remove unused feature
	$wp_customize->remove_setting('real_estate_salient_myaccount_page');
	$wp_customize->remove_control('real_estate_salient_myaccount_page');	
	$wp_customize->remove_setting('real_estate_salient_topbarsocial_enable');
	$wp_customize->remove_control('real_estate_salient_topbarsocial_enable');
	$wp_customize->remove_setting('real_estate_salient_topbar_linkedin');
	$wp_customize->remove_control('real_estate_salient_topbar_linkedin');
	$wp_customize->remove_setting('real_estate_salient_topbar_facebook');
	$wp_customize->remove_control('real_estate_salient_topbar_facebook');
	$wp_customize->remove_setting('real_estate_salient_topbar_twitter');
	$wp_customize->remove_control('real_estate_salient_topbar_twitter');
	$wp_customize->remove_setting('real_estate_salient_topbarsubmit_enable');
	$wp_customize->remove_control('real_estate_salient_topbarsubmit_enable');
	$wp_customize->remove_setting('real_estate_salient_submit_page');
	$wp_customize->remove_control('real_estate_salient_submit_page');
	$wp_customize->remove_setting('real_estate_salient_latestproperties_link');
	$wp_customize->remove_control('real_estate_salient_latestproperties_link');

	// Add customizer option to add contact number or text on left side
	$wp_customize->add_setting('real_estate_vital_top_mobile', array(
	    'sanitize_callback' => 'sanitize_text_field',
	    'default' => __('+00-000-000','real-estate-vital')
	));

	$wp_customize->add_control( 'real_estate_vital_top_mobile', array(
	    'label'   => __( 'Top bar text','real-estate-vital' ),
	    'section' => 'real_estate_salient_topbar',
	    'description' => __( 'Add your contact number or any other text here', 'real-estate-vital' ),
	    'type' => 'text',
	    'priority'   => 2
	));

	// Add customizer option to add email id on left side
	$wp_customize->add_setting( 'real_estate_vital_top_email', array(
	    'sanitize_callback' => 'sanitize_text_field',
	    'default' => __( 'yourmail@somemail.com','real-estate-vital' )
	));

	$wp_customize->add_control('real_estate_vital_top_email', array(
	    'label'   => __('Top bar text','real-estate-vital'),
	    'section' => 'real_estate_salient_topbar',
	    'description' => __( 'Add your contact number or any other text here', 'real-estate-vital' ),
	    'type' => 'text',
	    'priority'   => 2
	));

	// Add Option to edit title of home recent posts
	$wp_customize->add_setting('real_estate_vital_recent_post_desc', array(
	    'sanitize_callback' => 'sanitize_text_field',
	    'default' => __( 'You are seeing recently added posts','real-estate-vital' )
	));

	$wp_customize->add_control( 'real_estate_vital_recent_post_desc', array(
	    'label'   => __( 'Recent Posts Description','real-estate-vital' ),
	    'section' => 'real_estate_salient_homepage',
	    'type' => 'text',
	    'priority'   => 10
	));

	// Add Option to edit title of home recent posts
	$wp_customize->add_setting('real_estate_vital_recent_post_title', array(
	    'sanitize_callback' => 'sanitize_text_field',
	    'default' => __( 'Recent News','real-estate-vital' )
	));

	$wp_customize->add_control( 'real_estate_vital_recent_post_title', array(
	    'label'   => __( 'Recent Posts Title','real-estate-vital' ),
	    'section' => 'real_estate_salient_homepage',
	    'type' => 'text',
	    'priority'   => 9
	));
	#####---=== Enable Recent Posts ===--- #####
	$wp_customize->add_setting('real_estate_vital_recent_post', array(
	    'capability'     => 'edit_theme_options',
	    'sanitize_callback' => 'real_estate_salient_sanitize_checkbox',
	    'default' => true,
	));

	$wp_customize->add_control('real_estate_vital_recent_post', array(
	    'label'   => __('Enable Recent Posts','real-estate-vital'),
	    'section' => 'real_estate_salient_homepage',
	    'type' => 'checkbox',
	    'priority'   => 8
	));
}

add_action( 'customize_register', 'real_estate_vital_customize', 999, 1 );

/**
 * Template settings additions.
 */
require get_stylesheet_directory() . '/inc/template-tags.php';

