Skip to content

Instantly share code, notes, and snippets.

@ruslanas
Last active August 29, 2015 14:14
Show Gist options
  • Save ruslanas/4b8954dd5924bea2af32 to your computer and use it in GitHub Desktop.
Save ruslanas/4b8954dd5924bea2af32 to your computer and use it in GitHub Desktop.
<?php
/**
* Downloads latest WordPress and extracts it to script folder
* @author Ruslanas Balčiūnas
*/
/* DELETE AFTER USAGE */
$fname = 'latest.tar.gz';
file_put_contents($fname, fopen('http://wordpress.org/latest.tar.gz', 'r'));
// remove old version
if(file_exists('latest.tar')) {
unlink('latest.tar');
}
$p = new PharData($fname);
try {
$p->decompress();
} catch (Exception $e) {
die($e->getMessage());
}
try {
$phar = new PharData('latest.tar');
$phar->extractTo('./', null, true); // extract wordpress directory (overwrite)
} catch (Exception $e) {
$e->getMessage();
}
unlink('latest.tar');
unlink($fname);
echo 'Done!';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment