<?php
/**
 * Sifency Shop & Archive Template
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$shop_template_id = get_query_var( 'sifency_shop_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 ) {
	get_header();
	echo '<header id="sifency-custom-header" class="sifency-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 '<div class="sifency-shop-content-wrapper">';
if ( class_exists( '\Elementor\Plugin' ) && $shop_template_id ) {
     // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor already escapes content internally.
	echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $shop_template_id, true );
} elseif ( have_posts() ) {
		woocommerce_content();
}
echo '</div>';

if ( $footer_id ) {
	echo '<footer id="sifency-custom-footer" class="sifency-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();
}
