Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Enabler addons #229

Open
byteperfect opened this issue Apr 14, 2021 · 4 comments
Open

Cache Enabler addons #229

byteperfect opened this issue Apr 14, 2021 · 4 comments
Milestone

Comments

@byteperfect
Copy link

First of all, I would like to express my gratitude for the good work you are doing!

Could you please consider the possibility of adding add-ons functionality to the plugin? This will allow sites developers to use your plugin as a basis and gives the ability to flexibly configure the caching system for each specific site.

As one of the implementation options, I suggest you the scheme that I use on my sites.

  1. In the wp-config.php file, add an array with absolute paths to add-ons bootstrap files as a constant or a global variable, for example:
define(
	'CACHE_ENABLER_ADD_ONS',
	array(
		'/absolute/path/to/add-on1.php',
		'/absolute/path/to/add-on2.php',
	)
);
  1. In the advanced-cache.php file, before other require_once add the following code:
if ( defined( 'CACHE_ENABLER_ADD_ONS' ) && is_array( CACHE_ENABLER_ADD_ONS ) ) {
	foreach ( CACHE_ENABLER_ADD_ONS as $add_on ) {
		if ( is_readable( $add_on ) ) {
			require_once $add_on;
		}
	}
}
  1. Return values ​​from all functions must be passed through filters, for example:
public static function get_cache_file() {

    $cache_file = sprintf(
        '%s/%s',
        self::get_cache_file_dir(),
        self::get_cache_file_name()
    );

    return apply_filters( 'cache_enabler_get_cache_file', $cache_file );
}
  1. Maybe, add additional actions and filters inside functions.
@coreykn
Copy link
Contributor

coreykn commented Apr 16, 2021

You're welcome! Happy to hear that you're enjoying Cache Enabler. Anything is always up for consideration. To better understand this request, can you please let me know what type of add ons you'd like to implement if this were to be introduced? Like the functionality that you're trying to add with the add ons.

@byteperfect
Copy link
Author

For example, I need to have my own files naming based on certain conditions and be able to alter should_start, deliver_cache and start_buffering behavior.
I am sure that similar functionality will be in demand by other developers as well. For example:
#226.

@coreykn
Copy link
Contributor

coreykn commented Apr 19, 2021

Thanks for explaining a little more about why you would like this to be added. Like with our other requests, let's leave this open as that allows others to comment and/or upvote your request.

@davelit
Copy link
Contributor

davelit commented Apr 20, 2021

In case you are loooking for inspiration, WP Super Cache has support for cache plugins (docs) that go into ./wp-content/plugins/wp-super-cache-plugins/ (in wp-cache-phase1.php): Plugins can manipulate the results by hooking into "cache actions" (add_cacheaction() and do_cacheaction()).

In my humble opinion, I think the cache plugins should be normal plugins that can be installed/uninstalled via the normal WordPress plugin repository and they should make themselves "available" to advanced-cache.php through the creation and removal of symlinks in a conf.d like directory, which could default to ./wp-content/plugins/cache-enabler-plugins/ (but should be overridable via a constant like CACHE_ENABLER_PLUGINS_DIR).

@coreykn coreykn added this to the v2.0.0 milestone Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants