We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 821a9fa commit e4915d2Copy full SHA for e4915d2
1 file changed
php/class-media.php
@@ -356,22 +356,16 @@ public function maybe_file_exist_in_url( $url ) {
356
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
357
return false;
358
}
359
- // phpcs:disable WordPress.WP.AlternativeFunctions
360
- $ch = curl_init( $url );
361
- curl_setopt( $ch, CURLOPT_NOBODY, true );
362
- curl_exec( $ch );
363
- $code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
364
-
365
- if ( 200 === $code ) {
366
- $status = true;
367
- } else {
368
- $status = false;
+
+ $head = wp_safe_remote_head( $url );
+ if ( is_wp_error( $head ) ) {
+ return false;
369
370
371
- curl_close( $ch );
372
- // phpcs:enable
+ $code = wp_remote_retrieve_response_code( $head );
373
374
- return $status;
+ return 200 === $code;
375
376
377
/**
0 commit comments