-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-config.php
More file actions
141 lines (115 loc) · 4.1 KB
/
wp-config.php
File metadata and controls
141 lines (115 loc) · 4.1 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
<?php
/**
* Support HTTPS behind proxies
*/
if( isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) && $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] == 'https' ) {
$_SERVER[ 'HTTPS' ] = 'on';
}
/**
* Composer Vendor Autoload
*/
require_once dirname( __FILE__ ) . '/wp-content/vendor/autoload.php';
/**
* Load Environment Configuration
*/
try {
$dotenv = new Dotenv\Dotenv( __DIR__ );
$dotenv->load();
$dotenv->required( array( 'WP_HOME', 'WP_DIR' ) );
$dotenv->required( array( 'DB_NAME', 'DB_USER', 'DB_PASSWORD' ) );
$dotenv->required( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) );
} catch( Exception $e ) {
// if loading the .env file fails, add special handling here
}
/**
* Load RDS environment configs if we are hosted on RDS and the data is already available.
*/
if( empty( getenv( 'DB_HOST' ) ) && ! empty( getenv( 'RDS_HOSTNAME' ) ) ) {
putenv( 'DB_HOST=' . getenv( 'RDS_HOSTNAME' ) );
}
if( empty( getenv( 'DB_NAME' ) ) && ! empty( getenv( 'RDS_DB_NAME' ) ) ) {
putenv( 'DB_NAME=' . getenv( 'RDS_DB_NAME' ) );
}
if( empty( getenv( 'DB_USER' ) ) && ! empty( getenv( 'RDS_USERNAME' ) ) ) {
putenv( 'DB_USER=' . getenv( 'RDS_USERNAME' ) );
}
if( empty( getenv( 'DB_PASSWORD' ) ) && ! empty( getenv( 'RDS_PASSWORD' ) ) ) {
putenv( 'DB_PASSWORD=' . getenv( 'RDS_PASSWORD' ) );
}
/**
* Site Configs
*/
define( 'WP_HOME', getenv( 'WP_HOME' ) );
define( 'WP_SITEURL', getenv( 'WP_HOME' ) . '/' . getenv( 'WP_DIR' ) );
define( 'WP_CONTENT_URL', getenv( 'WP_HOME' ) . '/wp-content' );
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );
/**
* MySQL
*/
define('DB_NAME', getenv( 'DB_NAME' ) );
define('DB_USER', getenv( 'DB_USER' ) );
define('DB_PASSWORD', getenv( 'DB_PASSWORD' ) );
define('DB_COLLATE', getenv( 'DB_COLLATE' ) );
define('DB_HOST', ! empty( getenv( 'DB_HOST' ) ) ? getenv( 'DB_HOST' ) : 'localhost' );
define('DB_CHARSET', ! empty( getenv( 'DB_CHARSET' ) ) ? getenv( 'DB_CHARSET' ) : 'utf8' );
$table_prefix = ! empty( getenv( 'DB_TABLE_PREFIX' ) ) ? getenv( 'DB_TABLE_PREFIX' ) : 'wp_';
/**
* Authentication Keys and Salts
*/
define('AUTH_KEY', getenv( 'AUTH_KEY' ) );
define('SECURE_AUTH_KEY', getenv( 'SECURE_AUTH_KEY' ) );
define('LOGGED_IN_KEY', getenv( 'LOGGED_IN_KEY' ) );
define('NONCE_KEY', getenv( 'NONCE_KEY' ) );
define('AUTH_SALT', getenv( 'AUTH_SALT' ) );
define('SECURE_AUTH_SALT', getenv( 'SECURE_AUTH_SALT' ) );
define('LOGGED_IN_SALT', getenv( 'LOGGED_IN_SALT' ) );
define('NONCE_SALT', getenv( 'NONCE_SALT' ) );
/**
* Developer Flags
*/
define( 'WP_DEBUG', filter_var( getenv('WP_DEBUG'), FILTER_VALIDATE_BOOLEAN ) );
define( 'WP_DEBUG_DISPLAY', filter_var( getenv('WP_DEBUG_DISPLAY'), FILTER_VALIDATE_BOOLEAN ) );
define( 'WP_DEBUG_LOG', filter_var( getenv('WP_DEBUG_LOG'), FILTER_VALIDATE_BOOLEAN ) );
define( 'DISALLOW_FILE_EDIT', true ); // If you are using this as a base, you should know better.
/**
* Constants to define only if defined from our environment
*/
foreach( array(
/**
* Redis
*/
'WP_REDIS_DISABLED',
'WP_REDIS_CLIENT',
'WP_REDIS_SCHEME',
'WP_REDIS_HOST',
'WP_REDIS_PORT',
'WP_REDIS_PATH',
'WP_REDIS_DATABASE',
'WP_REDIS_SERVERS',
'WP_REDIS_CLUSTER',
'WP_REDIS_MAXTTL',
'WP_REDIS_GLOBAL_GROUPS',
'WP_REDIS_IGNORED_GROUPS',
'WP_CACHE_KEY_SALT',
/**
* S3 Uploads
*/
'S3_UPLOADS_BUCKET',
'S3_UPLOADS_KEY',
'S3_UPLOADS_SECRET',
'S3_UPLOADS_REGION',
'S3_UPLOADS_HTTP_CACHE_CONTROL',
'S3_UPLOADS_HTTP_EXPIRES',
) as $config ) {
if( ! empty( getenv( $config ) ) ) {
define( $config, getenv( $config ) );
}
}
/**
* WordPress Setup
*/
if ( ! defined('ABSPATH') ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';