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

if ( ! function_exists( 'festival_events_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 festival_events_setup() {
	load_theme_textdomain( 'festival-events', get_template_directory() . '/languages' );

	/**
	 * 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';

}
endif;
add_action( 'after_setup_theme', 'festival_events_setup' );

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

function festival_events_setup_theme() {
	if ( ! defined( 'FESTIVAL_EVENTS_PREMIUM_PAGE' ) ) {
		define('FESTIVAL_EVENTS_PREMIUM_PAGE',__('https://www.theclassictemplates.com/products/festival-wordpress-theme','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_PRO_NAME' ) ) {
		define( 'FESTIVAL_EVENTS_PRO_NAME', __( 'About Festival Events', 'festival-events' ));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_THEME_PAGE' ) ) {
		define('FESTIVAL_EVENTS_THEME_PAGE',__('https://www.theclassictemplates.com/collections/best-wordpress-templates','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_SUPPORT' ) ) {
		define('FESTIVAL_EVENTS_SUPPORT',__('https://wordpress.org/support/theme/festival-events/','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_REVIEW' ) ) {
		define('FESTIVAL_EVENTS_REVIEW',__('https://wordpress.org/support/theme/festival-events/reviews/','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_PRO_DEMO' ) ) {
		define('FESTIVAL_EVENTS_PRO_DEMO',__('https://live.theclassictemplates.com/festival-events-pro/','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_THEME_DOCUMENTATION' ) ) {
		define('FESTIVAL_EVENTS_THEME_DOCUMENTATION',__('https://live.theclassictemplates.com/demo/docs/festival-events-free/','festival-events'));
	}
	if ( ! defined( 'FESTIVAL_EVENTS_BUNDLE_PAGE' ) ) {
		define('FESTIVAL_EVENTS_BUNDLE_PAGE',__('https://www.theclassictemplates.com/products/wordpress-theme-bundle','festival-events'));
	}
}
add_action('after_setup_theme', 'festival_events_setup_theme');

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

add_filter( 'woocommerce_enable_setup_wizard', '__return_false' );