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() );

WP_Filesystem in custom customize control

To cache something you can use the Transients API (thanks @Otto), get_transient() to see if it exists already exists, if not then fetch the data and store it in a transient with set_transient(). if (get_transient(‘mytheme_webfonts’)) { $content = get_transient(‘mytheme_webfonts’); } else{ $googleApi = ‘https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&key={API_KEY}’; $fontContent = wp_remote_get( $googleApi, array(‘sslverify’ => false) ); $content = json_decode($fontContent[‘body’]); … Read more

Why WordPress not using WP_Filesystem

The real need for the WP_Filesystem is to be able to set the correct file owner/group permissions when writing new files. Reading or overwriting existing files does not change these permissions so the WP_Filesystem is not technically needed for that (though you can use it for that too.) The reason is it is a potential … Read more