<?php
/**
 * PCTech Child Theme — functions.php
 * Version: 1.0.0 (Sprint 0)
 *
 * KIẾN TRÚC:
 * - Child Theme chỉ enqueue CSS/JS modules.
 * - KHÔNG viết business logic ở đây nếu Bricks native hỗ trợ.
 * - KHÔNG copy/paste JS giữa các trang.
 * - Mọi JS được tập trung trong assets/js/modules/.
 */

if ( ! defined( 'ABSPATH' ) ) exit;
if ( file_exists( get_stylesheet_directory() . '/vendor/autoload.php' ) ) {
    require_once get_stylesheet_directory() . '/vendor/autoload.php';
    require_once get_stylesheet_directory() . '/inc/nav/pctech-nav-register.php';
   require_once get_stylesheet_directory() . '/inc/nav/pctech-nav-render.php';

}




/**
 * Bricks Builder: Đăng ký custom CSS classes để dùng trong Bricks editor.
 * Các class này được định nghĩa trong CSS modules.
 */
function pctech_register_bricks_classes( $classes ) {
    $pctech_classes = array(
        // Buttons
        'btn', 'btn-primary', 'btn-outline', 'btn-outline-white', 'btn-ghost',
        // Sections
        'section-tag', 'section-title', 'section-desc', 'section-header',
        // Animations
        'reveal', 'reveal-left', 'reveal-right', 'reveal-scale', 'reveal-rotate',
        'stagger', 'card-hover', 'glow-card',
        // UI Components
        'pulse-dot', 'trust-pill', 'badge-online', 'badge-featured',
        // Ticker
        'ticker-bar', 'ticker-track', 'ticker-item',
        // Count up
        'count-up',
        // Page decorations
        'deco-strip', 'page-bg',
    );

    return array_merge( $classes, $pctech_classes );
}
// Hook Bricks (nếu Bricks hỗ trợ filter này trong version đang dùng)
add_filter( 'bricks/builder/registered_css_classes', 'pctech_register_bricks_classes' );
// PCTech homepage dynamic migration.
foreach ( array(
    'inc/dynamic-data.php',
    'inc/homepage-assets.php',
    'inc/acf-load-json-fix.php',
    'inc/register-options-page.php',
     'inc/register-content-options.php',
    'inc/shortcode-homepage.php',   // ← DÒNG MỚI THÊM VÀO
    'inc/dynamic-data-t01.php', // <- DÒNG MỚI 1
 'inc/migrate-delivery-channel.php', // <- migration 1 lần: gán term 'remote' cho 13 bài Sửa Từ Xa
 'inc/shortcode-remote-hub.php', // <-
 'inc/dynamic-data-t01-post.php', // <-
 'inc/shortcode-remote-post.php', //
 'inc/dynamic-data-t02.php', // <- TPL-Service-Post (chi tiết dịch vụ chung, không phải Remote)
 'inc/shortcode-service-post.php', // <- shortcode [pctech_service_post]
 'inc/dynamic-data-t02.php',
'inc/shortcode-service-post.php',
'inc/dynamic-data-blog-post.php',
'inc/shortcode-blog-post.php',
'inc/dynamic-data-blog-post-remote.php', // <- Mới nhất 
'inc/shortcode-blog-post-remote.php',
'inc/dynamic-data-printer-post.php', // <- Mới nhất 
'inc/shortcode-printer-post.php',
'inc/register-service-type-taxonomy.php',
'inc/dynamic-data-dr-hub.php',        // <- DÒNG MỚI 1
'inc/shortcode-data-recovery-hub.php', // <- DÒNG MỚI 2
'inc/dynamic-data-dr-post.php',        // <- DÒNG MỚI 3
'inc/shortcode-data-recovery-post.php',// <- DÒNG MỚI 4
'inc/dynamic-data-nb-hub.php',        // <- DÒNG MỚI 1
'inc/shortcode-network-biz-hub.php',   // <- DÒNG MỚI 2
'inc/dynamic-data-nb-post.php',        // <- DÒNG MỚI 3
'inc/shortcode-network-biz-post.php',  // <- DÒNG MỚI 4
'inc/dynamic-data-cam-hub.php',        // <- DÒNG MỚI 1
'inc/shortcode-camera-hub.php',        // <- DÒNG MỚI 2
'inc/dynamic-data-cam-post.php',       // <- DÒNG MỚI 3
'inc/shortcode-camera-post.php',       // <- DÒNG MỚI 4
'inc/dynamic-data-lap-hub.php',       // <- DÒNG MỚI 4
'inc/dynamic-data-lap-post.php',        // <- DÒNG MỚI 2
'inc/shortcode-laptop-hub.php',       // <- DÒNG MỚI 3
'inc/shortcode-laptop-post.php',       // <- DÒNG MỚI 4
'inc/dynamic-data-its-hub.php',         // <- DÒNG MỚI 1
'inc/shortcode-it-support-hub.php',     // <- DÒNG MỚI 2
'inc/dynamic-data-its-post.php',        // <- DÒNG MỚI 3
'inc/shortcode-it-support-post.php',    // <- DÒNG MỚI 4
'inc/dynamic-data-aib-hub.php',         // <- DÒNG MỚI 5
'inc/shortcode-ai-business-hub.php',    // <- DÒNG MỚI 6
'inc/dynamic-data-aib-post.php',        // <- DÒNG MỚI 7
'inc/shortcode-ai-business-post.php',   // <- DÒNG MỚI 8
'inc/dynamic-data-printer-hub.php',   // <- DÒNG MỚI 1
'inc/shortcode-printer-hub.php',    // <- DÒNG MỚI 2
'inc/shortcode-pctech-edu.php',
'inc/dynamic-data-price.php',   // <- TPL-Price-Sheet: lớp dữ liệu (Sprint 1-2)
'inc/shortcode-price-sheet.php', // <- shortcode [pctech_price_sheet]
'inc/barcode-code128.php',      // <- Barcode Engine (Sprint 3)
'inc/qr-engine.php',            // <- QR Engine (Sprint 3, self-hosted qrcodejs)
'inc/pdf-engine.php',           // <- PDF Engine (Sprint 3, cần Dompdf — xem HUONG-DAN-CAI-DAT.md)
'inc/quote-request.php',        // <- Xử lý form "Gửi yêu cầu tư vấn" (Sprint 4, AJAX riêng, không dùng FluentForm)
'inc/price-tracking.php', // <- Module đếm view/download PDF/quote cho TPL-Price-Sheet


) as $pctech_homepage_include ) {
    $pctech_homepage_file = get_stylesheet_directory() . '/' . $pctech_homepage_include;

    if ( file_exists( $pctech_homepage_file ) ) {
        require_once $pctech_homepage_file;
    }
}

