Varnish HTTP Purge - Version 4.7.2

Version Description

  • October 2018
  • Fix regression with IP function name
  • Restore "Right Now" activity box only for people who use WP.com toolbar
Download this release

Release Info

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

Code changes from version 4.7.1 to 4.7.2

Files changed (5) hide show
  1. debug.php +0 -1
  2. readme.txt +18 -10
  3. settings.php +0 -2
  4. uninstall.php +1 -13
  5. varnish-http-purge.php +43 -3
debug.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
  /**
3
  * Debug Code
4
- *
5
  * @package varnish-http-purge
6
  */
7
 
1
  <?php
2
  /**
3
  * Debug Code
 
4
  * @package varnish-http-purge
5
  */
6
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Ipstenu, mikeschroder, techpriester, danielbachhuber
3
  Tags: proxy, purge, cache, varnish, nginx
4
  Requires at least: 4.7
5
- Tested up to: 4.9
6
- Stable tag: 4.7.1
7
  Requires PHP: 5.6
8
 
9
  Automatically empty proxy cached content when your site is modified.
@@ -60,6 +60,8 @@ By default, no data is tracked. If you use the site scanner/debugging tool, your
60
 
61
  Use of this service is required for the cache checking in order to provide up to date compatibility checks on plugins and themes that may conflict with running a server based cache without needing to update the plugin every day.
62
 
 
 
63
  == Installation ==
64
 
65
  No special instructions apply.
@@ -71,7 +73,7 @@ When using Nginx based proxies, your IP will likely be `localhost`.
71
  = Requirements =
72
 
73
  * Pretty Permalinks enabled
74
- * A server based proxy cache service
75
 
76
  == Frequently Asked Questions ==
77
 
@@ -99,7 +101,7 @@ No. WordPress can't detect those file changes so it can't tell your cache what t
99
 
100
  = Does every WordPress plugin and theme work with a proxy cache? =
101
 
102
- No. Some of them have behaviour that causes them not to cache, either by accident or design.
103
 
104
  = I'm a developer, can I tell your cache to empty in my plugin/theme? =
105
 
@@ -121,7 +123,7 @@ It is _not_ recommended you use development mode on production sites for extende
121
 
122
  = Why don't I have access to development mode? =
123
 
124
- Due to the damage this can cause a site, access is limited to admins only. In the case of a multisite network, only <em>Network Admins</em> can disable caching.
125
 
126
  = Why do I still see cached content in development mode? =
127
 
@@ -157,9 +159,9 @@ Your proxy IP must be one of the IPs that the service is listening on. If you us
157
 
158
  For example, if you have a Varnish based cache and it's listening on a public and private IP, you'll want to 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).
159
 
160
- If your webhost set up your service, check their documentation.
161
 
162
- = What if I have multiple varnish IPs? =
163
 
164
  Multiple IPs are not supported at this time.
165
 
@@ -169,7 +171,7 @@ This was built and tested on Varnish 3.x. While it is reported to work on 2.x an
169
 
170
  = Does this work with Nginx caching? =
171
 
172
- It can, if you've configured nginx caching to respect the curl PURGE request. If this doesn't work, I recommend setting your Varnish IP to `localhost` as Nginx requires a service control installed for the IP address to work.
173
 
174
  = What should my cache rules be? =
175
 
@@ -177,11 +179,12 @@ This is a question beyond the support of plugin. I do not have the resources ava
177
 
178
  * To empty any cached data, the service will need to respect the PURGE command
179
  * Not all cache services set up PURGE by default
180
- * When flushing the whole cache, the plugin sends a PURGE command of <code>/.*</code> and sets the `X-Purge-Method` header to `regex`.
 
181
 
182
  = How can I see what the plugin is sending to the cache service? =
183
 
184
- Yes _IF_ the service has an interface. Sadly Nginx doesn't. [Detailed directions can be found on the debugging section on GitHub](https://github.com/Ipstenu/varnish-http-purge/wiki#debugging). Bear in mind, these interfaces tend to be command-line only.
185
 
186
  = Don't you work at DreamHost? Is this Official or DreamHost only? =
187
 
@@ -192,6 +195,11 @@ This plugin is installed by default for _all_ DreamPress installs on DreamHost,
192
 
193
  == Changelog ==
194
 
 
 
 
 
 
195
  = 4.7.1 =
196
  * October 2018
197
  * Documentation: Cleaning up language and spelling
2
  Contributors: Ipstenu, mikeschroder, techpriester, danielbachhuber
3
  Tags: proxy, purge, cache, varnish, nginx
4
  Requires at least: 4.7
5
+ Tested up to: 5.0
6
+ Stable tag: 4.7.2
7
  Requires PHP: 5.6
