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

allow $cache_dir & $settings_dir to be overriden with constants #231

Closed Dynamo6Dev closed 3 years ago

Dynamo6Dev commented 3 years ago

Re issue #226

Dynamo6Dev commented 3 years ago

No worries, thats updated now

coreykn commented 3 years ago

Oops! I just realized I had made a mistake in my first review. When the advanced-cache.php drop-in is included by WordPress (based on if WP_CACHE is true), the Cache Enabler plugin (or any plugin for that matter) isn't loaded yet, meaning cache-enabler.php hasn't been loaded. That means the default constant wouldn't be defined yet. The change I requested won't work. I sincerely apologize for that oversight. However, the way you initially proposed won't work either because if a class property has an initialization it must be constant, which means the ternary operator in this declaration would cause a fatal error.

This is bringing up some memories of the limitations for why I didn't make those paths customizable yet. Let's close this for now while leaving the linked issue open as I'd like to introduce this control but I need to think of how to best approach it and what may need to change to support it. On the top of my head I'm thinking I will first explore a new way to handle the define statements for our constants so it doesn't rely on Cache Enabler being initialized. I will also explore if what was proposed in #229 would be a good way of handling this. If you or anyone else has ideas on a good approach please feel free to share.