<?php

/**
 * Real Estate Company functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Real Estate Company
 */

define( 'real_estate_company_VERSION', wp_get_theme()->get( 'Version' ) );

if ( ! function_exists( 'real_estate_company_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 for post thumbnails.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */
	function real_estate_company_setup() {

		// Make theme available for translation.
		load_theme_textdomain( 'real-estate-company', get_template_directory() . '/languages' );

		// Add theme support
		add_theme_support( 'automatic-feed-links' );
		add_theme_support( 'wp-block-styles' );
		add_theme_support( 'title-tag' );
		add_theme_support( 'post-thumbnails' );
		add_theme_support( 'editor-styles' );
		add_theme_support( 'html5', array( 'comment-form', 'comment-list' ) );
		add_theme_support( 'responsive-embeds' );
		add_theme_support( 'customize-selective-refresh-widgets' );
	}
}
add_action( 'after_setup_theme', 'real_estate_company_setup' );

/**
 * Enqueue scripts and styles
 */
function real_estate_company_scripts() {
	$version = wp_get_theme( 'real-estate-company' )->get( 'Version' );
	// Stylesheet
	wp_enqueue_style( 'real-estate-company-styles', get_theme_file_uri( '/style.css' ), array(), $version );

	if ( file_exists( get_template_directory() . '/assets/css/theme-style.css' ) ) {
		wp_enqueue_style( 'real-estate-company-theme-style', get_template_directory_uri() . '/assets/css/theme-style.css',  array(), $version );
	}
}
add_action( 'wp_enqueue_scripts', 'real_estate_company_scripts' );

/**
 * Add editor styles
 */
function real_estate_company_editor_style() {
    wp_enqueue_style( 'real-estate-company-editor-style', get_template_directory_uri() . '/assets/css/editor-style.css', array(), '1.0' );
}
add_action( 'enqueue_block_editor_assets', 'real_estate_company_editor_style' );

/**
 * Enqueue assets scripts for both backend and frontend
 */
function real_estate_company_block_assets()
{
    wp_enqueue_style( 'real-estate-company-blocks-style', get_template_directory_uri() . '/assets/css/blocks.css' );
}
add_action( 'enqueue_block_assets', 'real_estate_company_block_assets' );


/**
 * Enqueue the admin CSS files.
 *
 * @since 1.0.0
 *
 * @return void
 */
function real_estate_company_admin_styles() {
	wp_enqueue_style(
		'real-estate-company-theme-dashboard-style',
		get_template_directory_uri() . '/assets/css/theme-info.css',
		[],
		real_estate_company_VERSION
	);
}
add_action( 'admin_enqueue_scripts', 'real_estate_company_admin_styles' );

/**
 * Load core file
 */
require get_theme_file_path() . '/inc/core/init.php';

// Theme dashboard.
require get_theme_file_path( 'inc/theme-info.php' );

/**
 * Load Real Estate Company Dashboard
 */
require get_template_directory() . '/inc/admin/class-real-estate-company-admin.php';
require get_template_directory() . '/inc/admin/class-real-estate-company-notice.php';
require_once get_template_directory() . '/inc/pro-themes.php';

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