Varnish HTTP Purge - Version 4.0.3

Version Description

  • Better explanation when Cloudflare gets in the way of DNS
  • Rename flush button for people who don't speak Varnish
Download this release

Release Info

Developer Ipstenu
Plugin Icon 128x128 Varnish HTTP Purge
Version 4.0.3
Comparing to
See all releases

Code changes from version 4.0.2 to 4.0.3

Files changed (3) hide show
  1. readme.txt +5 -1
  2. varnish-http-purge.php +6 -6
  3. varnish-status.php +6 -4
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Ipstenu, mikeschroder, techpriester
3
  Tags: varnish, purge, cache
4
  Requires at least: 4.0
5
  Tested up to: 4.7
6
- Stable tag: 4.0.2
7
 
8
  Automatically purge Varnish Cache when content on your site is modified.
9
 
@@ -209,6 +209,10 @@ Yes I do, and yes and no. This plugin is installed by default for _all_ DreamPre
209
 
210
  == Changelog ==
211
 
 
 
 
 
212
  = 4.0.2 =
213
  * Support for WP-CLI commands and PHP > 5.5 (though please upgrade, props @robertpeake)
214
  * Better information regarding Cloudflare
3
  Tags: varnish, purge, cache
4
  Requires at least: 4.0
5
  Tested up to: 4.7
6
+ Stable tag: 4.0.3
7
 
8
  Automatically purge Varnish Cache when content on your site is modified.
9
 
209
 
210
  == Changelog ==
211
 
212
+ = 4.0.3 =
213
+ * Better explanation when Cloudflare gets in the way of DNS
214
+ * Rename flush button for people who don't speak Varnish
215
+
216
  = 4.0.2 =
217
  * Support for WP-CLI commands and PHP > 5.5 (though please upgrade, props @robertpeake)
218
  * Better information regarding Cloudflare
varnish-http-purge.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Varnish HTTP Purge
4
  Plugin URI: https://halfelf.org/plugins/varnish-http-purge/
5
  Description: Automatically purge Varnish Cache when content on your site is modified.
6
- Version: 4.0.2
7
  Author: Mika Epstein
8
  Author URI: https://halfelf.org/
9
  License: http://www.apache.org/licenses/LICENSE-2.0
