<?php
/**
 * House Dealer functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @subpackage House Dealer
 * @since House Dealer 1.0
 */

if ( ! function_exists( 'house_dealer_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which runs
 * before the init hook. The init hook is too late for some features, such as indicating
 * support post thumbnails.
 */
function house_dealer_setup() {
	load_theme_textdomain( 'house-dealer', get_template_directory() . '/languages' );
}
endif;
add_action( 'after_setup_theme', 'house_dealer_setup' );

function house_dealer_block_assets(){
	wp_enqueue_style( 'house-dealer-fontawesome', get_template_directory_uri() . '/assets/font-awesome/css/all.css', array(), '7.1.0' );
	wp_enqueue_style( 'house-dealer-animatecss', get_template_directory_uri() . '/assets/css/animate.css');
	wp_enqueue_style( 'house-dealer-owlcarousel-css', get_template_directory_uri() . '/assets/css/owl.carousel.css');
	wp_enqueue_style( 'house-dealer-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
	wp_enqueue_script('house-dealer-wow-script', get_template_directory_uri() . '/assets/js/wow.js', array('jquery'));
	wp_enqueue_script('house-dealer-owlcarousel-js', get_template_directory_uri() . '/assets/js/owl.carousel.js', array('jquery'));
	wp_enqueue_script('house-dealer-script', get_template_directory_uri() . '/assets/js/script.js', array('jquery'), '1.0.0', true);
	wp_style_add_data( 'house-dealer-style', 'rtl', 'replace' );
}
add_action('enqueue_block_assets', 'house_dealer_block_assets');


/**
 * Load TGM.
 */
require get_template_directory() . '/inc/tgm/tgm.php';

/**
 * Notice.
 */
require_once get_template_directory() . '/inc/notice/notice.php';

/**
 * Theme Info Page.
 */
require get_template_directory() . '/inc/addon.php';

/**
 * Customizer
 */
require get_template_directory() . '/inc/customizer.php';

function house_dealer_setup_theme() {
	if ( ! defined( 'HOUSE_DEALER_PREMIUM_PAGE' ) ) {
		define('HOUSE_DEALER_PREMIUM_PAGE',__('https://www.theclassictemplates.com/products/property-management-wordpress-theme','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_PRO_NAME' ) ) {
		define( 'HOUSE_DEALER_PRO_NAME', __( 'About House Dealer', 'house-dealer' ));
	}
	if ( ! defined( 'HOUSE_DEALER_THEME_PAGE' ) ) {
		define('HOUSE_DEALER_THEME_PAGE',__('https://www.theclassictemplates.com/collections/best-wordpress-templates','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_SUPPORT' ) ) {
		define('HOUSE_DEALER_SUPPORT',__('https://wordpress.org/support/theme/house-dealer/','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_REVIEW' ) ) {
		define('HOUSE_DEALER_REVIEW',__('https://wordpress.org/support/theme/house-dealer/reviews/','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_PRO_DEMO' ) ) {
		define('HOUSE_DEALER_PRO_DEMO',__('https://live.theclassictemplates.com/house-dealer-pro/','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_THEME_DOCUMENTATION' ) ) {
		define('HOUSE_DEALER_THEME_DOCUMENTATION',__('https://live.theclassictemplates.com/demo/docs/house-dealer-free/','house-dealer'));
	}
	if ( ! defined( 'HOUSE_DEALER_BUNDLE_PAGE' ) ) {
		define('HOUSE_DEALER_BUNDLE_PAGE',__('https://www.theclassictemplates.com/products/wordpress-theme-bundle','house-dealer'));
	}
}
add_action('after_setup_theme', 'house_dealer_setup_theme');

function house_dealer_enqueue_admin_script($hook) {
    // Enqueue admin JS for notices
    wp_enqueue_script('house-dealer-welcome-notice', get_template_directory_uri() . '/inc/notice/notice.js', array('jquery'), '', true);
    
    // Localize script to pass data to JavaScript
    wp_localize_script('house-dealer-welcome-notice', 'house_dealer_localize', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('house_dealer_welcome_nonce'),
        'dismiss_nonce' => wp_create_nonce('house_dealer_welcome_nonce'), 
        'redirect_url' => admin_url('themes.php?page=house-dealer')
    ));
}
add_action('admin_enqueue_scripts', 'house_dealer_enqueue_admin_script');