Skip to content

Instantly share code, notes, and snippets.

@mchobbel
Last active May 27, 2023 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchobbel/0f9851539f723a376d3a952fa66303db to your computer and use it in GitHub Desktop.
Save mchobbel/0f9851539f723a376d3a952fa66303db to your computer and use it in GitHub Desktop.
Regarding https://wordpress.org/plugins/varnish-http-purge 5.1.3 Users with Editor role who are not administrator should be able to use the button "Purge Cache (This Page)".
diff -ru plugin.orig/varnish-http-purge.php plugin.modified/varnish-http-purge.php
--- plugin.orig/varnish-http-purge.php 2023-05-27 10:07:28.893638677 +0200
+++ plugin.modified/varnish-http-purge.php 2023-05-27 10:07:37.241770054 +0200
@@ -410,19 +410,6 @@
);
}
- // If we're on a front end page and the current user can edit published posts, then they can do this.
- if ( ! is_admin() && get_post() !== false && current_user_can( 'edit_published_posts' ) ) {
- $page_url = esc_url( home_url( $wp->request ) );
- $args[] = array(
- 'parent' => 'purge-varnish-cache',
- 'id' => 'purge-varnish-cache-this',
- 'title' => __( 'Purge Cache (This Page)', 'varnish-http-purge' ),
- 'href' => wp_nonce_url( add_query_arg( 'vhp_flush_do', $page_url . '/' ), 'vhp-flush-do' ),
- 'meta' => array(
- 'title' => __( 'Purge Cache (This Page)', 'varnish-http-purge' ),
- ),
- );
- }
// If Devmode is in the config, don't allow it to be disabled.
if ( ! VHP_DEVMODE ) {
@@ -452,6 +439,19 @@
);
}
}
+ // If we're on a front end page and the current user can edit published posts, then they can do this.
+ if ( ! is_admin() && get_post() !== false && current_user_can( 'edit_published_posts' ) ) {
+ $page_url = esc_url( home_url( $wp->request ) );
+ $args[] = array(
+ 'parent' => 'purge-varnish-cache',
+ 'id' => 'purge-varnish-cache-this',
+ 'title' => __( 'Purge Cache (This Page)', 'varnish-http-purge' ),
+ 'href' => wp_nonce_url( add_query_arg( 'vhp_flush_do', $page_url . '/' ), 'vhp-flush-do' ),
+ 'meta' => array(
+ 'title' => __( 'Purge Cache (This Page)', 'varnish-http-purge' ),
+ ),
+ );
+ }
if ( $can_purge ) {
foreach ( $args as $arg ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment