Plugin Directory

Changeset 3180223


Ignore:
Timestamp:
11/02/2024 01:51:05 AM (17 months ago)
Author:
blizhost
Message:

Release version 5.0.1

Location:
blizhost-cache-purge
Files:
17 added
5 edited

Legend:

Unmodified
Added
Removed
  • blizhost-cache-purge/tags/4.0.6/wp-cli.php

    r3180208 r3180223  
    11<?php
    22
    3 if (!defined('ABSPATH')) {
    4     die();
     3if ( ! defined( 'ABSPATH' ) ) {
     4    die();
    55}
    66
    77// Bail if WP-CLI is not present
    8 if ( !defined( 'WP_CLI' ) ) return;
     8if ( ! defined( 'WP_CLI' ) ) {
     9    return;
     10}
    911
    1012/**
    11  * Purges CloudCache
     13 * Purges CloudCache using WP-CLI commands.
    1214 */
    13 class WP_CLI_BlizCCache_Purge_Command extends WP_CLI_Command {
     15class WP_CLI_BlizCloudCache_Purge_Command extends WP_CLI_Command {
    1416
    15     private $wildcard = false;
     17    /**
     18     * Instance of the BlizCloudCachePurger class.
     19     *
     20     * @var BlizCloudCachePurger
     21     */
     22    private $ccache_purge;
    1623
     24    /**
     25     * Constructor.
     26     */
    1727    public function __construct() {
    18         $this->ccache_purge = new BlizCCachePurger();
     28        $this->ccache_purge = new BlizCloudCachePurger();
    1929    }
    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.
    3233     *
    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 ) {
    4460        // 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];
    5264        }
    5365
    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            }
    5574
    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;
    6995        }
    7096
    71         $this->ccache_purge->purgeUrl( $url.$wild );
     97        // Execute the purge
     98        $this->ccache_purge->blizexecutePurge();
    7299
    73100        WP_CLI::success( 'The CloudCache was purged.' );
    74101    }
    75 
    76102}
    77103
    78 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCCache_Purge_Command' );
     104WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCloudCache_Purge_Command' );
  • blizhost-cache-purge/tags/5.0.0/wp-cli.php

    r3180208 r3180223  
    11<?php
    22
    3 if ( ! defined( 'ABSPATH' ) ) {
    4     die();
     3if (!defined('ABSPATH')) {
     4    die();
    55}
    66
    77// Bail if WP-CLI is not present
    8 if ( ! defined( 'WP_CLI' ) ) {
    9     return;
    10 }
     8if ( !defined( 'WP_CLI' ) ) return;
    119
    1210/**
    13  * Purges CloudCache using WP-CLI commands.
     11 * Purges CloudCache
    1412 */
    15 class WP_CLI_BlizCloudCache_Purge_Command extends WP_CLI_Command {
     13class WP_CLI_BlizCCache_Purge_Command extends WP_CLI_Command {
    1614
    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"
    1932     *
    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; }
    2346
    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 = ".*";
    6452        }
    6553
    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 );
    6959        } 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.' );
    9569        }
    9670
    97         // Execute the purge
    98         $this->ccache_purge->blizexecutePurge();
     71        $this->ccache_purge->purgeUrl( $url.$wild );
    9972
    10073        WP_CLI::success( 'The CloudCache was purged.' );
    10174    }
     75
    10276}
    10377
    104 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCloudCache_Purge_Command' );
     78WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCCache_Purge_Command' );
  • blizhost-cache-purge/trunk/blizhost-cache-purge.php

    r3180216 r3180223  
    44Plugin URI: https://www.blizhost.com
    55Description: Automatic Cache Clearing and CloudCache Integration to Boost Speed and Protect Your Site with Enhanced Security.
    6 Version: 5.0.0
     6Version: 5.0.1
    77Author: Blizhost
    88Author URI: https://www.blizhost.com
     
    2424    protected $purgeUrls = array();         // URLs to be purged
    2525    protected $processedPosts = array();    // Posts that have been processed
    26     public $p_version = '5.0.0';            // Plugin version
     26    public $p_version = '5.0.1';            // Plugin version
    2727    public $do_full_purge = false;          // Flag to trigger a full cache purge
    2828   
  • blizhost-cache-purge/trunk/readme.txt

    r3180217 r3180223  
    55Tested up to: 6.7
    66Requires PHP: 5.6
    7 Stable tag: 5.0.0
     7Stable tag: 5.0.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    102102
    103103== Changelog ==
     104
     105= 5.0.1 =
     106* Fix outdated wp-cli
    104107
    105108= 5.0.0 =
  • blizhost-cache-purge/trunk/wp-cli.php

    r3180199 r3180223  
    11<?php
    22
    3 if ( ! defined( 'ABSPATH' ) ) {
    4     die();
     3if (!defined('ABSPATH')) {
     4    die();
    55}
    66
    77// Bail if WP-CLI is not present
    8 if ( ! defined( 'WP_CLI' ) ) {
    9     return;
    10 }
     8if ( !defined( 'WP_CLI' ) ) return;
    119
    1210/**
    13  * Purges CloudCache using WP-CLI commands.
     11 * Purges CloudCache
    1412 */
    15 class WP_CLI_BlizCloudCache_Purge_Command extends WP_CLI_Command {
     13class WP_CLI_BlizCCache_Purge_Command extends WP_CLI_Command {
    1614
    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"
    1932     *
    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; }
    2346
    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 = ".*";
    6452        }
    6553
    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 );
    6959        } 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.' );
    9569        }
    9670
    97         // Execute the purge
    98         $this->ccache_purge->blizexecutePurge();
     71        $this->ccache_purge->purgeUrl( $url.$wild );
    9972
    10073        WP_CLI::success( 'The CloudCache was purged.' );
    10174    }
     75
    10276}
    10377
    104 WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCloudCache_Purge_Command' );
     78WP_CLI::add_command( 'ccache', 'WP_CLI_BlizCCache_Purge_Command' );
Note: See TracChangeset for help on using the changeset viewer.