Skip to content

Commit 875b61e

Browse files
Merge pull request #17 from Crowdhandler/strip-ch-url-parameters
Removing crowdhandler specific query parameters and redirect to sanat…
2 parents 05feb9b + d44c867 commit 875b61e

6 files changed

Lines changed: 52 additions & 29 deletions

File tree

README.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
=== CrowdHandler virtual waiting room ===
22
Contributors: rickmutt
33
Tags: waiting room, traffic management, queue management, ecommerce, CrowdHandler,
4-
Tested up to: 6.0
5-
Stable tag: 1.1.8
4+
Tested up to: 6.1.1
5+
Stable tag: 1.1.9
66
License: GPLv2 or later
77
License URI: http://www.gnu.org/licenses/gpl-2.0.html
88

@@ -89,6 +89,8 @@ You can uninstall the plugin at any time to remove CrowdHandler from your site.
8989

9090

9191
== Changelog ==
92+
= 1.1.9 =
93+
* Compatibility change for crowdhHandler-php-skd release 1.0.5 and added crowdhandler diagnostics
9294
= 1.1.8 =
9395
* Compatible with WP v6.0
9496
= 1.1.7 =

composer.lock

Lines changed: 11 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crowdhandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Plugin Name: CrowdHandler virtual waiting room
1717
* Plugin URI: https://signup.crowdhandler.com/?utm_source=WordPress&utm_medium=Plugin_Dir
1818
* Description: During periods of heavy traffic, our queue management solution helps safeguard your website from crashing and protects your sales.
19-
* Version: 1.1.8
19+
* Version: 1.1.9
2020
* Author: CROWDHANDLER LTD
2121
* License: GPL-2.0+
2222
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@@ -38,7 +38,7 @@
3838
* Start at version 0.1.0 and use SemVer - https://semver.org
3939
* Rename this for your plugin and update it as you release new versions.
4040
*/
41-
define('CROWDHANDLER_VERSION', '1.1.8');
41+
define('CROWDHANDLER_VERSION', '1.1.9');
4242

4343
/**
4444
* The code that runs during plugin activation.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
class CrowdhandlerDiagnostics
4+
{
5+
6+
/**
7+
* @var array
8+
*/
9+
private $options;
10+
11+
public function __construct()
12+
{
13+
if (function_exists('get_option')) {
14+
$this->options = get_option('crowdhandler_settings');
15+
}
16+
}
17+
18+
/**
19+
* Adds a crowdhandler header to the request
20+
*/
21+
public function addCHDiagnostics($headers)
22+
{
23+
if($this->options){
24+
$indexOverride = (isset($this->options['crowdhandler_settings_field_override_index'])) ? '1' : '0';
25+
$timestamp = new DateTime();
26+
$formatedTime = $timestamp->format(DateTime::ISO8601);
27+
$headers['x-crowdhandler-info'] = $this->options['crowdhandler_settings_field_public_key'] . '::' . $indexOverride . '::' . $formatedTime;
28+
}
29+
return $headers;
30+
}
31+
}

includes/class-crowdhandler-gatekeeper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ public function checkRequest()
4747
$this->gateKeeper = new GateKeeper($api);
4848

4949
$this->gateKeeper->setIgnoreUrls(
50-
"/^((?!.*\?).*(\.(avi|css|eot|gif|ico|jpg|jpeg|js|json|mov|mp4|mpeg|mpg|og[g|v]|pdf|png|svg|ttf|txt|wmv|woff|woff2|xml))$)|(?!.*\?.*w[c|p]-.+).*(^.*w[c|p]-.+)|^((?!.*\?.*xmlrpc\.php).*xmlrpc.php)|\?rest_route=.+/"
50+
"/^((?!.*\?).*(\.(avi|css|eot|gif|ico|jpg|jpeg|js|json|mov|mp4|mpeg|mpg|og[g|v]|pdf|png|svg|tiff|ttf|txt|wmv|woff|woff2|xml))$)|.*(^.*w[c|p]-.+)|^((?!.*\?.*xmlrpc\.php).*xmlrpc.php)|\?rest_route=.+/"
5151
);
5252

5353
$isHostServer = $this->gateKeeper->ip === $_SERVER["SERVER_ADDR"];
5454

5555
if (!$isHostServer) {
5656
$this->gateKeeper->setFailTrust(true);
5757
$this->gateKeeper->checkRequest();
58-
$this->gateKeeper->setCookie();
5958
$this->gateKeeper->redirectIfNotPromoted();
6059
}
6160

includes/class-crowdhandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ private function define_public_hooks()
169169
$this->loader->add_action('plugins_loaded', $plugin_public, 'checkRequest');
170170
$this->loader->add_action('shutdown', $plugin_public, 'recordPerformance');
171171
}
172+
173+
$diagnostics = new CrowdhandlerDiagnostics();
174+
$this->loader->add_filter('wp_headers', $diagnostics, 'addCHDiagnostics', 999);
172175
}
173176

174177
/**

0 commit comments

Comments
 (0)