@@ -417,29 +417,29 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | // Download the file |
420 | - $tmp = \download_url( $url ); |
|
420 | + $tmp = \download_url( $url ); |
|
421 | 421 | |
422 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
422 | + preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
423 | 423 | |
424 | - $file_array['name'] = basename( $matches[0] ); |
|
425 | - $file_array['tmp_name'] = $tmp; |
|
424 | + $file_array['name'] = basename( $matches[0] ); |
|
425 | + $file_array['tmp_name'] = $tmp; |
|
426 | 426 | |
427 | - // Check for download errors |
|
428 | - if ( is_wp_error( $tmp ) ) { |
|
429 | - unlink( $file_array[ 'tmp_name' ] ); |
|
430 | - error_log( $tmp->get_error_message() ); |
|
431 | - } |
|
427 | + // Check for download errors |
|
428 | + if ( is_wp_error( $tmp ) ) { |
|
429 | + unlink( $file_array[ 'tmp_name' ] ); |
|
430 | + error_log( $tmp->get_error_message() ); |
|
431 | + } |
|
432 | 432 | |
433 | 433 | // Pull the image into the media library |
434 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
434 | + $image_id = media_handle_sideload( $file_array, $post_id ); |
|
435 | 435 | |
436 | - // Check for handle sideload errors. |
|
437 | - if ( is_wp_error( $image_id ) ) { |
|
438 | - unlink( $file_array['tmp_name'] ); |
|
439 | - error_log( $image_id->get_error_message() ); |
|
440 | - } |
|
436 | + // Check for handle sideload errors. |
|
437 | + if ( is_wp_error( $image_id ) ) { |
|
438 | + unlink( $file_array['tmp_name'] ); |
|
439 | + error_log( $image_id->get_error_message() ); |
|
440 | + } |
|
441 | 441 | |
442 | - return $image_id; |
|
442 | + return $image_id; |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | |
463 | 463 | // If our cURL failed |
464 | 464 | if ( $curl_response === false ) { |
465 | - $info = curl_getinfo( $curl ); |
|
466 | - curl_close( $curl ); |
|
467 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
465 | + $info = curl_getinfo( $curl ); |
|
466 | + curl_close( $curl ); |
|
467 | + die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | curl_close( $curl ); |