@@ -145,10 +145,10 @@ class VarnishPurger {
145
  function varnish_rightnow_adminbar($admin_bar){
146
  $admin_bar->add_menu( array(
147
  'id' => 'purge-varnish-cache-all',
148
- 'title' => __('Purge Varnish','varnish-http-purge'),
149
  'href' => wp_nonce_url( add_query_arg('vhp_flush_all', 1), 'vhp-flush-all'),
150
  'meta' => array(
151
- 'title' => __('Purge Varnish','varnish-http-purge'),
152
  ),
153
  ));
154
  }
@@ -163,9 +163,9 @@ class VarnishPurger {
163
  global $blog_id;
164
  $url = wp_nonce_url(add_query_arg('vhp_flush_all', 1), 'vhp-flush-all');
165
  $intro = sprintf( __('<a href="%1$s">Varnish HTTP Purge</a> automatically purges your posts when published or updated. Sometimes you need a manual flush.', 'varnish-http-purge' ), 'http://wordpress.org/plugins/varnish-http-purge/' );
166
- $button = __('Press the button below to force it to purge your entire cache.', 'varnish-http-purge' );
167
  $button .= '</p><p><span class="button"><a href="'.$url.'"><strong>';
168
- $button .= __('Purge Varnish', 'varnish-http-purge' );
169
  $button .= '</strong></a></span>';
170
  $nobutton = __('You do not have permission to purge the cache for the whole site. Please contact your administrator.', 'varnish-http-purge' );
171
 
@@ -175,7 +175,7 @@ class VarnishPurger {
175
  // Multisite - Network Admin can always purge
176
  current_user_can('manage_network') ||
177
  // Multisite - Site admins can purge UNLESS it's a subfolder install and we're on site #1
178
- ( is_multisite() && !current_user_can('manage_network') && ( SUBDOMAIN_INSTALL || ( !SUBDOMAIN_INSTALL && ( BLOG_ID_CURRENT_SITE != $blog_id ) ) ) )
179
  ) {
180
  $text = $intro.' '.$button;
181
  } else {
3
  Plugin Name: Varnish HTTP Purge
4
  Plugin URI: https://halfelf.org/plugins/varnish-http-purge/
5
  Description: Automatically purge Varnish Cache when content on your site is modified.
6
+ Version: 4.0.3
7
  Author: Mika Epstein
8
  Author URI: https://halfelf.org/
9
  License: http://www.apache.org/licenses/LICENSE-2.0
145
  function varnish_rightnow_adminbar($admin_bar){
146
  $admin_bar->add_menu( array(
147
  'id' => 'purge-varnish-cache-all',
148
+ 'title' => __('Empty Cache','varnish-http-purge'),
149
  'href' => wp_nonce_url( add_query_arg('vhp_flush_all', 1), 'vhp-flush-all'),
150
  'meta' => array(
151
+ 'title' => __('Empty Cache','varnish-http-purge'),
152
  ),
153
  ));
154
  }
163
  global $blog_id;
164
  $url = wp_nonce_url(add_query_arg('vhp_flush_all', 1), 'vhp-flush-all');
165
  $intro = sprintf( __('<a href="%1$s">Varnish HTTP Purge</a> automatically purges your posts when published or updated. Sometimes you need a manual flush.', 'varnish-http-purge' ), 'http://wordpress.org/plugins/varnish-http-purge/' );
166
+ $button = __('Press the button below to force it to empty your entire Varnish cache.', 'varnish-http-purge' );
167
  $button .= '</p><p><span class="button"><a href="'.$url.'"><strong>';
168
+ $button .= __('Empty Cache', 'varnish-http-purge' );
169
  $button .= '</strong></a></span>';
170
  $nobutton = __('You do not have permission to purge the cache for the whole site. Please contact your administrator.', 'varnish-http-purge' );
171
 
175
  // Multisite - Network Admin can always purge
176
  current_user_can('manage_network') ||
177
  // Multisite - Site admins can purge UNLESS it's a subfolder install and we're on site #1
178
+ ( is_multisite() && current_user_can('activate_plugins') && ( SUBDOMAIN_INSTALL || ( !SUBDOMAIN_INSTALL && ( BLOG_ID_CURRENT_SITE != $blog_id ) ) ) )
179
  ) {
180
  $text = $intro.' '.$button;
181
  } else {
varnish-status.php CHANGED
@@ -88,7 +88,7 @@ class VarnishStatus {
88
  */
89
  function options_callback_ip() {
90
  ?>
91
- <p><a name="#configure"></a><?php _e('The majority of users will never need to so much as look down here. However there are cases when a custom Varnish IP Address will need to be set, in order to tell the plugin to flush cache in a specific location. If you\'re using a CDN like Cloudflare or a Firewall Proxy like Sucuri, you will want to set this.', 'varnish-http-purge'); ?></p>
92
  <p><?php _e('Your Varnish IP is just the IP address of the server where Varnish is installed. Your Varnish IP must be one of the IPs that Varnish is listening on. If you use multiple IPs, or if you\'ve customized your ACLs, you\'ll need to pick one that doesn\'t conflict with your other settings. For example, if you have Varnish listening on a public and private IP, pick the private. On the other hand, if you told Varnish to listen on 0.0.0.0 (i.e. "listen on every interface you can") you would need to check what IP you set your purge ACL to allow (commonly 127.0.0.1 aka localhost), and use that (i.e. 127.0.0.1).', 'varnish-http-purge'); ?></p>
93
  <p><?php _e('If your webhost set up Varnish for you, you may need to ask them for the specifics if they don\'t have it documented. I\'ve listed the ones I know about here, however you should still check with them if you\'re not sure.', 'varnish-http-purge'); ?></p>
94
 
@@ -174,6 +174,8 @@ class VarnishStatus {
174
  } elseif ( isset( $headers['HTTP_X_FORWARDED_FOR'] ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )
175
  ) {
176
  $remote_ip = $headers['HTTP_X_FORWARDED_FOR'];
 
 
177
  } else {
178
  $remote_ip = false;
179
  }
@@ -223,7 +225,7 @@ class VarnishStatus {
223
  if ( $remote_ip == false && !empty( $varniship) ) {
224
  ?>
225
  <td width="40px"><?php echo $icon_bad; ?></td>
226
- <td><?php printf( __( 'You have a Varnish IP set but you don\'t appear to be using a proxy like Cloudflare or Sucuri. Please <a href="%s">erase your Varnish IP</a>', 'varnish-http-purge' ), '#configure' ); ?></td>
227
  <?php
228
  } elseif ( $remote_ip !== false && $remote_ip !== $varniship ) {
229
  ?>
@@ -242,7 +244,7 @@ class VarnishStatus {
242
  if ( strpos( $headers['Server'] ,'cloudflare') !== false ) {
243
  ?><tr>
244
  <td><?php echo $icon_warning; ?></td>
245
- <td><?php printf( __( 'Because CloudFlare is running, you may experience some cache oddities. Make sure you <a href="%s">configure WordPress for Cloudflare</a>?', 'varnish-http-purge' ), '#configure' ); ?></td>
246
  </tr><?php
247
  }
248
 
@@ -270,7 +272,7 @@ class VarnishStatus {
270
  if ( strpos( $headers['Content-Encoding'] ,'Fastly') !== false ) {
271
  ?><tr>
272
  <td><?php echo $icon_good; ?></td>
273
- <td><?php printf( __( '<a href="%s">Fastly</a> is speeding up your site. Keep in mind, it may cache your CSS and images longer than Varnish does. Remember to flush both caches.', 'varnish-http-purge' ), esc_url('https://fastly.com') ); ?></td>
274
  </tr><?php
275
  }
276
  }
88
  */
89
  function options_callback_ip() {
90
  ?>
91
+ <p><a name="#configure"></a><?php _e('The majority of users will never need to so much as look down here. However there are cases when a custom Varnish IP Address will need to be set, in order to tell the plugin to empty the cache in a specific location. If you\'re using a CDN like Cloudflare or a Firewall Proxy like Sucuri, you will want to set this.', 'varnish-http-purge'); ?></p>
92
  <p><?php _e('Your Varnish IP is just the IP address of the server where Varnish is installed. Your Varnish IP must be one of the IPs that Varnish is listening on. If you use multiple IPs, or if you\'ve customized your ACLs, you\'ll need to pick one that doesn\'t conflict with your other settings. For example, if you have Varnish listening on a public and private IP, pick the private. On the other hand, if you told Varnish to listen on 0.0.0.0 (i.e. "listen on every interface you can") you would need to check what IP you set your purge ACL to allow (commonly 127.0.0.1 aka localhost), and use that (i.e. 127.0.0.1).', 'varnish-http-purge'); ?></p>
93
  <p><?php _e('If your webhost set up Varnish for you, you may need to ask them for the specifics if they don\'t have it documented. I\'ve listed the ones I know about here, however you should still check with them if you\'re not sure.', 'varnish-http-purge'); ?></p>
94
 
174
  } elseif ( isset( $headers['HTTP_X_FORWARDED_FOR'] ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )
175
  ) {
176
  $remote_ip = $headers['HTTP_X_FORWARDED_FOR'];
177
+ } elseif ( strpos( $headers['Server'] ,'cloudflare') !== false ) {
178
+ $remote_ip = 'cloudflare';
179
  } else {
180
  $remote_ip = false;
181
  }
225
  if ( $remote_ip == false && !empty( $varniship) ) {
226
  ?>
227
  <td width="40px"><?php echo $icon_bad; ?></td>
228
+ <td><?php printf( __( 'You have a Varnish IP set but you don\'t appear to be using a proxy like Cloudflare or Sucuri. Or at least we don\'t detect a proxy IP like we expected. You may need to <a href="%s">erase your Varnish IP</a> if you have issues with caches not emptying.', 'varnish-http-purge' ), '#configure' ); ?></td>
229
  <?php
230
  } elseif ( $remote_ip !== false && $remote_ip !== $varniship ) {
231
  ?>
244
  if ( strpos( $headers['Server'] ,'cloudflare') !== false ) {
245
  ?><tr>
246
  <td><?php echo $icon_warning; ?></td>
247
+ <td><?php printf( __( 'Because CloudFlare is running, you may experience some cache oddities. Make sure you <a href="%s">configure WordPress for Cloudflare</a>.', 'varnish-http-purge' ), '#configure' ); ?></td>
248
  </tr><?php
249
  }
250
 
272
  if ( strpos( $headers['Content-Encoding'] ,'Fastly') !== false ) {
273
  ?><tr>
274
  <td><?php echo $icon_good; ?></td>
275
+ <td><?php printf( __( '<a href="%s">Fastly</a> is speeding up your site. Keep in mind, it may cache your CSS and images longer than Varnish does. Remember to empty all caches.', 'varnish-http-purge' ), esc_url('https://fastly.com') ); ?></td>
276
  </tr><?php
277
  }
278
  }