filter_var($host, FILTER_VALIDATE_IP) ? array() : array($target), CURLOPT_PROXY => '', CURLOPT_FRESH_CONNECT => true, CURLOPT_FORBID_REUSE => true, CURLOPT_FOLLOWLOCATION => false))) { throw new RuntimeException('Unable to pin remote connection.'); } }; add_action('http_api_curl', $callback, PHP_INT_MAX, 3); return $callback; } /** Remove the scoped connection pin. */ public static function unpin_request(callable $callback): void { remove_action('http_api_curl', $callback, PHP_INT_MAX); } /** * Heuristic check for whether a URL looks like it points at a * downloadable file, even without a recognized file extension. * * @since 1.6.0 * @param string $url URL to check. * @return bool */ public static function looks_like_file_url(string $url): bool { static $file_indicators = array( '/download', '/file', '/attachment', '/media', '/uploads', 'wp-content', '.php?', 'download=', 'file=', 'attachment=', '/api/', '/archive', 'cdn.', // phpcs:ignore PluginCheck.CodeAnalysis.Offloading.OffloadedContent -- Substring detection for user-authored download URLs; no plugin assets are hosted here. 'amazonaws.com', // phpcs:ignore PluginCheck.CodeAnalysis.Offloading.OffloadedContent -- Substring detection for user-authored download URLs; no plugin assets are hosted here. 'googleusercontent.com', 'dropbox.com', 'drive.google.com', '.zip', '.rar', '.tar', '.gz', 'export', 'backup', ); $url_lower = strtolower($url); foreach ($file_indicators as $indicator) { if (strpos($url_lower, $indicator) !== false) { return true; } } return false; } }