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

Add filter to allow customizing who can flush the cache #535

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

pmgarman
Copy link
Contributor

@pmgarman pmgarman commented Jun 6, 2024

Couldn't find a CONTRIBUTING.md (i may be blind) so took a best guess. Also just assumed 2.6 but who knows?!

I think this could easily be a thing that gets enhanced deeper for multisite to allow individual site owners to flush their individual sites cache or something along those lines... but this probably serves my needs well enough :D

@pmgarman
Copy link
Contributor Author

pmgarman commented Jun 6, 2024

This was the code i used to test that this worked for the author role:

add_filter( 'roc_manage_redis_capability', function( $cap ) {
	return 'publish_posts';
});

@pmgarman
Copy link
Contributor Author

pmgarman commented Jun 6, 2024

Resolved conflict in changelog

@tillkruss
Copy link
Member

Should we also make this a constant for easier access?

@tillkruss tillkruss self-assigned this Jun 10, 2024
@pmgarman
Copy link
Contributor Author

You would only be able to define your default as a constant though right? Since the constant can't change after being filtered?

@tillkruss
Copy link
Member

You would only be able to define your default as a constant though right? Since the constant can't change after being filtered?

Yeah, it would be set once in the wp-config.php and should be opt-in, not used by default.

@pmgarman
Copy link
Contributor Author

Oh I see what you mean, inverse of what I was thinking. It's monday...

I could see that being handy too yeah. I can update my PR and fix those codestyle complaints.

Any preference on your constant name?

@pmgarman
Copy link
Contributor Author

Nevermind those errors are yours :P enjoy!

@pmgarman
Copy link
Contributor Author

Opted for WP_REDIS_MANAGER_CAPABILITY until @tillkruss says otherwise :)

CHANGELOG.md Outdated
@@ -2,6 +2,7 @@

## Unreleased

- Added `roc_manage_redis_capability` filter and `WP_REDIS_MANAGER_CAPABILITY` constant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmgarman: Could you add these to the README as well?

@pmgarman
Copy link
Contributor Author

@tillkruss try this on for size

@tillkruss tillkruss merged commit c67f84d into rhubarbgroup:develop Jul 12, 2024
0 of 3 checks passed
tillkruss added a commit that referenced this pull request Oct 15, 2024
* Add filter and constant to allow customizing who can manage the plugin

* Update CHANGELOG.md

* Update README.md

---------

Co-authored-by: Till Krüss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants