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

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

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

$data = PufferGo_Product_Data::from_current_post();

wp_enqueue_script( 'puffergo-product-gallery' );
$variant_id = PufferGo_Template_Loader::get_active_content_template( 'product-single' );
$template_file = PufferGo_Template_Loader::get_content_template_file( 'product-single', $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-content-wrapper"><p>' . esc_html__( 'Template not found.', 'puffergo' ) . '</p></main>';
}

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