unzip_file not working with the remote file

As @Buttered_Toast and @Sébastien Serre mentioned I first need to save file to a local directory before unzipping. So here is my final code: $source=”http://downloads.wordpress.org/theme/ona-creative.1.0.0.zip”; $file = get_theme_root() . “https://wordpress.stackexchange.com/” . $slug . ‘.zip’; file_put_contents( $file, file_get_contents( $source )); $unzipfile = unzip_file( $file, get_theme_root() );

How to include form for WP_Filesystem()?

First, remove that bit up front about calling WP_Filesystem(); by itself. You need to request_filesystem_credentials first, before invoking that. Second, you need to use the $wp_filesystem->wp_themes_dir(‘themename’) function call to get the proper “remote” directory, in order to be able to properly call the put_contents() function with the right filename. The “remote” directory won’t necessarily match … Read more