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

if ( ! defined( 'AI_MACHINE_LEARNING_VERSION' ) ) {
	// Replace the version number of the theme on each release.
	define( 'AI_MACHINE_LEARNING_VERSION', wp_get_theme()->get( 'Version' ) );
}

if ( ! function_exists( 'ai_machine_learning_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.
	 */
	function ai_machine_learning_setup() {

		load_theme_textdomain( 'ai-machine-learning', get_template_directory() . '/languages' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );

		add_theme_support( 'align-wide' );

		add_theme_support( 'woocommerce' );

		// Add support for block styles.
		add_theme_support( 'wp-block-styles' );

		// Enqueue editor styles.
		add_editor_style( 'style.css' );

		// Experimental support for adding blocks inside nav menus
		add_theme_support( 'block-nav-menus' );

		// Add support for experimental link color control.
		add_theme_support( 'experimental-link-color' );
	}
endif;
add_action( 'after_setup_theme', 'ai_machine_learning_setup' );

function ai_machine_learning_scripts() {

    wp_enqueue_style('ai-machine-learning-style', get_stylesheet_uri(), array() );
    wp_enqueue_script('jquery-wow', get_template_directory_uri() . '/assets/js/wow.js', array('jquery'));
    wp_enqueue_style('animate-css', get_template_directory_uri() . '/assets/css/animate.css');

    //font-awesome
    wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/font-awesome/css/all.css', array(), '7.0.0' );
    wp_enqueue_style( 'owl.carousel-style', get_template_directory_uri().'/assets/css/owl.carousel.css', array(), '2.2.1');
    wp_enqueue_script( 'owl.carousel-js', get_template_directory_uri(). '/assets/js/owl.carousel.js', array('jquery') , '2.3');
    
    wp_enqueue_script('ai-machine-learning-custom-scripts', get_template_directory_uri() . '/assets/js/custom.js', array('jquery'), '', true);
    wp_style_add_data( 'ai-machine-learning-style', 'rtl', 'replace' );

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


/**
 * Enqueue block editor styles
 */
function ai_machine_learning_enqueue_block_editor_styles() {
    wp_enqueue_style(
        'ai-machine-learning-block-editor-style', // Handle
        get_theme_file_uri( '/assets/css/block-editor.css' ), // File URI
        array(), // Dependencies
        filemtime( get_theme_file_path( '/assets/css/block-editor.css' ) ) // Version with file modification time for cache busting
    );
}
add_action( 'enqueue_block_editor_assets', 'ai_machine_learning_enqueue_block_editor_styles' );


function ai_machine_learning_init_setup() {

    // Add block patterns
    require get_template_directory() . '/inc/block-patterns.php';   
}
add_action( 'after_setup_theme', 'ai_machine_learning_init_setup' );