<?php
/**
 * Dinero functions and definitions
 *
 * @subpackage Dinero
 * @since 1.0
 */

include get_theme_file_path( 'vendor/wptrt/autoload/src/Dinero_Loader.php' );

$dinero_loader = new \WPTRT\Autoload\Dinero_Loader();

$dinero_loader->dinero_add( 'WPTRT\\Customize\\Section', get_theme_file_path( 'vendor/wptrt/customize-section-button/src' ) );

$dinero_loader->dinero_register();

function dinero_setup() {
	
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', ) );
	add_theme_support( 'woocommerce' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'custom-background', $defaults = array(
	    'default-color'          => '',
	    'default-image'          => '',
	    'default-repeat'         => '',
	    'default-position-x'     => '',
	    'default-attachment'     => '',
	    'wp-head-callback'       => '_custom_background_cb',
	    'admin-head-callback'    => '',
	    'admin-preview-callback' => ''
	));

	$GLOBALS['content_width'] = 525;
	register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'dinero' ),
	) );

	// Add theme support for Custom Logo.
	add_theme_support( 'custom-logo', array(
		'width'       => 250,
		'flex-width'  => true,
		'flex-height' => true,
	) );

	// Add theme support for selective refresh for widgets.
	add_theme_support( 'customize-selective-refresh-widgets' );

	/*
	 * This theme styles the visual editor to resemble the theme style,
	 * specifically font, colors, and column width.
 	 */
	add_editor_style( array( 'assets/css/editor-style.css', dinero_fonts_url() ) );
}
add_action( 'after_setup_theme', 'dinero_setup' );

function dinero_widgets_init() {
	register_sidebar( array(
		'name'          => __( 'Blog Sidebar', 'dinero' ),
		'id'            => 'sidebar-1',
		'description'   => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<div class="widget_container"><h2 class="widget-title">',
		'after_title'   => '</h2></div>',
	) );

	register_sidebar( array(
		'name'          => __( 'Sidebar 2', 'dinero' ),
		'id'            => 'sidebar-2',
		'description'   => __( 'Add widgets here to appear in your pages and posts', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<div class="widget_container"><h2 class="widget-title">',
		'after_title'   => '</h2></div>',
	) );

	register_sidebar( array(
		'name'          => __( 'Sidebar 3', 'dinero' ),
		'id'            => 'sidebar-3',
		'description'   => __( 'Add widgets here to appear in your pages and posts', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<div class="widget_container"><h2 class="widget-title">',
		'after_title'   => '</h2></div>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer 1', 'dinero' ),
		'id'            => 'footer-1',
		'description'   => __( 'Add widgets here to appear in your footer.', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer 2', 'dinero' ),
		'id'            => 'footer-2',
		'description'   => __( 'Add widgets here to appear in your footer.', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer 3', 'dinero' ),
		'id'            => 'footer-3',
		'description'   => __( 'Add widgets here to appear in your footer.', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer 4', 'dinero' ),
		'id'            => 'footer-4',
		'description'   => __( 'Add widgets here to appear in your footer.', 'dinero' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
}
add_action( 'widgets_init', 'dinero_widgets_init' );

function dinero_fonts_url(){
	$font_url      = '';
	$font_family   = array();
	$font_family[] = 'Poppins';
	$font_family[] = 'Alex Brush';
	$font_family[] = 'Dosis:200,300,400,500,600,700,800';
	$font_family[] = 'Libre Baskerville';
	$font_family[] = 'PT Sans:300,400,600,700,800,900';
	$font_family[] = 'Roboto:400,700';
	$font_family[] = 'Roboto Condensed:400,700';
	$font_family[] = 'Open Sans:300,300i,400,400i,600,600i,700,700i,800,800i';
	$font_family[] = 'Overpass';
	$font_family[] = 'Montserrat:300,400,600,700,800,900';
	$font_family[] = 'Playball:300,400,600,700,800,900';
	$font_family[] = 'Alegreya:300,400,600,700,800,900';
	$font_family[] = 'Julius Sans One';
	$font_family[] = 'Arsenal';
	$font_family[] = 'Slabo';
	$font_family[] = 'Lato';
	$font_family[] = 'Overpass Mono';
	$font_family[] = 'Source Sans Pro';
	$font_family[] = 'Raleway';
	$font_family[] = 'Merriweather';
	$font_family[] = 'Droid Sans';
	$font_family[] = 'Rubik';
	$font_family[] = 'Lora';
	$font_family[] = 'Ubuntu';
	$font_family[] = 'Cabin';
	$font_family[] = 'Arimo';
	$font_family[] = 'Playfair Display';
	$font_family[] = 'Quicksand';
	$font_family[] = 'Padauk';
	$font_family[] = 'Muli';
	$font_family[] = 'Inconsolata';
	$font_family[] = 'Bitter';
	$font_family[] = 'Pacifico';
	$font_family[] = 'Indie Flower';
	$font_family[] = 'VT323';
	$font_family[] = 'Dosis';
	$font_family[] = 'Frank Ruhl Libre';
	$font_family[] = 'Fjalla One';
	$font_family[] = 'Oxygen';
	$font_family[] = 'Arvo';
	$font_family[] = 'Noto Serif';
	$font_family[] = 'Lobster';
	$font_family[] = 'Crimson Text';
	$font_family[] = 'Yanone Kaffeesatz';
	$font_family[] = 'Anton';
	$font_family[] = 'Libre Baskerville';
	$font_family[] = 'Bree Serif';
	$font_family[] = 'Gloria Hallelujah';
	$font_family[] = 'Josefin Sans';
	$font_family[] = 'Abril Fatface';
	$font_family[] = 'Varela Round';
	$font_family[] = 'Vampiro One';
	$font_family[] = 'Shadows Into Light';
	$font_family[] = 'Cuprum';
	$font_family[] = 'Rokkitt';
	$font_family[] = 'Vollkorn';
	$font_family[] = 'Francois One';
	$font_family[] = 'Orbitron';
	$font_family[] = 'Patua One';
	$font_family[] = 'Acme';
	$font_family[] = 'Satisfy';
	$font_family[] = 'Josefin Slab';
	$font_family[] = 'Quattrocento Sans';
	$font_family[] = 'Architects Daughter';
	$font_family[] = 'Russo One';
	$font_family[] = 'Monda';
	$font_family[] = 'Righteous';
	$font_family[] = 'Lobster Two';
	$font_family[] = 'Hammersmith One';
	$font_family[] = 'Courgette';
	$font_family[] = 'Permanent Marker';
	$font_family[] = 'Cherry Swash';
	$font_family[] = 'Cormorant Garamond';
	$font_family[] = 'Poiret One';
	$font_family[] = 'BenchNine';
	$font_family[] = 'Economica';
	$font_family[] = 'Handlee';
	$font_family[] = 'Cardo';
	$font_family[] = 'Alfa Slab One';
	$font_family[] = 'Averia Serif Libre';
	$font_family[] = 'Cookie';
	$font_family[] = 'Chewy';
	$font_family[] = 'Great Vibes';
	$font_family[] = 'Coming Soon';
	$font_family[] = 'Philosopher';
	$font_family[] = 'Days One';
	$font_family[] = 'Kanit';
	$font_family[] = 'Shrikhand';
	$font_family[] = 'Tangerine';
	$font_family[] = 'IM Fell English SC';
	$font_family[] = 'Boogaloo';
	$font_family[] = 'Bangers';
	$font_family[] = 'Fredoka One';
	$font_family[] = 'Bad Script';
	$font_family[] = 'Volkhov';
	$font_family[] = 'Shadows Into Light Two';
	$font_family[] = 'Marck Script';
	$font_family[] = 'Gabriela';
	$font_family[] = 'Unica One';

	$query_args = array(
		'family' => rawurlencode(implode('|',$font_family)),
	);
	$font_url = add_query_arg($query_args,'//fonts.googleapis.com/css');
	return $font_url;
}

/* Breadcrumb Begin */
function dinero_breadcrumb() {
	if (!is_home()) {
		echo '<a href="';
			echo esc_url(home_url());
		echo '">';
			bloginfo('name');
		echo "</a> ";
		if (is_category() || is_single()) {
			echo "&nbsp;&#187;&nbsp;";
			the_category(', ');
			if (is_single()) {
				echo "&nbsp;&#187;&nbsp;";
				echo "<span> ";
					the_title();
				echo "</span>";
			}
		} elseif (is_page()) {
			echo "&nbsp;&#187;&nbsp;";
			echo "<span> ";
				the_title();
			echo "</span> ";
		}
	}
}

//Enqueue scripts and styles.
function dinero_scripts() {
	// Add custom fonts, used in the main stylesheet.
	wp_enqueue_style( 'dinero-fonts', dinero_fonts_url(), array(), null );
	
	//Bootstarp 
	wp_enqueue_style( 'bootstrap-css', esc_url( get_template_directory_uri() ).'/assets/css/bootstrap.css' );
	
	// Theme stylesheet.
	wp_enqueue_style( 'dinero-basic-style', get_stylesheet_uri() );

	// Load the Internet Explorer 9 specific stylesheet, to fix display issues in the Customizer.
	if ( is_customize_preview() ) {
		wp_enqueue_style( 'dinero-ie9', get_theme_file_uri( '/assets/css/ie9.css' ), array( 'dinero-style' ), '1.0' );
		wp_style_add_data( 'dinero-ie9', 'conditional', 'IE 9' );
	}
	// Load the Internet Explorer 8 specific stylesheet.
	wp_enqueue_style( 'dinero-ie8', get_theme_file_uri( '/assets/css/ie8.css' ), array( 'dinero-style' ), '1.0' );
	wp_style_add_data( 'dinero-ie8', 'conditional', 'lt IE 9' );

	wp_enqueue_style( 'animate-css', esc_url( get_template_directory_uri() ).'/assets/css/animate.css' );

	//font-awesome
	wp_enqueue_style( 'font-awesome-css', esc_url( get_template_directory_uri() ).'/assets/css/fontawesome-all.css' );

	require get_parent_theme_file_path( '/lz-custom-style.php' );
	wp_add_inline_style( 'dinero-basic-style',$dinero_custom_style );

	wp_enqueue_script( 'dinero-navigation-jquery', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '2.1.2', true );
	wp_enqueue_script( 'bootstrap-js', esc_url( get_template_directory_uri() ). '/assets/js/bootstrap.js', array('jquery') );
	wp_enqueue_script( 'jquery-superfish', esc_url( get_template_directory_uri() ). '/assets/js/jquery.superfish.js', array('jquery') ,'',true);
	wp_enqueue_script( 'jquery-wow', esc_url( get_template_directory_uri() ). '/assets/js/wow.js', array('jquery') );

	wp_enqueue_script( 'dinero-skip-link-focus-fix-jquery', get_template_directory_uri( '/assets/js/skip-link-focus-fix.js' ), array('jquery') );

	$dineroScreenReaderText=array();
	
	if ( has_nav_menu( 'primary' ) ) {

		$dineroScreenReaderText['expand']   = __( 'Expand child menu', 'dinero' );
		$dineroScreenReaderText['collapse'] = __( 'Collapse child menu', 'dinero' );
		
	}

	wp_localize_script( 'dinero-skip-link-focus-fix-jquery', 'dineroScreenReaderText', $dineroScreenReaderText );

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

function dinero_front_page_template( $template ) {
	return is_home() ? '' : $template;
}
add_filter( 'frontpage_template',  'dinero_front_page_template' );

function dinero_sanitize_dropdown_pages( $page_id, $setting ) {
	// Ensure $input is an absolute integer.
	$page_id = absint( $page_id );
	// If $page_id is an ID of a published page, return it; otherwise, return the default.
	return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}

function dinero_sanitize_choices( $input, $setting ) {
    global $wp_customize; 
    $control = $wp_customize->get_control( $setting->id ); 
    if ( array_key_exists( $input, $control->choices ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function dinero_sanitize_checkbox( $input ) {
	return ( ( isset( $input ) && true == $input ) ? true : false );
}

function dinero_sanitize_phone_number( $phone ) {
	return preg_replace( '/[^\d+]/', '', $phone );
}

function dinero_sanitize_float( $input ) {
    return filter_var($input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
}
// Integer sanitization
if ( ! function_exists( 'dinero_sanitize_integer' ) ) {
	function dinero_sanitize_integer( $input ) {
		return (int) $input;
	}
}

/* Excerpt Limit Begin */
function dinero_string_limit_words($string, $word_limit) {
	$words = explode(' ', $string, ($word_limit + 1));
	if(count($words) > $word_limit)
	array_pop($words);
	return implode(' ', $words);
}

// Change number or products per row to 3
add_filter('loop_shop_columns', 'dinero_loop_columns');
	if (!function_exists('dinero_loop_columns')) {
		function dinero_loop_columns() {
	return 3; // 3 products per row
	}
}
// Custom Controls
function dinero_sanitize_custom_control( $input ) {
	return $input;
}

function dinero_shortcode_enabled(){
	if(get_theme_mod('dinero_slider_section_option', 'Luzuk Slider') == 'Other Plugin Slider' ) {
		return true;
	}
	return false;
}

function dinero_teams_shortcode_enabled(){
	if(get_theme_mod('dinero_teams_section_option', 'Luzuk Teams Plugin') == 'Other Shortcode' ) {
		return true;
	}
	return false;
}

function dinero_service_type_posts(){
	if(get_theme_mod('dinero_service_type', 'With Posts') == 'With Posts' ) {
		return true;
	}
	return false;
}

function dinero_service_type_pages(){
	if(get_theme_mod('dinero_service_type', 'With Posts') == 'With Pages' ) {
		return true;
	}
	return false;
}

function dinero_service_bg_image_opacity(){
	if(get_theme_mod('dinero_service_section_bg_image') != '' ) {
		return true;
	}
	return false;
}

function dinero_switch_sanitization( $input ) {
	if ( true === $input ) {
		return 1;
	} else {
		return 0;
	}
}

function dinero_reset_all_settings() {
	remove_theme_mod( 'dinero_show_sticky_header' );
	remove_theme_mod( 'dinero_header_bg_color' );
	remove_theme_mod( 'dinero_header_image' );
	remove_theme_mod( 'dinero_site_title_color' );
	remove_theme_mod( 'dinero_site_text_color' );
	remove_theme_mod( 'dinero_mail_phone_icon_color' );
	remove_theme_mod( 'dinero_mail_phone_text_color' );
	remove_theme_mod( 'dinero_social_icon_color' );
	remove_theme_mod( 'dinero_social_icon_hover_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}
add_action( 'wp_ajax_dinero_reset_all_settings', 'dinero_reset_all_settings' );

add_action( 'wp_ajax_dinero_reset_logo_settings', 'dinero_reset_logo_settings' );
function dinero_reset_logo_settings() {
	remove_theme_mod( 'dinero_show_site_title' );
	remove_theme_mod( 'dinero_show_tagline' );
	remove_theme_mod( 'dinero_logo_size' );
	remove_theme_mod( 'dinero_logo_height' );
	remove_theme_mod( 'dinero_logo_margin' );
	remove_theme_mod( 'dinero_logo_top_margin' );
	remove_theme_mod( 'dinero_logo_bottom_margin' );
	remove_theme_mod( 'dinero_logo_left_margin' );
	remove_theme_mod( 'dinero_logo_right_margin' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_reset_header_menu_settings', 'dinero_reset_header_menu_settings' );
function dinero_reset_header_menu_settings() {
	remove_theme_mod( 'dinero_submenu_animation' );
	remove_theme_mod( 'dinero_menu_color' );
	remove_theme_mod( 'dinero_menu_hover_color' );
	remove_theme_mod( 'dinero_active_menu_color' );
	remove_theme_mod( 'dinero_dropdown_menu_color' );
	remove_theme_mod( 'dinero_menu_case' );
	remove_theme_mod( 'dinero_menu_font_size' );
	remove_theme_mod( 'dinero_menu_font_weight' );
	remove_theme_mod( 'dinero_dropdown_bg_menu_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_reset_blog_post_settings', 'dinero_reset_blog_post_settings' );
function dinero_reset_blog_post_settings() {
	remove_theme_mod( 'dinero_show_date' );
	remove_theme_mod( 'dinero_show_author' );
	remove_theme_mod( 'dinero_show_comments' );
	remove_theme_mod( 'dinero_show_time' );
	remove_theme_mod( 'dinero_show_category' );
	remove_theme_mod( 'dinero_show_tags' );
	remove_theme_mod( 'dinero_blog_post_button_text' );
	remove_theme_mod( 'dinero_show_thumbnail_image' );
	remove_theme_mod( 'dinero_blog_post_excerpt' );
	remove_theme_mod( 'dinero_blog_page_sidebar' );
	remove_theme_mod( 'dinero_blog_post_layout' );
	remove_theme_mod( 'dinero_blog_post_title_color' );
	remove_theme_mod( 'dinero_blog_metabox_text_color' );
	remove_theme_mod( 'dinero_blog_metabox_icon_color' );
	remove_theme_mod( 'dinero_blog_metabox_bg_color' );
	remove_theme_mod( 'dinero_blog_post_text_color' );
	remove_theme_mod( 'dinero_blog_post_button_text_color' );
	remove_theme_mod( 'dinero_blog_post_button_hover_color' );
	remove_theme_mod( 'dinero_blog_post_category_color' );
	remove_theme_mod( 'dinero_blog_post_category_icon_color' );
	remove_theme_mod( 'dinero_blog_post_tags_color' );
	remove_theme_mod( 'dinero_blog_post_tags_icon_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_single_post_reset_settings', 'dinero_single_post_reset_settings' );
function dinero_single_post_reset_settings() {
	remove_theme_mod( 'dinero_show_featured_image' );
	remove_theme_mod( 'dinero_single_post_image_height' );
	remove_theme_mod( 'dinero_single_post_sidebar' );
	remove_theme_mod( 'dinero_show_single_post_date' );
	remove_theme_mod( 'dinero_show_single_post_author' );
	remove_theme_mod( 'dinero_show_single_post_comments' );
	remove_theme_mod( 'dinero_single_post_time' );
	remove_theme_mod( 'dinero_show_single_post_category' );
	remove_theme_mod( 'dinero_show_single_post_tags' );
	remove_theme_mod( 'dinero_show_share_icons' );
	remove_theme_mod( 'dinero_single_post_metabox_bg_color' );
	remove_theme_mod( 'dinero_single_post_metabox_text_color' );
	remove_theme_mod( 'dinero_single_post_metabox_icon_color' );
	remove_theme_mod( 'dinero_single_post_category_color' );
	remove_theme_mod( 'dinero_single_post_category_icon_color' );
	remove_theme_mod( 'dinero_single_post_tags_icon_color' );
	remove_theme_mod( 'dinero_single_post_tags_color' );
	remove_theme_mod( 'dinero_single_post_title_color' );
	remove_theme_mod( 'dinero_single_post_content_color' );
	remove_theme_mod( 'dinero_single_post_comment_title_color' );
	remove_theme_mod( 'dinero_single_post_comment_text_color' );
	remove_theme_mod( 'dinero_single_post_comment_date_color' );
	remove_theme_mod( '' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_slider_reset_settings', 'dinero_slider_reset_settings' );
function dinero_slider_reset_settings() {
	remove_theme_mod( 'dinero_slider_section_width' );
	remove_theme_mod( 'dinero_slider_section_option' );
	remove_theme_mod( 'dinero_slider_shortcode' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_services_reset_settings', 'dinero_services_reset_settings' );
function dinero_services_reset_settings() {
	remove_theme_mod( 'dinero_service_button_enable' );
	remove_theme_mod( 'dinero_service_section_width' );
	remove_theme_mod( 'dinero_service_section_columns' );
	remove_theme_mod( 'dinero_service_section_padding' );
	remove_theme_mod( 'dinero_service_top_padding' );
	remove_theme_mod( 'dinero_service_bottom_padding' );
	remove_theme_mod( 'dinero_service_left_padding' );
	remove_theme_mod( 'dinero_service_right_padding' );
	remove_theme_mod( 'dinero_service_section_bg_color' );
	remove_theme_mod( 'dinero_service_section_bg_image' );
	remove_theme_mod( 'dinero_service_bg_opacity' );
	remove_theme_mod( 'dinero_service_onload_effects' );
	remove_theme_mod( 'dinero_service_small_title_color' );
	remove_theme_mod( 'dinero_service_section_title_color' );
	remove_theme_mod( 'dinero_service_section_icon_color' );
	remove_theme_mod( 'dinero_service_title_color' );
	remove_theme_mod( 'dinero_service_text_color' );
	remove_theme_mod( 'dinero_service_button_color' );
	remove_theme_mod( 'dinero_service_button_hover_color' );
	remove_theme_mod( 'dinero_service_box_color' );
	remove_theme_mod( 'dinero_service_box_hover_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_about_reset_settings', 'dinero_about_reset_settings' );
function dinero_about_reset_settings() {
	remove_theme_mod( 'dinero_about_section_padding' );
	remove_theme_mod( 'dinero_about_top_padding' );
	remove_theme_mod( 'dinero_about_bottom_padding' );
	remove_theme_mod( 'dinero_about_left_padding' );
	remove_theme_mod( 'dinero_about_right_padding' );
	remove_theme_mod( 'dinero_about_section_bg_color' );
	remove_theme_mod( 'dinero_about_section_bg_image' );
	remove_theme_mod( 'dinero_about_bg_opacity' );
	remove_theme_mod( 'dinero_about_onload_effects' );
	remove_theme_mod( 'dinero_about_section_width' );
	remove_theme_mod( 'dinero_about_small_title_color' );
	remove_theme_mod( 'dinero_about_section_title_color' );
	remove_theme_mod( 'dinero_about_section_text_color' );
	remove_theme_mod( 'dinero_about_section_list_color' );
	remove_theme_mod( 'dinero_about_button_bg_color' );
	remove_theme_mod( 'dinero_about_button_hover_bg_color' );
	remove_theme_mod( 'dinero_about_button_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_teams_reset_settings', 'dinero_teams_reset_settings' );
function dinero_teams_reset_settings() {
	remove_theme_mod( 'dinero_teams_section_width' );
	remove_theme_mod( 'dinero_teams_section_option' );
	remove_theme_mod( 'dinero_teams_small_title_color' );
	remove_theme_mod( 'dinero_teams_section_title_color' );
	remove_theme_mod( 'dinero_teams_section_bg_color' );
	remove_theme_mod( 'dinero_teams_section_bg_image' );
	remove_theme_mod( 'dinero_teams_section_bg_opacity' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

add_action( 'wp_ajax_dinero_footer_reset_settings', 'dinero_footer_reset_settings' );
function dinero_footer_reset_settings() {
	remove_theme_mod( 'dinero_footer_section_padding' );
	remove_theme_mod( 'dinero_footer_top_padding' );
	remove_theme_mod( 'dinero_footer_bottom_padding' );
	remove_theme_mod( 'dinero_widget_title_color' );
	remove_theme_mod( 'dinero_footer_section_bg_color1' );
	remove_theme_mod( 'dinero_footer_section_bg_color2' );
	remove_theme_mod( 'dinero_footer_section_bg_image' );
	remove_theme_mod( 'dinero_footer_section_bg_opacity' );
	remove_theme_mod( 'dinero_widget_text_color' );
	remove_theme_mod( 'dinero_widget_list_color' );
	remove_theme_mod( 'dinero_widget_anchor_color' );
	remove_theme_mod( 'dinero_widget_anchor_hover_color' );
	remove_theme_mod( 'dinero_copyright_color' );
	remove_theme_mod( 'dinero_footer_social_icon_color' );
	remove_theme_mod( 'dinero_footer_social_icon_hover_color' );
	wp_send_json_success(
		array(
			'success' => true,
			'message' => "Reset Completed",
		)
	);
}

require get_parent_theme_file_path( '/inc/custom-header.php' );

require get_parent_theme_file_path( '/inc/template-tags.php' );

require get_parent_theme_file_path( '/inc/template-functions.php' );

require get_parent_theme_file_path( '/inc/customizer.php' );

require get_parent_theme_file_path( '/inc/font-awesome-icons.php' );

require get_parent_theme_file_path( '/inc/tab-control.php' );

require get_parent_theme_file_path( '/inc/tgm/tgm.php' );

add_action('admin_menu', 'dinero_reorder_appearance_menu', 999);

function dinero_reorder_appearance_menu() {
    global $submenu;

    if (isset($submenu['themes.php'])) {
        $themes_submenu = $submenu['themes.php'];

        // Find and extract the Themes Dashboard item
        foreach ($themes_submenu as $key => $item) {
            if ($item[2] === 'themes-dashboard') {
                $dashboard_item = $item;
                unset($themes_submenu[$key]);
                break;
            }
        }

        // Re-index and add Themes Dashboard at the top
        if (isset($dashboard_item)) {
            $themes_submenu = array_values($themes_submenu); // reindex
            array_unshift($themes_submenu, $dashboard_item);
            $submenu['themes.php'] = $themes_submenu;
        }
    }
}

// Hook into current_screen to detect if we're on our custom page
add_action('current_screen', 'dinero_hide_admin_notices_on_custom_page');

function dinero_hide_admin_notices_on_custom_page($screen) {
    // Check for our custom page slug
    if ($screen->id === 'appearance_page_themes-dashboard') {
        // Remove all actions that show admin notices
        remove_all_actions('admin_notices');
        remove_all_actions('all_admin_notices');
        remove_all_actions('network_admin_notices');
    }
}

add_action('admin_menu', 'dinero_add_themes_dashboard_menu');

function dinero_add_themes_dashboard_menu() {
    add_theme_page(
        'Themes Dashboard',
        'Themes Dashboard',
        'manage_options',
        'themes-dashboard',
        'dinero_themes_dashboard_page'
    );
}

function dinero_themes_dashboard_page() {
    echo dinero_render_combined_dashboard();
}

function dinero_render_combined_dashboard() {
    $theme = wp_get_theme();
    $theme_name = $theme->get('Name');
    $screenshot = $theme->get_screenshot();
	$theme_description = $theme->get('Description');
    $theme_version = $theme->get('Version');

    $customize_url = admin_url('customize.php');

	// Dashboard file
	$dashboard_url = 'https://raw.githubusercontent.com/LuzukThemes/themes-dashboard/main/dashboard.html';
	$dashboard_response = wp_remote_get($dashboard_url);
	$dashboard_html = '';

	if (!is_wp_error($dashboard_response)) {
		$dashboard_html = wp_remote_retrieve_body($dashboard_response);
	} else {
		$dashboard_html = '<div class="notice notice-error"><p>Unable to load Dashboard content from GitHub.</p></div>';
	}

	// Coupon file
	$coupon_url = 'https://raw.githubusercontent.com/LuzukThemes/themes-dashboard/main/coupon.html';
	$coupon_response = wp_remote_get($coupon_url);
	$coupon_html = '';

	if (!is_wp_error($coupon_response)) {
		$coupon_html = wp_remote_retrieve_body($coupon_response);
	} else {
		$coupon_html = '<div class="notice notice-error"><p>Unable to load Coupon content from GitHub.</p></div>';
	}

    ob_start(); ?>
    <div class="wrap">
        <h1>Themes Dashboard</h1>
        <div style="display: flex; gap: 30px; margin-top: 30px;">

            <!-- Left Column -->
            <div style="flex: 1; background: #fff; padding: 20px; border: 1px solid #ddd; border-radius: 8px;">
				<h2 style="margin: 0 0 30px;background: #000;color: #fff;padding: 22px;text-align: center;border-radius: 6px;line-height: 2;">Use this coupon code and get 15% discount instantly <span style="background: #ff0000; color: #fff; padding: 5px 10px; border-radius: 5px;margin-left: 10px;font-weight: 800;">FREEWORDTHEME</span></h2>
                <img src="<?php echo esc_url($screenshot); ?>" alt="Theme Screenshot" style="max-width: 50%; border: 1px solid #ccc; float: left; margin-right: 20px; border-radius: 8px; border-right-color: #ff0000; border-bottom-color: #ff0000;" />
				<div style="background: #fff; padding: 20px; border: 1px solid #ddd; border-radius: 8px;">
					<h2 style="margin: 20px 0 30px;"><?php echo esc_html($theme_name); ?></h2>
					<p><strong>Version:</strong> <?php echo esc_html($theme_version); ?></p>
					<p><?php echo esc_html($theme_description); ?></p>
				</div>
                <div style="margin: 15px 0 50px;">
					<a href="https://www.luzukdemo.com/docs/dinero/" target="_blank" class="button" style="background: #000; color: #fff; margin-right: 10px; padding: 6px 24px; font-size: 16px; font-weight: bold">Pro Documentation</a>
                    <a href="https://wordpress.org/support/theme/dinero/" target="_blank" class="button" style="background: #000; color: #fff; margin-right: 10px; padding: 6px 24px; font-size: 16px;margin-bottom: 10px; font-weight: bold">Need Support</a>
					<a href="https://www.luzukdemo.com/demo/dinero/" target="_blank" class="button" style="background: #000; color: #fff; margin-right: 10px; padding: 6px 24px; font-size: 16px; font-weight: bold">Live Demo</a>
					<a href="https://www.luzuk.com/products/multipurpose-corporate-wordpress-theme/" target="_blank" class="button" style="background: #0056ff; color: #fff; margin-right: 10px; padding: 6px 24px; font-size: 16px; font-weight: bold">Buy Premium</a>
                </div>

                <?php echo $dashboard_html; ?>

		</div>
          
		<div style="display: flex; gap: 30px; margin-top: 30px; text-align: center;">
			<div style="flex: 2; margin: 20px 0; padding: 20px; background: #f7f7f7; border: 1px dashed #aaa;">
				<?php echo $coupon_html; ?>
				<a href="https://www.luzuk.com/products/multipurpose-corporate-wordpress-theme/" target="_blank" class="button button-primary" style="display: block; padding: 10px; background: #77b255;font-weight: bold; margin-top: 10px;">UPGRADE NOW</a><br>
			</div>
			<div style="flex: 2; margin: 20px 0; padding: 20px;"></div>
		</div>
    <?php
    return ob_get_clean();
}