PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.19
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.19
4.1.19 4.1.18 4.1.17 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 All 173 releases
searchpro / inc / thirdparty / hosting / GoDaddy.php

GoDaddy.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.1.19, at inc/thirdparty/hosting/GoDaddy.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 class GoDaddy extends berqIntegrations {
5 function __construct() {
6 add_action('berqwp_flush_all_cache', [$this, 'flush_cache']);
7 add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']);
8 add_action('berqwp_flush_page_cache', [$this, 'flush_page_cache']);
9 }
10
11 function flush_cache() {
12 $vip_url = $this->get_vip_url();
13 if (empty($vip_url)) {
14 return;
15 }
16 $this->purge_request($vip_url, 'BAN', berqwp_home_url());
17 }
18
19 function flush_page_cache($slug) {
20 $vip_url = $this->get_vip_url();
21 if (empty($vip_url)) {
22 return;
23 }
24 if (empty($slug)) {
25 $slug = '/';
26 }
27 $this->purge_request($vip_url, 'BAN', berqwp_home_url() . $slug);
28 }
29
30 private function get_vip_url(): string {
31 if (!method_exists('\WPaas\Plugin', 'vip')) {
32 return '';
33 }
34 return (string) \WPaas\Plugin::vip();
35 }
36
37 private function purge_request(string $vip_url, string $method, string $url) {
38 $host = wp_parse_url($url, PHP_URL_HOST);
39 $request = untrailingslashit(set_url_scheme(str_replace($host, $vip_url, $url), 'http'));
40
41 wp_cache_flush();
42 update_option('gd_system_last_cache_flush', time());
43
44 wp_remote_request(esc_url_raw($request), [
45 'method' => $method,
46 'blocking' => false,
47 'headers' => ['Host' => $host],
48 ]);
49 }
50 }
51
52 new GoDaddy();
53