Plugin Directory

Changeset 2512427


Ignore:
Timestamp:
04/09/2021 09:29:46 PM (5 years ago)
Author:
cynderhost
Message:

Update Purge Order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cynderhost/trunk/cynderhost.php

    r2512425 r2512427  
    99 * Plugin URI:        https://cynderhost.com
    1010 * Description:       Provides an easy interface to clear the CynderHost CDN cache, both automatically and programmatically.
    11  * Version:           1.4.8
     11 * Version:           1.4.9
    1212 * Author:            CynderHost
    1313 * Author URI:        https://profiles.wordpress.org/cynderhost/
     
    2424
    2525//Define version
    26 define('CYNDERHOST_VERSION', '1.4.8');
     26define('CYNDERHOST_VERSION', '1.4.9');
    2727
    2828/**
     
    116116    $api_key = $cynderhost_cdn_settings_options['api_key_0'];
    117117    $hostname = $cynderhost_cdn_settings_options['hostname_1'];
    118     //cdn cache multiple urls
    119     $response = wp_remote_post("https://api.cynderhost.com/high-performance/cache/cdn/purge-multiple/", array(
    120         'method' => 'POST',
    121         'timeout' => 0.12,
    122         'redirection' => 5,
    123         'blocking' => false,
    124         'body' => array(
    125             'API' => "$api_key",
    126             'URLS' => json_encode($stripped_urls)
    127         )
    128     ));
    129118    //server cache multiple url
    130119    $response = wp_remote_post("https://api.cynderhost.com/high-performance/cache/local/purge-multiple/", array(
     
    139128        )
    140129    ));
    141     //we don't know the response anyways
    142    
    143     return true;
    144 }
    145 
    146 /**
    147  * Purge CynderHost Server + CDN Cache (Single URL)
    148  * @params (string) url - url of page to purge
    149  * @return bool - returns true
    150  */
    151 function purge_cynderhost_single($url)
    152 {
    153     //strip http added automatically
    154     $url = preg_replace('#^https?://#', '', $url);
    155     $cynderhost_cdn_settings_options = get_option('cynderhost_cdn_settings_option_name'); // Array of All Options
    156     $api_key = $cynderhost_cdn_settings_options['api_key_0'];
    157     $hostname = $cynderhost_cdn_settings_options['hostname_1'];
    158     $stripped_urls = array($url);
    159     //server cache single url
     130
     131    //cdn cache multiple urls
    160132    $response = wp_remote_post("https://api.cynderhost.com/high-performance/cache/cdn/purge-multiple/", array(
    161133        'method' => 'POST',
     
    168140        )
    169141    ));
    170     //server cache multiple url
     142    //we don't know the response anyways
     143   
     144    return true;
     145}
     146
     147/**
     148 * Purge CynderHost Server + CDN Cache (Single URL)
     149 * @params (string) url - url of page to purge
     150 * @return bool - returns true
     151 */
     152function purge_cynderhost_single($url)
     153{
     154    //strip http added automatically
     155    $url = preg_replace('#^https?://#', '', $url);
     156    $cynderhost_cdn_settings_options = get_option('cynderhost_cdn_settings_option_name'); // Array of All Options
     157    $api_key = $cynderhost_cdn_settings_options['api_key_0'];
     158    $hostname = $cynderhost_cdn_settings_options['hostname_1'];
     159    $stripped_urls = array($url);
     160    //server cache single url
    171161    $response = wp_remote_post("https://api.cynderhost.com/high-performance/cache/local/purge-multiple/", array(
    172162        'method' => 'POST',
     
    177167            'API' => "$api_key",
    178168            "HOST" => $hostname,
     169            'URLS' => json_encode($stripped_urls)
     170        )
     171    ));
     172    //cdn cache single url
     173    $response = wp_remote_post("https://api.cynderhost.com/high-performance/cache/cdn/purge-multiple/", array(
     174        'method' => 'POST',
     175        'timeout' => 0.12,
     176        'redirection' => 5,
     177        'blocking' => false,
     178        'body' => array(
     179            'API' => "$api_key",
    179180            'URLS' => json_encode($stripped_urls)
    180181        )
Note: See TracChangeset for help on using the changeset viewer.