<?php
/**
* Chamspace Theme
*/
// ════════════════════════════════════════════════════════════
// FIX: Upload file lớn bị lỗi "không được phép tải lên định dạng này"
// Nguyên nhân: PHP finfo fail khi detect MIME type cho file > 300KB qua multipart upload
// Fix: nếu MIME detection fail (type empty) → fallback về extension check
add_filter('wp_check_filetype_and_ext', function($data, $file, $filename, $mimes, $real_mime) {
// Nếu type empty (MIME detection fail) hoặc ext empty → thử khôi phục từ tên file
if (empty($data['type']) || empty($data['ext'])) {
$file_ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if ($file_ext) {
// Kiểm tra extension có trong danh sách allowed MIME không
foreach ($mimes as $ext_pattern => $mime_type) {
$exts = explode('|', $ext_pattern);
if (in_array($file_ext, $exts)) {
$data = ['ext' => $file_ext, 'type' => $mime_type];
break;
}
}
}
}
return $data;
}, 99, 5);
// Add theme support
add_action('after_setup_theme', function() {
add_theme_support('post-thumbnails');
});
// Inject SVG icons into top-level menu items
add_filter('walker_nav_menu_start_el', function($item_output, $item, $depth, $args) {
if ($depth !== 0) return $item_output;
$icon_map = [
'TRANG CHỦ' => 'icon-nav-home',
'GIỚI THIỆU' => 'icon-nav-about',
'DỊCH VỤ' => 'icon-nav-services',
'BÁO GIÁ' => 'icon-nav-quote',
'CÔNG TRÌNH' => 'icon-nav-projects',
'QUY TRÌNH' => 'icon-nav-process',
'CẨM NANG' => 'icon-nav-guide',
'LIÊN HỆ' => 'icon-nav-contact',
];
if (isset($icon_map[$item->title])) {
$icon_file = get_stylesheet_directory() . '/img/icons/' . $icon_map[$item->title] . '.svg';
if (file_exists($icon_file)) {
$svg = file_get_contents($icon_file);
// Strip class attribute from SVG for cleanliness, add menu-icon class
$svg = str_replace('stroke="currentColor"', 'stroke="currentColor"', $svg);
$svg = '<span class="menu-item-icon">' . $svg . '</span>';
// Insert icon right after opening <a> tag
$item_output = preg_replace('/(<a[^>]*>)/', '$1' . $svg, $item_output, 1);
}
}
return $item_output;
}, 10, 4);
// Enqueue styles
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('chamspace-scale', get_stylesheet_directory_uri() . '/assets/css/chamspace-scale.css', [], '1.0');
wp_enqueue_style('chamspace-sidebar', get_stylesheet_directory_uri() . '/chamspace/sidebar/chamspace-sidebar.css', [], '10.10');
wp_enqueue_style('chamspace-dock', get_stylesheet_directory_uri() . '/chamspace/dock/chamspace-dock.css', [], '1.59');
wp_enqueue_style('chamspace-services', get_stylesheet_directory_uri() . '/chamspace/services/chamspace-services.css', [], '6.10');
wp_enqueue_style('chamspace-services-alt', get_stylesheet_directory_uri() . '/chamspace/services/chamspace-services-alt.css', [], '2.0');
wp_enqueue_style('chamspace-services-v3', get_stylesheet_directory_uri() . '/chamspace/services/chamspace-services-v3.css', [], '74.8');
wp_enqueue_style('chamspace-home', get_stylesheet_directory_uri() . '/chamspace/home/home.css', [], '6.0');
wp_enqueue_style('chamspace-chat', get_stylesheet_directory_uri() . '/chamspace/chat/chamspace-chat.css', [], '1.27');
wp_enqueue_style('chamspace-intro-text', get_stylesheet_directory_uri() . '/chamspace/shared/chamspace-intro-text.css', [], '3.5');
// Mobile fix: đảm bảo 3 ô Mô tả/Công trình/Hài lòng trong chamspace_intro luôn hiển thị
wp_add_inline_style('chamspace-intro-text', '.intro-info-bar{overflow:visible!important;flex-wrap:wrap}@media(max-width:860px){.intro-cell-a{flex:1 1 100%;min-width:100%;border-right:none;border-bottom:1px solid #e5e5e5;border-radius:0}.intro-cell-b{border-radius:0 0 0 16px}.intro-cell-c{border-radius:0 0 16px 0}}@media(max-width:520px){.intro-info-bar{flex-direction:column}.intro-cell{padding:10px 14px;width:100%;border-right:none;border-bottom:1px solid #e5e5e5;border-radius:0!important}.intro-cell:last-child{border-bottom:none;border-radius:0 0 16px 16px!important}.intro-cell-val{font-size:12px}.intro-cell-num{font-size:13px}.intro-cell-lab{margin-bottom:2px}}');
wp_enqueue_style('chamspace-about', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about.css', [], '1.0');
wp_enqueue_style('chamspace-about-v2', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v2.css', [], '1.0');
wp_enqueue_style('chamspace-about-v3', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v3.css', [], '1.0');
wp_enqueue_style('chamspace-about-v4', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v4.css', [], '1.0');
wp_enqueue_style('chamspace-about-v5', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v5.css', [], '1.0');
wp_enqueue_style('chamspace-bao-gia-3goi', get_stylesheet_directory_uri() . '/chamspace/bao-gia/chamspace-bao-gia-3goi.css', [], '2.3');
wp_enqueue_style('chamspace-bao-gia-4cards', get_stylesheet_directory_uri() . '/chamspace/bao-gia/chamspace-bao-gia-4cards.css', [], '1.4');
wp_enqueue_style('chamspace-about-v6', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v6.css', [], '1.0');
wp_enqueue_style('chamspace-about-v7', get_stylesheet_directory_uri() . '/chamspace/about/chamspace-about-v7.css', [], '1.0');
// [Cursor tắt 2026-07-09 theo yêu cầu anh Phát] wp_enqueue_style('mouse-follower', get_stylesheet_directory_uri() . '/assets/css/mouse-follower.min.css', [], '1.3');
// GSAP for curve animations
wp_enqueue_script('gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js', [], '3.12.5', true);
wp_enqueue_script('chamspace-curves', get_stylesheet_directory_uri() . '/assets/js/chamspace-curves.js', ['gsap'], '1.3', true);
// [Cursor tắt 2026-07-09 theo yêu cầu anh Phát] Custom cursor — disabled toan trang
// if (!wp_is_mobile()) {
// wp_enqueue_style('mouse-follower', get_stylesheet_directory_uri() . '/assets/css/mouse-follower.min.css', [], '1.3');
// wp_enqueue_script('mouse-follower', get_stylesheet_directory_uri() . '/assets/js/mouse-follower.min.js', ['gsap'], '1.3', true);
// wp_enqueue_script('chamspace-cursor', get_stylesheet_directory_uri() . '/assets/js/chamspace-cursor.js', ['mouse-follower'], '1.3', true);
// }
});
// Include shortcodes (must be top-level, not inside hooks)
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-featured-projects.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-process.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-hero.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-latest-camnang.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-cam-ket.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-cam-ket-kn.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-dich-vu-db.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-db.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-services.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-usp.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-cta-consult.php';
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-intro-text.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-journey.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-philosophy.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-journey.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-philosophy.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v2-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-journey.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-philosophy.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v3-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-vision.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-values.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-story.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-journey.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-process.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v4-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-story.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-values.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-process.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v5-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-opening.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-story.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-values.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-process.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v6-cta.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-hero.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-vision.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-values.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-story.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-journey.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-process.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-team.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-numbers.php';
require_once get_stylesheet_directory() . '/chamspace/about/chamspace-about-v7-cta.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-team.php';
require_once get_stylesheet_directory() . '/chamspace/home/chamspace-home-contact.php';
add_filter('the_content', function($content) {
return $content;
});
// Force Featured Image metabox ALWAYS visible in sidebar
add_action('add_meta_boxes_cham_project', function() {
remove_meta_box('postimagediv', 'cham_project', 'side');
add_meta_box('postimagediv', '🖼️ ẢNH THUMBNAIL (Featured Image)', 'post_thumbnail_meta_box', 'cham_project', 'side', 'high');
}, 999);
// Ensure cham_project HAS thumbnail support and show featured image box
add_action('init', function() {
add_post_type_support('cham_project', 'thumbnail');
}, 999);
// Hide admin bar
add_filter('show_admin_bar', '__return_false');
// Register WordPress Menu location
// Increase media items per page in AJAX queries (fix ACF media picker showing only 60/759)
add_filter('ajax_query_attachments_args', function($query) {
$query['posts_per_page'] = 200;
return $query;
});
add_action('init', function() {
// Fix chunked upload for Live Link - reduce chunk size for tunnel uploads
add_filter('plupload_default_settings', function($defaults) {
$defaults['chunk_size'] = '50mb';
$defaults['max_retries'] = 5;
$defaults['urlstream_upload'] = true;
return $defaults;
});
register_nav_menus(array(
'chamspace-menu' => __('Chamspace Menu', 'chamspace')
));
});
/**
* Register Custom Post Type: cham_project (Dự án)
*/
add_action('init', function() {
$labels = [
'name' => 'Dự án',
'singular_name' => 'Dự án',
'add_new' => 'Thêm mới',
'add_new_item' => 'Thêm dự án mới',
'edit_item' => 'Sửa dự án',
'view_item' => 'Xem dự án',
'all_items' => 'Tất cả dự án',
'search_items' => 'Tìm dự án',
'not_found' => 'Không tìm thấy dự án',
'menu_name' => 'Dự án',
];
$args = [
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'query_var' => true,
'rewrite' => ['slug' => 'project'],
'capability_type' => 'post',
'has_archive' => 'projects',
'hierarchical' => false,
'menu_icon' => 'dashicons-portfolio',
'supports' => ['title', 'editor', 'thumbnail', 'excerpt'],
'menu_position' => 5,
];
register_post_type('cham_project', $args);
// Taxonomy: cham_project_cat
$catLabels = [
'name' => 'Danh mục dự án',
'singular_name' => 'Danh mục',
'search_items' => 'Tìm danh mục',
'all_items' => 'Tất cả danh mục',
'parent_item' => 'Danh mục cha',
'edit_item' => 'Sửa danh mục',
'update_item' => 'Cập nhật danh mục',
'add_new_item' => 'Thêm danh mục mới',
'menu_name' => 'Danh mục',
];
register_taxonomy('cham_project_cat', 'cham_project', [
'hierarchical' => true,
'labels' => $catLabels,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => ['slug' => 'project-category'],
]);
});
/**
* Register Custom Post Type: cham_video (Video YouTube)
*/
add_action('init', function() {
$labels = [
'name' => 'Video',
'singular_name' => 'Video',
'add_new' => 'Thêm mới',
'add_new_item' => 'Thêm video mới',
'edit_item' => 'Sửa video',
'view_item' => 'Xem video',
'all_items' => 'Tất cả video',
'search_items' => 'Tìm video',
'not_found' => 'Không tìm thấy video',
'menu_name' => 'Video',
];
$args = [
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'query_var' => true,
'rewrite' => ['slug' => 'video'],
'capability_type' => 'post',
'has_archive' => 'videos',
'hierarchical' => false,
'menu_icon' => 'dashicons-video-alt3',
'supports' => ['title', 'editor', 'thumbnail', 'excerpt'],
'menu_position' => 6,
];
register_post_type('cham_video', $args);
// Taxonomy: cham_video_cat
$catLabels = [
'name' => 'Danh mục video',
'singular_name' => 'Danh mục',
'search_items' => 'Tìm danh mục',
'all_items' => 'Tất cả danh mục',
'parent_item' => 'Danh mục cha',
'edit_item' => 'Sửa danh mục',
'update_item' => 'Cập nhật danh mục',
'add_new_item' => 'Thêm danh mục mới',
'menu_name' => 'Danh mục',
];
register_taxonomy('cham_video_cat', 'cham_video', [
'hierarchical' => true,
'labels' => $catLabels,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => ['slug' => 'video-category'],
]);
});
/**
* Register ACF Fields cho cham_video
*/
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_video_info',
'title' => '🎬 Thông tin Video',
'fields' => [
[
'key' => 'field_youtube_url',
'label' => 'Link YouTube',
'name' => 'youtube_url',
'type' => 'url',
'instructions' => 'Nhập link YouTube, ví dụ: https://www.youtube.com/watch?v=xxxxx',
'required' => 1,
],
[
'key' => 'field_video_duration',
'label' => 'Thời lượng',
'name' => 'video_duration',
'type' => 'text',
'instructions' => 'Ví dụ: 12:34',
],
],
'location' => [
[
[
'param' => 'post_type',
'operator' => '==',
'value' => 'cham_video',
],
],
],
'menu_order' => 0,
'active' => true,
]);
});
/**
* Helper: Extract YouTube ID từ URL
*/
function get_youtube_id($url) {
if (!$url) return '';
preg_match('/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/', $url, $m);
return $m[1] ?? '';
}
/**
* Helper: Lấy YouTube thumbnail URL
*/
function get_youtube_thumb($url, $size = 'maxresdefault') {
$id = get_youtube_id($url);
if (!$id) return '';
return "https://img.youtube.com/vi/{$id}/{$size}.jpg";
}
/**
* Helper: Lấy YouTube embed URL
*/
function get_youtube_embed($url) {
$id = get_youtube_id($url);
if (!$id) return '';
return "https://www.youtube.com/embed/{$id}";
}
/**
* Register ACF Fields cho cham_project
*/
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_project_info',
'title' => 'Thông tin dự án',
'fields' => [
[
'key' => 'field_location',
'label' => 'Vị trí công trình',
'name' => 'location',
'type' => 'text',
],
[
'key' => 'field_total_area',
'label' => 'Diện tích đất (m²)',
'name' => 'total_area',
'type' => 'text',
],
[
'key' => 'field_built_area',
'label' => 'Diện tích xây dựng (m²)',
'name' => 'built_area',
'type' => 'text',
],
[
'key' => 'field_floors',
'label' => 'Số tầng',
'name' => 'number_of_floors',
'type' => 'text',
],
[
'key' => 'field_estimated_cost',
'label' => 'Chi phí xây dựng',
'name' => 'estimated_cost',
'type' => 'text',
],
[
'key' => 'field_master_image',
'label' => '🖼️ ẢNH BÌA — ảnh cover fullwidth trên đầu trang dự án',
'name' => 'master_image',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'medium',
],
[
'key' => 'field_project_gallery',
'label' => '📸 THƯ VIỆN ẢNH DỰ ÁN — gallery ảnh trong page',
'name' => 'project_gallery',
'type' => 'gallery',
'return_format' => 'id',
'preview_size' => 'medium',
'insert' => 'append',
'library' => 'all',
],
[
'key' => 'field_floorplan_gallery',
'label' => '📐 MẶT BẰNG & MẶT CẮT — gallery bản vẽ kỹ thuật',
'name' => 'floorplan_gallery',
'type' => 'gallery',
'return_format' => 'id',
'preview_size' => 'medium',
'insert' => 'append',
'library' => 'all',
],
[
'key' => 'field_other_detail',
'label' => '📋 THÔNG TIN CHI TIẾT — bảng thông số dự án',
'name' => 'other_detail',
'type' => 'repeater',
'layout' => 'table',
'button_label' => 'Thêm dòng',
'sub_fields' => [
[
'key' => 'field_detail_title',
'label' => 'Tiêu đề',
'name' => 'title',
'type' => 'text',
],
[
'key' => 'field_detail_content',
'label' => 'Nội dung',
'name' => 'content',
'type' => 'text',
],
],
],
[
'key' => 'field_project_videos',
'label' => '▶️ VIDEO CÔNG TRÌNH — danh sách video YouTube',
'name' => 'project_videos',
'type' => 'repeater',
'layout' => 'table',
'button_label' => 'Thêm video',
'sub_fields' => [
[
'key' => 'field_pv_url',
'label' => 'URL YouTube',
'name' => 'video_url',
'type' => 'text',
'instructions' => 'Ví dụ: https://www.youtube.com/watch?v=8T9pJsfCP0E',
],
[
'key' => 'field_pv_title',
'label' => 'Tiêu đề video',
'name' => 'video_title',
'type' => 'text',
],
[
'key' => 'field_pv_duration',
'label' => 'Thời lượng',
'name' => 'video_duration',
'type' => 'text',
'instructions' => 'Ví dụ: 1:17',
],
],
],
[
'key' => 'field_home_featured',
'label' => '⭐ Dự án tiêu biểu',
'name' => 'home_featured',
'type' => 'true_false',
'message' => 'Tick để hiển thị trong section "Dự án tiêu biểu" trên trang chủ',
'default_value' => 0,
'ui' => 1,
],
],
'location' => [
[
[
'param' => 'post_type',
'operator' => '==',
'value' => 'cham_project',
],
],
],
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
// Taxonomy: Fields cho cham_project_cat (Ảnh bìa + Mô tả + Kicker)
acf_add_local_field_group([
'key' => 'group_cat_intro',
'title' => '🎬 Hero Cover — Danh mục Dự án',
'fields' => [
[
'key' => 'field_cat_hero_bg',
'label' => '🖼️ Ảnh nền Hero (thay thế Ảnh bìa)',
'name' => 'cat_hero_bg',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'large',
'instructions' => 'Upload ảnh nền cho hero cover. Nếu để trống sẽ dùng Ảnh bìa bên dưới. Khuyến nghị: 1920×1080px.',
],
[
'key' => 'field_cat_hero_title',
'label' => '📝 Tiêu đề chính (hiển thị trên Hero)',
'name' => 'cat_hero_title',
'type' => 'wysiwyg',
'tabs' => 'visual',
'toolbar' => 'basic',
'media_upload' => 0,
'delay' => 0,
'instructions' => 'Tiêu đề chính xuất hiện trên hero cover. Nếu để trống sẽ dùng tên danh mục. Có thể dùng <br> để xuống dòng.',
],
[
'key' => 'field_cat_cover',
'label' => '🖼️ Ảnh bìa (fallback nếu thiếu ảnh nền Hero)',
'name' => 'cat_cover_image',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'large',
'instructions' => 'Ảnh bìa dự phòng, dùng khi Ảnh nền Hero trống.',
],
[
'key' => 'field_cat_desc',
'label' => '📝 Mô tả (hiển thị dưới tiêu đề)',
'name' => 'cat_description',
'type' => 'textarea',
'rows' => 4,
'new_lines' => 'br',
'instructions' => '1-2 câu mô tả ngắn gọn về danh mục này.',
],
[
'key' => 'field_cat_hero_kicker',
'label' => '✦ Dòng kicker (nhỏ phía trên tiêu đề)',
'name' => 'cat_hero_kicker',
'type' => 'text',
'default_value' => '✦ Dự án Chamspace',
'instructions' => 'VD: "✦ Nhà phố hiện đại" hoặc để mặc định.',
],
[
'key' => 'field_cat_hero_sub',
'label' => '💬 Mô tả phụ (chỉ hiện dưới Title lớn, trên hero)',
'name' => 'cat_hero_sub',
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
'instructions' => 'Khác với "Mô tả" ở info bar — field này chỉ hiện ngay dưới tiêu đề lớn. Để trống = ẩn.',
],
[
'key' => 'field_cat_hero_tag',
'label' => '🏷️ Text nút tag góc phải',
'name' => 'cat_hero_tag',
'type' => 'text',
'default_value' => 'Thiết kế & Thi công',
'instructions' => 'Text hiển thị trong nút tag góc phải. Bấm vào → mở form tư vấn.',
],
[
'key' => 'field_cat_hero_popup_title',
'label' => '📋 Tiêu đề popup tư vấn',
'name' => 'cat_hero_popup_title',
'type' => 'text',
'default_value' => 'Nhận tư vấn từ Chamspace',
'instructions' => 'Tiêu đề hiển thị trong popup form tư vấn.',
],
[
'key' => 'field_cat_hero_popup_sub',
'label' => '📋 Mô tả popup tư vấn',
'name' => 'cat_hero_popup_sub',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Để lại thông tin, đội ngũ Chamspace sẽ liên hệ tư vấn miễn phí trong 24h.',
'instructions' => 'Mô tả ngắn trong popup form.',
],
],
'location' => [[[
'param' => 'taxonomy',
'operator' => '==',
'value' => 'cham_project_cat',
]]],
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'menu_order' => 0,
'active' => true,
]);
// Homepage — Hero Section
acf_add_local_field_group([
'key' => 'group_home_hero',
'title' => '🏠 HOME — Hero Section',
'fields' => [
[
'key' => 'field_home_hero_bg',
'label' => 'Ảnh nền Hero',
'name' => 'home_hero_bg',
'type' => 'image',
'return_format' => 'url',
'preview_size' => 'medium',
'library' => 'all',
],
[
'key' => 'field_home_hero_kicker',
'label' => 'Kicker text',
'name' => 'home_hero_kicker',
'type' => 'text',
'default_value' => '✦ Chamspace — Chạm Tinh Tế',
],
[
'key' => 'field_home_hero_title',
'label' => 'Tiêu đề chính (H1) - mỗi dòng = 1 dòng hiển thị',
'name' => 'home_hero_title',
'type' => 'textarea',
'rows' => 3,
'new_lines' => 'br',
'default_value' => "Kiến tạo\nkhông gian\nsống của bạn",
],
[
'key' => 'field_home_hero_sub',
'label' => 'Sub text',
'name' => 'home_hero_sub',
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
'default_value' => 'Thiết kế & Thi công toàn diện — từ Kiến trúc đến Nội thất, một mối duy nhất.',
],
],
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
// Homepage — Design & Build Section (only 2 images)
acf_add_local_field_group([
'key' => 'group_home_db',
'title' => '🏠 HOME — Design & Build',
'fields' => [
[
'key' => 'field_home_db_img_left',
'label' => 'Ảnh trái — Design / Architecture',
'name' => 'home_db_img_left',
'type' => 'image',
'return_format' => 'url',
'preview_size' => 'medium',
'library' => 'all',
],
[
'key' => 'field_home_db_img_right',
'label' => 'Ảnh phải — Build / Construction',
'name' => 'home_db_img_right',
'type' => 'image',
'return_format' => 'url',
'preview_size' => 'medium',
'library' => 'all',
],
],
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => 1,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
// Homepage — Dịch vụ chuyên môn (4 groups)
$services = [
'01' => ['title' => '🏠 HOME — Dịch vụ 01 (Kiến trúc)', 'order' => 2],
'02' => ['title' => '🏠 HOME — Dịch vụ 02 (Nội thất)', 'order' => 3],
'03' => ['title' => '🏠 HOME — Dịch vụ 03 (Phần thô)', 'order' => 4],
'04' => ['title' => '🏠 HOME — Dịch vụ 04 (Hoàn thiện)', 'order' => 5],
];
foreach ($services as $num => $cfg) {
$num2 = (int)$num; // for repeater sub-key
acf_add_local_field_group([
'key' => "group_home_svc_$num",
'title' => $cfg['title'],
'fields' => [
[
'key' => "field_home_svc_{$num}_name",
'label' => 'Tên dịch vụ',
'name' => "home_svc_{$num}_name",
'type' => 'text',
],
[
'key' => "field_home_svc_{$num}_desc",
'label' => 'Mô tả dịch vụ',
'name' => "home_svc_{$num}_desc",
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
],
[
'key' => "field_home_svc_{$num}_bullets",
'label' => 'Bullet points',
'name' => "home_svc_{$num}_bullets",
'type' => 'repeater',
'sub_fields' => [
[
'key' => "field_home_svc_{$num}_bullet_item",
'label' => 'Item',
'name' => 'item',
'type' => 'text',
],
],
'min' => 1,
],
[
'key' => "field_home_svc_{$num}_image",
'label' => 'Hình ảnh',
'name' => "home_svc_{$num}_image",
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
],
],
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => $cfg['order'],
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
}
// Homepage — Quy trình triển khai (5 groups)
$process_steps = [
'01' => ['title' => '🏠 HOME — Quy trình 01 (Tiếp nhận)', 'order' => 6],
'02' => ['title' => '🏠 HOME — Quy trình 02 (Khảo sát)', 'order' => 7],
'03' => ['title' => '🏠 HOME — Quy trình 03 (Thiết kế)', 'order' => 8],
'04' => ['title' => '🏠 HOME — Quy trình 04 (Thi công)', 'order' => 9],
'05' => ['title' => '🏠 HOME — Quy trình 05 (Bàn giao)', 'order' => 10],
];
foreach ($process_steps as $num => $cfg) {
acf_add_local_field_group([
'key' => "group_home_proc_$num",
'title' => $cfg['title'],
'fields' => [
[
'key' => "field_home_proc_{$num}_title",
'label' => 'Tiêu đề bước',
'name' => "home_proc_{$num}_title",
'type' => 'text',
],
[
'key' => "field_home_proc_{$num}_desc",
'label' => 'Mô tả bước',
'name' => "home_proc_{$num}_desc",
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
],
[
'key' => "field_home_proc_{$num}_image",
'label' => 'Hình ảnh',
'name' => "home_proc_{$num}_image",
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
],
],
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => $cfg['order'],
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
}
// Homepage — Tại sao Chamspace (6 selling points)
$usp_items = [
'01' => ['title' => '🏠 HOME — USP 01 (Tiêu chuẩn Đức)', 'order' => 11],
'02' => ['title' => '🏠 HOME — USP 02 (Một đầu mối)', 'order' => 12],
'03' => ['title' => '🏠 HOME — USP 03 (Triết lý thiết kế)', 'order' => 13],
'04' => ['title' => '🏠 HOME — USP 04 (Kinh nghiệm quốc tế)', 'order' => 14],
'05' => ['title' => '🏠 HOME — USP 05 (Xưởng sản xuất)', 'order' => 15],
'06' => ['title' => '🏠 HOME — USP 06 (Bảo hành dài hạn)', 'order' => 16],
];
foreach ($usp_items as $num => $cfg) {
$fields = [
[
'key' => "field_home_usp_{$num}_title",
'label' => 'Tiêu đề',
'name' => "home_usp_{$num}_title",
'type' => 'text',
],
[
'key' => "field_home_usp_{$num}_desc",
'label' => 'Mô tả',
'name' => "home_usp_{$num}_desc",
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
],
[
'key' => "field_home_usp_{$num}_image",
'label' => 'Hình ảnh',
'name' => "home_usp_{$num}_image",
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
],
];
// Thêm icon cho card-type (USP 02, 03, 06)
$card_nums = ['02', '03', '06'];
if (in_array($num, $card_nums)) {
$icons = ['02' => '🔗', '03' => '✦', '06' => '🛡️'];
$fields[] = [
'key' => "field_home_usp_{$num}_icon",
'label' => 'Icon (emoji)',
'name' => "home_usp_{$num}_icon",
'type' => 'text',
'default_value' => $icons[$num] ?? '',
];
}
acf_add_local_field_group([
'key' => "group_home_usp_$num",
'title' => $cfg['title'],
'fields' => $fields,
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => $cfg['order'],
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
}
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 18. 🏠 HOME — Home Team (Đội ngũ)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
acf_add_local_field_group([
'key' => 'group_home_team',
'title' => '🏠 HOME — Home Team (Đội ngũ)',
'fields' => [
[
'key' => 'field_home_team_image',
'label' => 'Ảnh đội ngũ',
'name' => 'home_team_image',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'medium',
'library' => 'all',
],
[
'key' => 'field_home_team_role_1_title',
'label' => 'Role 1 — Chức danh',
'name' => 'home_team_role_1_title',
'type' => 'text',
],
[
'key' => 'field_home_team_role_1_desc',
'label' => 'Role 1 — Mô tả',
'name' => 'home_team_role_1_desc',
'type' => 'text',
],
[
'key' => 'field_home_team_role_2_title',
'label' => 'Role 2 — Chức danh',
'name' => 'home_team_role_2_title',
'type' => 'text',
],
[
'key' => 'field_home_team_role_2_desc',
'label' => 'Role 2 — Mô tả',
'name' => 'home_team_role_2_desc',
'type' => 'text',
],
[
'key' => 'field_home_team_role_3_title',
'label' => 'Role 3 — Chức danh',
'name' => 'home_team_role_3_title',
'type' => 'text',
],
[
'key' => 'field_home_team_role_3_desc',
'label' => 'Role 3 — Mô tả',
'name' => 'home_team_role_3_desc',
'type' => 'text',
],
],
'location' => [[[
'param' => 'page',
'operator' => '==',
'value' => '62',
]]],
'menu_order' => 18,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
]);
});
// Force cham_project archive to use our custom template
add_filter('template_include', function($template) {
// Page 1640: Thiết kế Kiến trúc → dùng template theo slug
if (is_page(1640)) {
$custom = get_stylesheet_directory() . '/page-thiet-ke-kien-truc.php';
if (file_exists($custom)) return $custom;
}
if (is_post_type_archive('cham_project') || (is_archive() && get_query_var('post_type') === 'cham_project')) {
$custom = get_stylesheet_directory() . '/archive-cham_project.php';
if (file_exists($custom)) return $custom;
}
return $template;
}, 99);
// Route single posts in specific categories to custom templates
add_filter('single_template', function($template) {
if (!is_single()) return $template;
$post = get_post();
if (!$post) return $template;
$cat_map = [
'bao-gia' => 'chamspace-single-bao-gia.php',
'quy-trinh' => 'chamspace-single-quy-trinh.php',
'kinh-nghiem-thiet-ke' => 'chamspace-single-kinh-nghiem-thiet-ke.php',
'kinh-nghiem-thi-cong' => 'chamspace-single-kinh-nghiem-thi-cong.php',
];
$cats = wp_get_post_categories($post->ID, ['fields' => 'slugs']);
foreach ($cats as $slug) {
if (isset($cat_map[$slug])) {
$custom = get_stylesheet_directory() . '/' . $cat_map[$slug];
if (file_exists($custom)) return $custom;
}
}
return $template;
}, 99);
// Hello Elementor required function
if ( ! function_exists( 'hello_header_footer_experiment_active' ) ) {
function hello_header_footer_experiment_active() {
return false;
}
}
// ACF Options Page — Cài đặt trang Công trình
add_action('acf/init', function() {
if (!function_exists('acf_add_options_page')) return;
acf_add_options_page([
'page_title' => 'Cài đặt trang Công trình',
'menu_title' => 'Cài đặt Công trình',
'menu_slug' => 'projects-settings',
'capability' => 'manage_options',
'position' => 6,
]);
acf_add_local_field_group([
'key' => 'group_projects_page',
'title' => '🎬 Hero Cover — Trang Công trình',
'fields' => [
[
'key' => 'field_proj_cover',
'label' => 'Ảnh bìa',
'name' => 'projects_cover',
'type' => 'image',
'return_format' => 'id',
],
[
'key' => 'field_proj_desc',
'label' => '📝 Mô tả (hiển thị dưới tiêu đề)',
'name' => 'projects_desc',
'type' => 'textarea',
'rows' => 4,
'new_lines' => 'br',
],
[
'key' => 'field_proj_hero_kicker',
'label' => '✦ Dòng kicker (nhỏ phía trên tiêu đề)',
'name' => 'projects_hero_kicker',
'type' => 'text',
'default_value' => '✦ Dự án Chamspace',
],
[
'key' => 'field_proj_hero_sub',
'label' => '💬 Mô tả phụ (chỉ hiện dưới Title lớn, trên hero)',
'name' => 'projects_hero_sub',
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
'instructions' => 'Khác với "Mô tả" ở info bar — field này chỉ hiện ngay dưới tiêu đề lớn. Để trống = ẩn.',
],
[
'key' => 'field_proj_hero_tag',
'label' => '🏷️ Text nút tag góc phải',
'name' => 'projects_hero_tag',
'type' => 'text',
'default_value' => 'Thiết kế & Thi công',
],
[
'key' => 'field_proj_hero_popup_title',
'label' => '📋 Tiêu đề popup tư vấn',
'name' => 'projects_hero_popup_title',
'type' => 'text',
'default_value' => 'Nhận tư vấn từ Chamspace',
],
[
'key' => 'field_proj_hero_popup_sub',
'label' => '📋 Mô tả popup tư vấn',
'name' => 'projects_hero_popup_sub',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Để lại thông tin, đội ngũ Chamspace sẽ liên hệ tư vấn miễn phí trong 24h.',
],
],
'location' => [[[
'param' => 'options_page',
'operator' => '==',
'value' => 'projects-settings',
]]],
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'active' => true,
]);
// Quy trình triển khai — Trang chủ
acf_add_options_page([
'page_title' => 'Quy trình triển khai — Trang chủ',
'menu_title' => 'Quy trình triển khai',
'menu_slug' => 'home-process',
'capability' => 'manage_options',
'position' => 7,
]);
});
// ═══════════════════════════════════════════
// Trọn gói Design & Build — Ảnh loại hình + Phong cách
// ═══════════════════════════════════════════
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
// Ảnh loại hình công trình
acf_add_local_field_group([
'key' => 'group_tg_loai_hinh',
'title' => '📦 Trọn gói — Ảnh loại hình',
'fields' => [
['key' => 'field_tg_img_nha_pho', 'label' => 'Nhà phố', 'name' => 'tg_img_nha_pho', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_can_ho', 'label' => 'Căn hộ', 'name' => 'tg_img_can_ho', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_van_phong', 'label' => 'Văn phòng', 'name' => 'tg_img_van_phong', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_bt_hd', 'label' => 'Biệt thự Hiện đại', 'name' => 'tg_img_bt_hd', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_bt_cd', 'label' => 'Biệt thự Cổ điển', 'name' => 'tg_img_bt_cd', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1614']]],
'position' => 'normal',
'style' => 'default',
'active' => true,
]);
// Ảnh phong cách thiết kế
acf_add_local_field_group([
'key' => 'group_tg_phong_cach',
'title' => '🎨 Trọn gói — Ảnh phong cách',
'fields' => [
['key' => 'field_tg_img_hien_dai', 'label' => 'Hiện đại', 'name' => 'tg_img_hien_dai', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_industrial', 'label' => 'Industrial', 'name' => 'tg_img_industrial', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_japandi', 'label' => 'Japandi', 'name' => 'tg_img_japandi', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_wabi_sabi', 'label' => 'Wabi-Sabi', 'name' => 'tg_img_wabi_sabi', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_indochine', 'label' => 'Indochine', 'name' => 'tg_img_indochine', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_tan_co_dien', 'label' => 'Tân cổ điển', 'name' => 'tg_img_tan_co_dien', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tg_img_luxury', 'label' => 'Luxury', 'name' => 'tg_img_luxury', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1614']]],
'position' => 'normal',
'style' => 'default',
'active' => true,
]);
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 🎨 Thiết kế — Ảnh loại hình (page 1246)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
acf_add_local_field_group([
'key' => 'group_tk_loai_hinh',
'title' => '🎨 Thiết kế — Ảnh loại hình',
'fields' => [
['key' => 'field_tk_img_nha_pho', 'label' => 'Nhà phố', 'name' => 'tk_img_nha_pho', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_can_ho', 'label' => 'Căn hộ', 'name' => 'tk_img_can_ho', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_van_phong', 'label' => 'Văn phòng', 'name' => 'tk_img_van_phong', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_bt_hd', 'label' => 'Biệt thự Hiện đại', 'name' => 'tk_img_bt_hd', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_bt_cd', 'label' => 'Biệt thự Cổ điển', 'name' => 'tk_img_bt_cd', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1246']]],
'position' => 'normal',
'style' => 'default',
'active' => true,
]);
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 🎨 Thiết kế — Ảnh phong cách (page 1246)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
acf_add_local_field_group([
'key' => 'group_tk_phong_cach',
'title' => '🎨 Thiết kế — Ảnh phong cách',
'fields' => [
['key' => 'field_tk_img_hien_dai', 'label' => 'Hiện đại', 'name' => 'tk_img_hien_dai', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_industrial', 'label' => 'Industrial', 'name' => 'tk_img_industrial', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_japandi', 'label' => 'Japandi', 'name' => 'tk_img_japandi', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_wabi_sabi', 'label' => 'Wabi-Sabi', 'name' => 'tk_img_wabi_sabi', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_indochine', 'label' => 'Indochine', 'name' => 'tk_img_indochine', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_tan_co_dien', 'label' => 'Tân cổ điển', 'name' => 'tk_img_tan_co_dien', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_tk_img_luxury', 'label' => 'Luxury', 'name' => 'tk_img_luxury', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1246']]],
'position' => 'normal',
'style' => 'default',
'active' => true,
]);
});
// ═══ Disable wpautop on dich-vu-3 + trang-chu pages (breaks layout) ═══
add_action('template_redirect', function() {
if (is_page('dich-vu-3') || is_page('trang-chu') || is_front_page()) {
remove_filter('the_content', 'wpautop');
}
});
// ═══ Homepage — tv3 form split 2 cột ═══
add_action('wp_footer', function() {
if (!is_front_page()) return;
echo '<script>
(function(){
var f = document.querySelector(".tv3-cf7");
if(!f) return;
var check = function(){
if(f.classList.contains("tv3-f-ready")) return;
var rows = f.querySelectorAll(":scope > .form-row");
if(rows.length < 9) { setTimeout(check, 200); return; }
var a = Array.from(rows);
var sb = f.querySelector("input.wpcf7-submit");
var rp = f.querySelector(".wpcf7-response-output");
if(rp && rp.parentNode) rp.parentNode.removeChild(rp);
var L = document.createElement("div"); L.className = "tv3-cf7-fields";
var R = document.createElement("div"); R.className = "tv3-cf7-message";
a.slice(0,6).forEach(function(x){ L.appendChild(x); });
a.slice(6).forEach(function(x){ R.appendChild(x); });
if(sb && sb.parentNode) sb.parentNode.removeChild(sb);
R.appendChild(sb);
f.appendChild(L);
f.appendChild(R);
if(rp) f.appendChild(rp);
f.classList.add("tv3-f-ready");
};
check();
window.addEventListener("load", function(){ setTimeout(check, 100); });
})();
</' . 'script>';
});
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 📐 PHẦN THÔ — Ảnh loại hình
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_pt_loai_hinh',
'title' => '📐 Phần thô — Ảnh loại hình',
'fields' => [
['key' => 'field_pt_img_nha_pho', 'label' => 'Nhà phố', 'name' => 'pt_img_nha_pho', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_pt_img_biet_thu_hien_dai', 'label' => 'Biệt thự Hiện đại', 'name' => 'pt_img_biet_thu_hien_dai', 'type' => 'image', 'return_format' => 'url'],
['key' => 'field_pt_img_biet_thu_co_dien', 'label' => 'Biệt thự Cổ điển', 'name' => 'pt_img_biet_thu_co_dien', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1606']]],
'menu_order' => 0,
'active' => true,
]);
});
// ── LIÊN HỆ Page (ID 1154) ──
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_lh_info',
'title' => '📞 Liên Hệ — Thông tin',
'fields' => [
// Chung
['key' => 'field_lh_phone', 'label' => 'Điện thoại chung', 'name' => 'lh_phone', 'type' => 'text', 'wrapper' => ['width' => '33']],
['key' => 'field_lh_email', 'label' => 'Email chung', 'name' => 'lh_email', 'type' => 'email', 'wrapper' => ['width' => '33']],
['key' => 'field_lh_hours', 'label' => 'Giờ làm việc', 'name' => 'lh_hours', 'type' => 'text', 'wrapper' => ['width' => '33']],
// Văn phòng
['key' => 'field_lh_office_title', 'label' => '🏢 Văn phòng — Tên', 'name' => 'lh_office_title', 'type' => 'text', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_office_addr', 'label' => '🏢 Văn phòng — Địa chỉ', 'name' => 'lh_office_addr', 'type' => 'text', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_map_office', 'label' => '🏢 Văn phòng — Google Maps Embed', 'name' => 'lh_map_office', 'type' => 'textarea', 'instructions' => 'Dán mã iframe từ Google Maps (Share → Embed a map)'],
// Xưởng
['key' => 'field_lh_workshop_title', 'label' => '🏭 Xưởng — Tên', 'name' => 'lh_workshop_title', 'type' => 'text', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_workshop_addr', 'label' => '🏭 Xưởng — Địa chỉ', 'name' => 'lh_workshop_addr', 'type' => 'text', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_map_workshop', 'label' => '🏭 Xưởng — Google Maps Embed', 'name' => 'lh_map_workshop', 'type' => 'textarea', 'instructions' => 'Dán mã iframe từ Google Maps'],
// ── Hình ảnh ──
['key' => 'field_lh_hero_image', 'label' => '🖼️ Hero — Ảnh nền', 'name' => 'lh_hero_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_cover_image', 'label' => '🖼️ Cover (Chạm Tinh Tế) — Ảnh', 'name' => 'lh_cover_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_office_image', 'label' => '🏢 Văn phòng — Ảnh bìa', 'name' => 'lh_office_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '50']],
['key' => 'field_lh_workshop_image','label' => '🏭 Xưởng — Ảnh bìa', 'name' => 'lh_workshop_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '50']],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1154']]],
'menu_order' => 10,
'active' => true,
]);
});
// Skip CF7 mail on localhost
add_filter('wpcf7_skip_mail', '__return_true');
// ── PDF Form API route ──
require_once get_stylesheet_directory() . '/chamspace/shared/chamspace-pdf-form-api.php';
add_action('rest_api_init', function() {
register_rest_route('chamspace/v1', '/pdf-form', [
'methods' => 'POST',
'callback' => 'chamspace_handle_pdf_form',
'permission_callback' => '__return_true',
]);
});
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 🏗️ QUY TRÌNH THIẾT KẾ (Page ID 1151)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Group 1 — BIM Intro (Section ②)
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_qt_bim_intro',
'title' => '🏗️ Quy trình TK — ① BIM Intro',
'fields' => [
['key' => 'field_qt_bim_image', 'label' => 'Ảnh BIM', 'name' => 'qt_bim_image', 'type' => 'image', 'return_format' => 'url'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1151']]],
'menu_order' => 10,
'active' => true,
]);
});
// Group 2 — Timeline 5 bước (Section ③)
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_qt_timeline',
'title' => '🏗️ Quy trình TK — ② Timeline 5 Bước',
'fields' => [
['key' => 'field_qt_tl_01_image', 'label' => 'Bước 01 — Ảnh', 'name' => 'qt_tl_01_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']],
['key' => 'field_qt_tl_02_image', 'label' => 'Bước 02 — Ảnh', 'name' => 'qt_tl_02_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']],
['key' => 'field_qt_tl_03_image', 'label' => 'Bước 03 — Ảnh', 'name' => 'qt_tl_03_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']],
['key' => 'field_qt_tl_04_image', 'label' => 'Bước 04 — Ảnh', 'name' => 'qt_tl_04_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']],
['key' => 'field_qt_tl_05_image', 'label' => 'Bước 05 — Ảnh', 'name' => 'qt_tl_05_image', 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1151']]],
'menu_order' => 20,
'active' => true,
]);
});
// Group 3 — Quy Trình Chi Tiết 5 card (Section ④)
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
$fields = [];
foreach (['01','02','03','04','05'] as $n) {
$fields[] = ['key' => "field_qt_dt_{$n}_image", 'label' => "Bước {$n} — Ảnh", 'name' => "qt_dt_{$n}_image", 'type' => 'image', 'return_format' => 'url', 'wrapper' => ['width' => '20']];
$fields[] = ['key' => "field_qt_dt_{$n}_tag", 'label' => "Bước {$n} — Tag", 'name' => "qt_dt_{$n}_tag", 'type' => 'text', 'wrapper' => ['width' => '30']];
$fields[] = ['key' => "field_qt_dt_{$n}_title", 'label' => "Bước {$n} — Title", 'name' => "qt_dt_{$n}_title", 'type' => 'text', 'wrapper' => ['width' => '50']];
$fields[] = ['key' => "field_qt_dt_{$n}_desc", 'label' => "Bước {$n} — Mô tả", 'name' => "qt_dt_{$n}_desc", 'type' => 'textarea'];
$fields[] = ['key' => "field_qt_dt_{$n}_link", 'label' => "Bước {$n} — Link", 'name' => "qt_dt_{$n}_link", 'type' => 'text', 'wrapper' => ['width' => '50']];
$fields[] = [
'key' => "field_qt_dt_{$n}_bullets",
'label' => "Bước {$n} — Bullet Points",
'name' => "qt_dt_{$n}_bullets",
'type' => 'repeater',
'button_label' => '+ Thêm bullet',
'sub_fields' => [['key' => "field_qt_dt_{$n}_bullet_item", 'label' => 'Nội dung', 'name' => 'item', 'type' => 'text']],
];
}
acf_add_local_field_group([
'key' => 'group_qt_detail',
'title' => '🏗️ Quy trình TK — ③ Quy Trình Chi Tiết (5 Card)',
'fields' => $fields,
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1151']]],
'menu_order' => 30,
'active' => true,
]);
});
// ========================
// ACF Field Groups cho trang "Thiết kế thi công kiến trúc" (ID 1640)
// ========================
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
// --- GROUP 1: Service Cards ---
$svc_fields = [
['key' => 'field_kt_svc_01_image', 'label' => 'Card 1 — Ảnh minh họa', 'name' => 'kt_svc_01_image', 'type' => 'image', 'return_format' => 'id', 'instructions' => 'Chọn ảnh cho card Thiết kế Kiến trúc'],
['key' => 'field_kt_svc_01_tag', 'label' => 'Card 1 — Kicker (Tag)', 'name' => 'kt_svc_01_tag', 'type' => 'text', 'default_value' => 'THIẾT KẾ'],
['key' => 'field_kt_svc_01_title', 'label' => 'Card 1 — Tiêu đề', 'name' => 'kt_svc_01_title', 'type' => 'text', 'default_value' => 'Thiết kế Kiến trúc'],
['key' => 'field_kt_svc_01_desc', 'label' => 'Card 1 — Mô tả', 'name' => 'kt_svc_01_desc', 'type' => 'textarea'],
['key' => 'field_kt_svc_01_bullets', 'label' => 'Card 1 — Danh sách chi tiết', 'name' => 'kt_svc_01_bullets', 'type' => 'repeater', 'layout' => 'table', 'sub_fields' => [
['key' => 'field_kt_svc_01_bullet_item', 'label' => 'Tên bước', 'name' => 'item', 'type' => 'text'],
['key' => 'field_kt_svc_01_bullet_detail', 'label' => 'Mô tả chi tiết', 'name' => 'detail', 'type' => 'textarea', 'rows' => 2],
['key' => 'field_kt_svc_01_bullet_time', 'label' => 'Thời gian (vd: 2 tuần)', 'name' => 'time', 'type' => 'text'],
]],
['key' => 'field_kt_svc_01_gallery', 'label' => 'Card 1 — Gallery ảnh cho 6 bước', 'name' => 'kt_svc_01_gallery', 'type' => 'gallery', 'return_format' => 'id', 'instructions' => 'Upload 6 ảnh riêng cho từng bước (thứ tự ảnh = thứ tự bước)'],
];
acf_add_local_field_group([
'key' => 'group_kt_service_cards',
'title' => '🏠 DỊCH VỤ KIẾN TRÚC — Service Cards',
'fields' => $svc_fields,
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1640']]],
'menu_order' => 0,
'active' => true,
]);
});
// ========================
// ACF Field Groups cho trang "Thiết kế thi công Nội thất" (ID 1166)
// ========================
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
// --- GROUP 1: Service Cards (4 cards) ---
$nt_svc_fields = [];
$card_labels = [
'01' => ['Thiết kế','Thiết kế Nội thất'],
'02' => ['Thi công','Thi công Nội thất'],
'03' => ['Sản xuất','Sản xuất Đồ gỗ'],
'04' => ['Trang trí','Trang trí & Styling'],
];
foreach ($card_labels as $num => $labels) {
$nt_svc_fields[] = ['key' => "field_nt_svc_{$num}_image", 'label' => "Card $num — Ảnh minh họa", 'name' => "nt_svc_{$num}_image", 'type' => 'image', 'return_format' => 'id'];
$nt_svc_fields[] = ['key' => "field_nt_svc_{$num}_tag", 'label' => "Card $num — Kicker (Tag)", 'name' => "nt_svc_{$num}_tag", 'type' => 'text', 'default_value' => strtoupper($labels[0])];
$nt_svc_fields[] = ['key' => "field_nt_svc_{$num}_title", 'label' => "Card $num — Tiêu đề", 'name' => "nt_svc_{$num}_title", 'type' => 'text', 'default_value' => $labels[1]];
$nt_svc_fields[] = ['key' => "field_nt_svc_{$num}_desc", 'label' => "Card $num — Mô tả", 'name' => "nt_svc_{$num}_desc", 'type' => 'textarea'];
$nt_svc_fields[] = ['key' => "field_nt_svc_{$num}_bullets", 'label' => "Card $num — Danh sách (Bullet points)", 'name' => "nt_svc_{$num}_bullets", 'type' => 'repeater', 'layout' => 'table', 'sub_fields' => [
['key' => "field_nt_svc_{$num}_bullet_item", 'label' => 'Item', 'name' => 'item', 'type' => 'text'],
]];
}
acf_add_local_field_group([
'key' => 'group_nt_service_cards',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Service Cards (4 card)',
'fields' => array_merge([
['key' => 'field_nt_svc_header_desc', 'label' => 'Section Header — Mô tả', 'name' => 'nt_svc_header_desc', 'type' => 'textarea', 'default_value' => 'Trọn gói từ thiết kế concept đến thi công hoàn thiện — một đầu mối, đồng bộ chất lượng.'],
], $nt_svc_fields),
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => 0,
'active' => true,
]);
// --- GROUP 2: Phong cách thiết kế ---
acf_add_local_field_group([
'key' => 'group_nt_styles',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Phong cách thiết kế',
'fields' => [
['key' => 'field_nt_style_head_title', 'label' => 'Section Title', 'name' => 'nt_style_head_title', 'type' => 'text', 'default_value' => 'Phong cách thiết kế'],
['key' => 'field_nt_style_head_sub', 'label' => 'Section Subtitle', 'name' => 'nt_style_head_sub', 'type' => 'text', 'default_value' => 'Đa dạng'],
['key' => 'field_nt_styles', 'label' => 'Danh sách phong cách', 'name' => 'nt_styles', 'type' => 'repeater', 'layout' => 'row', 'min' => 1, 'max' => 10, 'sub_fields' => [
['key' => 'field_nt_style_name', 'label' => 'Tên phong cách', 'name' => 'name', 'type' => 'text', 'instructions' => 'VD: Modern Luxury, Japandi, Minimalist...'],
['key' => 'field_nt_style_desc', 'label' => 'Mô tả ngắn', 'name' => 'desc', 'type' => 'textarea', 'instructions' => '1-2 câu mô tả phong cách'],
['key' => 'field_nt_style_image', 'label' => 'Ảnh minh họa', 'name' => 'image', 'type' => 'image', 'return_format' => 'id'],
]],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => 1,
'active' => true,
]);
// --- GROUP 3: Quy trình ---
acf_add_local_field_group([
'key' => 'group_nt_process',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Quy trình',
'fields' => [
['key' => 'field_nt_proc_head_title', 'label' => 'Section Title', 'name' => 'nt_proc_head_title', 'type' => 'text', 'default_value' => 'Quy trình triển khai'],
['key' => 'field_nt_proc_head_sub', 'label' => 'Section Subtitle', 'name' => 'nt_proc_head_sub', 'type' => 'text', 'default_value' => '5 bước'],
['key' => 'field_nt_proc_steps', 'label' => 'Các bước', 'name' => 'nt_proc_steps', 'type' => 'repeater', 'layout' => 'row', 'min' => 1, 'max' => 10, 'sub_fields' => [
['key' => 'field_nt_proc_step_num', 'label' => 'Số thứ tự', 'name' => 'num', 'type' => 'text'],
['key' => 'field_nt_proc_step_title', 'label' => 'Tiêu đề', 'name' => 'title', 'type' => 'text'],
['key' => 'field_nt_proc_step_desc', 'label' => 'Mô tả', 'name' => 'desc', 'type' => 'textarea'],
['key' => 'field_nt_proc_step_image', 'label' => 'Ảnh nền', 'name' => 'image', 'type' => 'image', 'return_format' => 'id'],
]],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => 2,
'active' => true,
]);
// --- GROUP 4: Đối tác vật liệu ---
acf_add_local_field_group([
'key' => 'group_nt_partners',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Đối tác Vật liệu',
'fields' => [
['key' => 'field_nt_partner_head_title', 'label' => 'Section Title', 'name' => 'nt_partner_head_title', 'type' => 'text', 'default_value' => 'Đối tác Vật liệu'],
['key' => 'field_nt_partner_head_sub', 'label' => 'Section Subtitle', 'name' => 'nt_partner_head_sub', 'type' => 'text', 'default_value' => 'Chất lượng'],
['key' => 'field_nt_partners', 'label' => 'Danh sách đối tác', 'name' => 'nt_partners', 'type' => 'repeater', 'layout' => 'row', 'min' => 1, 'max' => 20, 'sub_fields' => [
['key' => 'field_nt_partner_name', 'label' => 'Tên đối tác', 'name' => 'name', 'type' => 'text'],
['key' => 'field_nt_partner_category', 'label' => 'Danh mục', 'name' => 'category', 'type' => 'text', 'instructions' => 'VD: Gạch, Đá, Gỗ, Thiết bị vệ sinh...'],
['key' => 'field_nt_partner_logo', 'label' => 'Logo', 'name' => 'logo', 'type' => 'image', 'return_format' => 'id'],
]],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => 3,
'active' => true,
]);
// --- GROUP 5: Design & Build cho Nội thất ---
acf_add_local_field_group([
'key' => 'group_nt_db',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Design & Build',
'fields' => [
['key' => 'field_nt_db_kicker', 'label' => 'Eyebrow / Kicker', 'name' => 'nt_db_kicker', 'type' => 'text', 'default_value' => '✦ Chamspace — Chạm Tinh Tế'],
['key' => 'field_nt_db_title', 'label' => 'Tiêu đề', 'name' => 'nt_db_title', 'type' => 'text', 'default_value' => 'Thiết kế & Thi công Nội thất'],
['key' => 'field_nt_db_desc', 'label' => 'Mô tả', 'name' => 'nt_db_desc', 'type' => 'textarea'],
['key' => 'field_nt_db_stat_1_num', 'label' => 'Stat 1 — Con số', 'name' => 'nt_db_stat_1_num', 'type' => 'text', 'default_value' => '12+'],
['key' => 'field_nt_db_stat_1_cap', 'label' => 'Stat 1 — Nhãn', 'name' => 'nt_db_stat_1_cap', 'type' => 'text', 'default_value' => 'Năm kinh nghiệm'],
['key' => 'field_nt_db_stat_2_num', 'label' => 'Stat 2 — Con số', 'name' => 'nt_db_stat_2_num', 'type' => 'text', 'default_value' => '50+'],
['key' => 'field_nt_db_stat_2_cap', 'label' => 'Stat 2 — Nhãn', 'name' => 'nt_db_stat_2_cap', 'type' => 'text', 'default_value' => 'Dự án nội thất'],
['key' => 'field_nt_db_stat_3_num', 'label' => 'Stat 3 — Con số', 'name' => 'nt_db_stat_3_num', 'type' => 'text', 'default_value' => '500m²'],
['key' => 'field_nt_db_stat_3_cap', 'label' => 'Stat 3 — Nhãn', 'name' => 'nt_db_stat_3_cap', 'type' => 'text', 'default_value' => 'Xưởng sản xuất'],
['key' => 'field_nt_db_left_image', 'label' => 'Ảnh bên trái', 'name' => 'nt_db_left_image', 'type' => 'image', 'return_format' => 'id'],
['key' => 'field_nt_db_left_title', 'label' => 'Ảnh trái — Tiêu đề', 'name' => 'nt_db_left_title', 'type' => 'text', 'default_value' => 'Thiết kế'],
['key' => 'field_nt_db_left_sub', 'label' => 'Ảnh trái — Phụ đề', 'name' => 'nt_db_left_sub', 'type' => 'text', 'default_value' => 'Concept & 3D'],
['key' => 'field_nt_db_right_image', 'label' => 'Ảnh bên phải', 'name' => 'nt_db_right_image', 'type' => 'image', 'return_format' => 'id'],
['key' => 'field_nt_db_right_title', 'label' => 'Ảnh phải — Tiêu đề', 'name' => 'nt_db_right_title', 'type' => 'text', 'default_value' => 'Thi công'],
['key' => 'field_nt_db_right_sub', 'label' => 'Ảnh phải — Phụ đề', 'name' => 'nt_db_right_sub', 'type' => 'text', 'default_value' => 'Hoàn thiện & Bàn giao'],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => -1,
'active' => true,
]);
// --- GROUP 6: Thiết kế Kiến trúc — ACF fields ---
acf_add_local_field_group([
'key' => 'group_kt_articles',
'title' => '🏠 THIẾT KẾ KIẾN TRÚC — Bài viết & Dự án',
'fields' => [
[
'key' => 'field_kt_article_quytrinh',
'label' => 'Bài viết Quy trình thiết kế',
'name' => 'kt_article_quytrinh',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Quy trình thiết kế'
],
[
'key' => 'field_kt_article_hoso',
'label' => 'Bài viết Hồ sơ thiết kế',
'name' => 'kt_article_hoso',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Hồ sơ thiết kế'
],
[
'key' => 'field_kt_article_faq',
'label' => 'Bài viết Góc chuyên gia / FAQ',
'name' => 'kt_article_faq',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết để hiển thị ở section FAQ'
],
[
'key' => 'field_kt_hoso_pdf',
'label' => '📄 PDF — Hồ sơ thiết kế mẫu',
'name' => 'kt_hoso_pdf',
'type' => 'file',
'return_format' => 'url',
'mime_types' => 'pdf',
'instructions' => 'Upload file PDF mẫu hồ sơ thiết kế. Sẽ hiển thị dạng flipbook lật trang bên dưới section Hồ sơ thiết kế.',
],
[
'key' => 'field_kt_featured_projects',
'label' => 'Dự án tiêu biểu',
'name' => 'kt_featured_projects',
'type' => 'post_object',
'post_type' => ['cham_project'],
'multiple' => 1,
'return_format' => 'id',
'instructions' => 'Chọn các dự án muốn hiển thị trong section Dự án tiêu biểu'
],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1640']]],
'menu_order' => 4,
'active' => true,
]);
// --- GROUP 7: Nội thất — Bài viết & Dự án ---
acf_add_local_field_group([
'key' => 'group_nt_articles',
'title' => '🛋️ DỊCH VỤ NỘI THẤT — Bài viết & Dự án',
'fields' => [
[
'key' => 'field_nt_article_quytrinh',
'label' => 'Bài viết Quy trình thiết kế',
'name' => 'nt_article_quytrinh',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Quy trình'
],
[
'key' => 'field_nt_article_hoso',
'label' => 'Bài viết Hồ sơ thiết kế',
'name' => 'nt_article_hoso',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Hồ sơ'
],
[
'key' => 'field_nt_featured_projects',
'label' => 'Dự án tiêu biểu',
'name' => 'nt_featured_projects',
'type' => 'post_object',
'post_type' => ['cham_project'],
'multiple' => 1,
'return_format' => 'id',
'instructions' => 'Chọn các dự án muốn hiển thị trong section Dự án tiêu biểu'
],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1166']]],
'menu_order' => 5,
'active' => true,
]);
// Filter: chỉ hiện post thuộc category "Quy Trình" cho các field bài viết
$quytrinh_filter = function($args) {
$args['tax_query'] = [['taxonomy' => 'category', 'field' => 'slug', 'terms' => 'quy-trinh']];
return $args;
};
add_filter('acf/fields/post_object/query/name=kt_article_quytrinh', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=kt_article_hoso', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=kt_article_faq', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=nt_article_quytrinh', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=nt_article_hoso', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=pt_article_quytrinh', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=pt_article_hoso', $quytrinh_filter);
// --- GROUP 8: Phần thô — Bài viết & Dự án ---
acf_add_local_field_group([
'key' => 'group_pt_articles',
'title' => '🏗️ THI CÔNG PHẦN THÔ — Bài viết & Dự án',
'fields' => [
[
'key' => 'field_pt_article_quytrinh',
'label' => 'Bài viết Quy trình thi công',
'name' => 'pt_article_quytrinh',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Quy trình'
],
[
'key' => 'field_pt_article_hoso',
'label' => 'Bài viết Hồ sơ thi công',
'name' => 'pt_article_hoso',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình để hiển thị ở section Hồ sơ'
],
[
'key' => 'field_pt_featured_projects',
'label' => 'Dự án tiêu biểu',
'name' => 'pt_featured_projects',
'type' => 'post_object',
'post_type' => ['cham_project'],
'multiple' => 1,
'return_format' => 'id',
'instructions' => 'Chọn các dự án muốn hiển thị trong section Dự án tiêu biểu'
],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1160']]],
'menu_order' => 6,
'active' => true,
]);
// --- GROUP 9: Trọn gói — Bài viết & Dự án ---
acf_add_local_field_group([
'key' => 'group_tg_articles',
'title' => '🔑 THI CÔNG TRỌN GÓI — Bài viết & Dự án',
'fields' => [
[
'key' => 'field_tg_article_baogia',
'label' => 'Bài viết Báo giá',
'name' => 'tg_article_baogia',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết báo giá thi công trọn gói'
],
[
'key' => 'field_tg_article_quytrinh',
'label' => 'Bài viết Quy trình thi công',
'name' => 'tg_article_quytrinh',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình'
],
[
'key' => 'field_tg_article_hangmuc',
'label' => 'Bài viết Hạng mục bao gồm',
'name' => 'tg_article_hangmuc',
'type' => 'post_object',
'post_type' => ['post'],
'return_format' => 'id',
'instructions' => 'Chọn 1 bài viết trong mục Quy Trình'
],
[
'key' => 'field_tg_featured_projects',
'label' => 'Dự án tiêu biểu',
'name' => 'tg_featured_projects',
'type' => 'post_object',
'post_type' => ['cham_project'],
'multiple' => 1,
'return_format' => 'id',
'instructions' => 'Chọn các dự án muốn hiển thị trong section Công trình thi công'
],
],
'location' => [[['param' => 'page', 'operator' => '==', 'value' => '1157']]],
'menu_order' => 7,
'active' => true,
]);
add_filter('acf/fields/post_object/query/name=tg_article_quytrinh', $quytrinh_filter);
add_filter('acf/fields/post_object/query/name=tg_article_hangmuc', $quytrinh_filter);
});
// ════════════════════════════════════════════════════════════
// ACF Fields cho 3 trang Báo Giá — Hero Cover
// ════════════════════════════════════════════════════════════
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
// Field group cho cả 3 trang báo giá
acf_add_local_field_group([
'key' => 'group_bao_gia_hero',
'title' => '📋 BÁO GIÁ — Hero Cover',
'fields' => [
[
'key' => 'field_bg_hero_bg',
'label' => 'Hình nền Hero',
'name' => 'bg_hero_bg',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Chọn hình nền cho Hero Cover (nếu để trống sẽ dùng hình mặc định)',
],
[
'key' => 'field_bg_hero_title',
'label' => 'Tiêu đề chính',
'name' => 'bg_hero_title',
'type' => 'text',
'default_value' => 'Dự toán chi phí',
'instructions' => 'VD: Dự toán thiết kế, Dự toán phần thô, Trọn gói Design & Build',
],
[
'key' => 'field_bg_hero_kicker',
'label' => 'Dòng chữ nhỏ trên tiêu đề',
'name' => 'bg_hero_kicker',
'type' => 'text',
'default_value' => '✦ Chamspace — Công Cụ',
],
[
'key' => 'field_bg_hero_sub',
'label' => 'Mô tả dưới tiêu đề',
'name' => 'bg_hero_sub',
'type' => 'textarea',
'rows' => 2,
'instructions' => 'Mô tả ngắn về công cụ báo giá',
],
[
'key' => 'field_bg_hero_tag',
'label' => 'Chữ nút bấm',
'name' => 'bg_hero_tag',
'type' => 'text',
'default_value' => 'Nhận báo giá ngay',
],
[
'key' => 'field_bg_hero_popup_title',
'label' => 'Tiêu đề Popup',
'name' => 'bg_hero_popup_title',
'type' => 'text',
'default_value' => 'Nhận báo giá từ Chamspace',
],
[
'key' => 'field_bg_hero_popup_sub',
'label' => 'Mô tả Popup',
'name' => 'bg_hero_popup_sub',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Để lại thông tin, đội ngũ Chamspace sẽ liên hệ tư vấn và gửi báo giá chi tiết trong 24h.',
],
],
'location' => [
[
['param' => 'page', 'operator' => '==', 'value' => '1246'], // Báo giá thiết kế
],
[
['param' => 'page', 'operator' => '==', 'value' => '1606'], // Báo giá phần thô
],
[
['param' => 'page', 'operator' => '==', 'value' => '1614'], // Báo giá trọn gói
],
],
'menu_order' => 1,
'active' => true,
]);
});
// ════════════════════════════════════════════════════════════
// ACF Fields cho 3 trang Báo Giá — Section Cam Kết (CTA Pill)
// ════════════════════════════════════════════════════════════
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_bao_gia_cam_ket',
'title' => '📋 BÁO GIÁ — Cam Kết (CTA Pill)',
'fields' => [
[
'key' => 'field_bg_camket_img_left',
'label' => 'Hình ảnh BÊN TRÁI',
'name' => 'bg_camket_img_left',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Hình ảnh bên trái của section Cam Kết',
],
[
'key' => 'field_bg_camket_img_right',
'label' => 'Hình ảnh BÊN PHẢI',
'name' => 'bg_camket_img_right',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Hình ảnh bên phải của section Cam Kết',
],
[
'key' => 'field_bg_camket_pill_1_label',
'label' => 'Pill 1 — Nhãn (label)',
'name' => 'bg_camket_pill_1_label',
'type' => 'text',
'default_value' => 'Cam kết',
],
[
'key' => 'field_bg_camket_pill_1_title',
'label' => 'Pill 1 — Tiêu đề (title)',
'name' => 'bg_camket_pill_1_title',
'type' => 'text',
'default_value' => 'Chuẩn Đức',
],
[
'key' => 'field_bg_camket_pill_1_desc',
'label' => 'Pill 1 — Mô tả (desc)',
'name' => 'bg_camket_pill_1_desc',
'type' => 'text',
'default_value' => 'từng bước',
],
[
'key' => 'field_bg_camket_pill_2_label',
'label' => 'Pill 2 — Nhãn (label)',
'name' => 'bg_camket_pill_2_label',
'type' => 'text',
'default_value' => 'Chamspace',
],
[
'key' => 'field_bg_camket_pill_2_title',
'label' => 'Pill 2 — Tiêu đề (title)',
'name' => 'bg_camket_pill_2_title',
'type' => 'text',
'default_value' => 'Kỷ luật',
],
[
'key' => 'field_bg_camket_pill_2_desc',
'label' => 'Pill 2 — Mô tả (desc)',
'name' => 'bg_camket_pill_2_desc',
'type' => 'text',
'default_value' => 'không bỏ sót',
],
[
'key' => 'field_bg_camket_check_1',
'label' => 'Checklist 1',
'name' => 'bg_camket_check_1',
'type' => 'text',
'default_value' => 'Quy trình 4 bước rõ ràng',
],
[
'key' => 'field_bg_camket_check_2',
'label' => 'Checklist 2',
'name' => 'bg_camket_check_2',
'type' => 'text',
'default_value' => 'Giám sát chặt từng giai đoạn',
],
[
'key' => 'field_bg_camket_check_3',
'label' => 'Checklist 3',
'name' => 'bg_camket_check_3',
'type' => 'text',
'default_value' => 'Tiêu chuẩn Đức — từng chi tiết',
],
[
'key' => 'field_bg_camket_check_4',
'label' => 'Checklist 4',
'name' => 'bg_camket_check_4',
'type' => 'text',
'default_value' => 'Xưởng sản xuất trực tiếp Bình Tân',
],
],
'location' => [
[
['param' => 'page', 'operator' => '==', 'value' => '1246'], // Báo giá thiết kế
],
[
['param' => 'page', 'operator' => '==', 'value' => '1606'], // Báo giá phần thô
],
[
['param' => 'page', 'operator' => '==', 'value' => '1614'], // Báo giá trọn gói
],
],
'menu_order' => 2,
'active' => true,
]);
});
// ════════════════════════════════════════════════════════════
// ACF Fields cho 4 trang Dịch Vụ — Hero Cover
// ════════════════════════════════════════════════════════════
// ════════════════════════════════════════════════════════════
// ACF Fields cho 2 trang Kinh Nghiệm — Hero Cover + Cam Kết
// ════════════════════════════════════════════════════════════
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
// Hero Cover
acf_add_local_field_group([
'key' => 'group_kn_hero',
'title' => '📋 KINH NGHIỆM — Hero Cover',
'fields' => [
[
'key' => 'field_kn_hero_bg',
'label' => 'Hình nền Hero',
'name' => 'kn_hero_bg',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Chọn hình nền cho Hero Cover',
],
[
'key' => 'field_kn_hero_title',
'label' => 'Tiêu đề chính',
'name' => 'kn_hero_title',
'type' => 'text',
'default_value' => 'Kinh Nghiệm Thiết Kế',
],
[
'key' => 'field_kn_hero_kicker',
'label' => 'Dòng chữ nhỏ',
'name' => 'kn_hero_kicker',
'type' => 'text',
'default_value' => '✦ Chamspace — Kiến thức thực chiến',
],
[
'key' => 'field_kn_hero_sub',
'label' => 'Mô tả',
'name' => 'kn_hero_sub',
'type' => 'textarea',
'rows' => 2,
],
[
'key' => 'field_kn_hero_tag',
'label' => 'Chữ nút bấm',
'name' => 'kn_hero_tag',
'type' => 'text',
'default_value' => 'Khám phá ngay',
],
[
'key' => 'field_kn_hero_popup_title',
'label' => 'Tiêu đề Popup',
'name' => 'kn_hero_popup_title',
'type' => 'text',
'default_value' => 'Nhận tư vấn từ Chamspace',
],
[
'key' => 'field_kn_hero_popup_sub',
'label' => 'Mô tả Popup',
'name' => 'kn_hero_popup_sub',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Để lại thông tin, đội ngũ Chamspace sẽ liên hệ tư vấn miễn phí trong 24h.',
],
],
'location' => [
[
['param' => 'page', 'operator' => '==', 'value' => '1257'], // Kinh nghiệm thiết kế
],
[
['param' => 'page', 'operator' => '==', 'value' => '1259'], // Kinh nghiệm thi công
],
],
'menu_order' => 1,
'active' => true,
]);
// Cam Kết (CTA Pill)
acf_add_local_field_group([
'key' => 'group_kn_cam_ket',
'title' => '📋 KINH NGHIỆM — Cam Kết (CTA Pill)',
'fields' => [
[
'key' => 'field_kn_camket_img_left',
'label' => 'Hình ảnh BÊN TRÁI',
'name' => 'kn_camket_img_left',
'type' => 'image',
'return_format' => 'url',
],
[
'key' => 'field_kn_camket_img_right',
'label' => 'Hình ảnh BÊN PHẢI',
'name' => 'kn_camket_img_right',
'type' => 'image',
'return_format' => 'url',
],
[
'key' => 'field_kn_camket_pill_1_label',
'label' => 'Pill 1 — Nhãn',
'name' => 'kn_camket_pill_1_label',
'type' => 'text',
'default_value' => 'Cam kết',
],
[
'key' => 'field_kn_camket_pill_1_title',
'label' => 'Pill 1 — Tiêu đề',
'name' => 'kn_camket_pill_1_title',
'type' => 'text',
'default_value' => 'Chuẩn Đức',
],
[
'key' => 'field_kn_camket_pill_1_desc',
'label' => 'Pill 1 — Mô tả',
'name' => 'kn_camket_pill_1_desc',
'type' => 'text',
'default_value' => 'từng bước',
],
[
'key' => 'field_kn_camket_pill_2_label',
'label' => 'Pill 2 — Nhãn',
'name' => 'kn_camket_pill_2_label',
'type' => 'text',
'default_value' => 'Chamspace',
],
[
'key' => 'field_kn_camket_pill_2_title',
'label' => 'Pill 2 — Tiêu đề',
'name' => 'kn_camket_pill_2_title',
'type' => 'text',
'default_value' => 'Kỷ luật',
],
[
'key' => 'field_kn_camket_pill_2_desc',
'label' => 'Pill 2 — Mô tả',
'name' => 'kn_camket_pill_2_desc',
'type' => 'text',
'default_value' => 'không bỏ sót',
],
[
'key' => 'field_kn_camket_check_1',
'label' => 'Checklist 1',
'name' => 'kn_camket_check_1',
'type' => 'text',
'default_value' => 'Quy trình 4 bước rõ ràng',
],
[
'key' => 'field_kn_camket_check_2',
'label' => 'Checklist 2',
'name' => 'kn_camket_check_2',
'type' => 'text',
'default_value' => 'Giám sát chặt từng giai đoạn',
],
[
'key' => 'field_kn_camket_check_3',
'label' => 'Checklist 3',
'name' => 'kn_camket_check_3',
'type' => 'text',
'default_value' => 'Tiêu chuẩn Đức — từng chi tiết',
],
[
'key' => 'field_kn_camket_check_4',
'label' => 'Checklist 4',
'name' => 'kn_camket_check_4',
'type' => 'text',
'default_value' => 'Xưởng sản xuất trực tiếp Bình Tân',
],
],
'location' => [
[
['param' => 'page', 'operator' => '==', 'value' => '1257'], // Kinh nghiệm thiết kế
],
[
['param' => 'page', 'operator' => '==', 'value' => '1259'], // Kinh nghiệm thi công
],
],
'menu_order' => 2,
'active' => true,
]);
});
// ════════════════════════════════════════════════════════════
// ACF Fields cho 4 trang Dịch Vụ — Section Design & Build
// ════════════════════════════════════════════════════════════
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_dich_vu_db',
'title' => '📋 DỊCH VỤ — Design & Build',
'fields' => [
[
'key' => 'field_dv_db_img_left',
'label' => 'Hình ảnh BÊN TRÁI (Design)',
'name' => 'dv_db_img_left',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Hình ảnh minh họa phần Design (bên trái)',
],
[
'key' => 'field_dv_db_img_right',
'label' => 'Hình ảnh BÊN PHẢI (Build)',
'name' => 'dv_db_img_right',
'type' => 'image',
'return_format' => 'url',
'instructions' => 'Hình ảnh minh họa phần Build (bên phải)',
],
[
'key' => 'field_dv_db_kicker',
'label' => 'Dòng chữ nhỏ trên tiêu đề',
'name' => 'dv_db_kicker',
'type' => 'text',
'default_value' => 'Mô hình Design & Build của Chamspace',
],
[
'key' => 'field_dv_db_title',
'label' => 'Tiêu đề chính',
'name' => 'dv_db_title',
'type' => 'text',
'default_value' => 'Một cam kết. Không khoảng cách giữa ý tưởng thiết kế và thực tế thi công.',
],
[
'key' => 'field_dv_db_desc',
'label' => 'Mô tả',
'name' => 'dv_db_desc',
'type' => 'textarea',
'rows' => 3,
'default_value' => 'Khác với mô hình thuê thiết kế rồi tìm đơn vị thi công riêng, Chamspace làm tổng thầu trọn gói Design & Build. Ý tưởng từ kiến trúc sư được chuyển thẳng xuống xưởng thi công — không thất thoát, không đùn đẩy.',
],
[
'key' => 'field_dv_db_fig_1_num',
'label' => 'Số liệu 1 — Con số',
'name' => 'dv_db_fig_1_num',
'type' => 'text',
'default_value' => '10+',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_fig_1_cap',
'label' => 'Số liệu 1 — Chú thích',
'name' => 'dv_db_fig_1_cap',
'type' => 'text',
'default_value' => 'Năm kinh nghiệm',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_fig_2_num',
'label' => 'Số liệu 2 — Con số',
'name' => 'dv_db_fig_2_num',
'type' => 'text',
'default_value' => '17+',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_fig_2_cap',
'label' => 'Số liệu 2 — Chú thích',
'name' => 'dv_db_fig_2_cap',
'type' => 'text',
'default_value' => 'Dự án hoàn thành',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_fig_3_num',
'label' => 'Số liệu 3 — Con số',
'name' => 'dv_db_fig_3_num',
'type' => 'text',
'default_value' => '100%',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_fig_3_cap',
'label' => 'Số liệu 3 — Chú thích',
'name' => 'dv_db_fig_3_cap',
'type' => 'text',
'default_value' => 'Khách hàng hài lòng',
'wrapper' => ['width' => '33'],
],
[
'key' => 'field_dv_db_cap_left_label',
'label' => 'Caption trái — Nhãn',
'name' => 'dv_db_cap_left_label',
'type' => 'text',
'default_value' => 'Architecture & Concept',
],
[
'key' => 'field_dv_db_cap_left_title',
'label' => 'Caption trái — Tiêu đề',
'name' => 'dv_db_cap_left_title',
'type' => 'text',
'default_value' => 'Thiết kế. Nơi ý tưởng bắt đầu.',
],
[
'key' => 'field_dv_db_cap_left_desc',
'label' => 'Caption trái — Mô tả',
'name' => 'dv_db_cap_left_desc',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Mỗi dự án được tiếp cận như một câu chuyện riêng — từ moodboard, concept 3D đến bản vẽ kỹ thuật.',
],
[
'key' => 'field_dv_db_cap_right_label',
'label' => 'Caption phải — Nhãn',
'name' => 'dv_db_cap_right_label',
'type' => 'text',
'default_value' => 'Construction & Craft',
],
[
'key' => 'field_dv_db_cap_right_title',
'label' => 'Caption phải — Tiêu đề',
'name' => 'dv_db_cap_right_title',
'type' => 'text',
'default_value' => 'Thi công. Nơi ý tưởng thành hiện thực.',
],
[
'key' => 'field_dv_db_cap_right_desc',
'label' => 'Caption phải — Mô tả',
'name' => 'dv_db_cap_right_desc',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Xưởng sản xuất riêng đảm bảo chất lượng — không khoảng cách giữa thiết kế và thực tế.',
],
],
'location' => [
[
['param' => 'page', 'operator' => '==', 'value' => '1640'], // Thiết kế kiến trúc
],
[
['param' => 'page', 'operator' => '==', 'value' => '1166'], // Thiết kế nội thất
],
[
['param' => 'page', 'operator' => '==', 'value' => '1160'], // Thi công phần thô
],
[
['param' => 'page', 'operator' => '==', 'value' => '1157'], // Thi công hoàn thiện
],
],
'menu_order' => 3,
'active' => true,
]);
});
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 🔧 BÁO GIÁ PHẦN THÔ — 3 Gói So Sánh (18 ảnh)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Grid 1: Giá & Thời gian | Grid 2: Kết cấu | Grid 3: Tường
// Grid 4: Điện | Grid 5: Nước | Grid 6: Bảo hành
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
$goi_labels = [
'tietkiem' => 'Tiết kiệm',
'tieuchuan' => 'Tiêu chuẩn',
'caocap' => 'Cao cấp',
];
$grid_titles = [
1 => 'Giá & Thời gian',
2 => 'Kết cấu',
3 => 'Tường',
4 => 'Điện',
5 => 'Nước',
6 => 'Bảo hành & Bảo trì',
];
$fields = [];
$field_idx = 1;
foreach ($goi_labels as $goi_key => $goi_label) {
foreach ($grid_titles as $grid_num => $grid_title) {
$field_key = "field_pt_goi_{$goi_key}_img_{$grid_num}";
$field_name = "pt_goi_{$goi_key}_img_{$grid_num}";
$fields[] = [
'key' => $field_key,
'label' => "{$goi_label} — Grid {$grid_num}: {$grid_title}",
'name' => $field_name,
'type' => 'image',
'return_format' => 'url',
'preview_size' => 'medium',
'instructions' => "Upload ảnh minh họa cho gói {$goi_label}, hạng mục {$grid_title}",
];
$field_idx++;
}
}
acf_add_local_field_group([
'key' => 'group_pt_3goi_compare',
'title' => '🔧 PHẦN THÔ — So sánh 3 Gói (18 ảnh)',
'fields' => $fields,
'location' => [
[['param' => 'page', 'operator' => '==', 'value' => '1606']], // Báo giá phần thô
],
'menu_order' => 5,
'active' => true,
]);
});
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 🏔️ SERVICE PAGES — Hero Cover (4 trang dịch vụ)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Shortcode [chamspace_home_hero] tự động detect field 'bg_hero_bg'
// Nếu page có field này → dùng hero riêng, không thì fallback về trang chủ
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_service_hero',
'title' => '🏔️ SERVICE — Hero Cover (Ảnh nền + Text)',
'fields' => [
[
'key' => 'field_svc_hero_bg',
'label' => '🖼️ Ảnh nền Hero (cover toàn màn hình)',
'name' => 'bg_hero_bg',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'large',
'instructions' => 'Upload ảnh nền cho hero cover. Khuyến nghị: 1920×1080px, nén webp/jpeg.',
],
[
'key' => 'field_svc_hero_kicker',
'label' => '✦ Dòng kicker (nhỏ phía trên)',
'name' => 'bg_hero_kicker',
'type' => 'text',
'default_value' => '✦ Chamspace — Chạm Tinh Tế',
'instructions' => 'VD: "✦ Dịch vụ Kiến trúc" hoặc để mặc định.',
],
[
'key' => 'field_svc_hero_title',
'label' => '📝 Tiêu đề chính (H1 lớn)',
'name' => 'bg_hero_title',
'type' => 'textarea',
'rows' => 2,
'new_lines' => 'br',
'default_value' => "Thiết Kế Thi Công\nKiến Trúc",
'instructions' => 'Viết xuống dòng = xuống dòng trên web. Mỗi page khác nhau.',
],
[
'key' => 'field_svc_hero_sub',
'label' => '📝 Mô tả phụ (dưới tiêu đề)',
'name' => 'bg_hero_sub',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Giải pháp kiến trúc toàn diện — từ ý tưởng đến thi công hoàn thiện.',
'instructions' => '1-2 câu mô tả ngắn gọn.',
],
[
'key' => 'field_svc_hero_cta',
'label' => '🔘 Text nút CTA (góc phải)',
'name' => 'bg_hero_cta',
'type' => 'text',
'default_value' => 'Nhận tư vấn ngay',
'instructions' => 'VD: "Nhận báo giá", "Tư vấn miễn phí"...',
],
],
'location' => [
[['param' => 'page', 'operator' => '==', 'value' => '1640']], // Thiết kế kiến trúc
[['param' => 'page', 'operator' => '==', 'value' => '1166']], // Thiết kế nội thất
[['param' => 'page', 'operator' => '==', 'value' => '1157']], // Thi công trọn gói
[['param' => 'page', 'operator' => '==', 'value' => '1160']], // Thi công phần thô
[['param' => 'page', 'operator' => '==', 'value' => '1733']], // Chính sách bảo hành
[['param' => 'page', 'operator' => '==', 'value' => '1734']], // Bảo mật thông tin
[['param' => 'page', 'operator' => '==', 'value' => '1735']], // Điều khoản sử dụng
],
'menu_order' => 0,
'active' => true,
]);
// Quy trình Hero — 3 trang
acf_add_local_field_group([
'key' => 'group_qt_hero',
'title' => '🔧 QUY TRÌNH — Hero Cover (Ảnh nền + Text)',
'fields' => [
[
'key' => 'field_qt_hero_bg',
'label' => '🖼️ Ảnh nền Hero (cover toàn màn hình)',
'name' => 'qt_hero_bg',
'type' => 'image',
'return_format' => 'id',
'preview_size' => 'large',
'instructions' => 'Upload ảnh nền cho hero cover. Khuyến nghị: 1920×1080px, nén webp/jpeg.',
],
[
'key' => 'field_qt_hero_kicker',
'label' => '✦ Dòng kicker (nhỏ phía trên)',
'name' => 'qt_hero_kicker',
'type' => 'text',
'default_value' => '✦ Chamspace — Chạm Tinh Tế',
'instructions' => 'VD: "✦ Quy trình Thiết kế" hoặc để mặc định.',
],
[
'key' => 'field_qt_hero_title',
'label' => '📝 Tiêu đề chính (H1 lớn)',
'name' => 'qt_hero_title',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'TẤT CẢ QUY TRÌNH',
'instructions' => 'Có thể xuống dòng.',
],
[
'key' => 'field_qt_hero_subtitle',
'label' => '📝 Phụ đề (dòng nhỏ dưới H1)',
'name' => 'qt_hero_subtitle',
'type' => 'textarea',
'rows' => 2,
'default_value' => 'Quy trình minh bạch, chuẩn mực — từ ý tưởng đến bàn giao',
],
],
'location' => [
[['param' => 'page', 'operator' => '==', 'value' => '1576']], // Tất cả quy trình
[['param' => 'page', 'operator' => '==', 'value' => '1151']], // Quy trình thiết kế
[['param' => 'page', 'operator' => '==', 'value' => '1148']], // Quy trình thi công
],
'menu_order' => 0,
'active' => true,
]);
});
// ═══ B2B — Loại hình Images (page 1870) ═══
add_action('acf/init', function() {
if (!function_exists('acf_add_local_field_group')) return;
acf_add_local_field_group([
'key' => 'group_b2b_loai_hinh',
'title' => '🏠 B2B — Loại hình công trình (ảnh thumb)',
'fields' => [
['key' => 'field_b2b_loai_can_ho', 'label' => '🖼️ Căn hộ', 'name' => 'b2b_loai_can_ho', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_loai_nha_pho', 'label' => '🖼️ Nhà phố', 'name' => 'b2b_loai_nha_pho', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_loai_biet_thu', 'label' => '🖼️ Biệt thự', 'name' => 'b2b_loai_biet_thu', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_loai_van_phong','label' => '🖼️ Văn phòng', 'name' => 'b2b_loai_van_phong','type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_loai_fb', 'label' => '🖼️ F&B', 'name' => 'b2b_loai_fb', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
],
'location' => [
[['param' => 'page', 'operator' => '==', 'value' => '1870']],
],
'menu_order' => 10,
'active' => true,
]);
acf_add_local_field_group([
'key' => 'group_b2b_phong_cach',
'title' => '🎨 B2B — Phong cách thiết kế (ảnh thumb)',
'fields' => [
['key' => 'field_b2b_pc_hien_dai', 'label' => '🖼️ Hiện đại', 'name' => 'b2b_pc_hien_dai', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_industrial', 'label' => '🖼️ Industrial', 'name' => 'b2b_pc_industrial', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_japandi', 'label' => '🖼️ Japandi', 'name' => 'b2b_pc_japandi', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_wabi_sabi', 'label' => '🖼️ Wabi-Sabi', 'name' => 'b2b_pc_wabi_sabi', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_indochine', 'label' => '🖼️ Indochine', 'name' => 'b2b_pc_indochine', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_tan_co_dien', 'label' => '🖼️ Tân cổ điển', 'name' => 'b2b_pc_tan_co_dien', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
['key' => 'field_b2b_pc_luxury', 'label' => '🖼️ Luxury', 'name' => 'b2b_pc_luxury', 'type' => 'image', 'return_format' => 'id', 'preview_size' => 'medium'],
],
'location' => [
[['param' => 'page', 'operator' => '==', 'value' => '1870']],
],
'menu_order' => 20,
'active' => true,
]);
});
// Body background curves - position below content
add_action('wp_head', function() {
echo '<style>.body-background{position:fixed;bottom:0;left:0;right:0;height:clamp(200px,25vh,350px);overflow:hidden;pointer-events:none;}.body-background svg{position:absolute;bottom:0;left:50%;transform:translateX(-50%);width:1600px;height:auto;max-width:none;opacity:0.75;}</style>';
}, 999);