PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / trunk
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript vtrunk
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / BerqWP / src / CDN.php

CDN.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript trunk, at BerqWP/src/CDN.php

49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BerqWP;
4 use GuzzleHttp\Exception\RequestException;
5
6 class CDN {
7 protected $client = null;
8 protected $license_key = null;
9
10 function __construct($client, $license_key) {
11 $this->client = $client;
12 $this->license_key = $license_key;
13 }
14
15 function purge_all($domain) {
16 $post_data = ['domain' => $domain, 'license_key' => $this->license_key];
17
18 try {
19 $response = $this->client->post('cdn/flush', [
20 'form_params' => $post_data
21 ]);
22
23 if ($response->getStatusCode() === 200) {
24 return true;
25 }
26
27 } catch (RequestException $e) {} catch (\Throwable $e) {}
28
29 return false;
30 }
31
32 function stale_assets($domain) {
33 $post_data = ['domain' => $domain, 'license_key' => $this->license_key];
34
35 try {
36 $response = $this->client->post('cdn/stale-assets', [
37 'form_params' => $post_data
38 ]);
39
40 if ($response->getStatusCode() === 200) {
41 return true;
42 }
43
44 } catch (RequestException $e) {} catch (\Throwable $e) {}
45
46 return false;
47 }
48 }
49