Smacking WordPress Editor, or Making It Stop Messing With Code

I was having two irritating issues with the WordPress editor, which affected my highslide and Google video code. It took a lot of research but I’ve finally figured out how to edit the code in the Tiny MCE file to make the editor stop acting like it’s smarter than me. The location of the file is: wp-includes/js/tinymce/tiny_mce.js

It was messing up the formatting of my highslide images. That was a hard one to diagnose because I thought it was a css issue. Then I compared the code that I entered to the code that WordPress outputted in the html source and they differed. One thing I noticed was that it changed div to p. The solution to this was in the Tiny MCE documentation for the cleanup option, which I set to false to disable:

        this._def("cleanup", false);

The other thing was when I added code to embed a Google video. The editor tried to be so clever thinking it was changing <em> to <i> when actually it changed <embed> to <ibed>. This obviously broke the video code. I finally found the solution that was easy to implement: YouTube video: embed and not ibed, please:

    if (tinyMCE.isGecko) {
h = h.replace(/<strong/gi, '<b');
//h = h.replace(/<em(/?)/gi, '<i');
//h = h.replace(/<em /gi, '<i');
h = h.replace(/</strong>/gi, '</b>');
//h = h.replace(/</em>/gi, '</i>');
}

If after editing and uploading the file, there seems to be no change in behavior, do a forced refresh with ctrl-F5. I don’t know about other browsers, but Firefox will cache .js and .css files so modifications require forced refresh to get the latest version.

Update 2007-06-16:

Sigh… changing cleanup option to false caused another issue. It left mce_href tags in the html output. I guess “cleanup” actually cleans things up. If only it didn’t have to break things while it was at it.

4 thoughts on “Smacking WordPress Editor, or Making It Stop Messing With Code”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>