Created
February 24, 2024 12:28
-
-
Save obviousdisaster/060d79c4b1a19b2648eb7d5b3c269aac to your computer and use it in GitHub Desktop.
Wordpress 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
<?php | |
/** | |
* add security headers to Wordpress | |
* | |
* @author Mark Hall <https://markhall.dev> | |
*/ | |
function add_headers() | |
{ | |
header( 'Strict-Transport-Security: max-age=31536000' ); | |
header( 'Content-Security-Policy: frame-ancestors "none";' ); | |
header( 'X-Frame-Options: sameorigin' ); | |
header( 'X-Content-Type-Options: nosniff' ); | |
header( 'Referrer-Policy: same-origin' ); | |
header( 'Permissions-Policy: Permissions-Policy: accelerometer=*, ambient-light-sensor=*, autoplay=*, battery=*, camera=*, cross-origin-isolated=*, display-capture=*, document-domain=*, encrypted-media=*, execution-while-not-rendered=*, execution-while-out-of-viewport=*, fullscreen=*, geolocation=*, gyroscope=*, keyboard-map=*, magnetometer=*, microphone=*, midi=*, navigation-override=*, payment=*, picture-in-picture=*, publickey-credentials-get=*, screen-wake-lock=*, sync-xhr=*, usb=*, web-share=*, xr-spatial-tracking=*, clipboard-read=*, clipboard-write=*, gamepad=*, speaker-selection=*, conversion-measurement=*, focus-without-user-activation=*, hid=*, idle-detection=*, interest-cohort=*, serial=*, sync-script=*, trust-token-redemption=*, unload=*, window-placement=*, vertical-scroll=*' ); | |
header( 'X-XSS-Protection 1; mode=block' ); | |
} | |
add_action( 'send_headers', 'add_headers' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment