diff --git a/source/changelog.txt b/source/changelog.txt index 76fd494..97bd523 100644 --- a/source/changelog.txt +++ b/source/changelog.txt @@ -5,6 +5,7 @@ - Add settings link to plugin on plugins page - Add donation link to plugin on plugins page #### Changed +- Use wp_remote_get() instead of cURL functions for downloading the images #### Deprecated #### Removed #### Fixed diff --git a/source/includes/GraphQlClient.php b/source/includes/GraphQlClient.php index fb687e3..a6651e1 100644 --- a/source/includes/GraphQlClient.php +++ b/source/includes/GraphQlClient.php @@ -145,26 +145,8 @@ final class GraphQlClient { } private static function download_image($url) { - // Initialize curl handle - $ch = curl_init($url); - - // Set curl options - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Set timeout to 60 seconds (adjust as needed) - - // Execute the request - $image_data = curl_exec($ch); - - // Check for errors - if (curl_errno($ch)) { - print_r(curl_error($ch)); - throw new \Error('Error: ' . curl_error($ch)); - } - - // Close curl handle - curl_close($ch); - + $response = wp_remote_get($url); + $image_data = $response['body']; return $image_data; } }