forked from roots/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-config.php
More file actions
238 lines (207 loc) · 6.99 KB
/
wp-config.php
File metadata and controls
238 lines (207 loc) · 6.99 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* Do not edit this file. Edit the config files found in the config/ dir instead.
* This file is required in the root directory so WordPress can find it.
* WP is hardcoded to look in its own directory or one directory up for wp-config.php.
*
* @see https://developer.wordpress.org/apis/wp-config-php/
*/
require_once __DIR__ . '/vendor/autoload.php';
use function Env\env;
use Roots\WPConfig\Config;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
/**
* Allow WordPress to detect HTTPS when used behind a reverse proxy or a load balancer
*
* @see https://codex.wordpress.org/Function_Reference/is_ssl#Notes
*/
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
/**
* Directory containing all of the site's files
*
* @var string
*/
$root_dir = __DIR__;
/**
* Document Root
*
* @var string
*/
$webroot_dir = $root_dir . '/public';
/**
* Use Dotenv to set required environment variables and load .env file in root
* .env.local will override .env if it exists
*/
if (file_exists($root_dir . '/.env.local.php') || file_exists($root_dir . '/.env')) {
$dotenv = new Dotenv('WP_ENV', 'WP_DEBUG');
$dotenv->setProdEnvs(['production']);
$dotenv->usePutenv();
$dotenv->bootEnv($root_dir . '/.env', 'production');
if (!file_exists($root_dir . '/.env.local.php')) {
$secrets = $root_dir . '/config/secrets/' . env('WP_ENV');
if (is_file($secrets)) {
$dotenv->load($secrets);
}
}
}
/**
* Set up our global environment constant and load its config first
*/
define('WP_ENV', env('WP_ENV') ?: 'production');
/**
* Infer WP_ENVIRONMENT_TYPE based on WP_ENV
*
* @see https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type
*/
if (env('WP_ENVIRONMENT_TYPE')) {
define('WP_ENVIRONMENT_TYPE', env('WP_ENVIRONMENT_TYPE'));
} else {
if (in_array(WP_ENV, ['production', 'staging', 'development', 'local'])) {
define('WP_ENVIRONMENT_TYPE', WP_ENV);
} else {
define('WP_ENVIRONMENT_TYPE', 'production');
}
}
/**
* Debugging Settings
*
* @see https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
Config::define('WP_DEBUG', env('WP_DEBUG') ?: false);
Config::define('WP_DEBUG_DISPLAY', false);
Config::define('SCRIPT_DEBUG', false);
ini_set('display_errors', '0');
/**
* URLs
*
* @see https://developer.wordpress.org/apis/wp-config-php/#wp-siteurl
*/
Config::define('WP_HOME', env('WP_HOME'));
Config::define('WP_SITEURL', env('WP_SITEURL') ?? Config::get('WP_HOME'));
/**
* DB settings
*
* @see https://developer.wordpress.org/apis/wp-config-php/#configure-database-settings
*/
if (env('DB_SSL')) {
Config::define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
}
Config::define('DB_NAME', env('DB_NAME'));
Config::define('DB_USER', env('DB_USER'));
Config::define('DB_PASSWORD', env('DB_PASSWORD'));
Config::define('DB_HOST', env('DB_HOST') ?: 'localhost');
Config::define('DB_CHARSET', 'utf8mb4');
Config::define('DB_COLLATE', '');
$table_prefix = env('DB_PREFIX') ?: 'wp_';
if (env('DATABASE_URL')) {
$dsn = (object) parse_url(env('DATABASE_URL'));
Config::define('DB_NAME', substr($dsn->path, 1));
Config::define('DB_USER', $dsn->user);
Config::define('DB_PASSWORD', isset($dsn->pass) ? $dsn->pass : null);
Config::define('DB_HOST', isset($dsn->port) ? "{$dsn->host}:{$dsn->port}" : $dsn->host);
}
/**
* Authentication Unique Keys and Salts
*
* @see https://developer.wordpress.org/apis/wp-config-php/#security-keys
*
* Generate your keys here: https://roots.io/salts.html
* or run:
*
* php tools/random.php salt
*/
Config::define('AUTH_KEY', env('AUTH_KEY'));
Config::define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY'));
Config::define('LOGGED_IN_KEY', env('LOGGED_IN_KEY'));
Config::define('NONCE_KEY', env('NONCE_KEY'));
Config::define('AUTH_SALT', env('AUTH_SALT'));
Config::define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT'));
Config::define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
Config::define('NONCE_SALT', env('NONCE_SALT'));
/**
* Logging Settings
*
* @see https://developer.wordpress.org/apis/wp-config-php/#configure-error-logging
*/
$log_dir = $root_dir . '/var/log';
// It is possible to use PHP streams e.g. 'php://stderr', 'php://stdout'
Config::define('LOG_STREAM', env('LOG_STREAM') ?? sprintf('%s/%s.log', $log_dir, WP_ENV));
Config::define('WP_DEBUG_LOG', env('WP_DEBUG_LOG') ?? sprintf('%s/wordress_%s.log', $log_dir, WP_ENV));
// WooCommerce
Config::define('WC_LOG_DIR', $log_dir . '/');
/**
* Custom Settings
*/
Config::define('AUTOMATIC_UPDATER_DISABLED', true);
Config::define('DISABLE_WP_CRON', true);
// Disable the plugin and theme file editor in the admin
Config::define('DISALLOW_FILE_EDIT', true);
// Disable plugin and theme updates and installation from the admin
Config::define('DISALLOW_FILE_MODS', true);
// Limit the number of post revisions that Wordpress stores (true (default WP): store every revision)
Config::define('WP_POST_REVISIONS', env('WP_POST_REVISIONS') ?? 5);
Config::define('FS_METHOD', 'direct');
Config::define('WP_CACHE', true);
Config::define('WP_DEFAULT_THEME', 'app');
Config::define('WPLANG', env('WPLANG') ?? 'en_US');
// https://github.com/roots/soil#modules
Config::define('SOIL', [
'clean-up',
'disable-asset-versioning',
'disable-trackbacks',
'nice-search',
'relative-urls',
]);
// https://github.com/globalis-ms/wp-unhooked
Config::define('WP_UNHOOKED_CONFIG', [
'disable-comments' => true,
'disable-admin-dashboard-welcome-panel' => true,
'disable-admin-dashboard-widget-primary' => true,
]);
if ('development' === WP_ENVIRONMENT_TYPE) {
Config::define('SAVEQUERIES', true);
Config::define('WP_DEBUG_DISPLAY', true);
Config::define('WP_DISABLE_FATAL_ERROR_HANDLER', true);
Config::define('SCRIPT_DEBUG', true);
Config::define('DISALLOW_INDEXING', true);
Config::define('DISABLE_WP_CRON', false);
Config::define('WP_CACHE', false);
ini_set('display_errors', '1');
// Enable plugin and theme updates and installation from the admin
Config::define('DISALLOW_FILE_MODS', false);
}
if ('staging' === WP_ENVIRONMENT_TYPE) {
/**
* You should try to keep staging as close to production as possible. However,
* should you need to, you can always override production configuration values
* with `Config::define`.
*/
Config::define('DISALLOW_INDEXING', true);
}
if ('production' === WP_ENVIRONMENT_TYPE) {
Config::define('LOG_STREAM', env('LOG_STREAM') ?? 'php://stderr');
}
require_once $root_dir . '/config/application.php';
Config::apply();
/**
* Bootstrap Symfony ErrorHandler
*
* @see https://github.com/symfony/error-handler
*/
if (class_exists(Debug::class)
&& defined('WP_DEBUG') && WP_DEBUG
&& defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY
) {
define('QM_DISABLE_ERROR_HANDLER', true);
Debug::enable();
}
/**
* Bootstrap WordPress
*/
if (!defined('ABSPATH')) {
define('ABSPATH', $webroot_dir);
}
require_once ABSPATH . 'wp-settings.php';