|
1 <?php |
|
2 /** |
|
3 * Your base production configuration goes in this file. Environment-specific |
|
4 * overrides go in their respective config/environments/{{WP_ENV}}.php file. |
|
5 * |
|
6 * A good default policy is to deviate from the production config as little as |
|
7 * possible. Try to define as much of your configuration in this file as you |
|
8 * can. |
|
9 */ |
|
10 |
|
11 use Roots\WPConfig\Config; |
|
12 |
|
13 /** @var string Directory containing all of the site's files */ |
|
14 $root_dir = dirname(__DIR__); |
|
15 |
|
16 /** @var string Document Root */ |
|
17 $webroot_dir = $root_dir . '/web'; |
|
18 |
|
19 /** |
|
20 * Expose global env() function from oscarotero/env |
|
21 */ |
|
22 Env::init(); |
|
23 |
|
24 /** |
|
25 * Use Dotenv to set required environment variables and load .env file in root |
|
26 */ |
|
27 $dotenv = Dotenv\Dotenv::create($root_dir); |
|
28 if (file_exists($root_dir . '/.env')) { |
|
29 $dotenv->load(); |
|
30 $dotenv->required(['WP_HOME', 'WP_SITEURL']); |
|
31 if (!env('DATABASE_URL')) { |
|
32 $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']); |
|
33 } |
|
34 } |
|
35 |
|
36 /** |
|
37 * Set up our global environment constant and load its config first |
|
38 * Default: production |
|
39 */ |
|
40 define('WP_ENV', env('WP_ENV') ?: 'production'); |
|
41 |
|
42 /** |
|
43 * URLs |
|
44 */ |
|
45 Config::define('WP_HOME', env('WP_HOME')); |
|
46 Config::define('WP_SITEURL', env('WP_SITEURL')); |
|
47 |
|
48 /** |
|
49 * Custom Content Directory |
|
50 */ |
|
51 Config::define('CONTENT_DIR', '/app'); |
|
52 Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR')); |
|
53 Config::define('WP_CONTENT_URL', Config::get('WP_HOME') . Config::get('CONTENT_DIR')); |
|
54 |
|
55 /** |
|
56 * DB settings |
|
57 */ |
|
58 Config::define('DB_NAME', env('DB_NAME')); |
|
59 Config::define('DB_USER', env('DB_USER')); |
|
60 Config::define('DB_PASSWORD', env('DB_PASSWORD')); |
|
61 Config::define('DB_HOST', env('DB_HOST') ?: 'localhost'); |
|
62 Config::define('DB_CHARSET', 'utf8mb4'); |
|
63 Config::define('DB_COLLATE', ''); |
|
64 $table_prefix = env('DB_PREFIX') ?: 'wp_'; |
|
65 |
|
66 if (env('DATABASE_URL')) { |
|
67 $dsn = (object) parse_url(env('DATABASE_URL')); |
|
68 |
|
69 Config::define('DB_NAME', substr($dsn->path, 1)); |
|
70 Config::define('DB_USER', $dsn->user); |
|
71 Config::define('DB_PASSWORD', isset($dsn->pass) ? $dsn->pass : null); |
|
72 Config::define('DB_HOST', isset($dsn->port) ? "{$dsn->host}:{$dsn->port}" : $dsn->host); |
|
73 } |
|
74 |
|
75 /** |
|
76 * Authentication Unique Keys and Salts |
|
77 */ |
|
78 Config::define('AUTH_KEY', env('AUTH_KEY')); |
|
79 Config::define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY')); |
|
80 Config::define('LOGGED_IN_KEY', env('LOGGED_IN_KEY')); |
|
81 Config::define('NONCE_KEY', env('NONCE_KEY')); |
|
82 Config::define('AUTH_SALT', env('AUTH_SALT')); |
|
83 Config::define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT')); |
|
84 Config::define('LOGGED_IN_SALT', env('LOGGED_IN_SALT')); |
|
85 Config::define('NONCE_SALT', env('NONCE_SALT')); |
|
86 |
|
87 /** |
|
88 * Custom Settings |
|
89 */ |
|
90 Config::define('AUTOMATIC_UPDATER_DISABLED', true); |
|
91 Config::define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false); |
|
92 // Disable the plugin and theme file editor in the admin |
|
93 Config::define('DISALLOW_FILE_EDIT', true); |
|
94 // Disable plugin and theme updates and installation from the admin |
|
95 Config::define('DISALLOW_FILE_MODS', true); |
|
96 |
|
97 /** |
|
98 * Debugging Settings |
|
99 */ |
|
100 Config::define('WP_DEBUG_DISPLAY', false); |
|
101 Config::define('SCRIPT_DEBUG', false); |
|
102 ini_set('display_errors', 0); |
|
103 |
|
104 /** |
|
105 * Allow WordPress to detect HTTPS when used behind a reverse proxy or a load balancer |
|
106 * See https://codex.wordpress.org/Function_Reference/is_ssl#Notes |
|
107 */ |
|
108 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
109 $_SERVER['HTTPS'] = 'on'; |
|
110 } |
|
111 |
|
112 $env_config = __DIR__ . '/environments/' . WP_ENV . '.php'; |
|
113 |
|
114 if (file_exists($env_config)) { |
|
115 require_once $env_config; |
|
116 } |
|
117 |
|
118 Config::apply(); |
|
119 |
|
120 /** |
|
121 * Bootstrap WordPress |
|
122 */ |
|
123 if (!defined('ABSPATH')) { |
|
124 define('ABSPATH', $webroot_dir . '/wp/'); |
|
125 } |