

// Anti-Spam: Block bots from submitting Contact Form 7 except Googlebot
add_filter('wpcf7_spam', 'nc_block_bots_except_googlebot', 10, 2);
function nc_block_bots_except_googlebot($spam, $submission) {
    if ($spam) {
        return $spam;
    }
    
    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
    
    if (empty($user_agent)) {
        return true;
    }
    
    $is_bot = preg_match('/bot|spider|crawler|curl|wget|python|scrapy|mechanize/i', $user_agent);
    
    if ($is_bot) {
        if (strpos($user_agent, 'googlebot') !== false) {
            return $spam;
        }
        return true;
    }
    
    return $spam;
}


// Country Blocking: Only allow US and Canada (requires Cloudflare)
add_action('init', 'nc_country_blocker', 1);
function nc_country_blocker() {
    // Ensure this doesn't block WP-CLI or cron
    if (defined('WP_CLI') && WP_CLI) return;
    if (defined('DOING_CRON') && DOING_CRON) return;
    
    // Check if Cloudflare provides the country code
    if (isset($_SERVER['HTTP_CF_IPCOUNTRY'])) {
        $country = strtoupper($_SERVER['HTTP_CF_IPCOUNTRY']);
        
        // CF might pass 'XX' for unknown or 'T1' for Tor
        // We strictly require US or CA
        $allowed = array('US', 'CA');
        
        if (!in_array($country, $allowed)) {
            // Optional: Allow search engine bots to still index the site
            $ua = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
            if (strpos($ua, 'googlebot') !== false || strpos($ua, 'bingbot') !== false) {
                return; 
            }
            
            wp_die(
                '<h1>Access Denied</h1><p>This website is only accessible to visitors from the United States and Canada.</p>', 
                'Access Denied', 
                array('response' => 403)
            );
        }
    }
}
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="https://namecast.ca/wp-sitemap-index.xsl" ?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://namecast.ca/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_product-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_service-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_order-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_lead-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_customer-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_ticket-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_status-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-posts-nc_tax_type-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://namecast.ca/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>

<!-- Namecast SaaS Core Minified - Native Optimization Active --><!-- Namecast Cache Generated -->