WordPress.org

Ready to get started?Download WordPress

Forums

WP3.1-iframe code disappears when editing page and clicking update (22 posts)

  1. cnymike
    Member
    Posted 3 years ago #

    I'm either going crazy or there is a bug in WP3.1 that is causing iframe code blocks to disappear from the visual editor window when I click on Update.

    My page has an iframe (youtube video) with additional text on the page. I placed the iframe code onto the page using the HTML editor. Later on in the day I needed to change some text on that page and used the visual editor to make the text changes but when I click Update, the iframe code disappeared.

    This has happened consistently since I first discovered this issue.

    Bug? Something I'm doing wrong?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    The Visual Editor will strip most (if not all) HTML markup from posts/pages. Solution: If you have added markup using the HTML tab, don't switch to the Visual tab.

  3. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    It's definitely not a bug, it is a feature - that is, what you are observing is the intended design.

    WordPress uses a custom configuration for TinyMCE (the Visual Editor), that excludes, among others, IFRAME from the list of valid HTML tags.

    You have two options:

    1) Filter the TinyMCE configuration to allow IFRAME tags
    2) As esmi said: for posts in which you need to add iframes, only use the HTML editor.

  4. cnymike
    Member
    Posted 3 years ago #

    I realize that visual editors are not where iframe code should be placed. I always use HTML for that. But once a site is up and running, it's not always obvious that a particular page has iframe code on it. If a user opens a page intending to edit the text on that page in the visual editor, not knowing that there is iframe code present, the user should not lose any iframe code that may have been on that page simply by opening it in the visual editor. That's why it seems more like a bug rather than a feature. I don't know anything about filters in TinyMCE, but apparently that is something I will have to learn because I manage a lot of WordPress sites and many of them have iframe code in them. I also realize that I can revert to a previously saved version of the page, in some cases, but that is not a solution but a safety cushion.

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Then you'll want to filter the TinyMCE config.

    Add something like the following to your functions.php file:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Reference: http://tinymce.moxiecode.com/wiki.php/Configuration

  6. cnymike
    Member
    Posted 3 years ago #

    Chip, your code was moderated. Could you try that again, using the pastebin?

  7. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Um, hello. That code was not more than 10 lines. Come on.

  8. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Just a second, cnymike. I'll put that in a Pastebin. We've got some over-zealous moderators today, I guess. :/

  9. cnymike
    Member
    Posted 3 years ago #

    Somebody needs to moderate the moderator I guess.

  10. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Here you go: http://pastebin.com/rKuewx0P

    (And I took out the white space and the comments, just to ensure that it was, in fact, 10 lines exactly.)

  11. cnymike
    Member
    Posted 3 years ago #

    Thank you Chip. I'll see if that works for me. Now I gotta learn more about rutabaga's.

  12. cnymike
    Member
    Posted 3 years ago #

    Chip, sorry for the delay but your code worked perfectly. I'm now able to switch freely between HTML and visual editors without losing the iFrames code. Awesome and thanks again.

  13. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Awesome! Glad you got it working!

  14. cnymike
    Member
    Posted 3 years ago #

    Chip, I'm now having a related issue with quotes. What would I need to append to your previous code to also allow quotes not to get changed to curly quotes if I accidentally go into Visual editor mode?

  15. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    @cnymike, you need to remove the wptexturize() filter from the_content(). e.g. add the following the functions.php:

    remove_filter('the_content', 'wptexturize');
  16. cnymike
    Member
    Posted 3 years ago #

    OK, I"ll give that a go. Thank you.

    And thank you for keeping that under 10 lines to escape the wrath of moderation :-0

  17. cnymike
    Member
    Posted 3 years ago #

    Chip, once again you've provided the solution. Thanks.

  18. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Glad to help! :)

  19. qitupzach
    Member
    Posted 3 years ago #

    Chip...I am currently running WP 3.1.3 and I have tried implementing your code to allow iframe in the editor, but I continue to get an error for that line of Code when I update the functions.php file.

    I am not a pro at editing php files and wanted to make sure exactly what file and place should I implement this function. Any help would be appreciated.

    I have tried implementing it on the functions file (/wp-includes/functions.php) on line 2844.

  20. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Don't ever edit core files.

    Put that code in your Theme's functions.php file.

  21. qitupzach
    Member
    Posted 3 years ago #

    Thanks Chip...it works

  22. fastharry
    Member
    Posted 3 years ago #

    hi Chip..

    I am a newb, so please forgive my question...I have the pastebin code, I have located my themes (Atahualpa) functions.php file...now what so I do, just scroll to the bottom of the page and insert the code?...or does it have to into a specific part of the file...

    Thanks...Harry, fastharry.com

Topic Closed

This topic has been closed to new replies.

About this Topic