Created
October 22, 2020 17:49
-
-
Save jbd91/7c14ec075b75c1bd6e313ac80332d253 to your computer and use it in GitHub Desktop.
Security Headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Headers | |
if (!empty($_SERVER['HTTPS'])) { | |
function add_hsts_header($headers) { | |
$headers['strict-transport-security'] = 'max-age=31536000; includeSubDomains'; | |
$headers['x-xss-protection'] = '1; mode=block'; | |
$headers['x-content-type-options'] = 'nosniff'; | |
$headers['x-frame-options'] = 'SAMEORIGIN'; | |
$headers['referrer-policy'] = 'no-referrer-when-downgrade'; | |
$headers['permissions-policy'] = 'geolocation=(); midi=(); notifications=(); push=(); sync-xhr=(); microphone=(); camera=(); magnetometer=(); gyroscope=(); vibrate=(); fullscreen=(); payment=()'; | |
$headers['content-security-policy'] = 'default-src \'self\' \'unsafe-inline\' \'unsafe-eval\' https: data:'; | |
$headers['expect-ct'] = 'max-age=3600; enforce'; | |
return $headers; | |
} | |
add_filter('wp_headers', 'add_hsts_header'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment