Skip to content

Instantly share code, notes, and snippets.

@bhowe
Created August 14, 2025 11:12
Show Gist options
  • Select an option

  • Save bhowe/a4f6f01ee8adc346c982c619ff992951 to your computer and use it in GitHub Desktop.

Select an option

Save bhowe/a4f6f01ee8adc346c982c619ff992951 to your computer and use it in GitHub Desktop.
Basic Security Headers for WordPress
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