/** START || Fix MetForm issue in Header/Footer Template */
function remove_jkit_header_footer_default_filter() {
	remove_action( 'jkit_header', array( Jeg\Elementor_Kit\Templates\Template::instance(), 'render_header' ) );
	remove_action( 'jkit_footer', array( Jeg\Elementor_Kit\Templates\Template::instance(), 'render_footer' ) );
}
add_action( 'wp', 'remove_jkit_header_footer_default_filter' );

function add_custom_jkit_header_template() {
	$class_template = Jeg\Elementor_Kit\Templates\Template::instance();
	$post_id        = get_the_ID();
	$headers        = $class_template->get_header_template();
	$header_id      = null;

	foreach ( $headers as $header ) {
		$flag = $class_template->check_conditions( $post_id, $header['id'] );

		if ( $flag ) {
			$header_id = $header['id'];
			break;
		}
	}

	if ( $header_id ) {
		?>
			<header id="masthead" itemscope="itemscope" itemtype="https://schema.org/WPHeader">
				<?php
				echo $class_template->get_header_content( $header_id );
				?>
			</header>
		<?php
	}
}
add_action( 'jkit_header', 'add_custom_jkit_header_template' );

function add_custom_jkit_footer_template() {
	$class_template = Jeg\Elementor_Kit\Templates\Template::instance();
	$post_id        = get_the_ID();
	$footers        = $class_template->get_footer_template();
	$footer_id      = null;

	foreach ( $footers as $footer ) {
		$flag = $class_template->check_conditions( $post_id, $footer['id'] );

		if ( $flag ) {
			$footer_id = $footer['id'];
			break;
		}
	}

	if ( $footer_id ) {
		?>
			<footer itemscope="itemscope" itemtype="https://schema.org/WPFooter">
				<?php
				echo $class_template->get_footer_content( $footer_id );
				?>
			</footer>
		<?php
	}
}
add_action( 'jkit_footer', 'add_custom_jkit_footer_template' );
/** END || Fix MetForm issue in Header/Footer Template */