8
 
9
  Automatically empty proxy cached content when your site is modified.
60
 
61
  Use of this service is required for the cache checking in order to provide up to date compatibility checks on plugins and themes that may conflict with running a server based cache without needing to update the plugin every day.
62
 
63
+ <em>No visitor information from your site is tracked.</em>
64
+
65
  == Installation ==
66
 
67
  No special instructions apply.
73
  = Requirements =
74
 
75
  * Pretty Permalinks enabled
76
+ * A server based proxy cache service (such as Varnish or Nginx)
77
 
78
  == Frequently Asked Questions ==
79
 
101
 
102
  = Does every WordPress plugin and theme work with a proxy cache? =
103
 
104
+ No. Some of them have behavior that causes them not to cache, either by accident or design.
105
 
106
  = I'm a developer, can I tell your cache to empty in my plugin/theme? =
107
 
123
 
124
  = Why don't I have access to development mode? =
125
 
126
+ Due to the damage this can cause a site, access is limited to admins only. In the case of a multisite network, only <em>Network Admins</em> can disable caching and they must do so via `wp-config.php` for security.
127
 
128
  = Why do I still see cached content in development mode? =
129
 
159
 
160
  For example, if you have a Varnish based cache and it's listening on a public and private IP, you'll want to 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).
161
 
162
+ If your web host set up your service, check their documentation.
163
 
164
+ = What if I have multiple proxy cache IPs? =
165
 
166
  Multiple IPs are not supported at this time.
167
 
171
 
172
  = Does this work with Nginx caching? =
173
 
174
+ It can, if you've configured Nginx caching to respect the curl PURGE request. If this doesn't work, I recommend setting your Varnish IP to `localhost` as Nginx requires a service control installed for the IP address to work.
175
 
176
  = What should my cache rules be? =
177
 
179
 
180
  * To empty any cached data, the service will need to respect the PURGE command
181
  * Not all cache services set up PURGE by default
182
+ * When flushing the whole cache, the plugin sends a PURGE command of <code>/.*</code> and sets the `X-Purge-Method` header to `regex`
183
+ * Nginx expects the IP address to be 'localhost'
184
 
185
  = How can I see what the plugin is sending to the cache service? =
186
 
187
+ Yes _IF_ the service has an interface. Sadly Nginx does not. [Detailed directions can be found on the debugging section on GitHub](https://github.com/Ipstenu/varnish-http-purge/wiki#debugging). Bear in mind, these interfaces tend to be command-line only.
188
 
189
  = Don't you work at DreamHost? Is this Official or DreamHost only? =
190
 
195
 
196
  == Changelog ==
197
 
198
+ = 4.7.2 =
199
+ * October 2018
200
+ * Fix regression with IP function name
201
+ * Restore "Right Now" activity box _only_ for people who use WP.com toolbar
202
+
203
  = 4.7.1 =
204
  * October 2018
205
  * Documentation: Cleaning up language and spelling
settings.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
  /**
3
- *
4
  * Settings Code
5
- *
6
  * @package varnish-http-purge
7
  */
8
 
1
  <?php
2
  /**
 
3
  * Settings Code
 
4
  * @package varnish-http-purge
5
  */
6
 
uninstall.php CHANGED
@@ -1,20 +1,8 @@
1
  <?php
2
  /**
3
  * Uninstall
4
- *
5
  * @package varnish-http-purge
6
- *
7
- * Copyright 2016-2018 Mika Epstein (email: ipstenu@halfelf.org)
8
- *
9
- * This file is part of Proxy Cache Purge, a plugin for WordPress.
10
- *
11
- * Proxy Cache Purge is free software: you can redistribute it and/or modify
12
- * it under the terms of the Apache License 2.0 license.
13
- *
14
- * Proxy Cache Purge is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
- */
18
 
19
  if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
20
  exit();
1
  <?php
2
  /**
3
  * Uninstall
 
4
  * @package varnish-http-purge
5
+ */
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
8
  exit();
varnish-http-purge.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Proxy Cache Purge
4
  * Plugin URI: https://halfelf.org/plugins/varnish-http-purge/
5
  * Description: Automatically empty cached pages when content on your site is modified.
6
- * Version: 4.7.1
7
  * Author: Mika Epstein
8
  * Author URI: https://halfelf.org/
9
  * License: http://www.apache.org/licenses/LICENSE-2.0
@@ -35,7 +35,7 @@ class VarnishPurger {
35
  * Version Number
36
  * @var string
37
  */
38
- public static $version = '4.7.0';
39
 
40
  /**
41
  * List of URLs to be purged
@@ -101,6 +101,11 @@ class VarnishPurger {
101
  */
102
  public function admin_init() {
103
 
 
 
 
 
 
104
  // Failure: Pre WP 4.7.
105
  if ( version_compare( get_bloginfo( 'version' ), '4.7', '<=' ) ) {
106
  deactivate_plugins( plugin_basename( __FILE__ ) );
@@ -409,6 +414,41 @@ class VarnishPurger {
409
  return $svg;
410
  }
411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  /**
413
  * Registered Events
414
  * These are when the purge is triggered
@@ -572,7 +612,7 @@ class VarnishPurger {
572
 
573
  $parsed_url = $url;
574
  // Filter URL based on the Proxy IP for nginx compatibility
575
- if ( 'localhost' === $proxy_ip ) {
576
  $parsed_url = str_replace( $p['host'], 'localhost', $parsed_url );
577
  }
578
 
3
  * Plugin Name: Proxy Cache Purge
4
  * Plugin URI: https://halfelf.org/plugins/varnish-http-purge/
5
  * Description: Automatically empty cached pages when content on your site is modified.
6
+ * Version: 4.7.2
7
  * Author: Mika Epstein
8
  * Author URI: https://halfelf.org/
9
  * License: http://www.apache.org/licenses/LICENSE-2.0
35
  * Version Number
36
  * @var string
37
  */
38
+ public static $version = '4.7.2';
39
 
40
  /**
41
  * List of URLs to be purged
101
  */
102
  public function admin_init() {
103
 
104
+ // If WordPress.com Master Bar is active, show the activity box.
105
+ if ( is_plugin_active( 'jetpack/jetpack.php' ) && Jetpack::is_module_active( 'masterbar' ) ) {
106
+ add_action( 'activity_box_end', array( $this, 'varnish_rightnow' ), 100 );
107
+ }
108
+
109
  // Failure: Pre WP 4.7.
110
  if ( version_compare( get_bloginfo( 'version' ), '4.7', '<=' ) ) {
111
  deactivate_plugins( plugin_basename( __FILE__ ) );
414
  return $svg;
415
  }
416
 
417
+ /**
418
+ * Varnish Right Now Information
419
+ * This information is put on the Dashboard 'Right now' widget
420
+ *
421
+ * @since 1.0
422
+ */
423
+ public function varnish_rightnow() {
424
+ global $blog_id;
425
+ // translators: %1$s links to the plugin's page on WordPress.org.
426
+ $intro = sprintf( __( '<a href="%1$s">Proxy Cache Purge</a> automatically deletes your cached posts when published or updated. When making major site changes, such as with a new theme, plugins, or widgets, you may need to manually empty the cache.', 'varnish-http-purge' ), 'http://wordpress.org/plugins/varnish-http-purge/' );
427
+ $url = wp_nonce_url( add_query_arg( 'vhp_flush_do', 'all' ), 'vhp-flush-do' );
428
+ $button = __( 'Press the button below to force it to empty your entire Varnish cache.', 'varnish-http-purge' );
429
+ $button .= '</p><p><span class="button"><strong><a href="' . $url . '">';
430
+ $button .= __( 'Empty Cache', 'varnish-http-purge' );
431
+ $button .= '</a></strong></span>';
432
+ $nobutton = __( 'You do not have permission to empty the proxy cache for the whole site. Please contact your administrator.', 'varnish-http-purge' );
433
+ if (
434
+ // SingleSite - admins can always purge.
435
+ ( ! is_multisite() && current_user_can( 'activate_plugins' ) ) ||
436
+ // Multisite - Network Admin can always purge.
437
+ current_user_can( 'manage_network' ) ||
438
+ // Multisite - Site admins can purge UNLESS it's a subfolder install and we're on site #1.
439
+ ( is_multisite() && current_user_can( 'activate_plugins' ) && ( SUBDOMAIN_INSTALL || ( ! SUBDOMAIN_INSTALL && ( BLOG_ID_CURRENT_SITE !== $blog_id ) ) ) )
440
+ ) {
441
+ $text = $intro . ' ' . $button;
442
+ } else {
443
+ $text = $intro . ' ' . $nobutton;
444
+ }
445
+ // @codingStandardsIgnoreStart
446
+ // This is safe to echo as it's controlled and secured above.
447
+ // Using wp_kses will delete the icon.
448
+ echo '<p class="varnish-rightnow">' . $text . '</p>';
449
+ // @codingStandardsIgnoreEnd
450
+ }
451
+
452
  /**
453
  * Registered Events
454
  * These are when the purge is triggered
612
 
613
  $parsed_url = $url;
614
  // Filter URL based on the Proxy IP for nginx compatibility
615
+ if ( 'localhost' === $varniship ) {
616
  $parsed_url = str_replace( $p['host'], 'localhost', $parsed_url );
617
  }
618