fetch_remote_file() public method

Attempt to download a remote file attachment
public fetch_remote_file ( string $url, array $post ) : array | WP_Error
$url string URL of item to fetch
$post array Attachment details
return array | WP_Error Local file location details on success, WP_Error otherwise
 /**
  * Use local images instead of remote images
  * 
  * @see WP_Import::fetch_remote_file()
  */
 public function fetch_remote_file($url, $post)
 {
     // only use if demo-data is present in the url
     if (!strstr($url, '/demo-data/')) {
         return parent::fetch_remote_file($url, $post);
     }
     // extract the file name and extension from the url
     $file_name = basename($url);
     // get placeholder file in the upload dir with a unique, sanitized filename
     $upload = wp_upload_bits($file_name, 0, '', $post['upload_date']);
     if ($upload['error']) {
         return new WP_Error('upload_dir_error', $upload['error']);
     }
     // use the local image and write it to the placeholder file
     $local_file = WP_CONTENT_DIR . '/' . substr($url, strrpos($url, '/themes/'));
     file_put_contents($upload['file'], file_get_contents($local_file));
     $filesize = filesize($upload['file']);
     if (0 == $filesize) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', __('Zero size file downloaded', 'wordpress-importer'));
     }
     $max_size = (int) $this->max_attachment_size();
     if (!empty($max_size) && $filesize > $max_size) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', 'wordpress-importer'), size_format($max_size)));
     }
     // keep track of the old and new urls so we can substitute them later
     $this->url_remap[$url] = $upload['url'];
     $this->url_remap[$post['guid']] = $upload['url'];
     // r13735, really needed?
     return $upload;
 }