MarsEdit vs. PHP: dropping ‘class=’ from posts

MarsEdit 1.1 is out. It adds a number of nice new features and bug fixes. I use MarsEdit to edit all my weblog posts. It is a great tool.

Coincidentally, WordPress 2.0 was also recently released. WordPress is a nice enough weblog publishing engine. For me, the most important features were decent comments, useful permalinks, and a lot of canned templates so I didn’t have to torture myself any more than necessary with debugging random software. “It just works” was my mantra in choosing WordPress.

Of course, it doesn’t always “just work”. In particular, since upgrading to 2.0, posts made through MarsEdit that included class= attributes on div tags — what I use to float images left and right (amongst other things) — were being blown away.

Yuck.

After wading into some PHP code (GROSS! What a horrible piece of coding torture that was), the problem proved to be relatively easy to “fix”.

The file wp-includes/kses.php implements a filter that strips all posts of nefarious bits. Unfortunately, it doesn’t let the class= attribute through on div tags.

The fix is easy, even if it most be made in about a 2k character long single line of code.

Just add class => array() to the div tag specification:

'div' => array ('class' => array(), 'align' => array ())

There is a MarsEdit forum discussion and a WordPress bug.


Deprecated: link_pages is deprecated since version 2.1.0! Use wp_link_pages() instead. in /srv/www/friday/bbum/wp-includes/functions.php on line 4713


One Response to “MarsEdit vs. PHP: dropping ‘class=’ from posts”

  1. Red Sweater Blog » Blog Archive » WordPress 2.0 says:

    […] Update: The end of the honeymoon? After being perplexed by the permanent loss of significant and important attributes of my , and tags after uploading from MarsEdit, I learned that a WordPress 2.0 bug was the culprit. Thanks Gus for pointing me to Bill Bumgarner’s writeup, now a few weeks old! I even subscribe to his blog, but must have glossed over it since it wasn’t pertinent to me at that time. Fortunately, it looks like the core problem has been addressed by WP and is being slated for the 2.0.1 update. Until then, I’ll just be really careful what I post through the XMLRPC interface! […]

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>