← Back
Editing: index.php
<?php /** * OQILA Optimized WordPress Entry Point * Architecture: Solopreneur Lean-Efficiency Model * * Features: * - File-based Debug Toggle * - Google Ads (GCLID) Auto-attribution * - Google SEO (Organic) Auto-attribution * - PSR-compliant Security Filtering */ /** * Tells WordPress to load the WordPress theme and output it. */ define('WP_USE_THEMES', true); /** * 1. OQILA WP DEBUG MODE * Toggle via presence of a /DEBUG file in the root directory. */ if (file_exists(__DIR__ . '/DEBUG')) { ini_set('display_errors', '1'); error_reporting(E_ALL); define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', true); } /** * 2. OQILA UTM & ATTRIBUTION TRACKING * Maps traffic sources to session variables for CRM/Lead integration. */ if (session_status() === PHP_SESSION_NONE) { session_start(); } // Only track on the first entry of the session to preserve "First-Touch" attribution if (!isset($_SESSION['oqila_tracked'])) { $referer = $_SERVER['HTTP_REFERER'] ?? ''; $ref_host = $referer ? parse_url($referer, PHP_URL_HOST) : ''; $current_host = $_SERVER['HTTP_HOST'] ?? ''; $is_google = (strpos($ref_host, 'google.') !== false); // --- Attribution Logic --- // Case A: Google Ads (Auto-tagged via GCLID) if (isset($_GET['gclid'])) { $_SESSION['oqila_utm_source'] = 'google'; $_SESSION['oqila_utm_medium'] = 'adwords'; } // Case B: Google Organic (SEO) elseif ($is_google) { $_SESSION['oqila_utm_source'] = 'google'; $_SESSION['oqila_utm_medium'] = 'SEO'; } // Case C: External Referrer (Non-Google) elseif ($ref_host && $ref_host !== $current_host) { $_SESSION['oqila_referrer'] = htmlspecialchars($ref_host, ENT_QUOTES, 'UTF-8'); } // Case D: Manual UTM Overrides (Manual campaigns take priority) $utm_params = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term']; foreach ($utm_params as $param) { if (!empty($_GET[$param])) { // Using htmlspecialchars instead of deprecated FILTER_SANITIZE_STRING $_SESSION['oqila_' . $param] = htmlspecialchars($_GET[$param], ENT_QUOTES, 'UTF-8'); } } // Mark as tracked with timestamp for data integrity $_SESSION['oqila_tracked'] = time(); } /** * 3. EXECUTION * Loads the WordPress Environment and Template */ require __DIR__ . '/wp-blog-header.php';
Save File
Cancel