Posts about disabling ‘wptexturize()’ & ‘wpautop’ for Plain Text WordPress

Here’s a post about how to tweak WordPress to stop it from modifying your posts after entering ‘<!--PLAIN_TEXT-->'

Easy Plain Text WordPress (Look Ma! No curly quotes!)

So, after Googling extensively and searching far and wide through the WordPress forums, here is what I came up with to put a clean and simple leash on WordPress and make it do the following:

  1. Stop parsing my example codes.
  2. Stop fancifying my plain quotes and double quotes into those damnable fancy curly quotes.And above all…
  3. Stop pooping all over my raw HTML code, sweeping it aside and then formatting everything into its tunnel vision idea of paragraphing and creating line breaks.

In other words, display my blog post using the exact HTML I entered on the ‘Write Post’ screen.

Here’s what I did to accomplish this:

  1. First of all, I disabled the WYSIWYG editor. To do this, you have to go to Users >> Your Profile and simply clear the checkbox beside “Use the visual editor when writing”. Then click on ‘Update Profile’ to apply the changes.Done and done.Next…
  2. I installed Jason Litka’s Disable Texturizer plugin. This will prevent WordPress from fancifying a lot of your input like turning plain double quotes “…” into curly double quotes “…” and the like. This great little plugin is only 3 lines of code. All it does is disable the wptexturize filter for your posts, excerpts and comments. Very simple, very clean. Easy to install.And finally..
  3. I hacked into the WordPress formatting.php file just a wee bit. To do this, go to the wp-includes subfolder in the folder where your WordPress blog is installed, open the formatting.php file in a plain text editor and do a search for “function wpautop” which will bring you to this line of code:function wpautop($pee, $br = 1) {Directly after that type in (or copy and paste) these two lines of code: // Disable WP auto-paragraphing on call
    if ( preg_match('/<!--PLAIN_TEXT-->/', $pee) ) return $pee;

    The rest of the wpautop function should remain as is.

    Example:

    function wpautop($pee, $br = 1) {

    // Disable WP auto-paragraphing on call
    if ( preg_match(‘/<!–PLAIN_TEXT–>/’, $pee) ) return $pee;

    $pee = $pee . “n”; // just to make things a little easier, pad the end
    $pee = preg_replace(‘<br />s*<br />|’, “nn”, $pee);
    // Space things out a little

    The rest of the code follows…

    Save the file and you’re done.

    Now, whenever you want to have WordPress treat your blog post as plain text and parse your HTML exactly how you coded it, all you have to do is begin your blog post with this HTML comment line (no spaces and don’t forget the underscore ( _ ) between PLAIN and TEXT:

    <!--PLAIN_TEXT-->

    And boom. Bob’s yer uncle. No more wrestling with WordPress trying to get it to behave.

Code Snippet 2.0 + Disable wptexturize = Code in my blog

From the post:

The solutions: Code Snippet 2.0 for syntax highlighting and “Disable wptexturize” to… well… disable that particular “feature.” Code Snippet is built on top of Geshi, an excellent language syntax highlighter: JavaScript, PHP, and HTML, to name a few of the more important ones. The “Disable wptexturize” plugin is three lines from heaven, removing the texturize filter from the primary content of all blog entries.

With this combo of plugins, I can now do this in my blog…

// javascript:
var helloWorld = {
talk: function() {
alert(‘Hello, world!’);
}
};

… and this …

/* php: */
class HelloWorld {
public function talk() {
echo ‘Hello, world!’;
}
}