Created
February 18, 2015 20:14
-
-
Save isotrope/32a5de8fc706e20449e7 to your computer and use it in GitHub Desktop.
Allow iFrame code to be entered in TinyMCE
This file contains 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 | |
/** | |
* Below code could be placed inside your functions.php file | |
* | |
* Below is based on | |
* http://codex.wordpress.org/Plugin_API/Filter_Reference/tiny_mce_before_init | |
* and various places like | |
* https://www.leighton.com/blog/stop-tinymce-in-wordpress-3-x-messing-up-your-html-code | |
* http://redstarwebdevelopment.com/2011/07/15/iframes-in-wordpress/ | |
* http://www.lmhproductions.com/52/wordpress-tincymce-editor-removes-attributes/ | |
* | |
*/ | |
add_filter( 'tiny_mce_before_init', 'jcars_leave_my_iframes_alone' ); | |
function jcars_leave_my_iframes_alone( $settings ) { | |
// If you need more parameters, add them to the list of approved ones between the square brackets | |
$iframe_allow = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]'; | |
// Either add to the key or define it | |
if ( empty ( $settings['extended_valid_elements'] ) ) { | |
$settings['extended_valid_elements'] = $iframe_allow; | |
} else { | |
$settings['extended_valid_elements'] .= ',' . $iframe_allow; | |
} | |
// Send it back to let it do its thang | |
return $settings; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment