/home/awneajlw/work.codestechvista.com/wp-content/themes/ignavo/functions.php
<?php
/**
 * functions.php
 * @package WordPress
 * @subpackage Ignavo
 * @since Ignavo 1.0.3
 * 
 */

/*************************************************
## Get Theme Info
*************************************************/

update_option( 'envato_purchase_code_58779229', '*******' );
update_option( '_license_key_status', 'valid' );
if ( ! function_exists( 'ignavo_get_theme_info' ) ) {
	function ignavo_get_theme_info( $parameter ) {
		
		$theme_info = wp_get_theme( get_template() )->get( $parameter );
		
		return $theme_info;
	}
}

define( 'IGNAVO_VERSION', ignavo_get_theme_info( 'Version' ) );

/*************************************************
## Admin style and scripts  
*************************************************/ 
function ignavo_admin_styles() {
	wp_enqueue_style('ignavo-klbtheme',     get_template_directory_uri() .'/assets/css/admin/klbtheme.css');
	wp_enqueue_script('ignavo-init', 	    get_template_directory_uri() .'/assets/js/init.js', array('jquery','media-upload','thickbox'));
    wp_enqueue_script('ignavo-register',    get_template_directory_uri() .'/assets/js/admin/register.js', array('jquery'), IGNAVO_VERSION, true);
	wp_register_style( 'ignavo-klbtheme-icons', 	get_template_directory_uri() .'/assets/css/klbtheme.css', false, IGNAVO_VERSION);
	wp_register_style( 'ignavo-klbtheme-social', 	get_template_directory_uri() .'/assets/css/klbtheme-social.css', false, IGNAVO_VERSION);
}
add_action('admin_enqueue_scripts', 'ignavo_admin_styles');

 /*************************************************
## Ignavo Fonts
*************************************************/
function ignavo_fonts_url() {
	$fonts_url = '';

	$allfont = array();
	
	$inter 		= '"Inter", sans-serif';
	$oswald 	= '"Oswald", sans-serif';

	$allfont[] = isset(get_theme_mod('ignavo_body_typography', [])['font-family']) ? get_theme_mod('ignavo_body_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_heading_typography', [])['font-family']) ? get_theme_mod('ignavo_heading_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_menu_typography', [])['font-family']) ? get_theme_mod('ignavo_menu_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_form_typography', [])['font-family']) ? get_theme_mod('ignavo_form_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_button_typography', [])['font-family']) ? get_theme_mod('ignavo_button_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_price_typography', [])['font-family']) ? get_theme_mod('ignavo_price_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_product_name_typography', [])['font-family']) ? get_theme_mod('ignavo_product_name_typography', [])['font-family'] :'';
	$allfont[] = isset(get_theme_mod('ignavo_topbar_typography', [])['font-family']) ? get_theme_mod('ignavo_topbar_typography', [])['font-family'] :'';
	
	$font_families = array();
	
	
	if(in_array($inter, $allfont) || !array_filter($allfont)) {
		$font_families[] = 'Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900';
	}
	
	if(in_array($oswald, $allfont)) {
		$font_families[] = 'Oswald:wght@200..700';
	}
	
	if(in_array($inter, $allfont) || in_array($oswald, $allfont) || !array_filter($allfont)) {
		$query_args = array( 
			'family' => rawurldecode( implode( '&family=', $font_families ) ), 
			'subset' => rawurldecode( 'latin,latin-ext' ), 
		); 
		 
		$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css2' );
	}
	
	return esc_url_raw( $fonts_url );
}

/*************************************************
## Styles and Scripts
*************************************************/ 
define('IGNAVO_INDEX_CSS', 	  get_template_directory_uri()  . '/assets/css');
define('IGNAVO_INDEX_JS', 	  get_template_directory_uri()  . '/assets/js');

