<?php
/**
 * Custom Elementor Template for Single Product
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$template_id = get_query_var( 'sifency_product_template_id' );
$header_id   = Sifency_Addons_Frontend_Helper::find_matching_template( 'header' );
$footer_id   = Sifency_Addons_Frontend_Helper::find_matching_template( 'footer' );

if ( $header_id ) {
	include get_query_template( 'header' );
	echo '<header id="sifency-custom-header">';
     // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor already escapes content internally.
	echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $header_id, true );
	echo '</header>';
} else {
	get_header();
}

echo '<main class="sifency-single-product-main">';
if ( class_exists( '\Elementor\Plugin' ) ) {
     // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor already escapes content internally.
	echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template_id, true );
}
echo '</main>';

if ( $footer_id ) {
	echo '<footer id="sifency-custom-footer">';
     // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor already escapes content internally.
	echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $footer_id, true );
	echo '</footer>';
	wp_footer();
	echo '</body></html>';
} else {
	get_footer();
}
