Update how Cache Enabler sets and unsets the WP_CACHE constant in the wp-config.php file:
Update getting wp-config.php contents as a string instead of an array. This simplifies the logic by allowing simple searches to find and replace what we need.
Update it to be more strict by only setting the WP_CACHE constant if we believe it is the default wp-config.php, which is currently true if we find /** Sets up WordPress vars and included files. */. This makes it so changes are not being made to a heavily customized config file, like if using Bedrock (#136).
Update what is inserted from define( 'WP_CACHE', true ); // Added by Cache Enabler to the following instead:
This will prevent potential constant already defined errors if WP_CACHE is defined elsewhere and we end up setting the constant (@nlemoine).
Update the location where the Cache Enabler config lines are inserted. Previously, the old single line was inserted at the very top beneath the opening PHP tag. Now, insert new config lines to be above the minimum requirement, which is before WordPress sets up its vars and included files. If it is set below this the default WordPress constant would be applied that is set in the wp-includes/default-constants.php file. This cleans up how we change the config file.
Update how the Cache_Enabler::_set_wp_cache_constant() method is called. No longer check the WP_CACHE constant itself beforehand because the checks done in this method are enough. This fixes the issue occurring in #65 where the WP_CACHE constant would not be added if Cache Enabler was activated immediately after being deactivated.
Update how Cache Enabler sets and unsets the
WP_CACHE
constant in thewp-config.php
file:Update getting
wp-config.php
contents as a string instead of an array. This simplifies the logic by allowing simple searches to find and replace what we need.Update it to be more strict by only setting the
WP_CACHE
constant if we believe it is the defaultwp-config.php
, which is currently true if we find/** Sets up WordPress vars and included files. */
. This makes it so changes are not being made to a heavily customized config file, like if using Bedrock (#136).Update what is inserted from
define( 'WP_CACHE', true ); // Added by Cache Enabler
to the following instead:This will prevent potential constant already defined errors if
WP_CACHE
is defined elsewhere and we end up setting the constant (@nlemoine).Update the location where the Cache Enabler config lines are inserted. Previously, the old single line was inserted at the very top beneath the opening PHP tag. Now, insert new config lines to be above the minimum requirement, which is before WordPress sets up its vars and included files. If it is set below this the default WordPress constant would be applied that is set in the
wp-includes/default-constants.php
file. This cleans up how we change the config file.Update how the
Cache_Enabler::_set_wp_cache_constant()
method is called. No longer check theWP_CACHE
constant itself beforehand because the checks done in this method are enough. This fixes the issue occurring in #65 where theWP_CACHE
constant would not be added if Cache Enabler was activated immediately after being deactivated.Closes #65 and closes #136