Created
August 6, 2024 05:51
-
-
Save BruceMcKinnon/75cce605b36314c191a6b0a46a6216ee to your computer and use it in GitHub Desktop.
Support the serving of iframe content from a specific page
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
// | |
// Wordpress - Support for iframes being called for a specific page. Add this to functions.php | |
// In this case, the URL $allowed_url will be allowed to pull the contents of the 'my-embed' page | |
// | |
add_action( 'send_headers', 'add_header_xframe', 99 ); | |
function add_header_xframe() { | |
if ( is_page('my-embed') ) { | |
$allowed_url = 'http://test.local'; | |
header( 'Content-Security-Policy: frame-ancestors '.$allowed_url ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment