Created
August 14, 2025 11:12
-
-
Save bhowe/a4f6f01ee8adc346c982c619ff992951 to your computer and use it in GitHub Desktop.
Basic Security Headers for WordPress
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
| function add_security_headers() { | |
| // HTTP Strict Transport Security | |
| header("Strict-Transport-Security: max-age=31536000; includeSubDomains"); | |
| // X-Frame-Options for clickjacking protection | |
| header("X-Frame-Options: SAMEORIGIN"); | |
| // Referrer Policy for privacy and security | |
| header("Referrer-Policy: strict-origin-when-cross-origin"); | |
| // Permissions Policy to restrict browser APIs | |
| header("Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=(), usb=()"); | |
| } | |
| add_action( 'send_headers', 'add_security_headers' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment