Created
November 15, 2023 03:58
-
-
Save getneerajk/26cf3c6b645caec2a26638bac357bb49 to your computer and use it in GitHub Desktop.
Set csp headers #wp
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 a filter to modify the HTTP headers | |
function add_csp_header() { | |
header("Content-Security-Policy: default-src 'self'; script-src 'self' https://example.com; style-src 'self' https://example.com;"); | |
// Add more directives as needed based on your specific requirements | |
} | |
// Hook the function to the 'send_headers' action | |
add_action('send_headers', 'add_csp_header'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment