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 / CriticalCSS.php

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

52 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 CriticalCSS {
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_url($page_url) {
16 $post_data = ['page_url' => $page_url, 'license_key' => $this->license_key];
17
18 try {
19
20 $response = $this->client->post('critical-css/flush-page', [
21 'form_params' => $post_data
22 ]);
23
24 if ($response->getStatusCode() === 200) {
25 return true;
26 }
27
28 } catch (RequestException $e) {} catch (\Throwable $e) {}
29
30
31 return false;
32 }
33
34 function purge_all($domain) {
35 $post_data = ['domain' => $domain, 'license_key' => $this->license_key];
36
37 try {
38
39 $response = $this->client->post('critical-css/flush-all', [
40 'form_params' => $post_data
41 ]);
42
43 if ($response->getStatusCode() === 200) {
44 return true;
45 }
46
47 } catch (RequestException $e) {} catch (\Throwable $e) {}
48
49 return false;
50 }
51 }
52