-
Notifications
You must be signed in to change notification settings - Fork 7
/
wpsalts
69 lines (61 loc) · 1.83 KB
/
wpsalts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env php
<?php
/**
* PHP CLI Excutable file. Outputs the required WordPress keys and salts in
* either the traditional WordPress define format or the Composer driven
* DotEnv format.
*
* When loaded via composer this file can be executed in CLI as follows:
* vendor/bin/wpsalts
*
* @author Rob Waller <[email protected]>
*/
/**
* Load the correct autoloader dependent on how this file is being executed.
*/
$paths = [
__DIR__.'/vendor/autoload.php',
__DIR__.'/../../autoload.php'
];
foreach ($paths as $path) {
if (file_exists($path)) {
require_once $path;
break;
}
}
/**
* Load the WordPress salts class
*/
$salts = new WPSalts\Salts;
/**
* Return the WordPress salts in a DotEnv format for use in .env files.
*/
if (isset($argv[1]) && $argv[1] === 'dotenv') {
if (isset($argv[2]) && $argv[2] === '--clean') {
echo $salts->dotEnv();
die();
}
echo "\33[33mCopy and paste these keys and salts into your \33[32m.env\33[33m file.\33[0m" . PHP_EOL . PHP_EOL;
echo "\33[32m" . $salts->dotEnv() . "\33[0m";
die();
}
/**
* Return the WordPress salts in the traditional WordPress define format for
* use in wp-config.php files.
*/
if (isset($argv[1]) && $argv[1] === 'traditional') {
if (isset($argv[2]) && $argv[2] === '--clean') {
echo $salts->traditional();
die();
}
echo "\33[33mCopy and paste these keys and salts into your \33[32mwp-config.php\33[33m file.\33[0m" . PHP_EOL . PHP_EOL;
echo "\33[32m" . $salts->traditional() . "\33[0m";
die();
}
/**
* By default this script will return the WordPress salts in the traditioanl
* define format.
*/
echo "\33[33mCopy and paste these keys and salts into your \33[32mwp-config.php\33[33m file.\33[0m" . PHP_EOL . PHP_EOL;
echo "\33[32m" . $salts->traditional() . "\33[0m";
die();