<?php
/**
 * Load Core Files.
 *
 * @package Ayyash
 */

if ( ! defined( 'ABSPATH' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	die();
}

/** @define "THEMEOO_THEME_DIR" "./../" */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort

// phpcs:disable WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require THEMEOO_THEME_DIR . 'inc/vendor/class-tgm-plugin-activation.php';
require THEMEOO_THEME_DIR . 'inc/vendor/jetpack.php';

// Load customizer.
require THEMEOO_THEME_DIR . 'inc/customizer/class-themeoo-customize.php';

// Load core theme files.
require THEMEOO_THEME_DIR . 'inc/themeoo-tags.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-info.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-helper-functions.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-hooks.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-hook-helper.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-recommend-plugins.php';
require THEMEOO_THEME_DIR . 'inc/themeoo-register-widget.php';

// Elementor Related Options
if ( class_exists('Elementor\Plugin') ) {
	require THEMEOO_THEME_DIR . 'inc/class-themeoo-global-color.php';
	require THEMEOO_THEME_DIR . 'inc/class-themeoo-global-typography.php';
}

// WooCommerce & Related Addons.
if ( class_exists( 'WooCommerce' ) ) {
	require THEMEOO_THEME_DIR . 'inc/woocommerce/woocommerce.php';
	require THEMEOO_THEME_DIR . 'inc/woocommerce/yith-plugin-integration.php';
	require THEMEOO_THEME_DIR . 'inc/woocommerce/themeoo-woocommerce-hook-helper.php';
	require THEMEOO_THEME_DIR . 'inc/woocommerce/themeoo-woocommerce-hook.php';
}

// Mega Menu Extension.
require THEMEOO_THEME_DIR . 'inc/menu/menu.php';

// Header Button
require THEMEOO_THEME_DIR . 'inc/themeoo-header-button.php';

if ( ! function_exists( 'themeoo_scripts' ) ) {
	/**
	 * Enqueue scripts and styles.3
	 *
	 * @return void
	 */
	function themeoo_scripts() {

		// Enqueue required styles.
		wp_enqueue_style( 'themeoo-bootstrap', THEMEOO_THEME_URI . 'assets/dist/css/bootstrap.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-gutenberg', THEMEOO_THEME_URI . 'assets/dist/css/gutenberg-custom.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-themify-icons', THEMEOO_THEME_URI . 'assets/plugins/themify-icons/themify-icons.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-fontawesome-icons', THEMEOO_THEME_URI . 'assets/plugins/fontawesome/css/fontawesome.min.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-plyr', THEMEOO_THEME_URI . 'assets/plugins/plyr/plyr.min.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-main', THEMEOO_THEME_URI . 'assets/dist/css/themeoo_main.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-absolute-addons', THEMEOO_THEME_URI . 'assets/dist/css/absolute-addons.css', [], THEMEOO_THEME_VERSION );

		if ( class_exists( 'WooCommerce' ) ) {
			wp_enqueue_style( 'themeoo-woocommerce', THEMEOO_THEME_URI . 'assets/dist/css/woocommerce.css', [], THEMEOO_THEME_VERSION );
		}

		if ( class_exists( 'WPCF7_ContactForm' ) ) {
			wp_enqueue_style( 'themeoo-wpcf7', THEMEOO_THEME_URI . 'assets/dist/css/wpcf7.css', [], THEMEOO_THEME_VERSION );
		}

		// Enqueue Base jQuery From WordPress Core
		wp_enqueue_script( 'jquery' );

		// Enqueue required scripts.
		wp_enqueue_script( 'themeoo-jquery-easing', THEMEOO_THEME_URI . 'assets/plugins/jquery-easing/jquery.easing.min.js', [ 'jquery' ], '1.3', true );

		if ( themeoo_get_mod( 'smoothscroll' ) ) {
			wp_enqueue_script( 'themeoo-smoothscroll', THEMEOO_THEME_URI . 'assets/plugins/smoothscroll/SmoothScroll.min.js', [], '1.2.1', true );
		}

		wp_enqueue_script( 'jquery-masonry' );

		wp_enqueue_script( 'themeoo-lazyLoad', THEMEOO_THEME_URI . 'assets/plugins/lazyLoad/jquery.lazy.min.js', [ 'jquery' ], '1.7.5', true );

		wp_enqueue_script( 'themeoo-plyr', THEMEOO_THEME_URI . 'assets/plugins/plyr/plyr.min.js', [], THEMEOO_THEME_VERSION, true );

		wp_enqueue_script( 'superfish', THEMEOO_THEME_URI . 'assets/dist/js/superfish.js', [ 'jquery', 'hoverIntent' ], THEMEOO_THEME_VERSION, true );

		wp_enqueue_script( 'themeoo-main', THEMEOO_THEME_URI . 'assets/dist/js/themeoo.js', [ 'superfish', 'jquery' ], THEMEOO_THEME_VERSION, true );

		wp_enqueue_script( 'site-script', THEMEOO_THEME_URI . 'assets/dist/js/scripts.js', [ 'themeoo-main', 'jquery-masonry' ], THEMEOO_THEME_VERSION, true );

		$sticky_viewport = themeoo_get_mod( 'layout_header_menu_mobileshow' );

		switch ( $sticky_viewport ) {
			case 'sm':
				$sticky_viewport_size = '576';
				break;
			case 'md':
				$sticky_viewport_size = '991';
				break;
			case 'lg':
			case 'xl':
				$sticky_viewport_size = '1201';
				break;
			default:
				$sticky_viewport_size = '768';
				break;
		}

		wp_localize_script(
			'themeoo-main',
			'themeoo_ajax',
			[
				'ajaxurl'         => admin_url( 'admin-ajax.php' ),
				'siteurl'         => get_template_directory_uri(),
				'error'           => __( 'Error!', 'ayyash' ),
				'nonce'           => wp_create_nonce( 'themeoo-nonce' ),
				'viewport'        => $sticky_viewport_size,
				'sticky'          => themeoo_get_mod( 'layout_header_sticky' ),
				'header'          => themeoo_get_mod( 'layout_header_sticky_height' ),
				'accent'          => ( themeoo_get_mod( 'skin' ) !== 'default' ) ? themeoo_get_mod( 'accent_color' ) : '#428bca',
				'no_smoothscroll' => ( themeoo_get_mod( 'smoothscroll' ) ) ? '1' : '0',
			]
		);
	}
}

add_action( 'wp_enqueue_scripts', 'themeoo_scripts' );



/**
 * Enqueue Block Editor Styles
 *
 * @return void
 */
function themeoo_action_enqueue_block_editor_assets() {
	wp_enqueue_style( 'themeoo-themify-icons', THEMEOO_THEME_URI . 'assets/plugins/themify-icons/themify-icons.css', [], THEMEOO_THEME_VERSION );
	wp_enqueue_style( 'themeoo-fontawesome-icons', THEMEOO_THEME_URI . 'assets/plugins/fontawesome/css/fontawesome.min.css', [], THEMEOO_THEME_VERSION );
	wp_enqueue_style( 'themeoo-gutenberg-editor', THEMEOO_THEME_URI . 'assets/dist/css/gutenberg-editor-custom.css', array(), THEMEOO_THEME_VERSION );
}
add_action('enqueue_block_editor_assets', 'themeoo_action_enqueue_block_editor_assets' );


if ( ! function_exists( 'themeoo_admin_scripts' ) ) {
	/**
	 * Enqueue Admin scripts and styles.
	 *
	 * @param string $hook admin page hook.
	 *
	 * @return void
	 */
	function themeoo_admin_scripts( $hook ) {

		wp_enqueue_style( 'themeoo-themify-icons', THEMEOO_THEME_URI . 'assets/plugins/themify-icons/themify-icons.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_style( 'themeoo-fontawesome-icons', THEMEOO_THEME_URI . 'assets/plugins/fontawesome/css/fontawesome.min.css', [], THEMEOO_THEME_VERSION );

		// Admin & Customizer.
		wp_enqueue_style( 'themeoo-admin', THEMEOO_THEME_URI . 'assets/dist/css/admin.css', [], THEMEOO_THEME_VERSION );

		// Mega Menu Editor.
		wp_enqueue_style( 'themeoo-mega-menu', THEMEOO_THEME_URI . 'assets/dist/css/edit-mega-menu.css', [], THEMEOO_THEME_VERSION );
		wp_enqueue_script( 'themeoo-mega-menu', THEMEOO_THEME_URI . 'assets/dist/js/edit-mega-menu.js', [ 'jquery', 'jquery-ui-dialog' ], THEMEOO_THEME_VERSION, true );
		wp_enqueue_script('wp-codemirror');

		if ( in_array( $hook, [ 'post-new.php', 'post.php' ], true ) ) {
			// Enqueue required scripts.
			wp_enqueue_script( 'themeoo-admin', THEMEOO_THEME_URI . 'assets/dist/js/admin.js', [], THEMEOO_THEME_VERSION, true );
		}
	}
}

add_action( 'admin_enqueue_scripts', 'themeoo_admin_scripts' );

// End of file themeoo-include.php
