Skip to content

Commit e4915d2

Browse files
author
Marco Pereirinha
committed
Replace cURL request by WordPress core functionality
1 parent 821a9fa commit e4915d2

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

php/class-media.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,22 +356,16 @@ public function maybe_file_exist_in_url( $url ) {
356356
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
357357
return false;
358358
}
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;
359+
360+
$head = wp_safe_remote_head( $url );
361+
362+
if ( is_wp_error( $head ) ) {
363+
return false;
369364
}
370365

371-
curl_close( $ch );
372-
// phpcs:enable
366+
$code = wp_remote_retrieve_response_code( $head );
373367

374-
return $status;
368+
return 200 === $code;
375369
}
376370

377371
/**

0 commit comments

Comments
 (0)