PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 1.2.4
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v1.2.4
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
powered-cache / extensions / cloudflare / cloudflare.php

cloudflare.php in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 1.2.4, at extensions/cloudflare/cloudflare.php

60 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Extension Name: Cloudflare
4 * Extension URI: https://poweredcache.com/extensions/cloudflare
5 * Description: Cloudflare extension for Powered Cache
6 * Author: Powered Cache Team
7 * Version: 1.0
8 * Author URI: https://poweredcache.com
9 * Extension Image: extension-image.png
10 * License: GPLv2 (or later)
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 require_once 'inc/class-powered-cache-cloudflare-api.php';
18
19 // Fixes Flexible SSL
20 if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
21 $_SERVER['HTTPS'] = 'on';
22 }
23
24 // real user ip
25 if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
26 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
27 }
28
29 if ( is_admin() ) {
30 require_once 'inc/class-powered-cache-cloudflare-admin.php';
31 Powered_Cache_Cloudflare_Admin::factory();
32 }
33
34
35 /**
36 * Purge cloudflare cache
37 *
38 * @since 1.0
39 * @return array|bool|mixed|object|string
40 */
41 function powered_cache_cloudflare_purge_cache() {
42 $email = powered_cache_get_extension_option( 'cloudflare', 'email' );
43 $api_key = powered_cache_get_extension_option( 'cloudflare', 'api_key' );
44 if ( $email && $api_key ) {
45 $api = new Powered_Cache_Cloudflare_Api( $email, $api_key );
46
47 $zone = powered_cache_get_extension_option( 'cloudflare', 'zone' );
48 if ( $zone ) {
49 return $api->purge( $zone );
50 }
51 }
52
53 return false;
54 }
55
56 add_action( 'powered_cache_purge_all_cache', 'powered_cache_cloudflare_purge_cache' );
57
58 // make description translatable
59 __( 'Cloudflare extension for Powered Cache', 'powered-cache' );
60