Plugin Directory

Changeset 695896


Ignore:
Timestamp:
04/11/2013 11:48:05 AM (13 years ago)
Author:
byrev
Message:
  • update wp-upload-image.php
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pixabay-images/trunk/wp-upload-image.php

    r695891 r695896  
    2020
    2121    // upload image file
    22     if (ini_get('allow_url_fopen')) {
    23         $data = file_get_contents($source_url);
    24     } elseif (function_exists('curl_init')) {
    25         $ch = curl_init();
    26         curl_setopt($ch, CURLOPT_URL, $source_url);
    27         curl_setopt($ch, CURLOPT_HEADER, 0);
    28         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    29         $data = curl_exec($ch);
    30         curl_close($ch);
    31     } else {
    32         die(json_response(0, "This plugin requires the cURL module or the 'allow_url_fopen' option enabled. Please check your php.ini."));
    33     }
     22    $response = wp_remote_get( $source_url );
     23    if( is_wp_error( $response ) ) {
     24       $error_message = $response->get_error_message();
     25       die(json_response(0, "Something went wrong: ". $error_message));
     26    }
     27    $data = $response['body'];
    3428
    3529    $path_parts = pathinfo($source_url);
Note: See TracChangeset for help on using the changeset viewer.