• I use inline javascript and php sometimes in posts and I’m not a big fan of how WordPress can’t seem to leave these blocks alone when it comes to wpautop and wptexturize. When code within script or php tags gets messed with by these functions, it often breaks. I have the text-control plug-in which allows me to turn off both wpautop and wptexturize on a post-by-post basis, but really, this is not ideal.

    Given that there is pretty much never *any* circumstance where text within script or php blocks should be touched by formatting functions, it seems to me that one of two things should happen (hopefully as a standard part of WordPress) —

    1. wpautop and wptexturize should be improved such that they ignore at least script tags and possibly php tags, and even better a configurable array of tags. Basically, nothing within these tags should get touched and they shouldn’t be wrapped in p tags either.

    2. There should be some sort of “no-op” markup you can add to posts which prevents wpautop and wptexturize from touching what’s inside. So, for instance, you could manually wrap a script tag in specially designated HTML comments which would tell formatting functions to lay off.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Working toward collecting and developing solutions at:

    https://codex.www.ads-software.com/How_Wordpress_Processes_Entry_Text

    @here:

    You don’t need to keep digging up old threads and posting the same thing…

    that’s typically considered spamming, even if for a good cause.

    Just chiming in to say that I, too, am wondering how to accomplish this (or how I understand it): what I’m looking for is the ability to effectively keep wpautop “on” for the majority of a post, but selectively disable it within a post; for example, discussing a chunk of code would use wpautop — the code itself would not.

    Surely there’s a way to allow either the tag itself or a specially named div (or a set of comment-like thingies) to enable this?

    I've been trying, but a) I am not good with regexp, and b) I have no idea what's going on. :(

    discussing a chunk of code

    If you only want this for discussing code, check out the various code-pasting plugins available.

    There are more elaborate plugins if you want to paste code into posts, but I’ve written one that will do the trick. (It’s mainly for comments, but it works in posts too.)

    here

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Preserving Javascript and other code blocks in posts’ is closed to new replies.