<?php

/*-----------------------------------------------------------------------------------*/
/* Enqueue script and styles */
/*-----------------------------------------------------------------------------------*/

if (!function_exists('lms_academy_enqueue_scripts')) {

	function lms_academy_enqueue_scripts() {

	    $lms_academy_my_theme = wp_get_theme();
	    $version = $lms_academy_my_theme['Version'];

	    wp_enqueue_style(
			'bootstrap-css',
			esc_url( get_template_directory_uri() ) . '/css/bootstrap.css',
			array(),'4.5.0'
		);

	    wp_enqueue_style( 'lms-education-style', get_template_directory_uri() . '/style.css' );

	    wp_enqueue_style( 'lms-academy-style', get_stylesheet_directory_uri() . '/style.css', array('lms-education-woocommerce-css'), $version );

	    wp_enqueue_style( 'lms-academy-style', get_stylesheet_directory_uri() . '/style.css', array('lms-education-style'), $version );

		if ( is_singular() ) wp_enqueue_script( 'comment-reply' );

	}

	add_action( 'wp_enqueue_scripts', 'lms_academy_enqueue_scripts' );

}

/*-----------------------------------------------------------------------------------*/
/* Setup theme */
/*-----------------------------------------------------------------------------------*/

if (!function_exists('lms_academy_after_setup_theme')) {

	function lms_academy_after_setup_theme() {

		if ( ! isset( $lms_academy_content_width ) ) $lms_academy_content_width = 900;

		add_theme_support( 'align-wide' );
		add_theme_support( 'woocommerce' );
		add_theme_support('title-tag');
		add_theme_support('automatic-feed-links');
		add_theme_support('post-thumbnails');
		add_theme_support( "responsive-embeds" );
		add_theme_support( 'wp-block-styles' );
		add_theme_support( 'custom-background', array(
		  'default-color' => 'ffffff'
		));

		add_theme_support( 'custom-logo', array(
			'height'      => 70,
			'width'       => 70,
		) );

		add_theme_support( 'custom-header', array(
			'width' => 1920,
			'height' => 100
		));

		add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		add_editor_style( array( '/css/editor-style.css' ) );
	}

	add_action( 'after_setup_theme', 'lms_academy_after_setup_theme', 999 );

}

if (!function_exists('lms_academy_widgets_init')) {

	function lms_academy_widgets_init() {
		register_sidebar(array(
			'name' => esc_html__('Sidebar','lms-academy'),
			'id'   => 'lms-education-sidebar',
			'description'   => esc_html__('This sidebar will be shown next to the content.', 'lms-academy'),
			'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h4 class="title">',
			'after_title'   => '</h4>'
		));

		register_sidebar(array(
			'name' => esc_html__('Footer sidebar','lms-academy'),
			'id'   => 'lms-education-footer-sidebar',
			'description'   => esc_html__('This sidebar will be shown next at the bottom of your content.', 'lms-academy'),
			'before_widget' => '<div id="%1$s" class="col-lg-3 col-md-3 %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h4 class="title">',
			'after_title'   => '</h4>'
		));
	}

	add_action( 'widgets_init', 'lms_academy_widgets_init' );

}

/*-----------------------------------------------------------------------------------*/
/* Enqueue Global color style */
/*-----------------------------------------------------------------------------------*/


add_action( 'customize_register', 'lms_academy_child_theme_override_global_color_default', 20 );
function lms_academy_child_theme_override_global_color_default( $wp_customize ) {

    // Replace 'global_color' with the setting ID from the parent theme
    if ( $wp_customize->get_setting( 'lms_education_first_color' ) ) {
        $wp_customize->get_setting( 'lms_education_first_color' )->default = '#ff5e5e';
    }

    if ( $wp_customize->get_setting( 'lms_education_second_color' ) ) {
        $wp_customize->get_setting( 'lms_education_second_color' )->default = '#001f33';
    }
}

