<?php
/**
 * mediapulse functions and definitions
 *
 * @package mediapulse
 * @since mediapulse 1.0
 */
 
 

 
// Global variables define
define('MEDIAPULSE_TEMPLATE_DIR_URI', get_template_directory_uri());
define('MEDIAPULSE_TEMPLATE_DIR', get_template_directory());

if ( ! isset( $content_width ) ) {
	$content_width = 800; /* pixels */
}



if ( ! function_exists( 'mediapulse_setup' ) ) :

	function mediapulse_setup() {

		/**
		 * Make theme available for translation.
		 * Translations can be placed in the /languages/ directory.
		 */
		load_theme_textdomain( 'mediapulse', get_template_directory() . '/languages' );

		/**
		 * Add default posts and comments RSS feed links to <head>.
		 */
		add_theme_support( 'automatic-feed-links' );

		/**
		 * Enable support for post thumbnails and featured images.
		 */
		add_theme_support( 'post-thumbnails' );
		
		add_theme_support( "title-tag" );
		add_theme_support( "align-wide" );
		//add_theme_support( "html5" );
		add_theme_support( "wp-block-styles" );
		add_theme_support( "responsive-embeds" );
		add_theme_support( 'custom-logo' );
		
		$args = array(
			'default-text-color' => 'fff',
			'width'              => 1000,
			'height'             => 250,
			'flex-width'         => true,
			'flex-height'        => true,
		);
		add_theme_support( "custom-header", $args );
		add_theme_support( "custom-background", $args );

		/**
		 * Add support for two custom navigation menus.
		 */
		register_nav_menus( array(
			'primary'   => __( 'Primary Menu', 'mediapulse' ),
			'secondary' => __( 'Secondary Menu', 'mediapulse' ),
		) );
		
		add_image_size( 'mediapulse-full', 1200, 900 );

	}
endif;
add_action( 'after_setup_theme', 'mediapulse_setup' );

if ( is_admin() ) {
	require_once('core/admin/admin-themes.php');
}



 /**
 * Customizer theme option...
*/
require get_template_directory() . '/customizer.php';
	/**

/**
 * Proper way to enqueue scripts and styles
 */
function mediapulse_theme_name_scripts() {
	wp_enqueue_style( 'style', get_stylesheet_uri() );
	wp_enqueue_style( 'all-min-css', get_template_directory_uri() . '/css/all.min.css' );
	wp_enqueue_style( 'owl-style-css', get_template_directory_uri() . '/css/owl.carousel.min.css' );
	
	wp_enqueue_script( 'jquery' );
	wp_enqueue_script( 'owl-carousel-min', get_template_directory_uri() . '/js/owl.carousel.min.js' );
	wp_enqueue_script( 'bootstrap-min', get_template_directory_uri() . '/js/bootstrap.min.js' );
	
	wp_enqueue_script( 'mediapulse-main-js', get_template_directory_uri() . '/js/main.js' );
	wp_enqueue_script( 'mediapulse-script-js', get_template_directory_uri() . '/js/script.js',Null,Null,true );
	
	/* Web Fonts Typography Settings code start */		

        wp_enqueue_style('mediapulse-google-fonts',esc_url(mediapulse_scripts2()));
		
		$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', 'mediapulse_theme_name_scripts' );

require( get_template_directory() . '/lib/menu/class-wp-bootstrap-navwalker.php' );
require( get_template_directory() . '/lib/customizer/customizer.php' );
require( get_template_directory() . '/lib/theme-function.php' );
require( get_template_directory() . '/lib/theme-taxanomy-image.php' );



/* Add Typography Settings code start */	
add_action('wp_enqueue_scripts', 'mediapulse_custom_css');
function mediapulse_custom_css()
{
    $output = '';
	
	$output .= 'h3.logo-title, p.description {
		font-family: ' . get_theme_mod('main_heading_font', 'Open Sans') . '!important;
		}
		 ul.navbar-nav li a {
			font-family: ' . get_theme_mod('menu_font', 'Open Sans') . '!important ;
		}
		h1, h2, h3, h4, h5, h6, .owl-carousel-2 .overlay a{
			font-family: ' . get_theme_mod('theme_title', 'Open Sans') . ';
		}
       
		
		 .carousel-item-2 .h4, html, body, p, table, caption, tbody, tfoot, thead, tr, th, td, input, button, select, textarea, input#searchsubmit {
			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 */


function mediapulse_scripts2() {
	// Include google webfont locally Typography Settings //
	require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );
	
	$font_families = array(
		'Poppins:wght@100;200;300;400;500;600;700;800;900'
		
	);

	$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 */



?>