<?php

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

if (!function_exists('lms_training_institute_enqueue_scripts')) {

	function lms_training_institute_enqueue_scripts() {

	    $my_theme = wp_get_theme();
	    $version = $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-training-institute-style', get_stylesheet_directory_uri() . '/style.css', array('lms-education-woocommerce-css'), $version );

	    wp_enqueue_style( 'lms-training-institute-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_training_institute_enqueue_scripts' );

}

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

if (!function_exists('lms_training_institute_after_setup_theme')) {

	function lms_training_institute_after_setup_theme() {

		if ( ! isset( $content_width ) ) $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_training_institute_after_setup_theme', 999 );

}

if (!function_exists('lms_training_institute_widgets_init')) {

	function lms_training_institute_widgets_init() {

		register_sidebar(array(

			'name' => esc_html__('Sidebar','lms-training-institute'),
			'id'   => 'lms-education-sidebar',
			'description'   => esc_html__('This sidebar will be shown next to the content.', 'lms-training-institute'),
			'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-training-institute'),
			'id'   => 'lms-education-footer-sidebar',
			'description'   => esc_html__('This sidebar will be shown next at the bottom of your content.', 'lms-training-institute'),
			'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_training_institute_widgets_init' );

}

add_action( 'customize_register', 'lms_training_institute_child_theme_override_global_color_default', 20 );
function lms_training_institute_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 = '#a52150';
    }
    // Replace 'global_color' with the setting ID from the parent theme
    if ( $wp_customize->get_setting( 'lms_education_second_color' ) ) {
        $wp_customize->get_setting( 'lms_education_second_color' )->default = '#173359';
    }
}

function lms_training_institute_remove_custom($wp_customize) {
  $wp_customize->remove_setting('lms_education_slider_phone_heading');
  $wp_customize->remove_setting('lms_education_slider_phone_text');
 	$wp_customize->remove_setting('lms_education_phone_detail_unable_disable');
 	$wp_customize->remove_setting('lms_education_text_unable_disable');
 	$wp_customize->remove_setting('lms_education_slider_xcerpt_heading');
 	$wp_customize->remove_setting('lms_education_slide_excerpt_number');
	$wp_customize->remove_setting('lms_education_slider_content_alignment');
	$wp_customize->remove_setting('lms_education_footer_text_heading_1');
	$wp_customize->remove_setting('lms_education_slider_opacity_color');
	$wp_customize->remove_setting('lms_education_overlay_option');
	$wp_customize->remove_setting('lms_education_slider_image_overlay_color');
}
add_action( 'customize_register', 'lms_training_institute_remove_custom', 1000 );


/*-----------------------------------------------------------------------------------*/
/* Customizer */
/*-----------------------------------------------------------------------------------*/

function lms_training_institute_template_setup() {

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

if ( class_exists("Kirki")){

	// ABOUT US SECTION

	Kirki::add_section( 'lms_training_institute_aboutus_section', array(
    'title'          => esc_html__( 'About Us Settings', 'lms-training-institute' ),
    'panel'          => 'lms_education_panel_id',
    'priority'       => 170,
  ) );

  Kirki::add_field( 'theme_config_id', [
	    'label'       => '<span class="custom-label-class">' . esc_html__( 'INFORMATION ABOUT PREMIUM VERSION :-', 'lms-training-institute' ) . '</span>',
	    'default'     => '<a class="premium_info_btn" target="_blank" href="' . esc_url( LMS_EDUCATION_BUY_NOW ) . '">' . __( 'GO TO PREMIUM', 'lms-training-institute' ) . '</a>',
	    'type'        => 'custom',
	    'section'     => 'lms_training_institute_aboutus_section',
	    'description' => '<div class="custom-description-class">' . __( '<p>1. One Click Demo Importer </p><p>2. Color Pallete Setup </p><p>3. Section Reordering Facility</p><p>4. For More Options kindly Go For Premium Version.</p>', 'lms-training-institute' ) . '</div>',
	    'priority'    => 1,
	] );

  Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_services_enable_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Enable / Disable Our Story Section', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

  Kirki::add_field( 'theme_config_id', [
		'type'        => 'switch',
		'settings'    => 'lms_training_institute_aboutus_enable',
		'label'       => esc_html__( 'Section Enable / Disable', 'lms-training-institute' ),
		'section'     => 'lms_training_institute_aboutus_section',
		'default'     => '0',
		'priority'    => 10,
		'choices'     => [
			'on'  => esc_html__( 'Enable', 'lms-training-institute' ),
			'off' => esc_html__( 'Disable', 'lms-training-institute' ),
		],
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_aboutus_section_title_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Section Title', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

  Kirki::add_field( 'theme_config_id', [
		'type'     => 'text',
		'settings' => 'lms_training_institute_aboutus_section_title',
		'section'  => 'lms_training_institute_aboutus_section',
		'default'  => '',
		'priority' => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_aboutus_image1_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Image 1', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'image',
		'settings'    => 'lms_training_institute_aboutus_image1',
		'section'     => 'lms_training_institute_aboutus_section',
		'default'     => '',
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_aboutus_image2_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Image 2', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'image',
		'settings'    => 'lms_training_institute_aboutus_image2',
		'section'     => 'lms_training_institute_aboutus_section',
		'default'     => '',
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_aboutus_page_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Page Dropdown', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'dropdown-pages',
		'settings'    => 'lms_training_institute_aboutus',
		'section'     => 'lms_training_institute_aboutus_section',
		'default'     => 42,
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_training_institute_aboutus_xcerpt_heading',
		'section'     => 'lms_training_institute_aboutus_section',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Number Of Text', 'lms-training-institute' ) . '</h3>',
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'        => 'slider',
		'settings'    => 'lms_training_institute_story_excerpt_number',
		'label'       => esc_html__( 'About Us Content Range', 'lms-training-institute' ),
		'section'     => 'lms_training_institute_aboutus_section',
		'default'     => 15,
		'choices'     => [
			'min'  => 0,
			'max'  => 100,
			'step' => 1,
		],
	] );

}
require get_stylesheet_directory() . '/core/includes/importer/config.php';
}
add_action('after_setup_theme', 'lms_training_institute_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 );

/*-----------------------------------------------------------------------------------*/
/* Enqueue Dark Mode Style */
/*-----------------------------------------------------------------------------------*/
function lms_training_institute_dark_mode() {

$lms_training_institute_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_training_institute_custom_css .= 'body,.fixed-header,tr:nth-child(2n+2),.header {';
    $lms_training_institute_custom_css .= 'background: #000;';
    $lms_training_institute_custom_css .= '}';

    $lms_training_institute_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_training_institute_custom_css .= 'color: #fff;';
    $lms_training_institute_custom_css .= '}';

    $lms_training_institute_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 a,.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,a, h1, h2, h3, h4, h5, h6, .woocommerce ul.products li.product .price, .woocommerce div.product p.price, .woocommerce div.product span.price, .blog_inner_box h3.post-title a, .page-template-frontpage .logo a, .page-template-frontpage .logo span, .page-template-frontpage #main-menu ul li a, h2.woocommerce-loop-product__title, .logo a, .logo span, #main-menu ul li a,#main-menu ul li.current-menu-item > a, #main-menu ul li.current_page_item > a, #main-menu a:hover, #main-menu ul li a:hover, #main-menu ul li.current-menu-parent > a, #main-menu ul li.current-menu-ancestor > a,p.woocommerce-result-count{';
    $lms_training_institute_custom_css .= 'color: #fff !important;';
    $lms_training_institute_custom_css .= '}';

    $lms_training_institute_custom_css .= 'h5.product-text a,#featured-product p.price,.card-header a,.comment-content.card-block p,.blog_box h3 a, .login-to,p,.pagination .nav-links a, .pagination .nav-links span.current, .lms-education-pagination a span, .lms-education-pagination span.current,h2.comments-title,h2#reply-title,p.logged-in-as a{';
    $lms_training_institute_custom_css .= 'color: #000 !important';
    $lms_training_institute_custom_css .= '}';

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

    wp_add_inline_style( 'lms-training-institute-style',$lms_training_institute_custom_css );
    wp_add_inline_style( 'lms-training-institute-woocommerce-css',$lms_training_institute_custom_css );

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