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

Make it easier to add new WP Super Cache plugins by outside code. #574

Merged
merged 3 commits into from Aug 7, 2018

Conversation

donnchawp
Copy link
Contributor

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.
@donnchawp donnchawp self-assigned this Jul 24, 2018
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 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
@donnchawp
Copy link
Contributor Author

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.

@donnchawp donnchawp merged commit e5595b9 into master Aug 7, 2018
@donnchawp donnchawp deleted the add_new_plugins_dir branch August 7, 2018 10:20
donnchawp added a commit that referenced this pull request Aug 9, 2018
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' );`
donnchawp added a commit that referenced this pull request Aug 9, 2018
…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' );`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant