Skip to content

Instantly share code, notes, and snippets.

@ninnypants
Created March 15, 2013 15:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ninnypants/5170883 to your computer and use it in GitHub Desktop.
Save ninnypants/5170883 to your computer and use it in GitHub Desktop.
Download latest WordPress unzip and add keys
<?php
$fp = fopen('wordpress.zip', 'w');
$ch = curl_init('http://wordpress.org/latest.zip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
exec('unzip wordpress.zip');
exec('cp -R wordpress/* .');
exec('rm wordpress.zip');
exec('rm -rf wordpress');
$ch = curl_init('https://api.wordpress.org/secret-key/1.1/salt/');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$keys = explode("\n", trim($result));
$keys_replace = array(
"define('AUTH_KEY', 'put your unique phrase here');",
"define('SECURE_AUTH_KEY', 'put your unique phrase here');",
"define('LOGGED_IN_KEY', 'put your unique phrase here');",
"define('NONCE_KEY', 'put your unique phrase here');",
"define('AUTH_SALT', 'put your unique phrase here');",
"define('SECURE_AUTH_SALT', 'put your unique phrase here');",
"define('LOGGED_IN_SALT', 'put your unique phrase here');",
"define('NONCE_SALT', 'put your unique phrase here');",
);
unset($result);
$config = file_get_contents('wp-config-sample.php');
$config = str_replace($keys_replace, $keys, $config);
file_put_contents('wp-config.php', $config);
exec('rm wp-config-sample.php');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment