WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WordPress 2.8 - no more iframe? (7 posts)

  1. Kivgaen
    Member
    Posted 4 years ago #

    I am currently using wordpress version 2.8 with tinymce-advanced version 3.1. I wrote a tool for our bloggers to use that basically works like the Tinymce-advanced "emotions" button. The user clicks on their choice from the pop-up window, and then I insert some pre defined code into the WYSIWYG editor.

    I had to make a modification to my wordpress in order for the WYSIWYG editor to recognize the "iframe" element. I found the following line in the file wp-includes/js/tinymce/tiny_mce_config.php

    // Add external plugins and init
    $content .= $ext_plugins . 'tinyMCE.init({' . $mce_options . '});';

    And I changed it to:

    // Add external plugins and init
    $content .= $ext_plugins . 'tinyMCE.init({extended_valid_elements : "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]",' . $mce_options . '});';

    Before I updated my wordpress, this solution was working.

    Now that I am running wordpress 2.8, this solution is no longer working. The "iframe" element keeps disappearing inwordpress 2.8.

    How can I make it so that I can insert an iframe into my blog without the WYSIWYG editor stripping it out?

  2. Kivgaen
    Member
    Posted 4 years ago #

    I just wanted to add -- is there any plugin that works with 2.8 that will make an iframe a legitimate tag in wordpress WYSIWYG editor?

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    function add_iframe($initArray) {
    $initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]";
    return $initArray;
    }
    
    add_filter('tiny_mce_before_init', 'add_iframe');

    That bit of code should do the trick, I think. Try it in your theme's functions.php file, or create a plugin and put that in it.

  4. Kivgaen
    Member
    Posted 4 years ago #

    I think that did the trick. Thanks, Otto!

  5. claytonkessler
    Member
    Posted 4 years ago #

    Thank you! I added the function and now I can insert the very cool gpsies maps into my posts.

  6. LambWarren
    Member
    Posted 4 years ago #

    I tried putting the code in my functions.php file and it solved the iframe problem disappearing, but then i kept getting this error on lots of pages:

    Warning: Cannot modify header information - headers already sent by (output started at /..../functions.php:12) in /..../wp-includes/pluggable.php on line 868

    I'll keep messing with it. Thanks for the push forward.

  7. Gabriel Radic
    Member
    Posted 4 years ago #

    @Otto42 You rock!

    @LambWarren Maybe you have some extra spaces or line-breaks after the closing ?>

Topic Closed

This topic has been closed to new replies.

About this Topic