/**
 * PCTech — Đăng ký Options Page cho nội dung TĨNH (Hero, tiêu đề section,
 * mô tả, nút CTA...) của từng trang/template, để tách khỏi HTML cứng
 * trong Bricks Code Element — phục vụ đa ngôn ngữ (WPML ACF Multilingual).
 *
 * KIẾN TRÚC DÙNG CHUNG CHO MỌI TEMPLATE SAU NÀY:
 * - 1 trang cha "Nội Dung Trang" chứa danh sách các trang con.
 * - Mỗi template (Trang Chủ, Template 01, Template 02...) có 1 trang con
 *   riêng, field riêng — không lẫn nội dung giữa các trang.
 * - Khi tạo template mới, chỉ cần thêm 1 khối acf_add_options_sub_page()
 *   mới theo đúng mẫu bên dưới, và 1 file ACF JSON field group riêng.
 *
 * @package PCTechChild
 */

defined( 'ABSPATH' ) || exit;

if ( ! function_exists( 'acf_add_options_page' ) ) {
	return;
}

// Trang cha — gom nhóm mọi trang nội dung lại 1 chỗ trong menu wp-admin.
acf_add_options_page( array(
	'page_title' => 'Nội Dung Trang (Đa Ngôn Ngữ)',
	'menu_title' => 'Nội Dung Trang',
	'menu_slug'  => 'pctech-content',
	'capability' => 'manage_options',
	'redirect'   => true, // Tự chuyển vào trang con đầu tiên khi bấm vào menu cha.
	'icon_url'   => 'dashicons-editor-textcolor',
	'position'   => 3,
) );

// Trang con: TRANG CHỦ (Homepage).
acf_add_options_sub_page( array(
	'page_title'  => 'Nội Dung — Trang Chủ',
	'menu_title'  => 'Trang Chủ',
	'parent_slug' => 'pctech-content',
	'menu_slug'   => 'pctech-content-homepage',
	'capability'  => 'manage_options',
) );

// Trang con: TEMPLATE 01 — Sửa Từ Xa.
acf_add_options_sub_page( array(
	'page_title'  => 'Nội Dung — Template 01 (Sửa Từ Xa)',
	'menu_title'  => 'Template 01 — Sửa Từ Xa',
	'parent_slug' => 'pctech-content',
	'menu_slug'   => 'pctech-content-template01',
	'capability'  => 'manage_options',
) );

/**
 * MẪU CHO TEMPLATE SAU NÀY (Template 02, 03...) — copy khối dưới đây,
 * đổi tên trang + menu_slug cho đúng, rồi tạo file ACF JSON field group
 * riêng (tham khảo acf-json/group_pctech_content_template01.json).
 *
 * acf_add_options_sub_page( array(
 * 	'page_title'  => 'Nội Dung — Template 02 (Tên Dịch Vụ)',
 * 	'menu_title'  => 'Template 02 — Tên Dịch Vụ',
 * 	'parent_slug' => 'pctech-content',
 * 	'menu_slug'   => 'pctech-content-template02',
 * 	'capability'  => 'manage_options',
 * ) );
 */
 
 $pctech_mainmenu_about_file = get_stylesheet_directory() . '/inc/pctech-mainmenu-about-setup.php';
 if ( file_exists( $pctech_mainmenu_about_file ) ) {
        require_once $pctech_mainmenu_about_file;
        
 
 }