<?php
/**
 * The template for loaded all third party css & js files.
 *
 * @link https://developer.wordpress.org/themes/basics/including-css-javascript/
 *
 * The template loading under functions.php
 *
 * @package RB_Themes
 * @subpackage RB_Blog_Two
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/*
=========================================
Table of Third Party Assets List Start Here
===========================================
	01. Prefix with file directory
	02. Font Awesome
	03. Bootstrap
	04. OwlCarousel2
	05. jQuery Nice Select
	06. jQuery meanMenu
*/

// Home Root.
define( 'THEME_ROOT', get_template_directory_uri() );

// Font Awesome Root.
define( 'FONT_AWESOME_CSS', THEME_ROOT . '/third-party/font-awesome/css/' );

// Bootstrap Root.
define( 'BOOTSTRAP_ASSETS', THEME_ROOT . '/third-party/bootstrap/' );

// Swiper Root.
define( 'SWIPER_ASSETS', THEME_ROOT . '/third-party/swiper/' );

// jQuery meanMenu Root.
define( 'MEAN_MENU_ASSETS', THEME_ROOT . '/third-party/mean-menu/' );

/**
 * Remove Elementor FontAwesome
 */
if ( ! function_exists( 'rb_blog_two_remove_elementor_font_awesome' ) ) {
	/**
	 * Remove Elementor default Font Awesome.
	 */
	function rb_blog_two_remove_elementor_font_awesome() {
		// Remove Elementor registered FA styles.
		wp_deregister_style( 'elementor-icons-fa-solid' );
		wp_deregister_style( 'elementor-icons-fa-regular' );
		wp_deregister_style( 'elementor-icons-fa-brands' );
		wp_deregister_style( 'elementor-icons-fa' );

		// Sometimes Elementor Pro uses this handle.
		wp_deregister_style( 'font-awesome' );
	}
	add_action( 'elementor/frontend/after_register_styles', 'rb_blog_two_remove_elementor_font_awesome', 5 );
}

/***************************
 * **** 02. Font Awesome *****
 ***************************/
function rb_blog_two_fontawesome_css() {
	wp_enqueue_style( 'font-awesome', FONT_AWESOME_CSS . 'font-awesome.css', '', '6.4.2', 'all' );
}
add_action( 'wp_enqueue_scripts', 'rb_blog_two_fontawesome_css' );

/************************
 * **** 03. Bootstrap *****
 ************************/
function rb_blog_two_bootstrap_assets() {
	// Bootstrap CSS.
	if ( is_rtl() ) {
		wp_enqueue_style( 'bootstrap-rtl', BOOTSTRAP_ASSETS . 'bootstrap.rtl.css', '', '5.3.2', 'all' );
	} else {
		wp_enqueue_style( 'bootstrap', BOOTSTRAP_ASSETS . 'bootstrap.css', '', '5.3.2', 'all' );
	}
}
add_action( 'wp_enqueue_scripts', 'rb_blog_two_bootstrap_assets' );

/*********************
 * **** 04. Swiper *****
 *********************/
function rb_blog_two_swiper_assets() {
	// Swiper CSS.
	wp_enqueue_style( 'swiper-bundle', SWIPER_ASSETS . 'swiper-bundle.css', '', '11.0.4', 'all' );

	// Swiper JS.
	wp_enqueue_script( 'swiper-bundle', SWIPER_ASSETS . 'swiper-bundle.js', array( 'jquery' ), '11.0.4', true );
}
add_action( 'wp_enqueue_scripts', 'rb_blog_two_swiper_assets' );

/******************************
 * **** 06. jQuery meanMenu *****
 ******************************/
function rb_blog_two_mean_menu_assets() {
	// Mean Menu.
	wp_enqueue_style( 'meanmenu', MEAN_MENU_ASSETS . 'meanmenu.css', '', '2.0.7', 'all' );

	// Mean Menu.
	wp_enqueue_script( 'jquery-meanmenu', MEAN_MENU_ASSETS . 'jquery.meanmenu.js', array( 'jquery' ), '2.0.8', true );
}
add_action( 'wp_enqueue_scripts', 'rb_blog_two_mean_menu_assets' );
