<?php

function jenny_theme_enqueue() {

	/***********
	Register & Enqueue CSS Styles
	************/
	wp_register_style(
		'jenny-fonts',
		'//fonts.googleapis.com/css?family=Oswald:500'
	);

	wp_register_style(
		'jenny-fonts-devanagari',
		'//fonts.googleapis.com/css?family=Hind:400,500,700|Oswald:500&subset=devanagari,latin-ext'
	);

	wp_register_style(
		'bootstrap',
		get_template_directory_uri() . '/assets/css/bootstrap.min.css',
		false,
		'5.3.6'
	);

	wp_register_style(
		'bootstrap-grid',
		get_template_directory_uri() . '/assets/css/bootstrap-grid.min.css',
		false,
		'5.3.6'
	);

	wp_register_style(
		'fontawesome-icons',
		get_template_directory_uri() . '/assets/css/fontawesome-icons.css',
		false,
		'1.2.5'
	);

	wp_register_style(
		'jenny-style',
		get_template_directory_uri() . '/style.css',
		false,
		wp_get_theme()->get( 'Version' )
	);

	/* Enqueue Fonts Based on the Settings */
	if( get_theme_mod( 'jenny_font_hindi' ) === 1 ) {
		wp_enqueue_style( 'jenny-fonts-devanagari' );
	} else {
		wp_enqueue_style( 'jenny-fonts' );
	}


	/* Enqueue Bootstrap JS Based on the Settings */
	if( get_theme_mod( 'jenny_bootstrap', 1 ) === 1 ) {
		wp_enqueue_style( 'bootstrap' );
	} else {
		// Enqueue Bootstrap Grid Only
		wp_enqueue_style( 'bootstrap-grid' );
	}

	wp_enqueue_style( 'fontawesome-icons' );
	wp_enqueue_style( 'jenny-style' );

	/***********
	Register & Enqueue JS Scripts
	************/
	wp_register_script(
		'skip-link-focus-fix',
		get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js',
		array(), '1.0', true
	);

	wp_register_script(
		'jquery-bootstrap',
		get_template_directory_uri() . '/assets/js/bootstrap.min.js',
		array( 'jquery' ),
		'5.3.6', true
	);

	wp_register_script(
		'jenny-main-js',
		get_template_directory_uri() . '/assets/js/main.js',
		array( 'jquery' ),
		'1.0', true
	);

	wp_localize_script( 'jenny-main-js', 'jenny_screenReaderText', array(
		'expand'   => __( 'Expand child menu', 'jenny' ),
		'collapse' => __( 'Collapse child menu', 'jenny' ),
	) );

	wp_enqueue_script( 'skip-link-focus-fix' );

	/* Enqueue Bootstrap JS Based on the Settings */
	if( get_theme_mod( 'jenny_bootstrap', 1 ) === 1 ) {
		wp_enqueue_script( 'jquery-bootstrap' );
	} else {
		// Do not enqueue Bootstrap JS
	}

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}

	wp_enqueue_script( 'jenny-main-js' );

}