<?php

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

if (!function_exists('webinar_education_enqueue_scripts')) {

	function webinar_education_enqueue_scripts() {

	    $webinar_education_my_theme = wp_get_theme();
	    $webinar_education_version = $webinar_education_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( 'webinar-education-style', get_stylesheet_directory_uri() . '/style.css', array('lms-education-woocommerce-css'), $webinar_education_version );

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

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

	}

	add_action( 'wp_enqueue_scripts', 'webinar_education_enqueue_scripts' );

}

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

if (!function_exists('webinar_education_after_setup_theme')) {

	function webinar_education_after_setup_theme() {

		if ( ! isset( $webinar_education_content_width ) ) $webinar_education_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', 'webinar_education_after_setup_theme', 999 );

}

if (!function_exists('webinar_education_widgets_init')) {

	function webinar_education_widgets_init() {

		register_sidebar(array(

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

}

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


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

if ( $wp_customize->get_setting( 'lms_education_first_color' ) ) {
    $wp_customize->get_setting( 'lms_education_first_color' )->default = '#f39f01';
}

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

/*-----------------------------------------------------------------------------------*/

function webinar_education_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_slider_content_alignment');
	$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', 'webinar_education_remove_custom', 1000 );

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

if ( ! defined( 'LMS_EDUCATION_PREMIUM_THEME_LINK' ) ) {
	define( 'LMS_EDUCATION_PREMIUM_THEME_LINK', 'https://www.misbahwp.com/products/education-webinar-wordpress-theme' );
}
if ( ! defined( 'LMS_EDUCATION_PREMIUM_THEME_DEMO_LINK' ) ) {
    define( 'LMS_EDUCATION_PREMIUM_THEME_DEMO_LINK', 'https://demo.misbahwp.com/webinar-education/' );
}
if ( ! defined( 'LMS_EDUCATION_PREMIUM_THEME_NAME' ) ) {
define( 'LMS_EDUCATION_PREMIUM_THEME_NAME', 'Webinar Pro' );
}

function webinar_education_template_setup() {

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

if ( class_exists("Kirki")){


	// FEATURES SECTION

	Kirki::add_section( 'lms_education_section_header', array(
	    'title'          => esc_html__( 'Header Settings', 'lms-education' ),
	    'panel'          => 'lms_education_panel_id',
	    'priority'       => 160,
	) );

	Kirki::add_section( 'webinar_education_features_section', array(
    'title'          => esc_html__( 'Features Settings', 'webinar-education' ),
    '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 :-', 'webinar-education' ) . '</span>',
	    'default'     => '<a class="premium_info_btn" target="_blank" href="' . esc_url( LMS_EDUCATION_BUY_NOW ) . '">' . __( 'GO TO PREMIUM', 'webinar-education' ) . '</a>',
	    'type'        => 'custom',
	    'section'     => 'webinar_education_features_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>', 'webinar-education' ) . '</div>',
	] );

	Kirki::add_field( 'theme_config_id', [
    'type'        => 'number',
    'settings'    => 'webinar_education_features_counter',
    'label'       => esc_html__( 'Features Counter Section',  'webinar-education' ),
    'section'     => 'webinar_education_features_section',
    'default'     => 0,
    'choices'     => [
      'min'  => 0,
      'max'  => 80,
      'step' => 1,
    ],
  ] );

  Kirki::add_field( 'theme_config_id', [
		'type'        => 'custom',
		'settings'    => 'lms_education_email_icon_11',
		'section'     => 'lms_education_section_header',
			'default'         => '<h3 style="color: #2271b1; padding:10px; background:#fff; margin:0; border-left: solid 5px #2271b1; ">' . __( 'Choose Your Icon Here', 'lms-education' ) . '</h3>',
		'priority'    => 10,
	] );

	Kirki::add_field( 'theme_config_id', [
		'type'     => 'dashicons',
		'settings' => 'lms_education_dashicons_setting_3',
		'label'    => esc_html__( 'Select Appropriate Icon', 'lms-education' ),
		'section'  => 'lms_education_section_header',
		'default'  => 'dashicons dashicons-email',
		'priority' => 10,
	] );

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

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

  $webinar_education_feature_box = get_theme_mod('webinar_education_features_counter','');
  for ( $i = 1; $i <= $webinar_education_feature_box; $i++ ) :

		Kirki::add_field( 'theme_config_id', [
			'type'     => 'dashicons',
			'settings' => 'webinar_education_features_icon_setting'.$i,
			'label'    => esc_html__( 'Features Icon ', 'webinar-education' ).$i,
			'section'  => 'webinar_education_features_section',
			'priority' => 10,
	    ] );

		Kirki::add_field( 'theme_config_id', [
			'type'     => 'text',
			'settings' => 'webinar_education_features_title_text'.$i,
			'label'    => esc_html__( 'Features Title ', 'webinar-education' ).$i,
			'section'  => 'webinar_education_features_section',
			'priority' => 10,
	    ] );

	endfor;
}

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

}
add_action('after_setup_theme', 'webinar_education_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 webinar_education_dark_mode() {

$webinar_education_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 ) {

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

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

    $webinar_education_custom_css .= 'h5.product-text a,#featured-product p.price,.card-header a,.comment-content.card-block p,.blog_box h3 a,#site-navigation ul.sub-menu li a{';
    $webinar_education_custom_css .= 'color: #000 !important';
    $webinar_education_custom_css .= '}';

    $webinar_education_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{';
    $webinar_education_custom_css .= 'color: #fff !important;';
    $webinar_education_custom_css .= '}';

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

    wp_add_inline_style( 'webinar-education-style',$webinar_education_custom_css );
    wp_add_inline_style( 'webinar-education-woocommerce-css',$webinar_education_custom_css );

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