. "report-uri https://{{ your reporting uri }}", ] ); } /** * Adds nonce attribute to script attributes. */ add_filters( ['wp_script_attributes', 'wp_inline_script_attributes',], function (array $attributes): array { $attributes['nonce'] = get_nonce(); return $attributes; } ); /** * Sends Strict CSP header. */ add_action('login_init', function () { header(sprintf('Content-Security-Policy: %s', get_csp_header_value())); }); /** * Send the header on the frontend and in the login screen. */ add_filter( 'wp_headers', static function ($headers) { $headers['Content-Security-Policy'] = get_csp_header_value(); return $headers; } );