3

All those damned wp-config constants you can never remember.

 1 year ago
source link: https://gist.github.com/MikeNGarrett/e20d77ca8ba4ae62adf5
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

All those damned wp-config constants you can never remember. · GitHub

Instantly share code, notes, and snippets.

All those damned wp-config constants you can never remember.

Thanks, very helpful :)

I found this little fellow was missing:

// Turn off WSOD Protection (and don't send email notification)
define( 'WP_SANDBOX_SCRAPING', true );

I just added sandbox scraping. Thanks for mentioning it.

There are a ton of constants that are useful in different scenarios. I recommending checking out the default constants file: https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php

Thanks
here are few missing to boost site speed a little

define('COMPRESS_SCRIPTS', true);
define('COMPRESS_CSS', true);
define('ENFORCE_GZIP', true);

Thanks for the additions!

Hi @MikeNGarrett !

Pay attention to these two constants that you cannot override:

define('SHORTINIT', false); defined in wp-includes/ms-files.php (line 11)
define('WP_FEATURE_BETTER_PASSWORDS', true); defined in wp-includes/default-constants.php (line 123)

You cannot override them because WP team didn't check if the constant is already defined or not.
If you use them in your wp-config.php, you'll get a "Notice: Constant WP_FEATURE_BETTER_PASSWORDS already defined"

BTW, thanks for this ;)

Sources:
https://github.com/WordPress/WordPress/blob/master/wp-includes/ms-files.php#L11
https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php#L123

Hi @MikeNGarrett !

Pay attention to these two constants that you cannot override:

define('SHORTINIT', false); defined in wp-includes/ms-files.php (line 11)
define('WP_FEATURE_BETTER_PASSWORDS', true); defined in wp-includes/default-constants.php (line 123)

You cannot override them because WP team didn't check if the constant is already defined or not.
If you use them in your wp-config.php, you'll get a "Notice: Constant WP_FEATURE_BETTER_PASSWORDS already defined"

BTW, thanks for this ;)

Sources:
https://github.com/WordPress/WordPress/blob/master/wp-includes/ms-files.php#L11
https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php#L123

You're right about WP_FEATURE_BETTER_PASSWORDS, but you're wrong about SHORTINIT
https://github.com/WordPress/WordPress/blob/master/wp-includes/default-constants.php#L118

Hi @MikeNGarrett,

In a usual use of WP, you're right for SHORTINIT: the system gets index.php -> wp-blog-header.php -> wp-load.php -> wp-config.php -> wp-settings.php -> wp-includes/default-constants.php. If you define your constant in wp-config.php, WP will check it on default-constants.php file. Everything works welle.

But if you use WP as a multisite and you make an upload, WP will use the wp-includes/ms-files.php as a direct call. It will define the SHORTINIT constant and call wp-load.php -> wp-config.php (error !)

That's why I do not recommand to override it.

Nominating WP_DISABLE_FATAL_ERROR_HANDLER to the Fatal error handling section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK