Changeset 3180223
- Timestamp:
- 11/02/2024 01:51:05 AM (17 months ago)
- Location:
- blizhost-cache-purge
- Files:
-
- 17 added
- 5 edited
-
tags/4.0.6/wp-cli.php (modified) (1 diff)
-
tags/5.0.0/wp-cli.php (modified) (1 diff)
-
tags/5.0.1 (added)
-
tags/5.0.1/blizhost-cache-purge.php (added)
-
tags/5.0.1/font (added)
-
tags/5.0.1/font/blizhost_logo.eot (added)
-
tags/5.0.1/font/blizhost_logo.svg (added)
-
tags/5.0.1/font/blizhost_logo.ttf (added)
-
tags/5.0.1/font/blizhost_logo.woff (added)
-
tags/5.0.1/font/index.php (added)
-
tags/5.0.1/font/style.css (added)
-
tags/5.0.1/js (added)
-
tags/5.0.1/js/bliz-purge.js (added)
-
tags/5.0.1/js/index.php (added)
-
tags/5.0.1/lang (added)
-
tags/5.0.1/lang/blizhost-cache-purge.pot (added)
-
tags/5.0.1/lang/index.php (added)
-
tags/5.0.1/readme.txt (added)
-
tags/5.0.1/wp-cli.php (added)
-
trunk/blizhost-cache-purge.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-cli.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
blizhost-cache-purge/tags/4.0.6/wp-cli.php
r3180208 r3180223 1 1 <?php 2 2 3 if ( !defined('ABSPATH')) {4 die();3 if ( ! defined( 'ABSPATH' ) ) { 4 die(); 5 5 } 6 6 7 7 // Bail if WP-CLI is not present 8 if ( !defined( 'WP_CLI' ) ) return; 8 if ( ! defined( 'WP_CLI' ) ) { 9 return; 10 } 9 11 10 12 /** 11 * Purges CloudCache 13 * Purges CloudCache using WP-CLI commands. 12 14 */ 13 class WP_CLI_BlizC Cache_Purge_Command extends WP_CLI_Command {15 class WP_CLI_BlizCloudCache_Purge_Command extends WP_CLI_Command { 14 16 15 private $wildcard = false; 17 /** 18 * Instance of the BlizCloudCachePurger class. 19 * 20 * @var BlizCloudCachePurger 21 */ 22 private $ccache_purge; 16 23 24 /** 25 * Constructor. 26 */ 17 27 public function __construct() { 18 $this->ccache_purge = new BlizC CachePurger();28 $this->ccache_purge = new BlizCloudCachePurger(); 19 29 } 20 21 /** 22 * Forces a full CloudCache Purge of the entire site (provided 23 * regex is supported). 24 * 25 * ## EXAMPLES 26 * 27 * wp ccache purge 28 * 29 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 30 * 31 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 30 31 /** 32 * Forces a CloudCache purge of the specified URL or the entire site. 32 33 * 33 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 34 * 35 * wp ccache purge "/wp-content/themes/" --wildcard 36 * 37 */ 38 39 function purge( $args , $assoc_args ) { 40 41 $wp_version = get_bloginfo( 'version' ); 42 $cli_version = WP_CLI_VERSION; 43 34 * ## OPTIONS 35 * 36 * [<url>] 37 * : The URL to purge from the cache. If omitted, the entire cache will be purged. 38 * 39 * [--wildcard] 40 * : Purge using a wildcard, purging all URLs under the specified path. 41 * 42 * ## EXAMPLES 43 * 44 * wp ccache purge 45 * 46 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 47 * 48 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 49 * 50 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 51 * 52 * wp ccache purge "/wp-content/themes/" --wildcard 53 * 54 * @synopsis [<url>] [--wildcard] 55 * 56 * @param array $args The URL argument. 57 * @param array $assoc_args The associative arguments. 58 */ 59 public function purge( $args, $assoc_args ) { 44 60 // Set the URL/path 45 if ( !empty($args) ) { list( $url ) = $args; } 46 47 // If wildcard is set, or the URL argument is empty 48 // then treat this as a full purge 49 $wild = ''; 50 if ( isset( $assoc_args['wildcard'] ) || empty($url) ) { 51 $wild = ".*"; 61 $url = ''; 62 if ( ! empty( $args ) ) { 63 $url = $args[0]; 52 64 } 53 65 54 wp_create_nonce('ccache-purge-cli'); 66 // If the URL argument is empty, treat this as a full purge 67 if ( empty( $url ) ) { 68 $this->ccache_purge->do_full_purge = true; 69 } else { 70 // Make sure the URL is a full URL 71 if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { 72 $url = home_url( '/' . ltrim( $url, '/' ) ); 73 } 55 74 56 // Make sure the URL is a URL: 57 if ( !empty($url) ) { 58 $url = $this->ccache_purge->the_home_url() . esc_url( $url ); 59 } else { 60 $url = $this->ccache_purge->the_home_url(); 61 } 62 63 if ( version_compare( $wp_version, '4.6', '>=' ) && ( version_compare( $cli_version, '0.25.0', '<' ) || version_compare( $cli_version, '0.25.0-alpha', 'eq' ) ) ) { 64 65 WP_CLI::log( sprintf( 'This plugin does not work on WP 4.6 and up, unless WP-CLI is version 0.25.0 or greater. You\'re using WP-CLI %s and WordPress %s.', $cli_version, $wp_version ) ); 66 WP_CLI::log( 'To flush your cache, please run the following command:'); 67 WP_CLI::log( sprintf( '$ curl -X PURGE "%s"' , $url.$wild ) ); 68 WP_CLI::error( 'CloudCache must be purged manually.' ); 75 // If wildcard is set, append '.*' to the path 76 if ( isset( $assoc_args['wildcard'] ) ) { 77 // Parse the URL to manipulate the path 78 $parsed_url = wp_parse_url( $url ); 79 $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; 80 81 // Ensure the path ends with '/' before appending '.*' 82 if ( substr( $path, -1 ) !== '/' ) { 83 $path .= '/'; 84 } 85 $path .= '.*'; 86 87 // Reconstruct the URL with the modified path 88 $url = ( isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '' ) 89 . ( isset( $parsed_url['host'] ) ? $parsed_url['host'] : '' ) 90 . $path; 91 } 92 93 // Add the URL to the purge list 94 $this->ccache_purge->purgeUrls[] = $url; 69 95 } 70 96 71 $this->ccache_purge->purgeUrl( $url.$wild ); 97 // Execute the purge 98 $this->ccache_purge->blizexecutePurge(); 72 99 73 100 WP_CLI::success( 'The CloudCache was purged.' ); 74 101 } 75 76 102 } 77 103 78 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizC Cache_Purge_Command' );104 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCloudCache_Purge_Command' ); -
blizhost-cache-purge/tags/5.0.0/wp-cli.php
r3180208 r3180223 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' )) {4 die();3 if (!defined('ABSPATH')) { 4 die(); 5 5 } 6 6 7 7 // Bail if WP-CLI is not present 8 if ( ! defined( 'WP_CLI' ) ) { 9 return; 10 } 8 if ( !defined( 'WP_CLI' ) ) return; 11 9 12 10 /** 13 * Purges CloudCache using WP-CLI commands.11 * Purges CloudCache 14 12 */ 15 class WP_CLI_BlizC loudCache_Purge_Command extends WP_CLI_Command {13 class WP_CLI_BlizCCache_Purge_Command extends WP_CLI_Command { 16 14 17 /** 18 * Instance of the BlizCloudCachePurger class. 15 private $wildcard = false; 16 17 public function __construct() { 18 $this->ccache_purge = new BlizCCachePurger(); 19 } 20 21 /** 22 * Forces a full CloudCache Purge of the entire site (provided 23 * regex is supported). 24 * 25 * ## EXAMPLES 26 * 27 * wp ccache purge 28 * 29 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 30 * 31 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 19 32 * 20 * @var BlizCloudCachePurger 21 */ 22 private $ccache_purge; 33 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 34 * 35 * wp ccache purge "/wp-content/themes/" --wildcard 36 * 37 */ 38 39 function purge( $args , $assoc_args ) { 40 41 $wp_version = get_bloginfo( 'version' ); 42 $cli_version = WP_CLI_VERSION; 43 44 // Set the URL/path 45 if ( !empty($args) ) { list( $url ) = $args; } 23 46 24 /** 25 * Constructor. 26 */ 27 public function __construct() { 28 $this->ccache_purge = new BlizCloudCachePurger(); 29 } 30 31 /** 32 * Forces a CloudCache purge of the specified URL or the entire site. 33 * 34 * ## OPTIONS 35 * 36 * [<url>] 37 * : The URL to purge from the cache. If omitted, the entire cache will be purged. 38 * 39 * [--wildcard] 40 * : Purge using a wildcard, purging all URLs under the specified path. 41 * 42 * ## EXAMPLES 43 * 44 * wp ccache purge 45 * 46 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 47 * 48 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 49 * 50 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 51 * 52 * wp ccache purge "/wp-content/themes/" --wildcard 53 * 54 * @synopsis [<url>] [--wildcard] 55 * 56 * @param array $args The URL argument. 57 * @param array $assoc_args The associative arguments. 58 */ 59 public function purge( $args, $assoc_args ) { 60 // Set the URL/path 61 $url = ''; 62 if ( ! empty( $args ) ) { 63 $url = $args[0]; 47 // If wildcard is set, or the URL argument is empty 48 // then treat this as a full purge 49 $wild = ''; 50 if ( isset( $assoc_args['wildcard'] ) || empty($url) ) { 51 $wild = ".*"; 64 52 } 65 53 66 // If the URL argument is empty, treat this as a full purge 67 if ( empty( $url ) ) { 68 $this->ccache_purge->do_full_purge = true; 54 wp_create_nonce('ccache-purge-cli'); 55 56 // Make sure the URL is a URL: 57 if ( !empty($url) ) { 58 $url = $this->ccache_purge->the_home_url() . esc_url( $url ); 69 59 } else { 70 // Make sure the URL is a full URL 71 if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { 72 $url = home_url( '/' . ltrim( $url, '/' ) ); 73 } 74 75 // If wildcard is set, append '.*' to the path 76 if ( isset( $assoc_args['wildcard'] ) ) { 77 // Parse the URL to manipulate the path 78 $parsed_url = wp_parse_url( $url ); 79 $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; 80 81 // Ensure the path ends with '/' before appending '.*' 82 if ( substr( $path, -1 ) !== '/' ) { 83 $path .= '/'; 84 } 85 $path .= '.*'; 86 87 // Reconstruct the URL with the modified path 88 $url = ( isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '' ) 89 . ( isset( $parsed_url['host'] ) ? $parsed_url['host'] : '' ) 90 . $path; 91 } 92 93 // Add the URL to the purge list 94 $this->ccache_purge->purgeUrls[] = $url; 60 $url = $this->ccache_purge->the_home_url(); 61 } 62 63 if ( version_compare( $wp_version, '4.6', '>=' ) && ( version_compare( $cli_version, '0.25.0', '<' ) || version_compare( $cli_version, '0.25.0-alpha', 'eq' ) ) ) { 64 65 WP_CLI::log( sprintf( 'This plugin does not work on WP 4.6 and up, unless WP-CLI is version 0.25.0 or greater. You\'re using WP-CLI %s and WordPress %s.', $cli_version, $wp_version ) ); 66 WP_CLI::log( 'To flush your cache, please run the following command:'); 67 WP_CLI::log( sprintf( '$ curl -X PURGE "%s"' , $url.$wild ) ); 68 WP_CLI::error( 'CloudCache must be purged manually.' ); 95 69 } 96 70 97 // Execute the purge 98 $this->ccache_purge->blizexecutePurge(); 71 $this->ccache_purge->purgeUrl( $url.$wild ); 99 72 100 73 WP_CLI::success( 'The CloudCache was purged.' ); 101 74 } 75 102 76 } 103 77 104 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizC loudCache_Purge_Command' );78 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCCache_Purge_Command' ); -
blizhost-cache-purge/trunk/blizhost-cache-purge.php
r3180216 r3180223 4 4 Plugin URI: https://www.blizhost.com 5 5 Description: Automatic Cache Clearing and CloudCache Integration to Boost Speed and Protect Your Site with Enhanced Security. 6 Version: 5.0. 06 Version: 5.0.1 7 7 Author: Blizhost 8 8 Author URI: https://www.blizhost.com … … 24 24 protected $purgeUrls = array(); // URLs to be purged 25 25 protected $processedPosts = array(); // Posts that have been processed 26 public $p_version = '5.0. 0'; // Plugin version26 public $p_version = '5.0.1'; // Plugin version 27 27 public $do_full_purge = false; // Flag to trigger a full cache purge 28 28 -
blizhost-cache-purge/trunk/readme.txt
r3180217 r3180223 5 5 Tested up to: 6.7 6 6 Requires PHP: 5.6 7 Stable tag: 5.0. 07 Stable tag: 5.0.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 102 102 103 103 == Changelog == 104 105 = 5.0.1 = 106 * Fix outdated wp-cli 104 107 105 108 = 5.0.0 = -
blizhost-cache-purge/trunk/wp-cli.php
r3180199 r3180223 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' )) {4 die();3 if (!defined('ABSPATH')) { 4 die(); 5 5 } 6 6 7 7 // Bail if WP-CLI is not present 8 if ( ! defined( 'WP_CLI' ) ) { 9 return; 10 } 8 if ( !defined( 'WP_CLI' ) ) return; 11 9 12 10 /** 13 * Purges CloudCache using WP-CLI commands.11 * Purges CloudCache 14 12 */ 15 class WP_CLI_BlizC loudCache_Purge_Command extends WP_CLI_Command {13 class WP_CLI_BlizCCache_Purge_Command extends WP_CLI_Command { 16 14 17 /** 18 * Instance of the BlizCloudCachePurger class. 15 private $wildcard = false; 16 17 public function __construct() { 18 $this->ccache_purge = new BlizCCachePurger(); 19 } 20 21 /** 22 * Forces a full CloudCache Purge of the entire site (provided 23 * regex is supported). 24 * 25 * ## EXAMPLES 26 * 27 * wp ccache purge 28 * 29 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 30 * 31 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 19 32 * 20 * @var BlizCloudCachePurger 21 */ 22 private $ccache_purge; 33 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 34 * 35 * wp ccache purge "/wp-content/themes/" --wildcard 36 * 37 */ 38 39 function purge( $args , $assoc_args ) { 40 41 $wp_version = get_bloginfo( 'version' ); 42 $cli_version = WP_CLI_VERSION; 43 44 // Set the URL/path 45 if ( !empty($args) ) { list( $url ) = $args; } 23 46 24 /** 25 * Constructor. 26 */ 27 public function __construct() { 28 $this->ccache_purge = new BlizCloudCachePurger(); 29 } 30 31 /** 32 * Forces a CloudCache purge of the specified URL or the entire site. 33 * 34 * ## OPTIONS 35 * 36 * [<url>] 37 * : The URL to purge from the cache. If omitted, the entire cache will be purged. 38 * 39 * [--wildcard] 40 * : Purge using a wildcard, purging all URLs under the specified path. 41 * 42 * ## EXAMPLES 43 * 44 * wp ccache purge 45 * 46 * wp ccache purge http://example.com/wp-content/themes/twentyeleventy/style.css 47 * 48 * wp ccache purge "/wp-content/themes/twentysixty/style.css" 49 * 50 * wp ccache purge http://example.com/wp-content/themes/ --wildcard 51 * 52 * wp ccache purge "/wp-content/themes/" --wildcard 53 * 54 * @synopsis [<url>] [--wildcard] 55 * 56 * @param array $args The URL argument. 57 * @param array $assoc_args The associative arguments. 58 */ 59 public function purge( $args, $assoc_args ) { 60 // Set the URL/path 61 $url = ''; 62 if ( ! empty( $args ) ) { 63 $url = $args[0]; 47 // If wildcard is set, or the URL argument is empty 48 // then treat this as a full purge 49 $wild = ''; 50 if ( isset( $assoc_args['wildcard'] ) || empty($url) ) { 51 $wild = ".*"; 64 52 } 65 53 66 // If the URL argument is empty, treat this as a full purge 67 if ( empty( $url ) ) { 68 $this->ccache_purge->do_full_purge = true; 54 wp_create_nonce('ccache-purge-cli'); 55 56 // Make sure the URL is a URL: 57 if ( !empty($url) ) { 58 $url = $this->ccache_purge->the_home_url() . esc_url( $url ); 69 59 } else { 70 // Make sure the URL is a full URL 71 if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { 72 $url = home_url( '/' . ltrim( $url, '/' ) ); 73 } 74 75 // If wildcard is set, append '.*' to the path 76 if ( isset( $assoc_args['wildcard'] ) ) { 77 // Parse the URL to manipulate the path 78 $parsed_url = wp_parse_url( $url ); 79 $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; 80 81 // Ensure the path ends with '/' before appending '.*' 82 if ( substr( $path, -1 ) !== '/' ) { 83 $path .= '/'; 84 } 85 $path .= '.*'; 86 87 // Reconstruct the URL with the modified path 88 $url = ( isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '' ) 89 . ( isset( $parsed_url['host'] ) ? $parsed_url['host'] : '' ) 90 . $path; 91 } 92 93 // Add the URL to the purge list 94 $this->ccache_purge->purgeUrls[] = $url; 60 $url = $this->ccache_purge->the_home_url(); 61 } 62 63 if ( version_compare( $wp_version, '4.6', '>=' ) && ( version_compare( $cli_version, '0.25.0', '<' ) || version_compare( $cli_version, '0.25.0-alpha', 'eq' ) ) ) { 64 65 WP_CLI::log( sprintf( 'This plugin does not work on WP 4.6 and up, unless WP-CLI is version 0.25.0 or greater. You\'re using WP-CLI %s and WordPress %s.', $cli_version, $wp_version ) ); 66 WP_CLI::log( 'To flush your cache, please run the following command:'); 67 WP_CLI::log( sprintf( '$ curl -X PURGE "%s"' , $url.$wild ) ); 68 WP_CLI::error( 'CloudCache must be purged manually.' ); 95 69 } 96 70 97 // Execute the purge 98 $this->ccache_purge->blizexecutePurge(); 71 $this->ccache_purge->purgeUrl( $url.$wild ); 99 72 100 73 WP_CLI::success( 'The CloudCache was purged.' ); 101 74 } 75 102 76 } 103 77 104 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizC loudCache_Purge_Command' );78 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCCache_Purge_Command' );
Note: See TracChangeset
for help on using the changeset viewer.