Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: WP constants in .env & application.php #680

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ WP_SITEURL="${WP_HOME}/wp"
# Specify optional debug.log path
# WP_DEBUG_LOG='/path/to/debug.log'

# Configuring development mode
# Values: core, plugin, theme, all (default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that default is an empty string, not all

An empty string indicates that no particular development mode is enabled for this site. This is the default value and should be used on any site that is not used for development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, my bad, I've coded it too fast! ^^'

# See: https://make.wordpress.org/core/2023/07/14/configuring-development-mode-in-6-3/
# WP_DEVELOPMENT_MODE=core

## WP OPTIONS
WP_CACHE=true
WP_POST_REVISIONS=5
WP_CONCATENATE_SCRIPTS=false
WP_COMPRESS_SCRIPTS=true
WP_COMPRESS_CSS=true
WP_ENFORCE_GZIP=true
DISABLE_WP_CRON=false

Comment on lines +20 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need any of this here if we have sensible production-ready defaults.

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
Expand Down
33 changes: 33 additions & 0 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,39 @@
// Limit the number of post revisions
Config::define('WP_POST_REVISIONS', env('WP_POST_REVISIONS') ?? true);

// Autosave
Config::define('AUTOSAVE_INTERVAL', env('WP_AUTOSAVE_INTERVAL') ?? 300);

// Empty trash
Config::define('EMPTY_TRASH_DAYS', env('WP_EMPTY_TRASH_DAYS') ?? 120);

// Memory limit
Config::define('WP_MEMORY_LIMIT', env('WP_MEMORY_LIMIT') ?? '128M');

// Max execution time (can't overide server settings)
Config::define('WP_MAX_EXECUTION_TIME', env('WP_MAX_EXECUTION_TIME') ?? '300');

// Max upload size (can't overide server settings)
Config::define('WP_MAX_UPLOAD_SIZE', env('WP_MAX_UPLOAD_SIZE') ?? '128M');

// Max post size (can't overide server settings)
Config::define('WP_MAX_POST_SIZE', env('WP_MAX_POST_SIZE') ?? '128M');

// Activate cache
Config::define( 'WP_CACHE', env('WP_CACHE') ?? false );

// Concatenate scripts
Config::define( 'CONCATENATE_SCRIPTS', env('WP_CONCATENATE_SCRIPTS') ?? false );

// Compress scripts
Config::define( 'COMPRESS_SCRIPTS', env('WP_COMPRESS_SCRIPTS') ?? false );

// Compress CSS
Config::define( 'COMPRESS_CSS', env('WP_COMPRESS_CSS') ?? false );

// Force GZIP compression (default is deflate)
Config::define( 'ENFORCE_GZIP', env('WP_ENFORCE_GZIP') ?? 'deflate' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is interesting, but I would rather this not be handled by the application. This is something that should be handled by the server.


/**
* Debugging Settings
*/
Expand Down
1 change: 1 addition & 0 deletions config/environments/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use function Env\env;

Config::define('SAVEQUERIES', true);
Config::define('WP_DEVELOPMENT_MODE', env('WP_DEVELOPMENT_MODE') ?? 'all');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config::define('WP_DEBUG', true);
Config::define('WP_DEBUG_DISPLAY', true);
Config::define('WP_DEBUG_LOG', env('WP_DEBUG_LOG') ?? true);
Expand Down
24 changes: 24 additions & 0 deletions config/environments/local.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of this file.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Configuration overrides for WP_ENV === 'local'
*/

use Roots\WPConfig\Config;
use function Env\env;

Config::define('SAVEQUERIES', true);
Config::define('WP_DEVELOPMENT_MODE', env('WP_DEVELOPMENT_MODE') ?? 'all');
Config::define('WP_DEBUG', true);
Config::define('WP_DEBUG_DISPLAY', true);
Config::define('WP_DEBUG_LOG', env('WP_DEBUG_LOG') ?? true);
Config::define('WP_DISABLE_FATAL_ERROR_HANDLER', true);
Config::define('SCRIPT_DEBUG', true);
Config::define('DISALLOW_INDEXING', true);

ini_set('display_errors', '1');

// Enable plugin and theme updates and installation from the admin
Config::define('DISALLOW_FILE_MODS', false);

// Disable the plugin and theme file editor in the admin
Config::define('DISALLOW_FILE_EDIT', false);
Loading