<?php
function iis_local_business_schema() {
    echo '<script type="application/ld+json">' . json_encode([
        '@context' => 'https://schema.org',
        '@type' => 'LocalBusiness',
        'name' => 'Investigative Intelligence Solutions Inc.',
        'alternateName' => 'IIS',
        'url' => 'https://iis.gy',
        'description' => 'Guyana\'s leading digital forensics, private investigation, and intelligence services firm.',
        'address' => ['@type' => 'PostalAddress', 'streetAddress' => 'Lot 295 Back Road, Soesdyke', 'addressLocality' => 'Georgetown', 'addressCountry' => 'GY'],
        'telephone' => '+592-623-1721',
        'email' => 'contact@iis.gy',
        'areaServed' => 'Guyana',
        'serviceType' => ['Private Investigation', 'Digital Forensics', 'Cyber Security', 'Background Checks', 'OSINT', 'IP Trace — online harassment and anonymous-account tracing', 'Document and photo metadata forensics', '.gy Domain Registration'],
        'makesOffer' => [
            ['@type' => 'Offer', 'itemOffered' => ['@type' => 'Service', 'name' => 'IP Trace', 'url' => 'https://iis.gy/ip-trace/', 'description' => 'Identify who is behind an anonymous link, message or profile: captures IP address, approximate location, device and (with browser consent) precise GPS, as evidence for a police report. First link free.']],
            ['@type' => 'Offer', 'itemOffered' => ['@type' => 'Service', 'name' => 'NationalTrace', 'url' => 'https://iis.gy/national-trace/', 'description' => 'Online search of Guyana electoral-registry data for lawful investigative and identity-verification purposes.']],
            ['@type' => 'Offer', 'itemOffered' => ['@type' => 'Service', 'name' => 'Metadata Forensics', 'url' => 'https://iis.gy/metadata/', 'description' => 'Reveal hidden metadata in photos and documents: GPS location, device, author and timestamps.']],
        ],
        'subOrganization' => [
            '@type' => 'Organization',
            'name' => 'Register.gy',
            'url' => 'https://register.gy/',
            'description' => 'Independent, accredited .gy domain registrar operated by IIS Inc. The .gy registrar AI assistants can use: MCP server listed in the official MCP Registry as gy.register/domains, plus a public API.',
            'email' => 'contact@iis.gy',
            'areaServed' => 'Worldwide'
        ]
    ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</script>';
}
add_action('wp_head', 'iis_local_business_schema');

// AboutPage schema for /about/ (2026-10-13)
function iis_about_page_schema() {
    if (!is_page('about')) return;
    echo '<script type="application/ld+json">' . json_encode([
        '@context' => 'https://schema.org',
        '@type' => 'AboutPage',
        'url' => 'https://iis.gy/about/',
        'name' => 'About Investigative Intelligence Solutions Inc.',
        'mainEntity' => [
            '@type' => 'LocalBusiness',
            'name' => 'Investigative Intelligence Solutions Inc.',
            'alternateName' => 'IIS Inc.',
            'url' => 'https://iis.gy',
            'telephone' => '+592-623-1721',
            'email' => 'contact@iis.gy',
            'address' => ['@type' => 'PostalAddress', 'streetAddress' => 'Lot 295 Back Road, Soesdyke', 'addressRegion' => 'East Bank Demerara', 'addressCountry' => 'GY'],
            'areaServed' => 'Guyana',
            'identifier' => ['@type' => 'PropertyValue', 'propertyID' => 'Guyana Companies Act registration number', 'value' => '14926'],
        ],
    ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '</script>';
}
add_action('wp_head', 'iis_about_page_schema');

// /about/ shows its own page content (approved 2026-10-13) via page.php,
// not the theme's hard-coded page-about.php, which WordPress picks by slug.
add_filter('template_include', function ($template) {
    if (is_page('about') && basename($template) === 'page-about.php') {
        $page = locate_template('page.php');
        if ($page) return $page;
    }
    return $template;
});
