WordPress / wordpress-importer

The WordPress Importer
https://wordpress.org/plugins/wordpress-importer/
GNU General Public License v2.0
80 stars 81 forks source link

Filter to skip the fetch_remote_file call #103

Open ovidiul opened 3 years ago

ovidiul commented 3 years ago

Looking at this line of code

$upload = $this->fetch_remote_file( $url, $post );

it would be useful to add a filter on top of it and a conditional check to maybe defer the remote upload to a user-defined hook.

In our specific case, we are uploading the files ahead of time, and it would be useful to try not to fetch the data again as we could code the results in that specific hook.


$upload = apply_filters( 'wp_fetch_remote_file', false, $url, $post);

if( false === $upload ) {
  $upload = $this->fetch_remote_file( $url, $post ); 
}