PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.19
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.19
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / Services / Cloudflare_Detector.php

Cloudflare_Detector.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.19, at includes/Services/Cloudflare_Detector.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cloudflare detection for WCPOS settings.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 namespace WCPOS\WooCommercePOS\Services;
9
10 /**
11 * Detects Cloudflare proxy and official plugin status.
12 */
13 class Cloudflare_Detector {
14 /**
15 * Detect Cloudflare from the current request or injected inputs.
16 *
17 * @param array|null $server Server values, defaults to $_SERVER.
18 * @param array|null $active_plugins Active plugin basenames, defaults to WordPress detection.
19 * @return array{proxied:bool,plugin_active:bool} Cloudflare status.
20 */
21 public function detect( ?array $server = null, ?array $active_plugins = null ): array {
22 $server = $server ?? $_SERVER;
23 if ( null !== $active_plugins ) {
24 $plugin_active = \in_array( 'cloudflare/cloudflare.php', $active_plugins, true );
25 } else {
26 if ( ! \function_exists( 'is_plugin_active' ) ) {
27 $file = ABSPATH . 'wp-admin/includes/plugin.php';
28 if ( is_readable( $file ) ) {
29 require_once $file;
30 }
31 }
32 $plugin_active = \function_exists( 'is_plugin_active' ) && is_plugin_active( 'cloudflare/cloudflare.php' );
33 }
34
35 return array(
36 'proxied' => ! empty( $server['HTTP_CF_RAY'] ),
37 'plugin_active' => $plugin_active,
38 );
39 }
40 }
41