keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

advanced-cache.php: use reasonable default location for constants.php. #322

Closed orlitzky closed 7 months ago

orlitzky commented 1 year ago

In advanced-cache.php, a variable $cache_enabler_constants_file is defined with a "junk" value that needs to be changed upon installation. If the wp-content directory is writable, then the cache-enabler activation routine will copy the included advanced-cache.php into it, modifying the junk value to point to the real location of constants.php.

If, however, wp-content is hardened to prevent writes to the plugins subdirectory [0], then the user has to copy advanced-cache.php into wp-content himself, and edit $cache_enabler_constants_file manually. To avoid this step, it would be nice if the user could simply symlink wp-content/advanced-cache.php to the sample copy provided by the plugin and have everything work "out of the box."

This commit replaces the junk default $cache_enabler_constants_file with one that allows said symlinking. Since the old value could never work, this should not be any worse for anyone's use case. The find/replace that the activation routine uses when wp-content is writable has also been updated and is a tiny bit uglier, but otherwise still works the same.

[0] https://wordpress.org/documentation/article/hardening-wordpress/

orlitzky commented 7 months ago

Thanks! I had forgotten about these. I guess I'll clean up the changes I've made to fix https://github.com/keycdn/cache-enabler/issues/324 and https://github.com/keycdn/cache-enabler/issues/320 now.