diff --git a/README.md b/README.md index 601cfbec..b679e557 100644 --- a/README.md +++ b/README.md @@ -220,15 +220,7 @@ WordPlate has archived the `wordplate/framework` package and moved everything in 1. Replace your `public/wp-config.php` file [the one in this repository](public/wp-config.php). Remember to save any custom constans defined in your `wp-config.php` file. -1. Add the [`src/helpers.php`](public/wp-config.php) file from this repository and autoload it in the `composer.json` file: - - ```diff - +"autoload": { - + "files": [ - + "src/helpers.php" - + ] - +} - ``` +1. Replace any usage of the `env` function with the native [`$_ENV`](https://github.com/vlucas/phpdotenv#usage) PHP superglobal. 1. Run `composer update` in the root of your project. diff --git a/composer.json b/composer.json index 281393e0..069a9931 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,12 @@ { "name": "vinkla/wordplate", - "type": "project", "description": "The WordPlate boilerplate", - "keywords": ["wordplate", "wordpress"], "license": "MIT", + "type": "project", + "keywords": [ + "wordplate", + "wordpress" + ], "require": { "php": "^8.0", "composer/installers": "^2.1", @@ -24,11 +27,6 @@ ] } ], - "autoload": { - "files": [ - "src/helpers.php" - ] - }, "config": { "allow-plugins": { "composer/installers": true, diff --git a/public/wp-config.php b/public/wp-config.php index c7b23c8e..f0e012aa 100644 --- a/public/wp-config.php +++ b/public/wp-config.php @@ -11,23 +11,23 @@ Dotenv::createImmutable(realpath(__DIR__ . '/../'))->safeLoad(); // Set the environment type. -define('WP_ENVIRONMENT_TYPE', env('WP_ENVIRONMENT_TYPE', 'production')); +define('WP_ENVIRONMENT_TYPE', $_ENV['WP_ENVIRONMENT_TYPE'] ?? 'production'); // For developers: WordPress debugging mode. -$isDebugModeEnabled = env('WP_DEBUG', false); +$isDebugModeEnabled = $_ENV['WP_DEBUG'] ?? false; define('WP_DEBUG', $isDebugModeEnabled); -define('WP_DEBUG_LOG', env('WP_DEBUG_LOG', false)); -define('WP_DEBUG_DISPLAY', env('WP_DEBUG_DISPLAY', $isDebugModeEnabled)); -define('SCRIPT_DEBUG', env('SCRIPT_DEBUG', $isDebugModeEnabled)); +define('WP_DEBUG_LOG', $_ENV['WP_DEBUG_LOG'] ?? false); +define('WP_DEBUG_DISPLAY', $_ENV['WP_DEBUG_DISPLAY'] ?? $isDebugModeEnabled); +define('SCRIPT_DEBUG', $_ENV['SCRIPT_DEBUG'] ?? $isDebugModeEnabled); // The database configuration with database name, username, password, // hostname charset and database collae type. -define('DB_NAME', env('DB_NAME')); -define('DB_USER', env('DB_USER')); -define('DB_PASSWORD', env('DB_PASSWORD')); -define('DB_HOST', env('DB_HOST', '127.0.0.1')); -define('DB_CHARSET', env('DB_CHARSET', 'utf8mb4')); -define('DB_COLLATE', env('DB_COLLATE', 'utf8mb4_unicode_ci')); +define('DB_NAME', $_ENV['DB_NAME']); +define('DB_USER', $_ENV['DB_USER']); +define('DB_PASSWORD', $_ENV['DB_PASSWORD']); +define('DB_HOST', $_ENV['DB_HOST'] ?? '127.0.0.1'); +define('DB_CHARSET', $_ENV['DB_CHARSET'] ?? 'utf8mb4'); +define('DB_COLLATE', $_ENV['DB_COLLATE'] ?? 'utf8mb4_unicode_ci'); // Detect HTTPS behind a reverse proxy or a load balancer. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { @@ -35,52 +35,52 @@ } // Set the unique authentication keys and salts. -define('AUTH_KEY', env('AUTH_KEY')); -define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY')); -define('LOGGED_IN_KEY', env('LOGGED_IN_KEY')); -define('NONCE_KEY', env('NONCE_KEY')); -define('AUTH_SALT', env('AUTH_SALT')); -define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT')); -define('LOGGED_IN_SALT', env('LOGGED_IN_SALT')); -define('NONCE_SALT', env('NONCE_SALT')); +define('AUTH_KEY', $_ENV['AUTH_KEY']); +define('SECURE_AUTH_KEY', $_ENV['SECURE_AUTH_KEY']); +define('LOGGED_IN_KEY', $_ENV['LOGGED_IN_KEY']); +define('NONCE_KEY', $_ENV['NONCE_KEY']); +define('AUTH_SALT', $_ENV['AUTH_SALT']); +define('SECURE_AUTH_SALT', $_ENV['SECURE_AUTH_SALT']); +define('LOGGED_IN_SALT', $_ENV['LOGGED_IN_SALT']); +define('NONCE_SALT', $_ENV['NONCE_SALT']); // Set the home url to the current domain. -define('WP_HOME', env('WP_HOME', (new Request())->getSchemeAndHttpHost())); +define('WP_HOME', $_ENV['WP_HOME'] ?? (new Request())->getSchemeAndHttpHost()); // Set the WordPress directory path. -define('WP_SITEURL', env('WP_SITEURL', sprintf('%s/%s', WP_HOME, env('WP_DIR', 'wordpress')))); +define('WP_SITEURL', $_ENV['WP_SITEURL'] ?? sprintf('%s/%s', WP_HOME, $_ENV['WP_DIR'] ?? 'wordpress')); // Set the WordPress content directory path. -define('WP_CONTENT_DIR', env('WP_CONTENT_DIR', realpath(__DIR__ . '/../public'))); -define('WP_CONTENT_URL', env('WP_CONTENT_URL', WP_HOME)); +define('WP_CONTENT_DIR', $_ENV['WP_CONTENT_DIR'] ?? realpath(__DIR__ . '/../public')); +define('WP_CONTENT_URL', $_ENV['WP_CONTENT_URL'] ?? WP_HOME); // Set the trash to less days to optimize WordPress. -define('EMPTY_TRASH_DAYS', env('EMPTY_TRASH_DAYS', 7)); +define('EMPTY_TRASH_DAYS', $_ENV['EMPTY_TRASH_DAYS'] ?? 7); // Set the default WordPress theme. -define('WP_DEFAULT_THEME', env('WP_DEFAULT_THEME', 'wordplate')); +define('WP_DEFAULT_THEME', $_ENV['WP_DEFAULT_THEME'] ?? 'wordplate'); // Constant to configure core updates. -define('WP_AUTO_UPDATE_CORE', env('WP_AUTO_UPDATE_CORE', 'minor')); +define('WP_AUTO_UPDATE_CORE', $_ENV['WP_AUTO_UPDATE_CORE'] ?? 'minor'); // Specify the number of post revisions. -define('WP_POST_REVISIONS', env('WP_POST_REVISIONS', 2)); +define('WP_POST_REVISIONS', $_ENV['WP_POST_REVISIONS'] ?? 2); // Cleanup WordPress image edits. -define('IMAGE_EDIT_OVERWRITE', env('IMAGE_EDIT_OVERWRITE', true)); +define('IMAGE_EDIT_OVERWRITE', $_ENV['IMAGE_EDIT_OVERWRITE'] ?? true); // Prevent file edititing from the dashboard. -define('DISALLOW_FILE_EDIT', env('DISALLOW_FILE_EDIT', true)); +define('DISALLOW_FILE_EDIT', $_ENV['DISALLOW_FILE_EDIT'] ?? true); // Disable technical issues emails. -define('WP_DISABLE_FATAL_ERROR_HANDLER', env('WP_DISABLE_FATAL_ERROR_HANDLER', false)); +define('WP_DISABLE_FATAL_ERROR_HANDLER', $_ENV['WP_DISABLE_FATAL_ERROR_HANDLER'] ?? false); // Set the absolute path to the WordPress directory. if (!defined('ABSPATH')) { - define('ABSPATH', sprintf('%s/%s/', realpath(__DIR__ . '/../public'), env('WP_DIR', 'wordpress'))); + define('ABSPATH', sprintf('%s/%s/', realpath(__DIR__ . '/../public'), $_ENV['WP_DIR'] ?? 'wordpress')); } // Set the database table prefix. -$table_prefix = env('DB_TABLE_PREFIX', 'wp_'); +$table_prefix = $_ENV['DB_TABLE_PREFIX'] ?? 'wp_'; require_once ABSPATH . 'wp-settings.php'; diff --git a/src/helpers.php b/src/helpers.php deleted file mode 100644 index a255a417..00000000 --- a/src/helpers.php +++ /dev/null @@ -1,35 +0,0 @@ -