• WordPress is sometimes stripping class and id attributes from html tags after editing an existing post and I have no idea why.

    The closest explanation I’ve found relates to kses.php disallowing certain strings, but that would surely happen consistently and not after minor edits of some existing posts?

    * in WP 2.6.x – 2.7.x, not WPMU
    * strips all class and id attributes from an edited post
    * only affects existing posts, not consistently or frequently
    * we only use HTML editing window, never visual
    * can happen after either Edit or Quick Edit actions
    * of two admins, one has experienced this problem numerous times, the other admin only once in six months
    * in Post Revisions, the timestamp for the unexplained change has no user associated with it, ie:

    2 July, 2009 @ 18:19 by
    2 July, 2009 @ 18:13 by xyz

    Today drove me to desperation because we made very minor edits to 35 posts (just removing a word from their titles) and 27 of them then lost all their attributes.

    Does anyone know a reason or a fix?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Have you tried deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    Thread Starter lamington

    (@lamington)

    Thanks for the suggestion but it wouldn’t be practical — the problem doesn’t happen predictably, so I’d have to run the site for a few weeks without any plugins ??

    Thread Starter lamington

    (@lamington)

    No progress on this issue. We’ve tried:

    • modifying kses.php to permit class and id attributes
    • disabled the Role Manager plugin to see if permissions had been corrupted in some way

    Neither of these had any effect. We use the TDO mini forms plugin to create our articles and we are currently testing disabling the plugin while editing already published articles. No obvious reason for this to make a difference though.

    The problem looks as if kses.php is kicking in on already published articles, and not all the time. I can’t find a reason for this on the web. This is driving us crazy!

    Are the tags valid XHTML? Do you have dashboard -> Settings -> Writing -> “WordPress should correct invalidly nested XHTML automatically” deselected?

    Thread Starter lamington

    (@lamington)

    Hi iridiax. Yes, all valid tags and the setting is deselected. An example:

    ORIGINAL:
    <table class="bookdatabox"><tr><td id="book-title"><span id="maintitle">...</span></td></tr><tr><td id="book-author">by <span id="mainauthor">...</span></td></tr><tr><td id="book-isbned">ISBN: <span id="isbn">...</span></td></tr></table>

    STRIPPED:
    <table><tr><td><span>...</span></td></tr><tr><td>by <span>...</span></td></tr><tr><td>ISBN: <span>...</span></td></tr></table>

    Very strange, I can’t see why WordPress should be doing this to valid code. Make sure that dashboard -> users -> your profile -> “Disable the visual editor when writing” is selected, since even an accidental view with the visual editor can mess up code.

    Thread Starter lamington

    (@lamington)

    Yes, tried that as well as one of the first steps. It’s so frustrating… especially because it happens unpredictably (though at times many posts in a row).

    this still happens regularly – I installed tinymce advanced and that helped some.

    For me, the html would strip when I had a < ? php function in the html. It would remove the php and strip the classes. So I replaced the < ? php with [php ] and for whatever reason that seemed to help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘why does WP sometimes strip class and id from html?’ is closed to new replies.