Skip to content

Commit

Permalink
->
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Jan 26, 2025
1 parent 73ad0e9 commit f6c24d0
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function wpcom_handle_media_url_upload() {

$url = esc_url_raw( wp_unslash( $_POST['url'] ) );

$tmp = download_url( $url );
if ( is_wp_error( $tmp ) ) {
return wp_send_json_error( $tmp );
$tmp_file = download_url( $url );
if ( is_wp_error( $tmp_file ) ) {
return wp_send_json_error( $tmp_file );
}

if ( is_multisite() ) {
Expand All @@ -57,12 +57,12 @@ function wpcom_handle_media_url_upload() {
$attachment_id = media_handle_sideload(
array(
'name' => basename( wp_parse_url( $url, PHP_URL_PATH ) ),
'tmp_name' => $tmp,
'tmp_name' => $tmp_file,
)
);

if ( file_exists( $tmp ) ) {
wp_delete_file( $tmp );
if ( file_exists( $tmp_file ) ) {
wp_delete_file( $tmp_file );
}

if ( is_wp_error( $attachment_id ) ) {
Expand Down

0 comments on commit f6c24d0

Please sign in to comment.