tags into . * * Download: wget -O glorics-ld.php https://sdk.glorics.com/glorics-ld.php.txt * * Drop on the origin, then in the page (before ): * * * * WordPress (header.php or a small must-use plugin): * * add_action('wp_head', function () { * $glorics_site_key = 'sk_YOUR_KEY'; * include WP_CONTENT_DIR . '/glorics-ld.php'; * }, 1); * * Fail-open: network errors print nothing. Cached 60s in sys_get_temp_dir(). */ if (!isset($glorics_site_key) || !is_string($glorics_site_key) || $glorics_site_key === '') { $glorics_site_key = getenv('GLORICS_SITE_KEY') ?: ''; } if ($glorics_site_key === '') { return; } $path = isset($glorics_path) && is_string($glorics_path) && $glorics_path !== '' ? $glorics_path : (parse_url(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/', PHP_URL_PATH) ?: '/'); $cache_file = rtrim(sys_get_temp_dir(), '/') . '/glorics-ld-' . md5($glorics_site_key . '|' . $path) . '.html'; if (is_file($cache_file) && (time() - filemtime($cache_file)) < 60) { $cached = @file_get_contents($cache_file); if (is_string($cached) && $cached !== '') { echo $cached; return; } } $url = 'https://engine.glorics.com/sdk/ld.html?key=' . rawurlencode($glorics_site_key) . '&path=' . rawurlencode($path); $html = false; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 2, CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTPHEADER => ['Accept: text/html'], ]); $html = curl_exec($ch); $code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code !== 200) { $html = false; } } else { $ctx = stream_context_create([ 'http' => ['timeout' => 2, 'ignore_errors' => true, 'header' => "Accept: text/html\r\n"], 'ssl' => ['verify_peer' => true, 'verify_peer_name' => true], ]); $html = @file_get_contents($url, false, $ctx); } if (!is_string($html) || $html === '') { return; } @file_put_contents($cache_file, $html, LOCK_EX); echo $html;