File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -255,8 +255,8 @@ function jq_image_posted_on() {
255
255
/**
256
256
* Content Security Policy
257
257
*/
258
- function jq_content_security_policy () {
259
- $ nonce = wp_create_nonce ( JQUERY_LIVE_SITE );
258
+ function jq_content_security_policy ( $ headers ) {
259
+ $ nonce = bin2hex ( random_bytes ( 8 ) );
260
260
$ policy = array (
261
261
'default-src ' => "'self' " ,
262
262
'script-src ' => "'self' 'nonce- $ nonce' code.jquery.com " ,
@@ -285,5 +285,9 @@ function jq_content_security_policy() {
285
285
$ policy_string .= $ key . ' ' . $ value . '; ' ;
286
286
}
287
287
288
- header ( 'Content-Security-Policy-Report-Only: ' . $ policy_string );
288
+ $ headers [] = 'Content-Security-Policy: ' . $ policy_string ;
289
+
290
+ return $ headers ;
289
291
}
292
+
293
+ add_filter ( 'wp_headers ' , 'jq_content_security_policy ' );
Original file line number Diff line number Diff line change 1
- <?php jq_content_security_policy () ?>
2
1
<!doctype html>
3
2
<html class="no-js" <?php language_attributes (); ?> >
4
3
<head>
You can’t perform that action at this time.
0 commit comments