<?php
/**
 * Rest House functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Rest House
 */

if (!defined('REST_HOUSE_VERSION')) {
	define('REST_HOUSE_VERSION', wp_get_theme()->get('Version'));
}

// Theme setup
if (!function_exists('rest_house_setup')) :
	function rest_house_setup() {

		define('REST_HOUSE_LIVE_DEMO', 'https://demos.buywptemplates.com/rest-house/');
		define('REST_HOUSE_BUY_PRO', 'https://www.buywptemplates.com/products/dormitory-wordpress-theme');
		define('REST_HOUSE_PRO_DOC', 'https://demos.buywptemplates.com/demo/docs/rest-house-pro/');
		define('REST_HOUSE_FREE_DOC', 'https://demos.buywptemplates.com/demo/docs/rest-house-lite/');
		define('REST_HOUSE_PRO_SUPPORT', 'https://buywptemplates.com/pages/community');
		define('REST_HOUSE_FREE_SUPPORT', 'https://wordpress.org/support/theme/rest-house/');
		define('REST_HOUSE_REVIEW', 'https://wordpress.org/support/theme/rest-house/reviews/');
		define('REST_HOUSE_CREDIT', 'https://www.buywptemplates.com/products/rest-house');

		load_theme_textdomain('rest-house', get_template_directory() . '/languages');

		add_theme_support('automatic-feed-links');
		add_theme_support('align-wide');
		add_theme_support('woocommerce');
		add_theme_support('wp-block-styles');
		add_editor_style('style.css');

		add_theme_support('custom-logo', array(
			'height' => 192,
			'width' => 192,
			'flex-width' => true,
			'flex-height' => true,
		));

		add_theme_support('block-nav-menus');
		add_theme_support('experimental-link-color');
	}
endif;
add_action('after_setup_theme', 'rest_house_setup');

// Frontend scripts and styles
function rest_house_scripts() {
	wp_enqueue_style('rest-house-style', get_stylesheet_uri(), array());
	wp_enqueue_script('rest-house-jquery-wow', get_template_directory_uri() . '/js/wow.js', array('jquery'));
	wp_enqueue_style('rest-house-animate-css', get_template_directory_uri() . '/css/animate.css');
	wp_enqueue_style('rest-house-swiper-css', get_template_directory_uri() . '/css/swiper-bundle.css');
	wp_enqueue_script('rest-house-swiper-js', get_template_directory_uri() . '/js/swiper-bundle.js', array('jquery'));
	wp_enqueue_script('rest-house-custom-scripts', get_template_directory_uri() . '/js/custom.js', array('jquery'), '', true);
	wp_enqueue_style('rest-house-font-awesome-css', get_template_directory_uri() . '/css/fontawesome-all.css');
	wp_style_add_data('rest-house-style', 'rtl', 'replace');
}
add_action('wp_enqueue_scripts', 'rest_house_scripts');

// Block editor styles
function rest_house_block_editor_styles() {
	wp_enqueue_style('rest-house-block-patterns-style-editor', get_theme_file_uri('/css/block-editor.css'), false, '1.0', 'all');
}
add_action('enqueue_block_editor_assets', 'rest_house_block_editor_styles');

// Initialize block patterns & TGM
function rest_house_init_setup() {
	require get_template_directory() . '/inc/block-patterns.php';
	require_once get_template_directory() . '/inc/tgm/tgm.php';
}
add_action('after_setup_theme', 'rest_house_init_setup');

// Load Getting Started info
require get_template_directory() . '/inc/dashboard/get_started_info.php';

// Section Pro Customizer
require get_template_directory() . '/inc/section-pro/customizer.php';
