/**
* Template Name: Bespoke Door Landing Page
* Description: Custom template for heritage door landing pages with AI content integration
*/
Bespoke Front Doors & Sash Windows in London & Essex
$favicon = Avada()->settings->get('favicon');
if ($favicon) :
endif;
// Icon mapping function - MUST BE DEFINED FIRST
function get_door_icon($icon_name) {
$icon_map = array(
// USP Bar icons
'icon-heritage' => 'fa-solid fa-landmark',
'icon-craftsmanship' => 'fa-solid fa-hammer',
'icon-custom' => 'fa-solid fa-ruler-combined',
'icon-guarantee' => 'fa-solid fa-shield-halved',
// Feature category icons
'icon-design' => 'fa-solid fa-paintbrush',
'icon-technical' => 'fa-solid fa-cog',
'icon-customization' => 'fa-solid fa-sliders',
'icon-heritage' => 'fa-solid fa-building-columns',
// Specification icons
'icon-timber' => 'fa-solid fa-tree',
'icon-glazing' => 'fa-solid fa-window-restore',
'icon-security' => 'fa-solid fa-lock',
'icon-weather' => 'fa-solid fa-cloud-sun-rain',
'icon-thermal' => 'fa-solid fa-temperature-half',
'icon-acoustic' => 'fa-solid fa-volume-low',
// Default fallback
'default' => 'fa-solid fa-door-open'
);
return isset($icon_map[$icon_name]) ? $icon_map[$icon_name] : $icon_map['default'];
}
// Placeholder image function - MOVED TO TOP
function create_placeholder_image_url($width = 400, $height = 300, $text = 'Door Image') {
return 'data:image/svg+xml;base64,' . base64_encode('
');
}
// Section visibility function
function should_show_section($section) {
$options = get_option('door_design_options', array());
// Debug logging
error_log('Checking section: ' . $section);
error_log('Options: ' . print_r($options, true));
// If no options are saved, show all sections by default
if (empty($options) || !isset($options['sections'])) {
return true;
}
// Check if the section is explicitly set
// IMPORTANT: Checkboxes that are unchecked don't get posted, so they won't exist in the array
if (isset($options['sections'][$section])) {
// If it exists and is '1', show it
return $options['sections'][$section] == '1';
}
// If the key doesn't exist (unchecked), don't show it
return false;
}
get_header();
// Get all AI-generated content
$page_id = get_the_ID();
// Get design settings
$design_options = get_option('door_design_options', array());
$ai_content = array(
'hero' => json_decode(get_post_meta($page_id, '_ai_hero_content', true), true),
'usps' => json_decode(get_post_meta($page_id, '_ai_usps_content', true), true),
'overview' => json_decode(get_post_meta($page_id, '_ai_overview_content', true), true),
'features' => json_decode(get_post_meta($page_id, '_ai_features_content', true), true),
'customization' => json_decode(get_post_meta($page_id, '_ai_customization_content', true), true),
'specifications' => json_decode(get_post_meta($page_id, '_ai_specifications_content', true), true),
'heritage' => json_decode(get_post_meta($page_id, '_ai_heritage_content', true), true),
'process' => json_decode(get_post_meta($page_id, '_ai_process_content', true), true),
'testimonials' => json_decode(get_post_meta($page_id, '_ai_testimonials_content', true), true),
'pricing' => json_decode(get_post_meta($page_id, '_ai_pricing_content', true), true),
'faqs' => json_decode(get_post_meta($page_id, '_ai_faqs_content', true), true),
'local_seo' => json_decode(get_post_meta($page_id, '_ai_local_seo_content', true), true),
'final_cta' => json_decode(get_post_meta($page_id, '_ai_final_cta_content', true), true),
'related' => json_decode(get_post_meta($page_id, '_ai_related_content', true), true),
'seo' => json_decode(get_post_meta($page_id, '_ai_seo_content', true), true)
);
// Get door style and images
$door_style = get_post_meta($page_id, '_door_style', true) ?: 'Victorian';
// Get template images - with fallback if function doesn't exist
if (function_exists('get_template_door_images')) {
$template_images = get_template_door_images($page_id);
} else {
// Create placeholder images using our function
$template_images = array(
'hero' => create_placeholder_image_url(1200, 600, $door_style . ' Door Hero'),
'overview_main' => create_placeholder_image_url(600, 400, $door_style . ' Detail'),
'overview_details' => array(
'panel' => create_placeholder_image_url(200, 150, 'Panel Detail'),
'glass' => create_placeholder_image_url(200, 150, 'Glass Detail'),
'hardware' => create_placeholder_image_url(200, 150, 'Hardware Detail')
),
'gallery' => array(),
'heritage' => create_placeholder_image_url(600, 400, $door_style . ' Heritage Property'),
'customization' => array(
'panels' => create_placeholder_image_url(500, 300, 'Panel Options'),
'glazing' => create_placeholder_image_url(500, 300, 'Glazing Options'),
'hardware' => create_placeholder_image_url(500, 300, 'Hardware Options'),
'finishes' => create_placeholder_image_url(500, 300, 'Finish Options'),
'sizes' => create_placeholder_image_url(500, 300, 'Measuring Guide')
)
);
// Generate gallery images
for ($i = 1; $i <= 8; $i++) {
$template_images['gallery'][] = array(
'url' => create_placeholder_image_url(400, 600, $door_style . ' Door ' . $i),
'alt' => $door_style . ' Door ' . $i,
'title' => $door_style . ' Door Gallery Image ' . $i
);
}
}
if (should_show_section('hero') && !empty($ai_content['hero'])):
50 Year Rot Guarantee on Accoya®
10 Yr Guarantee on Joinery Defect
Accoya Approved Manufacturer
echo esc_html($ai_content['hero']['headline']);
echo esc_html($ai_content['hero']['subheadline']);
echo esc_html($ai_content['hero']['location_reference']);
endif;
if (should_show_section('usp_bar') && !empty($ai_content['usps'])):
echo esc_html($ai_content['usps']['usp_1']);
echo esc_html($ai_content['usps']['usp_2']);
echo esc_html($ai_content['usps']['usp_3']);
echo esc_html($ai_content['usps']['usp_4']);
endif;
if (should_show_section('overview') && !empty($ai_content['overview'])):
Authentic echo esc_html($door_style); Craftsmanship
echo esc_html($ai_content['overview']['style_description']);
Historical Heritage
echo esc_html($ai_content['overview']['historical_context']);
Master Joinery
echo esc_html($ai_content['overview']['craftsmanship_details']);
Premium Materials
echo esc_html($ai_content['overview']['material_highlights']);
View Technical Specifications →
endif;
if (should_show_section('features') && !empty($ai_content['features'])):
foreach ($ai_content['features'] as $feature) {
echo '
';
echo '
';
echo '';
echo '
';
echo '
' . esc_html($feature['title']) . '
';
echo '
' . esc_html($feature['description']) . '
';
echo '
';
}
endif;
if (should_show_section('customization') && !empty($ai_content['customization'])):
- Panel Designs
- Glazing Options
- Door Furniture
- Finishes
- Sizing
Traditional Panel Configurations
echo esc_html($ai_content['customization']['panel_options']);
Period-Appropriate Glazing
echo esc_html($ai_content['customization']['glazing_options']);
Authentic Door Furniture Selection
echo esc_html($ai_content['customization']['hardware_options']);
Professional Finishes
echo esc_html($ai_content['customization']['finish_options']);
Perfect Fit Guarantee
echo esc_html($ai_content['customization']['size_options']);
endif;
if (should_show_section('specifications') && !empty($ai_content['specifications'])):
// Define the specifications to display
$spec_icons = array(
'timber_specs' => 'icon-timber',
'glazing_specs' => 'icon-glazing',
'security_features' => 'icon-security',
'weather_resistance' => 'icon-weather',
'thermal_performance' => 'icon-thermal',
'acoustic_performance' => 'icon-acoustic'
);
$spec_titles = array(
'timber_specs' => 'Timber Specifications',
'glazing_specs' => 'Glazing Performance',
'security_features' => 'Security Features',
'weather_resistance' => 'Weather Resistance',
'thermal_performance' => 'Thermal Performance',
'acoustic_performance' => 'Acoustic Performance'
);
// Loop through and display each specification
foreach ($spec_icons as $spec_key => $icon_key) {
if (isset($ai_content['specifications'][$spec_key])) {
echo '
';
echo '
';
echo '';
echo '
';
echo '
' . $spec_titles[$spec_key] . '
';
echo '
' . esc_html($ai_content['specifications'][$spec_key]) . '
';
echo '
';
}
}
CE Mark
Secured by Design
BSI Kitemark
endif;
if (should_show_section('heritage') && !empty($ai_content['heritage'])):
Approved for Heritage Properties
Conservation Area Compliance
echo esc_html($ai_content['heritage']['compliance']);
Building Regulations
echo esc_html($ai_content['heritage']['building_regs']);
Period Authenticity
echo esc_html($ai_content['heritage']['authenticity']);
Restoration Expertise
echo esc_html($ai_content['heritage']['expertise']);
Trusted by
500+
Listed Buildings
endif;
if (should_show_section('gallery')):
if (!empty($template_images['gallery']) && is_array($template_images['gallery'])):
foreach ($template_images['gallery'] as $index => $image) {
echo '
';
echo '
 . ')
';
echo '
';
echo '
' . esc_html($door_style) . ' Door
';
echo '
Click to view details
';
echo '
';
echo '
';
}
else:
for($i = 1; $i <= 8; $i++):
echo esc_html($door_style); Door echo $i;
echo esc_html($door_style); Door
Click to view details
endfor;
endif;
endif;
if (should_show_section('process') && !empty($ai_content['process'])):
1
Consultation
echo esc_html($ai_content['process']['consultation']);
2
Design
echo esc_html($ai_content['process']['design']);
3
Crafting
echo esc_html($ai_content['process']['crafting']);
4
Finishing
echo esc_html($ai_content['process']['finishing']);
5
Installation
echo esc_html($ai_content['process']['installation']);
endif;
if (should_show_section('testimonials') && !empty($ai_content['testimonials'])):
$index = 1;
foreach ($ai_content['testimonials'] as $testimonial) {
echo '
';
echo '
';
echo '
Customer Review ' . $index . '
'; // NEW HEADING
echo '
"
';
echo '
' . esc_html($testimonial['quote']) . '
';
echo '
';
echo '' . esc_html($testimonial['name']) . '
';
echo '' . esc_html($testimonial['location']) . '';
echo '' . esc_html($testimonial['door_type']) . '';
echo '
';
echo '
';
echo '
';
$index++;
}
endif;
if (should_show_section('pricing') && !empty($ai_content['pricing'])):
Price Range
echo esc_html($ai_content['pricing']['range_text']);
What Affects the Price?
echo esc_html($ai_content['pricing']['factors']);
Finance Options
echo esc_html($ai_content['pricing']['finance_options']);
Example Configurations
if (!empty($ai_content['pricing']['example_configs'])):
foreach ($ai_content['pricing']['example_configs'] as $config) {
echo '
';
echo '
' . esc_html($config['description']) . '
';
echo '
' . esc_html($config['guide_price']) . '
';
echo '
';
}
endif;
endif;
if (should_show_section('faqs') && !empty($ai_content['faqs'])):
foreach ($ai_content['faqs'] as $index => $faq) {
echo '
';
echo '
';
echo '
';
echo '
' . esc_html($faq['answer']) . '
';
echo '
';
echo '
';
}
endif;
if (should_show_section('local_seo') && !empty($ai_content['local_seo'])):
Serving London's Finest Properties
Our Service Areas
echo esc_html($ai_content['local_seo']['service_areas']);
Notable Local Projects
echo esc_html($ai_content['local_seo']['local_projects']);
London's Architectural Heritage
echo esc_html($ai_content['local_seo']['local_heritage']);
Visit Our Showroom
echo esc_html($ai_content['local_seo']['showroom_info']);
Interactive map would be displayed here
endif;
if (should_show_section('final_cta') && !empty($ai_content['final_cta'])):
endif;
echo door_landing_dynamic_css();
if (!wp_is_mobile()):
endif;