<?php
/**
 * PufferGo Product Archive Layout — 薄路由层。
 *
 * 职责：准备公共数据 → 确定内容模板变体 → 渲染脚手架 + 变体。
 * 具体的模板内容在 content-templates/product-archive/{variant}.php。
 *
 * @package PufferGo
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

require PUFFERGO_PLUGIN_DIR . '/templates/scaffold/init.php';
require PUFFERGO_PLUGIN_DIR . '/templates/data/class-puffergo-archive-data.php';

$data = PufferGo_Archive_Data::from_current_query();

$variant_id = PufferGo_Template_Loader::get_active_content_template( 'product-archive' );
$template_file = PufferGo_Template_Loader::get_content_template_file( 'product-archive', $variant_id );

require PUFFERGO_PLUGIN_DIR . '/templates/scaffold/document-open.php';
PufferGo_Template_Loader::render_header();

if ( $template_file ) {
	require $template_file;
} else {
	echo '<main class="puffergo-fullpage-layout puffergo-product-archive"><p>' . esc_html__( 'Template not found.', 'puffergo' ) . '</p></main>';
}

PufferGo_Template_Loader::render_footer();
require PUFFERGO_PLUGIN_DIR . '/templates/scaffold/document-close.php';