/*-----------------------------------------------------------------------------------*/
/* Enqueue Global color style */
/*-----------------------------------------------------------------------------------*/
function lms_academy_dark_mode() {

$lms_academy_custom_css = '';

$lms_education_is_dark_mode_enabled = get_theme_mod( 'lms_education_is_dark_mode_enabled', false );

if ( $lms_education_is_dark_mode_enabled ) {

    $lms_academy_custom_css .= 'body,.fixed-header,tr:nth-child(2n+2),.header {';
    $lms_academy_custom_css .= 'background: #000;';
    $lms_academy_custom_css .= '}';

    $lms_academy_custom_css .= 'body,h1,h2,h3,h4,h5,p,#main-menu ul li a,.woocommerce .woocommerce-ordering select, .woocommerce form .form-row input.input-text, .woocommerce form .form-row textarea,a,#trending h2{';
    $lms_academy_custom_css .= 'color: #fff;';
    $lms_academy_custom_css .= '}';

    $lms_academy_custom_css .= 'a.wc-block-components-product-name, .wc-block-components-product-name,.wc-block-components-totals-footer-item .wc-block-components-totals-item__value,
.wc-block-components-totals-footer-item .wc-block-components-totals-item__label,
.wc-block-components-totals-item__label,.wc-block-components-totals-item__value,
.wc-block-components-product-metadata .wc-block-components-product-metadata__description>p,
.is-medium table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__total .wc-block-components-formatted-money-amount,
.wc-block-components-quantity-selector input.wc-block-components-quantity-selector__input,
.wc-block-components-quantity-selector .wc-block-components-quantity-selector__button,
.wc-block-components-quantity-selector,table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link,
.wc-block-components-product-price__value.is-discounted,del.wc-block-components-product-price__regular,.logo span,li.menu-item-has-children:after,h1.woocommerce-products-header__title.page-title,h2.woocommerce-loop-product__title,h1.product_title.entry-title,div#tab-description h2,section.related.products h2,h2.woocommerce-Reviews-title,h2#reply-title,h2.comments-title{';
    $lms_academy_custom_css .= 'color: #fff !important;';
    $lms_academy_custom_css .= '}';

    $lms_academy_custom_css .= '.logo a,h5.product-text a,#featured-product p.price,.card-header a,.comment-content.card-block p,.blog_box h3 a{';
    $lms_academy_custom_css .= 'color: #000 !important';
    $lms_academy_custom_css .= '}';

	$lms_academy_custom_css .= '.post-box{';
    $lms_academy_custom_css .= '    border: 1px solid rgb(229 229 229 / 48%)';
    $lms_academy_custom_css .= '}';
}

    wp_add_inline_style( 'lms-academy-style',$lms_academy_custom_css );
    wp_add_inline_style( 'lms-academy-woocommerce-css',$lms_academy_custom_css );

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

function lms_academy_remove_custom($wp_customize) {
	$wp_customize->remove_section('lms-education-customizer-notify-section');
    $wp_customize->remove_control('lms_education_pro_setting_1');
    $wp_customize->remove_control('lms_education_pro_setting_2');
    $wp_customize->remove_control('lms_education_pro_setting_3');
    $wp_customize->remove_control('lms_education_pro_setting_4');
    $wp_customize->remove_control('lms_education_pro_setting_5');
    $wp_customize->remove_control('lms_education_pro_setting_6');
    $wp_customize->remove_control('lms_education_pro_setting_7');
    $wp_customize->remove_control('lms_education_pro_setting_8');
    $wp_customize->remove_control('lms_education_pro_setting_9');
    $wp_customize->remove_control('lms_education_pro_setting_10');
    $wp_customize->remove_control('lms_education_pro_setting_11');
    $wp_customize->remove_control('lms_education_pro_setting_12');
    $wp_customize->remove_control('lms_education_pro_setting_13');
    $wp_customize->remove_control('lms_education_pro_setting_14');
    $wp_customize->remove_control('lms_education_pro_setting_14');

    }
add_action( 'customize_register', 'lms_academy_remove_custom', 1000 );

function lms_academy_template_setup() {

if ( ! defined( 'LMS_EDUCATION_DOCS_FREE' ) ) {
define('LMS_EDUCATION_DOCS_FREE',__('https://demo.misbahwp.com/docs/lms-education-free-docs/','lms-academy'));
}
if ( ! defined( 'LMS_EDUCATION_DOCS_PRO' ) ) {
define('LMS_EDUCATION_DOCS_PRO',__('https://demo.misbahwp.com/docs/lms-education-pro-docs/','lms-academy'));
}
if ( ! defined( 'LMS_EDUCATION_BUY_NOW' ) ) {
define('LMS_EDUCATION_BUY_NOW',__('https://www.misbahwp.com/products/education-wordpress-theme','lms-academy'));
}
if ( ! defined( 'LMS_EDUCATION_SUPPORT_FREE' ) ) {
define('LMS_EDUCATION_SUPPORT_FREE',__('https://wordpress.org/support/theme/lms-academy','lms-academy'));
}
if ( ! defined( 'LMS_EDUCATION_REVIEW_FREE' ) ) {
define('LMS_EDUCATION_REVIEW_FREE',__('https://wordpress.org/support/theme/lms-academy/reviews/#new-post','lms-academy'));
}
if ( ! defined( 'LMS_EDUCATION_DEMO_PRO' ) ) {
define('LMS_EDUCATION_DEMO_PRO',__('https://demo.misbahwp.com/lms-education/','lms-academy'));
}

require get_stylesheet_directory() . '/core/includes/importer/config.php';

}
add_action('after_setup_theme', 'lms_academy_template_setup');

add_action( 'after_setup_theme', function () {
    // If the parent used a different priority than 5, detect it first:
    $prio = has_action( 'after_setup_theme', 'lms_education_template_include_wizard' );
    if ( false !== $prio ) {
        remove_action( 'after_setup_theme', 'lms_education_template_include_wizard', $prio );
    } else {
        // If you're unsure, also try removing at 5 explicitly:
        remove_action( 'after_setup_theme', 'lms_education_template_include_wizard', 5 );
    }
}, 0 );