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



if ( ! function_exists( 'ice_cream_dish_support' ) ) :
	function ice_cream_dish_support() {

		load_theme_textdomain( 'ice-cream-dish', get_template_directory() . '/languages' );
		
		add_theme_support( 'html5', array(
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		add_theme_support( 'custom-background', apply_filters( 'ice_cream_dish_custom_background', array(
            'default-color' => 'ffffff',
            'default-image' => '',
        )));
		
		add_theme_support( 'wp-block-styles' );

		add_editor_style( 'style.css' );

		define('ICE_CREAM_DISH_BUY_NOW',__('https://www.themescarts.com/products/solar-wordpress-theme/','ice-cream-dish'));
		define('ICE_CREAM_DISH_FOOTER_BUY_NOW',__('https://www.themescarts.com/products/ice-cream-dish/','ice-cream-dish'));

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


if ( ! function_exists( 'ice_cream_dish_setup' ) ) :
	function ice_cream_dish_setup() {

		load_theme_textdomain( 'ice-cream-dish', 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_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' );
		register_nav_menus(
			array(
				'primary' => __( 'Primary Navigation', 'ice-cream-dish' ),
			)
		);
	}
endif;
add_action( 'after_setup_theme', 'ice_cream_dish_setup' );

/**
 * Enqueue scripts and styles.
 */
function ice_cream_dish_scripts() {
	$min  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

	$theme_version = wp_get_theme()->get( 'Version' );

	$deps = array( 'dashicons' );
	global $wp_styles;
	if ( in_array( 'wc-blocks-vendors-style', $wp_styles->queue ) ) {
		$deps[] = 'wc-blocks-vendors-style';
	}

	// Enqueue for frontend
	wp_enqueue_script( 'ice-cream-dish-theme-script', get_theme_file_uri( '/js/theme.js' ), array( 'jquery' ), true );

	wp_enqueue_style( 'ice-cream-dish-style', get_stylesheet_uri(), $deps, date( 'Ymd-Gis', filemtime( get_theme_file_path( 'style.css' ) ) ) );

	$ice_cream_dish_enable_animations = get_option( 'ice_cream_dish_enable_animations', true );

    if ( $ice_cream_dish_enable_animations ) {
        //animation
		wp_enqueue_script( 'wow-script', get_theme_file_uri( '/js/wow.js' ), array( 'jquery' ), true );

		wp_enqueue_style( 'animate-css', get_template_directory_uri().'/css/animate.css' );
    }

	wp_style_add_data('ice-cream-dish', 'rtl', 'replace');

	
	wp_enqueue_style( 'owl.carousel-css', get_template_directory_uri() . '/css/owl.carousel.css', array(),'2.3.4');

	wp_enqueue_script( 'owl.carousel-js', get_template_directory_uri() . '/js/owl.carousel.js', array('jquery'), '2.3.4', TRUE );

}
add_action( 'wp_enqueue_scripts', 'ice_cream_dish_scripts' );

/**
 * Enqueue admin scripts and styles.
 */
function ice_cream_dish_admin_scripts() {
	$min  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

	$theme_version = wp_get_theme()->get( 'Version' );

	$deps = array();

	$screen = get_current_screen();
	if ( is_admin() && $screen && !$screen->is_block_editor() ) {
		wp_enqueue_style( 'ice-cream-dish-admin-style', get_stylesheet_directory_uri() . '/css/admin-style.css', $deps, date( 'Ymd-Gis', filemtime( get_theme_file_path( 'style.css' ) ) ) );
	}

	wp_enqueue_style(
		'ice-cream-dish-admin-css',
		get_template_directory_uri() . '/notice-getstart/theme-info.css',
		[],
		wp_get_theme()->get( 'Version' )
	);

	// Enqueue JS
	wp_enqueue_script(
		'ice-cream-dish-admin-js',
		get_template_directory_uri() . '/notice-getstart/theme-info.js',
		[],
		wp_get_theme()->get( 'Version' ),
		true // Load in footer
	);
}
add_action( 'admin_enqueue_scripts', 'ice_cream_dish_admin_scripts' );

function ice_cream_dish_block_editor_styles() {
	wp_enqueue_style( 'ice-cream-dish-block-editor-style', get_stylesheet_directory_uri() . '/css/admin-style.css', array(), date( 'Ymd-Gis', filemtime( get_theme_file_path( 'style.css' ) ) ) );
}
add_action( 'enqueue_block_assets', 'ice_cream_dish_block_editor_styles' );

/**
 * Load core file.
 */
require_once get_template_directory() . '/core/init.php';


/** 
 * Customizer
 */
require get_template_directory() . '/core/section-pro/customizer.php';

/** 
 * Animation
 */

require get_template_directory() . '/animation-setting.php';




/**
 * Current theme path.
 * Current theme url.
 * Current theme version.
 * Current theme name.
 * Current theme option name.
 */
define( 'ICE_CREAM_DISH_PATH', trailingslashit( get_template_directory() ) );
define( 'ICE_CREAM_DISH_URL', trailingslashit( get_template_directory_uri() ) );
define( 'ICE_CREAM_DISH_VERSION', '1.0.0' );
define( 'ICE_CREAM_DISH_THEME_NAME', 'ice-cream-dish' );
define( 'ICE_CREAM_DISH_OPTION_NAME', 'ice-cream-dish' );

/**
 * The core theme class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require ICE_CREAM_DISH_PATH . 'notice-getstart/main.php';


/**
 * Begins execution of the theme.
 *
 * @since    1.0.0
 */
function ice_cream_dish_run() {
	new Ice_Cream_Dish();
}
ice_cream_dish_run();
