tinymce_valid_elements.zip (version 0.3)
Tags: tinymce, editor, html, element
Requires at least: 2.5
Tested up to: 2.7.1
Description
By default, WordPress’ WYSIWYG editor, TinyMCE, will strip out of your Article and Page HTML code any elements that are not defined as “valid elements”; this can be extremely annoying (especially if you want to include iframes).
This plugin will allow you to extend what TinyMCE defines as “valid elements”. By doing so, TinyMCE will no longer remove, delete, or strip-out the additional elements and attributes that you specify.
** NOTE: Make sure after you add elements or attributes you do a hard refresh (ctrl + F5) of your browser on a TinyMCE screen (editing or creating a page/post) so that the TinyMCE cache will be refreshed! You will not see your changes until you do this!
Installation
- Upload the
tinymce_valid_elements/directory and its contents to the/wp-content/plugins/directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Go to Manage -> TinyMCE Valid Elements and add some elements and attributes.
Read the Help Section at the bottom of the management page.
Frequently Asked Questions
I added new elements/attributes, why is TinyMCE still stripping it out?
- Most likely, you need to do a hard refresh of your browser (ctrl + F5). Your JavaScript cache needs to be refreshed.
Hi,
thanks for this. I spent yesterday evening trying to figure out how to do exactly this, and gave up. Now I find your plugin and I don’t have to figure it out anymore. Good stuff!
Tony.
hi. Thanks for plugin
perfect.
Regards
Thnks. Very good plugin.
Almost perfect. Still have a problem. I would like to enable one further attribute for element . When doing so my attribute is enabled while all *default* attributes (like “class”) are gone. How can I tell this plugin to just *add* my attribute?
Greetz, Wolfgang
Thank you. This plugin saved the day.
I have tested this on two WordPress 2.7 instances. It worked flawlessly on one instance but I noticed a bug on the other instance. The HTML form on the “Tools > TinyMCE Valid Elements” page incorrectly has its action attribute set to “/cgi-system/php.cgi” instead of “/{your wordpress install dir}/wp-admin/tools.php”.
One workaround is to use a browser plugin that allows you to modify the DOM in real-time. For example, I used a Firefox plugin called Firebug (https://addons.mozilla.org/en-US/firefox/addon/1843) to change the form action to the correct URL so that the POST works–only a mild annoyance when you consider that you’re not editing the valid fields very often.
Thanks for sharing such a handy resource! Please consider adding it to the standard WordPress Plugins Directory so that more people can benefit from it! http://wordpress.org/extend/plugins/
/cgi-system/php.cgi
I had the same problem as Clint is describing, we have a WPMU installation with subdirs instead of sub-domains. What happened was that all POSTS went to the main blog while editing the settings of a sub blog.
I’ve corrected this by replacing $_SERVER['SCRIPT_NAME'] by $_SERVER['REQUEST_URI'] resolved this problem.
Please consider this patch for your next release.
Besides this bug, I was relieved to find this plugin because I had spend way to many time resolving this i-frame issue (which needed TWO plugins on a WPMU installation, one unfiltered-mu for the WP side of the story and this one for the RTE side of the story).
Still doesn’t work with Youtube’s “embed” code…
But this allows those elements to be entered into comments. I use iframes on two pages on one of my sites (a google map and a databases page maintained by someone else) and would love to not have them messed up by the Visual editor, but I don’t want people to be able to put iframes into their comment text either. Any solution to that problem?
Never mind! It strips it out of the comment when you’re not logged in as an administrator.
thanks for the great plugin. i made a few mods to get it running in wordpress mu. posted info here: http://www.sharpdotinc.com/jdost/2009/03/17/update-tool-for-wordpress-mu-and-allowable-tags/ i *think* it gets rid of the need to use unfiltered-mu.
didn’t work
This is great! Finally!
Thank you very much.
When I try to remove an attribute however this error is returned:
Cannot load tinymce-valid-elements/tinymce_valid_elements.php?page=tinymce-valid-elements/tinymce_valid_elements.php.
Considering that the plugin allows for clearing of the database upon deactivation though, it’s a rather quick process to just re-enter the info from scratch if necessary.
Nice plugin, was looking for a way so it didn’t strip the iframe and could make it easier to embed google maps. I am using it on 2.8 alright, but I can’t delete attributes.
Thanks for this plugin. I am still trying to figure out how to allow PHP code in posts without it being stripped by the TinyMCE editor when switching between Visual and HTML modes.
I have something like this:
With the plugin, I can get the phpcode tag to stay, but the PHP code in the middle still gets stripped out since it can’t be added as an HTML tag.
Any ideas would be much appreciated.