You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding new plugins to WP Super Cache to extend it is complicated but
where they should go should be easy. This patch makes the plugin check
in a particular directory if it exists and load the PHP files there.
The files there won't be deleted when WP Super Cache is updated.
Adding new plugins to WP Super Cache to extend it is complicated but
where they should go should be easy. This patch makes the plugin check
in a particular directory if it exists and load the PHP files there.
The files there won't be deleted when WP Super Cache is updated.
Add helper functions to add and delete plugin files from the list to be
loaded by WP Super Cache:
wpsc_add_plugin( $file );
wpsc_delete_plugin( $file );
And this function to return the list of plugins:
wpsc_get_plugins();
donnchawp
changed the title
Put plugins in wp-content/plugins/wp-super-cache-plugins/
Make it easier to add new WP Super Cache plugins by outside code.
Jul 25, 2018
wpsc_add_plugin() and wpsc_delete_plugin() can be used to add new plugins to be loaded by WP Super Cache.
Each takes one parameter, a filename. It can be with or without the ABSPATH but ABSPATH is stripped out before storing the filename.
The files are loaded way before most of WordPress loads.
These filters will allow WordPress plugins to modify the cookies and
plugins lists used by WP Super Cache instead of the add/delete functions
introducted in #574 and #580.
Duplicate entries are removed so the filter function does not need to
worry about that. Example code:
`function myplugin_add_wpsc_cookies_filter( $cookies ) {
$cookies[] = 'myplugin';
return $cookies;
}
add_filter( 'wpsc_cookies', 'myplugin_add_wpsc_cookies_filter' );`
`function myplugin_delete_wpsc_cookies_filter( $cookies ) {
if ( in_array( 'myplugin', $cookies ) ) {
unset( $cookies[ array_search( 'myplugin', $cookies ) ] );
}
return $cookies;
}
add_filter( 'wpsc_cookies', 'myplugin_delete_wpsc_cookies_filter' );`
…tings (#582)
This PR adds four actions to modify wpsc_cookies and wpsc_plugins:
* wpsc_add_plugin
* wpsc_delete_plugin
* wpsc_add_cookie
* wpsc_delete_cookie
These actions will allow WordPress plugins to modify the cookies and
plugins lists used by WP Super Cache instead of the add/delete functions
introduced in #574 and #580.
Duplicate entries are removed. Example code:
For example, to add a cookie name called 'euCookie':
`do_action( 'wpsc_add_cookie', 'euCookie' );`
To remove that cookie:
`do_action( 'wpsc_delete_cookie', 'euCookie' );`
I know this is an old commit, but this is exactly the thing I was looking for!
However, something isn't quite right, and I wonder if the desired behaviour is that of the comment, or the code.
The comment states that the code will "also look for plugins in wp-content/wp-super-cache-plugins/" but this is incorrect.
The code instead looks for plugins in wp-content/plugins/wp-super-cache-plugins/ which is, of course, inside the general WP plugins directory.
This does work, but it seems a bit strange, as I'd have thought that the WP plugins directory was intended only for proper WP plugins.
There's also the (small) risk that someone could add a new plugin to the WP plugins database, called wp-super-cache-plugins, which when installed would over-write any plugins added by this commit.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding new plugins to WP Super Cache to extend it is complicated but
where they should go should be easy. This patch makes the plugin check
in a particular directory if it exists and load the PHP files there.
The files there won't be deleted when WP Super Cache is updated.