<?php
/**
 * 
 * wheelify functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package wheelify
 * 
 * @since  1.0.0
 * 
*/
require get_template_directory() . '/upgrade-to-pro/class-customize.php';

/**
 * Initialize Theme.
**/
require get_template_directory() . '/inc/theme-setup.php';

/**
 * Implement the Custom Header feature.
**/
require get_template_directory() . '/inc/custom-header.php';

/**
 * Custom template tags for this theme.
**/
require get_template_directory() . '/inc/template-tags.php';

/**
 * Functions which enhance the theme by hooking into WordPress.
**/
require get_template_directory() . '/inc/template-functions.php';

/**
 * Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';

/**
 * Typography Options.
*/
require get_template_directory() . '/typography.php';

/**
 * Wheelify Theme Nav Walker.
**/
require get_template_directory() . '/inc/wheelify_custom_nav_walker.php';

/**
 * basic.
**/
require get_template_directory() . '/inc/basic.php';

/**
 * Aabout Wheelify Page.
**/




/* theme style */
function wheelify_theme_style(){
		
		/* Web Fonts Typography Settings code start */		

        wp_enqueue_style('wheelify-google-fonts',esc_url(wheelify2()));
		
		$font_var          = '300,400,600,700,900,300italic,400italic,600italic,700italic,900italic';
        $http              = ( ! empty( $_SERVER['HTTPS'] ) ) ? "https" : "http";
        $main_heading_font = str_replace( ' ' , '+', get_theme_mod( 'main_heading_font', 'Open Sans' ) );
        $menu_font         = str_replace( ' ' , '+', get_theme_mod( 'menu_font', 'Open Sans' ) );
        $theme_title       = str_replace( ' ' , '+', get_theme_mod( 'theme_title', 'Open Sans' ) );
        $desc_font_all     = str_replace( ' ' , '+', get_theme_mod( 'desc_font_all', 'Open Sans' ) );

        wp_enqueue_style('main_heading_font', $http . '://fonts.googleapis.com/css?family=' . $main_heading_font . ':' . $font_var);	
        wp_enqueue_style('menu_font', $http . '://fonts.googleapis.com/css?family=' . $menu_font . ':' . $font_var);	
        wp_enqueue_style('theme_title', $http . '://fonts.googleapis.com/css?family=' . $theme_title . ':' . $font_var);
        wp_enqueue_style('desc_font_all', $http . '://fonts.googleapis.com/css?family=' . $desc_font_all . ':' . $font_var);
		
}
add_action( 'wp_enqueue_scripts', 'wheelify_theme_style' );



/* Add Typography Settings code start */	
add_action('wp_enqueue_scripts', 'wheelify_custom_css');
function wheelify_custom_css()
{
    $output = '';
	
	$output .= '.site-title a, .site-description {
		font-family: ' . get_theme_mod('main_heading_font', 'Open Sans') . '!important;
		}
		 .first-menu .navbar .navbar-nav a.nav-link, .dropdown-item {
			font-family: ' . get_theme_mod('menu_font', 'Open Sans') . '!important ;
		}
		h1, h2, h3, h4, h5, h6{
			font-family: ' . get_theme_mod('theme_title', 'Open Sans') . ';
		}
       
		
		  html, body, p, table, caption, tbody, tfoot, thead, tr, th, td, input, button, select, textarea, ul.detail-meta-tag li, #mainSlider .owl-carousel a.btn.btn-large, a.btn.main-btn{
			font-family: ' . get_theme_mod('desc_font_all', 'Open Sans') . ';
		}';

    
    $output     .='
    .logo img{
        height:'.esc_attr(get_theme_mod('logo_height','100')).'px;
        width:'.esc_attr(get_theme_mod('logo_width','100')).'px;
    }';
    //custom css
    $custom_css = get_theme_mod('custom_css') ; 
    if (!empty ($custom_css)) {
        $output .= get_theme_mod('custom_css') . "\n";
    }

    wp_register_style('custom-header-style', false);
    wp_enqueue_style('custom-header-style', get_template_directory_uri() . '/css/custom-header-style.css');
    wp_add_inline_style('custom-header-style', $output);
}
/* Add Typography Settings code end */

	

add_action( 'wp_enqueue_scripts', 'wheelify2' );

if ( is_admin() ) {
	require_once('core/admin/admin-themes.php');
}
function wheelify2() {
	// Include google webfont locally Typography Settings //
	require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );
	
	$font_families = array(
		'Bree Serif:wght@300;400;500;600;700',
		'Open Sans:wght@300;400;500;600;700'
	);

	$fonts_url = add_query_arg( array(
		'family' => implode( '&family=', $font_families ),
		'display' => 'swap',
		'subset' => 'latin,latin-ext',
	), 'https://fonts.googleapis.com/css2' );
	
	$contents = wptt_get_webfont_url( esc_url_raw( $fonts_url ) );
	
	// Load the webfont.
	wp_enqueue_style(
		'googlewebfonts_local',
		$contents,
		array(),
		'1.0'
	);}
/* Web Fonts Typography Settings code end */






