Consider adding an API hook to purge Cloudflare cache

[ad_1]

Plugin Support
qtwrk

(@qtwrk)

I will forward this as feature reuqest

as a temp solution ,add this to your theme’s functions.php

function lscwp_cf_purge_function() {
  $url = "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache";

  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

  $headers = array(
     "Authorization: Bearer API_TOKEN",
     "Content-Type: application/json",
  );
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

  $data="{"purge_everything":true}";
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_exec($curl);
  curl_close($curl);
}

add_action('lscwp_cf_purge', 'lscwp_cf_purge_function');

replace ZONE_ID and API_TOKEN to actual on , then you can call it as

do_action('lscwp_cf_purge');

for example

add_action('litespeed_purged_all', 'cloudflare_purge_all');
function cloudflare_purge_all() {
    do_action('lscwp_cf_purge');
}

to fire when LSCWP purge all

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer