Skip to content

Instantly share code, notes, and snippets.

View mike-sheppard's full-sized avatar
🦦

Mike Sheppard mike-sheppard

🦦
View GitHub Profile
@joshuafredrickson
joshuafredrickson / csp-mu-plugin.php
Last active April 30, 2025 23:34
Add CSP to WordPress, including nonces for inline scripts
<?php
/**
* Plugin Name: Content Security Policy
* Version: 1.0.1
* Description: Adds a Content-Security-Policy header to all non-admin requests.
* Requires PHP: 8.1
* Requires at least: 5.7.0
* License: GNU General Public License v2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Original Inspiration: https://gist.github.com/westonruter/c8b49406391a8d86a5864fb41a523ae9