stuttter / wp-spider-cache

Your friendly neighborhood caching solution for WordPress
GNU General Public License v2.0
134 stars 16 forks source link

Drop-in includes #8

Closed bueltge closed 8 years ago

bueltge commented 8 years ago

The Drop-ins use the constant WP_CONTENT_DIR, like require_once WP_CONTENT_DIR . '/plugins/wp... in advanced-cache.php. WordPress allow, that the install define a custom path to the plugin directory, via WP_PLUGIN_DIR and WP_PLUGIN_URL like

// Custom plugin directory
define( 'WP_PLUGIN_DIR',   dirname( __FILE__ ) . '/wp-plugins' );
define( 'WP_PLUGIN_URL',   'http://' . $_SERVER['HTTP_HOST'] . '/wp-plugins' );

The plugin should also allow this (usage from WP_PLUGIN_DIR), that users with a defined plugin directory can use the nice plugin.

Maybe also a pull request, if you like?

JJJ commented 8 years ago

Yes, please.

The best case scenario is for the include path to allow placement in plugins, mu-plugins, or any other custom directory.

This isn't possible unless the main plugin that provides the admin UI is active, since there's no other code executed to announce its location. The drop-ins themselves don't have a way to know, and filters aren't available as early as advanced-cache.php is loaded.

Perhaps custom constants might work, and if they're defined they'll be blindly used instead? I usually shy away from these types of unchecked settings, but I have a hunch it's the most flexible way.

JJJ commented 8 years ago

I've taken a deeper look, and I don't think these changes will work.

wp_plugin_directory_constants() is called after advanced-cache.php is included, meaning if WP_PLUGIN_DIR is not explicitly defined in wp-config.php or earlier, these drop-ins cannot be located.

Another approach was taken in e6742c5, where we check if the constant is defined, and if it is not, we define it (pretty early) and use it.

This should cover all scenarios, while also remaining flexible. I'm comfortable closing this issue since the root suggestion is resolved. Feel free to reopen or create a new issue if you feel otherwise.

Thanks for everything here everyone!

bueltge commented 8 years ago

The approach works fine me, all is good. Leave close the ticket. Best.