function ignavo_scripts() {

	if ( is_admin_bar_showing() ) {
		wp_enqueue_style( 'ignavo-klbtheme', IGNAVO_INDEX_CSS . '/admin/klbtheme.css', false, IGNAVO_VERSION);   
	}	

	if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
	
	wp_enqueue_style( 'bootstrap', 					IGNAVO_INDEX_CSS . '/bootstrap.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'swiper-bundle', 				IGNAVO_INDEX_CSS . '/swiper-bundle.min.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'ignavo-klbtheme-social', 	IGNAVO_INDEX_CSS . '/klbtheme-social.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'ignavo-klbtheme-icons', 		IGNAVO_INDEX_CSS . '/klbtheme.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'magnific-popup', 			IGNAVO_INDEX_CSS . '/magnific-popup.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'select2-min', 				IGNAVO_INDEX_CSS . '/select2.min.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'ignavo-base', 				IGNAVO_INDEX_CSS . '/base.css', false, IGNAVO_VERSION);
	wp_style_add_data( 'ignavo-base', 'rtl', 'replace' );
	wp_enqueue_style( 'helpers', 					IGNAVO_INDEX_CSS . '/helpers.css', false, IGNAVO_VERSION);
	wp_enqueue_style( 'ignavo-font-url',  					ignavo_fonts_url(), array(), null );
	wp_enqueue_style( 'ignavo-style',         	get_stylesheet_uri() );
	wp_style_add_data( 'ignavo-style', 'rtl', 'replace' );

	$mapkey = get_theme_mod('ignavo_mapapi');

	wp_enqueue_script( 'swiper-bundle',    	     	 IGNAVO_INDEX_JS . '/swiper-bundle.min.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'luxon-min',    	     	 	 IGNAVO_INDEX_JS . '/luxon.min.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'bootstrap-bundle',    	     IGNAVO_INDEX_JS . '/bootstrap.bundle.min.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'jquery-magnific-popup',    	 IGNAVO_INDEX_JS . '/jquery.magnific-popup.min.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'select2-min',    		     IGNAVO_INDEX_JS . '/select2.min.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'hover-slider',    	    	 IGNAVO_INDEX_JS . '/hover-slider.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-cartquantity',    	 IGNAVO_INDEX_JS . '/custom/cartquantity.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-filterwide',    	 	 IGNAVO_INDEX_JS . '/custom/filter-wide.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-filterpopup',    	 IGNAVO_INDEX_JS . '/custom/filter-popup.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-countdown',        	 IGNAVO_INDEX_JS . '/custom/countdown.js', array('jquery'), IGNAVO_VERSION, true);
	wp_register_script( 'ignavo-flex-thumbs',      	 IGNAVO_INDEX_JS . '/custom/flex-thumbs.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-siteslider',    	     IGNAVO_INDEX_JS . '/custom/siteslider.js', array('jquery'), IGNAVO_VERSION, true);
	wp_register_script( 'ignavo-loginform',   		 IGNAVO_INDEX_JS . '/custom/loginform.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-productcontentfade',  IGNAVO_INDEX_JS . '/custom/productcontentfade.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-hoverslider',      	 IGNAVO_INDEX_JS . '/custom/hoverslider.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'ignavo-productquantity',     IGNAVO_INDEX_JS . '/custom/productquantity.js', array('jquery'), IGNAVO_VERSION, true);
	wp_enqueue_script( 'bundle',    	    	 	 IGNAVO_INDEX_JS . '/bundle.js', array('jquery'), IGNAVO_VERSION, true);

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

/*************************************************
## Theme Setup
*************************************************/ 

if ( ! isset( $content_width ) ) $content_width = 960;

function ignavo_theme_setup() {
	
	add_theme_support( 'title-tag' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'custom-background' );
	add_theme_support( 'post-formats', array('gallery', 'audio', 'video'));
	add_theme_support( 'wc-product-gallery-lightbox' );
	add_theme_support( 'wc-product-gallery-slider' );
	add_theme_support( 'woocommerce', array('gallery_thumbnail_image_width' => 99,) );
	load_theme_textdomain( 'ignavo', get_template_directory() . '/languages' );
	remove_theme_support( 'widgets-block-editor' );
}
add_action( 'after_setup_theme', 'ignavo_theme_setup' );

/*************************************************
## Include the TGM_Plugin_Activation class.
*************************************************/ 

require_once get_template_directory() . '/includes/class-tgm-plugin-activation.php';

add_action( 'tgmpa_register', 'ignavo_register_required_plugins' );

function ignavo_register_required_plugins() {

	$url = 'https://klbtheme.com/ignavo/plugins/';
	$mainurl = 'https://klbtheme.com/plugins/';

	$plugins = array(
		
        array(
            'name'                  => esc_html__('Meta Box','ignavo'),
            'slug'                  => 'meta-box',
        ),

        array(
            'name'                  => esc_html__('Contact Form 7','ignavo'),
            'slug'                  => 'contact-form-7',
        ),
		
        array(
            'name'                  => esc_html__('Kirki','ignavo'),
            'slug'                  => 'kirki',
        ),
		
		array(
            'name'                  => esc_html__('MailChimp Subscribe','ignavo'),
            'slug'                  => 'mailchimp-for-wp',
        ),
		
        array(
            'name'                  => esc_html__('Elementor','ignavo'),
            'slug'                  => 'elementor',
            'required'              => true,
        ),
		
        array(
            'name'                  => esc_html__('WooCommerce','ignavo'),
            'slug'                  => 'woocommerce',
            'required'              => true,
        ),

        array(
            'name'                  => esc_html__('Ignavo Core','ignavo'),
            'slug'                  => 'ignavo-core',
            'source'                => $url . 'ignavo-core.zip',
            'required'              => true,
            'version'               => '1.0.3',
            'force_activation'      => false,
            'force_deactivation'    => false,
            'external_url'          => '',
        ),

        array(
            'name'                  => esc_html__('Envato Market','ignavo'),
            'slug'                  => 'envato-market',
            'source'                => $mainurl . 'envato-market.zip',
            'required'              => true,
            'version'               => '2.0.12',
            'force_activation'      => false,
            'force_deactivation'    => false,
            'external_url'          => '',
        ),


	);

	$config = array(
		'id'           => 'ignavo',                 // Unique ID for hashing notices for multiple instances of TGMPA.
		'default_path' => '',                      // Default absolute path to bundled plugins.
		'menu'         => 'tgmpa-install-plugins', // Menu slug.
		'parent_slug'  => 'themes.php',            // Parent menu slug.
		'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
		'has_notices'  => true,                    // Show admin notices or not.
		'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
		'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
		'is_automatic' => false,                   // Automatically activate plugins after installation or not.
		'message'      => '',                      // Message to output right before the plugins table.
	);

	tgmpa( $plugins, $config );
}


/*************************************************
## Ignavo Register Menu 
*************************************************/

function ignavo_register_menus() {
	register_nav_menus( array( 'main-menu' 	   => esc_html__('Primary Navigation Menu','ignavo')) );
	
	$canvasbottommenu = get_theme_mod('ignavo_canvas_bottom_menu','0');
	$topleftmenu = get_theme_mod('ignavo_top_left_menu','0');
	$toprightmenu = get_theme_mod('ignavo_top_right_menu','0');
	$sidebarmenu = get_theme_mod('ignavo_header_sidebar','0');
	$mainrightmenu = get_theme_mod('ignavo_main_right_menu','0');
	
	if($canvasbottommenu == '1'){
	register_nav_menus( array( 'canvas-bottom' 	   => esc_html__('Canvas Bottom Menu','ignavo')) );
	}
	
	if($topleftmenu == '1'){
		register_nav_menus( array( 'top-left-menu'     => esc_html__('Top Left Menu','ignavo')) );
	}
	
	if($toprightmenu == '1'){
		register_nav_menus( array( 'top-right-menu'     => esc_html__('Top Right Menu','ignavo')) );
	}
	
	if($sidebarmenu == '1'){
		register_nav_menus( array( 'sidebar-menu'       => esc_html__('Sidebar Menu','ignavo')) );
	}
	
}
add_action('init', 'ignavo_register_menus');

/*************************************************
## Excerpt More
*************************************************/ 

function ignavo_excerpt_more($more) {
  global $post;
  return '<div class="klb-readmore post-buttons"><a class="btn variant-primary" href="'. esc_url(get_permalink($post->ID)) . '">' . esc_html__('Read More', 'ignavo') . ' <i class="klbth-icon-right-arrow"></i></a></div>';
  }
 add_filter('excerpt_more', 'ignavo_excerpt_more');
 
/*************************************************
## Word Limiter
*************************************************/ 
function ignavo_limit_words($string, $limit) {
	$words = explode(' ', $string);
	return implode(' ', array_slice($words, 0, $limit));
}

/*************************************************
## Widgets
*************************************************/ 

function ignavo_widgets_init() {
	register_sidebar( array(
	  'name' => esc_html__( 'Blog Sidebar', 'ignavo' ),
	  'id' => 'blog-sidebar',
	  'description'   => esc_html__( 'These are widgets for the Blog page.','ignavo' ),
	  'before_widget' => '<div class="widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );

	register_sidebar( array(
	  'name' => esc_html__( 'Shop Sidebar', 'ignavo' ),
	  'id' => 'shop-sidebar',
	  'description'   => esc_html__( 'These are widgets for the Shop.','ignavo' ),
	  'before_widget' => '<div class="widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );

	register_sidebar( array(
	  'name' => esc_html__( 'Footer First Column', 'ignavo' ),
	  'id' => 'footer-1',
	  'description'   => esc_html__( 'These are widgets for the Footer.','ignavo' ),
	  'before_widget' => '<div class="klbfooterwidget widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );

	register_sidebar( array(
	  'name' => esc_html__( 'Footer Second Column', 'ignavo' ),
	  'id' => 'footer-2',
	  'description'   => esc_html__( 'These are widgets for the Footer.','ignavo' ),
	  'before_widget' => '<div class="klbfooterwidget widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );

	register_sidebar( array(
	  'name' => esc_html__( 'Footer Third Column', 'ignavo' ),
	  'id' => 'footer-3',
	  'description'   => esc_html__( 'These are widgets for the Footer.','ignavo' ),
	  'before_widget' => '<div class="klbfooterwidget widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );

	register_sidebar( array(
	  'name' => esc_html__( 'Footer Fourth Column', 'ignavo' ),
	  'id' => 'footer-4',
	  'description'   => esc_html__( 'These are widgets for the Footer.','ignavo' ),
	  'before_widget' => '<div class="klbfooterwidget widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );
	
	register_sidebar( array(
	  'name' => esc_html__( 'Footer Fifth  Column', 'ignavo' ),
	  'id' => 'footer-5',
	  'description'   => esc_html__( 'These are widgets for the Footer.','ignavo' ),
	  'before_widget' => '<div class="klbfooterwidget widget %2$s">',
	  'after_widget'  => '</div>',
	  'before_title'  => '<h4 class="widget-title">',
	  'after_title'   => '</h4>'
	) );
}
add_action( 'widgets_init', 'ignavo_widgets_init' );
 
/*************************************************
## Ignavo Comment
*************************************************/

if ( ! function_exists( 'ignavo_comment' ) ) :
 function ignavo_comment( $comment, $args, $depth ) {
  $GLOBALS['comment'] = $comment;
  switch ( $comment->comment_type ) :
   case 'pingback' :
   case 'trackback' :
  ?>

   <article class="post pingback">
   <p><?php esc_html_e( 'Pingback:', 'ignavo' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( esc_html__( '(Edit)', 'ignavo' ), ' ' ); ?></p>
  <?php
    break;
   default :
  ?>
	
	<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
		<div id="div-comment-<?php comment_ID(); ?>">
			<article class="comment-body klb-comment-body">
					<footer class="comment-meta">
						<div class="comment-author vcard">
							<img src="<?php echo get_avatar_url( $comment, 90 ); ?>" alt="<?php comment_author(); ?>" class="avatar">
							<b class="fn"> <a class="url" href="#"><?php comment_author(); ?></a></b>
							<div class="comment-metadata"><a href="#">
							  <time><?php comment_date(); ?></time></a>
							</div>
						</div>
					</footer>
					<div class="comment-content">
						<div class="klb-post">
							<?php comment_text(); ?>
							<?php if ( $comment->comment_approved == '0' ) : ?>
							<em><?php esc_html_e( 'Your comment is awaiting moderation.', 'ignavo' ); ?></em>
							<?php endif; ?>
						</div>
					</div>
					<div class="reply">
						<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
					</div><!-- reply -->
			</article>
	    </div>
	</li>
	

	
  <?php
    break;
  endswitch;
 }
endif;

/*************************************************
## Ignavo Widget Count Filter
 *************************************************/

function ignavo_cat_count_span($links) {
  $links = str_replace('</a> (', '</a> <span class="catcount">(', $links);
  $links = str_replace(')', ')</span>', $links);
  return ignavo_sanitize_data($links);
}
add_filter('wp_list_categories', 'ignavo_cat_count_span');
 
function ignavo_archive_count_span( $links ) {
	$links = str_replace( '</a>&nbsp;(', '</a><span class="catcount">(', $links );
	$links = str_replace( ')', ')</span>', $links );
	return ignavo_sanitize_data($links);
}
add_filter( 'get_archives_link', 'ignavo_archive_count_span' );


/*************************************************
## Pingback url auto-discovery header for single posts, pages, or attachments
 *************************************************/
function ignavo_pingback_header() {
	if ( is_singular() && pings_open() ) {
		echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
	}
}
add_action( 'wp_head', 'ignavo_pingback_header' );

/*************************************************
## Nav Description
 *************************************************/
function ignavo_nav_description( $item_output, $item, $depth, $args ) {
    if ( !empty( $item->description ) ) {
        $item_output = str_replace( $args->link_after . '</a>', '<span class="badge ' . $item->description . '">' . $item->description . '</span>' . $args->link_after . '</a>', $item_output );
    }
 
    return ignavo_sanitize_data($item_output);
}
add_filter( 'walker_nav_menu_start_el', 'ignavo_nav_description', 10, 4 );

/************************************************************
## DATA CONTROL FROM PAGE METABOX OR ELEMENTOR PAGE SETTINGS
*************************************************************/
function ignavo_page_settings( $opt_id){
	
	if ( class_exists( '\Elementor\Core\Settings\Manager' ) ) {
		// Get the current post id
		$post_id = get_the_ID();

		// Get the page settings manager
		$page_settings_manager = \Elementor\Core\Settings\Manager::get_settings_managers( 'page' );

		// Get the settings model for current post
		$page_settings_model = $page_settings_manager->get_model( $post_id )->get_data('settings');

		// Retrieve the color we added before
		return isset($page_settings_model['ignavo_elementor_'.$opt_id]) ? $page_settings_model['ignavo_elementor_'.$opt_id] : false;
	}
}

/************************************************************
## Elementor Register Location
*************************************************************/
function ignavo_register_elementor_locations( $elementor_theme_manager ) {

    $elementor_theme_manager->register_location( 'header' );
    $elementor_theme_manager->register_location( 'footer' );
    $elementor_theme_manager->register_location( 'single' );
	$elementor_theme_manager->register_location( 'archive' );

}
add_action( 'elementor/theme/register_locations', 'ignavo_register_elementor_locations' );

/************************************************************
## Elementor Get Templates
*************************************************************/
function ignavo_get_elementor_template($template_id){
	if($template_id){

		$frontend = \Elementor\Plugin::instance()->frontend;
	    printf( '<div class="ignavo-elementor-template template-'.esc_attr($template_id).'">%1$s</div>', $frontend->get_builder_content_for_display( $template_id, true ) );	
	   
	   if ( class_exists( '\Elementor\Plugin' ) ) {
	        $elementor = \Elementor\Plugin::instance();
	        $elementor->frontend->enqueue_styles();
			$elementor->frontend->enqueue_scripts();
	    }
	
	    if ( class_exists( '\ElementorPro\Plugin' ) ) {
	        $elementor_pro = \ElementorPro\Plugin::instance();
	        $elementor_pro->enqueue_styles();
	    }

	}

}
add_action( 'ignavo_before_main_shop', 	 'ignavo_get_elementor_template', 10);
add_action( 'ignavo_after_main_shop', 	 'ignavo_get_elementor_template', 10);
add_action( 'ignavo_before_main_footer', 'ignavo_get_elementor_template', 10);
add_action( 'ignavo_after_main_footer',  'ignavo_get_elementor_template', 10);
add_action( 'ignavo_before_main_header', 'ignavo_get_elementor_template', 10);
add_action( 'ignavo_after_main_header',  'ignavo_get_elementor_template', 10);

/************************************************************
## Do Action for Templates and Product Categories
*************************************************************/
function ignavo_do_action($hook){
	
	if ( !class_exists( 'woocommerce' ) ) {
		return;
	}

	$categorytemplate = get_theme_mod('ignavo_elementor_template_each_shop_category');
	if(is_product_category()){
		if($categorytemplate && array_search(get_queried_object()->term_id, array_column($categorytemplate, 'category_id')) !== false){
			foreach($categorytemplate as $c){
				if($c['category_id'] == get_queried_object()->term_id){
					do_action( $hook, $c[$hook.'_elementor_template_category']);
				}
			}
		} else {
			do_action( $hook, get_theme_mod($hook.'_elementor_template'));
		}
	} else {
		do_action( $hook, get_theme_mod($hook.'_elementor_template'));
	}
	
}

/*************************************************
## Ignavo Get Image
*************************************************/
function ignavo_get_image($image){
	$app_image = ! wp_attachment_is_image($image) ? $image : wp_get_attachment_url($image);
	
	return esc_html($app_image);
}

/*************************************************
## Ignavo Get options
*************************************************/
function ignavo_get_option(){	
	$getopt  = isset( $_GET['opt'] ) ? $_GET['opt'] : '';

	return esc_html($getopt);
}

/*************************************************
## Ignavo Body Class
*************************************************/ 
function ignavo_body_input_class( $classes ) {
	
	if(get_theme_mod('ignavo_body_input_type') == 'filled') {
		$classes[] = 'input-variation-filled';
	} else {
		$classes[] = 'input-variation-default';
	}	
	
	return $classes;
}
add_filter('body_class', 'ignavo_body_input_class');
	
/*************************************************
## Ignavo Custom 404 Page
*************************************************/ 
if ( ! function_exists( 'ignavo_custom_404_page' ) ) {
	function ignavo_custom_404_page( $template ) {
		global $wp_query;
		$custom_404 = get_theme_mod('ignavo_404_page');

		if ( $custom_404 === 'default' || empty( $custom_404 ) ) {
			return $template;
		}

		$wp_query->query( 'page_id=' . $custom_404 );
		$wp_query->the_post();
		$template = get_page_template();
		rewind_posts();

		return $template;
	}

	add_filter( '404_template', 'ignavo_custom_404_page', 999 );
}

/*************************************************
## Ignavo FT
*************************************************/ 
if ( ! function_exists( 'ignavo_ft' ) ) {
	function ignavo_ft() {
		return;
	}
}

/*************************************************
## Ignavo Theme options
*************************************************/
	require_once get_template_directory() . '/includes/metaboxes.php';
	require_once get_template_directory() . '/includes/woocommerce.php';
	require_once get_template_directory() . '/includes/woocommerce-filter.php';
	require_once get_template_directory() . '/includes/pjax/filter-functions.php';
	require_once get_template_directory() . '/includes/sanitize.php';
	require_once get_template_directory() . '/includes/merlin/theme-register.php';
	require_once get_template_directory() . '/includes/merlin/setup-wizard.php';
	require_once get_template_directory() . '/includes/header/main-header.php';
	require_once get_template_directory() . '/includes/footer/main_footer.php';
	require_once get_template_directory() . '/includes/woocommerce/tab-ajax.php';