-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordpress-cache-protection.php
More file actions
45 lines (40 loc) · 1.92 KB
/
wordpress-cache-protection.php
File metadata and controls
45 lines (40 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Plugin Name: WordPress Cache Protection
* Plugin URI: https://github.com/augustash/wordpress-cache-protection
* Description: Strips/redirects tracking params so Varnish caches canonical URLs, augments robots.txt with bot-throttling rules. WordPress equivalent of drupal_cache_protection.
* Version: 1.0.0-dev
* Requires at least: 5.5
* Requires PHP: 7.4
* Author: August Ash
* Author URI: https://augustash.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wordpress-cache-protection
*
* @package Augustash\WordpressCacheProtection
*/
if (! defined('ABSPATH')) {
exit;
}
define('WPCP_VERSION', '1.0.0-dev');
define('WPCP_PLUGIN_FILE', __FILE__);
define('WPCP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WPCP_PLUGIN_URL', plugin_dir_url(__FILE__));
require_once WPCP_PLUGIN_DIR . 'includes/class-cache-protection.php';
require_once WPCP_PLUGIN_DIR . 'includes/class-search-protection.php';
require_once WPCP_PLUGIN_DIR . 'includes/class-settings.php';
require_once WPCP_PLUGIN_DIR . 'includes/class-robots.php';
// Strip/redirect runs as early as possible — at plugin load time, before
// muplugins_loaded fires, before WP queries posts, before page caches key on
// the URL. The Drupal middleware fires at priority 290; this is the WP
// equivalent of being early in the request pipeline.
\Augustash\WordpressCacheProtection\CacheProtection::boot();
// Search protection runs at plugins_loaded — it needs the options API and
// transient store to be available, which CacheProtection doesn't. Still
// early enough to set headers and short-circuit before WP runs the main query.
add_action('plugins_loaded', function () {
\Augustash\WordpressCacheProtection\SearchProtection::boot();
\Augustash\WordpressCacheProtection\Settings::boot();
\Augustash\WordpressCacheProtection\Robots::boot();
}, 1);