PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / 3.6.3
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score v3.6.3
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 / includes / compat / plugins / gdpr.php

gdpr.php in Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score 3.6.3, at includes/compat/plugins/gdpr.php

71 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compat with GDPR Plugin
4 *
5 * @package PoweredCache\Compat
6 * @link https://wordpress.org/plugins/gdpr/
7 */
8
9 namespace PoweredCache\Compat\GDPR;
10
11 use PoweredCache\Config;
12 use function PoweredCache\Utils\clean_site_cache_dir;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 if ( class_exists( '\GDPR' ) ) {
19 add_filter( 'powered_cache_mod_rewrite', '__return_false', 23 );
20 add_filter( 'powered_cache_vary_cookies', __NAMESPACE__ . '\\add_vary_cookie' );
21 }
22
23
24 /**
25 * Add cookie to vary cookie options
26 *
27 * @param array $cookies The list of vary cookies
28 *
29 * @return array Altered cookie list.
30 * @since 2.0
31 */
32 function add_vary_cookie( $cookies ) {
33 $cookies['gdpr'] = [
34 'allowed_cookies',
35 'consent_types',
36 ];
37
38 return $cookies;
39 }
40
41 /**
42 * Setup vary cookie on activation
43 *
44 * @since 2.0
45 */
46 function activate() {
47 add_filter( 'powered_cache_mod_rewrite', '__return_false' );
48 add_filter( 'powered_cache_vary_cookies', __NAMESPACE__ . '\\add_vary_cookie' );
49 $settings = \PoweredCache\Utils\get_settings();
50 Config::factory()->save_configuration( $settings, POWERED_CACHE_IS_NETWORK );
51 clean_site_cache_dir();
52 }
53
54 /**
55 * Remove vary cookie on deactivation
56 *
57 * @since 2.0
58 */
59 function deactivate() {
60 remove_filter( 'powered_cache_mod_rewrite', '__return_false', 23 );
61 remove_filter( 'powered_cache_vary_cookies', __NAMESPACE__ . '\\add_vary_cookie' );
62 $settings = \PoweredCache\Utils\get_settings();
63 Config::factory()->save_configuration( $settings, POWERED_CACHE_IS_NETWORK );
64 clean_site_cache_dir();
65 }
66
67 add_action( 'activate_gdpr/gdpr.php', __NAMESPACE__ . '\\activate', 23 );
68 add_action( 'deactivate_gdpr/gdpr.php', __NAMESPACE__ . '\\deactivate', 23 );
69
70
71