Enhance WordPress editor

Posted on February 11th, 2011

WordPress editor don’t allow html tags which aren’t compliant with the XHTML 1.0 standard. For example, iframes will be stripped out by the editor. If for some reason you have to insert an iframe into a post or page, this can be very frustrating.

The code below will force the editor to accept more tags. Just paste it into your themefunctions.php file, save it, and you’re done.

function fb_change_mce_options($initArray) {
	$ext = 'pre[id|name|class|style],
iframe[align|longdesc| name|width|height|frameborder|
scrolling|marginheight| marginwidth|src]';

	if ( isset( $initArray['extended_valid_elements'] ) ) {
		$initArray['extended_valid_elements'] .= ',' . $ext;
	} else {
		$initArray['extended_valid_elements'] = $ext;

	return $initArray;
add_filter('tiny_mce_before_init', 'fb_change_mce_options');