Skip to content

Instantly share code, notes, and snippets.

@sander1
Forked from bjorn2404/wp_kses_post_tags.php
Created August 20, 2017 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sander1/25423ec9c0791f26337eaabc39f74abc to your computer and use it in GitHub Desktop.
Save sander1/25423ec9c0791f26337eaabc39f74abc to your computer and use it in GitHub Desktop.
WordPress allow iFrames with wp_kses_post filter
<?php
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param string $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post',
*
* @return mixed
*/
function custom_wpkses_post_tags( $tags, $context ) {
if ( 'post' === $context ) {
$tags['iframe'] = array(
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
'scrolling' => true,
'allowfullscreen' => true,
);
}
return $tags;
}
add_filter( 'wp_kses_allowed_html', 'custom_wpkses_post_tags', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment