unzip_file not working with the remote file
I'm trying to use unzip_file to extract the remote archive with no success. It works only with the local path using get_template_directory() but with a remote zip archive URL I'm getting Incompatible Archive. message.
Here is the stripped version of my code:
WP_Filesystem();
global $wp_filesystem;
$source = 'http://downloads.wordpress.org/theme/ona-creative.1.0.0.zip';
$unzipfile = unzip_file( $source, get_theme_root() );
if ( is_wp_error( $unzipfile ) ) {
wp_send_json(
array(
'done' = 1,
'message' = esc_html__( $unzipfile-get_error_message() . ' There was an error unzipping the file.', 'ona' )
)
);
}
Topic wp-filesystem ziparchive Wordpress
Category Web