Skip to content

Commit 040204f

Browse files
committed
Listen to adds and use a more restrictive rule
1 parent fbbd8e6 commit 040204f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

includes/Cloudflare/CloudflareFeaturesManager.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ class CloudflareFeaturesManager {
1818
*/
1919
public function __construct() {
2020
add_action( 'update_option_nfd_image_optimization', array( $this, 'on_image_optimization_change' ), 10, 2 );
21+
add_action( 'add_option_nfd_image_optimization', array( $this, 'on_image_optimization_change' ), 10, 2 );
2122
add_action( 'update_option_nfd_fonts_optimization', array( $this, 'on_fonts_optimization_change' ), 10, 2 );
23+
add_action( 'add_option_nfd_fonts_optimization', array( $this, 'on_fonts_optimization_change' ), 10, 2 );
2224
add_action( 'update_option_nfd_site_capabilities', array( $this, 'on_site_capabilities_change' ), 10, 2 );
25+
add_action( 'add_option_nfd_site_capabilities', array( $this, 'on_site_capabilities_change' ), 10, 2 );
2326
}
2427

2528
/**
@@ -80,15 +83,15 @@ private function update_htaccess_header( $image_settings, $fonts_enabled ) {
8083
$rules = array(
8184
'# BEGIN Newfold CF Optimization Header',
8285
'<IfModule mod_headers.c>',
83-
"\tHeader set Set-Cookie \"nfd-enable-google-font-replace=true; path=/; Max-Age=86400; HttpOnly\" env=nfd_cf_opt",
86+
"\tHeader set Set-Cookie \"nfd-enable-cf-opt={$header_value}; path=/; Max-Age=86400; HttpOnly\" env=nfd_cf_opt",
8487
'</IfModule>',
8588
'# Exclude admin and API paths',
8689
'SetEnvIf Request_URI "^/wp-admin/" no_nfd_cf',
8790
'SetEnvIf Request_URI "^/wp-json/" no_nfd_cf',
8891
'SetEnvIf Request_URI "^/xmlrpc.php" no_nfd_cf',
8992
'SetEnvIf Request_URI "^/wp-login.php" no_nfd_cf',
9093
'SetEnvIf Request_URI "^/admin-ajax.php" no_nfd_cf',
91-
'# Apply CF header on all non-admin, non-API requests',
94+
'# Apply CF cookie on all non-admin, non-API requests',
9295
'SetEnvIf Request_URI ".*" nfd_cf_opt=!no_nfd_cf',
9396
'# END Newfold CF Optimization Header',
9497
);

0 commit comments

Comments
 (0)