Skip to content

Cache Enabler addons #229

@AleksandrLevashov

Description

@AleksandrLevashov

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions