Make it easier to add new WP Super Cache plugins by outside code.#574
Make it easier to add new WP Super Cache plugins by outside code.#574
Conversation
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();
|
wpsc_add_plugin() and wpsc_delete_plugin() can be used to add new plugins to be loaded by WP Super Cache. |
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 The code instead looks for plugins in This does work, but it seems a bit strange, as I'd have thought that the WP There's also the (small) risk that someone could add a new plugin to the WP plugins database, called |
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.