# searchpro/4.0.21/BerqWP/src/CriticalCSS.php

BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS &amp; JavaScript, version 4.0.21. 52 lines.

- Page: https://pluginprobe.com/plugins/searchpro/4.0.21/code/BerqWP/src/CriticalCSS.php
- Raw: https://pluginprobe.com/plugins/searchpro/4.0.21/raw/BerqWP/src/CriticalCSS.php
- Modified: 2026-05-20T17:15:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/searchpro/4.0.21/code/BerqWP/src/CriticalCSS.php#L10-L20`.

```php
<?php

namespace BerqWP;
use GuzzleHttp\Exception\RequestException;

class CriticalCSS {
    protected $client = null;
    protected $license_key = null;

    function __construct($client, $license_key) {
        $this->client = $client;
        $this->license_key = $license_key;
    }

    function purge_url($page_url) {
        $post_data = ['page_url' => $page_url, 'license_key' => $this->license_key];

        try {

            $response = $this->client->post('critical-css/flush-page', [
                'form_params'   => $post_data
            ]);

            if ($response->getStatusCode() === 200) {
                return true;
            }

        } catch (RequestException $e) {} catch (\Throwable $e) {}


        return false;
    }

    function purge_all($domain) {
        $post_data = ['domain' => $domain, 'license_key' => $this->license_key];

        try {

            $response = $this->client->post('critical-css/flush-all', [
                'form_params'   => $post_data
            ]);

            if ($response->getStatusCode() === 200) {
                return true;
            }

        } catch (RequestException $e) {} catch (\Throwable $e) {}

        return false;
    }
}

```
