PATH:
home
/
sparklp6
/
public_html
/
website_356c8563
/
nitropack
/
classes
/
Integration
/
Plugin
<?php namespace NitroPack\Integration\Plugin; class Cloudflare { const STAGE = "very_early"; private $siteConfig = NULL; public static function isApoActive() { if (self::canUseCloudflareHelper()) { $cfHelper = new CF_Helper(); return $cfHelper->isApoEnabled(); } else { return false; } } public static function isApoCacheByDeviceTypeEnabled() { if (self::canUseCloudflareHelper()) { $cfHelper = new CF_Helper(); return $cfHelper->isApoCacheByDeviceTypeEnabled(); } else { return false; } } public function init($stage) { switch ($stage) { case "very_early": $this->siteConfig = get_nitropack()->getSiteConfig(); if ($this->siteConfig && !empty($this->siteConfig["isApoActive"])) { add_filter( 'cloudflare_use_cache', function ($useCache){ return false; }); add_action('nitropack_early_cache_headers', [$this, 'preventApoCache'], PHP_INT_MAX); add_action( 'nitropack_cacheable_cache_headers', [$this, 'allowApoCache'], PHP_INT_MAX ); add_action( 'nitropack_cachehit_cache_headers', [$this, 'allowApoCache'], PHP_INT_MAX ); \NitroPack\ModuleHandler::initSemAcquire(); } return true; case "late": if ($this->siteConfig && !empty($this->siteConfig["isApoActive"])) { \NitroPack\ModuleHandler::initSemRelease(); add_action('nitropack_execute_purge_url', [$this, 'purgeUrl']); add_action('nitropack_execute_purge_all', [$this, 'purgeAll']); } default: return false; } } public function purgeUrl($url) { if (self::canUseCloudflareHelper()) { $cfHelper = new CF_Helper(); $cfHelper->purgeUrl($url); } } public function purgeAll() { if (self::canUseCloudflareHelper()) { $cfHelper = new CF_Helper(); $cfHelper->purgeCacheEverything(); } } public function allowApoCache() { nitropack_header("cf-edge-cache: cache,platform=wordpress"); } public function preventApoCache() { nitropack_header("cf-edge-cache: no-cache"); } private static function canUseCloudflareHelper() { return defined('CLOUDFLARE_PLUGIN_DIR') && class_exists('\CF\WordPress\Hooks'); } }
[-] ShortPixel.php
[edit]
[-] YoastSEO.php
[edit]
[-] DownloadManager.php
[edit]
[-] .htaccess
[edit]
[-] WPCacheHelper.php
[edit]
[-] BeaverBuilder.php
[edit]
[-] ThriveTheme.php
[edit]
[-] Ezoic.php
[edit]
[-] MPG.php
[edit]
[-] WPRocket.php
[edit]
[-] JetPackNP.php
[edit]
[-] WooCommerce.php
[edit]
[-] WoocommerceCacheHandler.php
[edit]
[-] WPML.php
[edit]
[-] TheEventsCalendar.php
[edit]
[-] AdvancedMathCaptcha.php
[edit]
[-] CookieNotice.php
[edit]
[-] FusionBuilder.php
[edit]
[-] WCML.php
[edit]
[-] NginxHelper.php
[edit]
[-] SquirrlySEO.php
[edit]
[-] CURCY_MultiCurrency.php
[edit]
[-] Elementor.php
[edit]
[-] GeoTargetingWP.php
[edit]
[-] GravityForms.php
[edit]
[-] ACF.php
[edit]
[-] Cloudflare.php
[edit]
[-] RankMathNP.php
[edit]
[-] RC.php
[edit]
[-] WPBakeryNP.php
[edit]
[-] AeliaCurrencySwitcher.php
[edit]
[-] CommonHelpers.php
[edit]
[-] WPForms.php
[edit]
[+]
..
[-] CF_Helper.php
[edit]