Raw HTML Plugin for WordPress

Introduction

Recently I needed to put some style definitions and a JavaScript function in a post on another blog that I have. I wasted several hours trying to do this, because WordPress insisted on putting backslashes in front of my apostrophes, inserting superfluous <p> or <br /> tags in place of newlines, and generally breaking my HTML in various horrible ways.

In the end I decided to just go and write a plugin that would let me disable the automatic formatting that WordPress applies to post content. This plugin adds a set of shortcodes that you can use to “protect” specific parts of your post and prevent WP from messing with them.

Download & Installation

Requirements :

  • WordPress 2.8 or later
  • If you use the free version, I strongly recommend disabling the visual editor. It (the editor) can mess up your code even if you use this plugin.

Installation is straightforward – download the zip file, unzip, upload the raw-html folder to /wp-content/plugins and activate it in the Plugins tab.

Usage

There are two ways to use the plugin. First, to turn off “smart quotes” and other built-in filters for an entire post, use the checkboxes that Raw HTML adds to the “Edit Post” screen:

Raw HTML meta box screenshot

If you want to prevent a specific part of your post or page from being processed and “texturized” by WordPress, wrap it in ... or <!–raw–>…<!–/raw–> tags. The two versions work exactly the same, with one exception – the <!–raw–>’s won’t be visible to your visitors even if you deactivate the plugin.

Example :
<!--raw-->
This

is

a ‘test’!
<!–/raw–>

Result :
This is a 'test'!

If you view the source code of this page, you will see that the newlines are still there, and the apostrophes haven’t been converted/escaped.

Other Notes

This plugin is provided AS IS, with no guarantee that it will work on your site.

Related posts :

318 Responses to “Raw HTML Plugin for WordPress”

  1. White Shadow says:

    Yes, the free version does not really support the visual editor. It only works right if you use the HTML mode.

    The difference between between free and pro is that with the pro version you can switch between visual and HTML without the editor messing up your tags. The way it works is by making any code you surround with the raw tags editable only in HTML mode. Perhaps these screenshots will explain it better.

  2. Jason says:

    Upgraded to Pro, now I rocking…I am going to make this a standard on all my WP sites.

  3. White Shadow says:

    Yay, thanks šŸ™‚

  4. Paul Strydom says:

    Testing your plugin and really having a hard time, look at this page in a browser like chrome to see what I am talking about, http://www.sbsgroup.co.za/water-tanks/
    What I am trying to do is add h1, h2, h3 tags into the copy for seo purposes, something like this
    We at SBS deal in two main
    This should all be on one line, if I view source on the page it is correct
    The SBS word is jumping down a line on the browser
    If in google I right click on this area and say inspect element
    We at
    SBS
    ” deal in two main……”

    I figured it was my stylesheets but it is working in some places and not in others and I have used this style sheet before on a Dreamweaver project and it was all good.

    The style definition looks like this
    h1, h2, h3, h4, h5, h6 {display:inline; font-family:Trebuchet MS, Arial, Helvetica, sans serif; font-size:100%; font-style:normal; font-weight:normal; margin:0; padding:0; font-weight:inherit; color:inherit; }

    Please try tell me why.

    If I purchase the plugin will I be able to do it on text within widgets too.

  5. White Shadow says:

    Try moving the opening <–raw–> tag up so that it’s right after the image and there are no spaces between them. There’s a small(ish) chance that it might work.

    No, the paid version does not work in widgets.

  6. Paul Strydom says:

    Thanks for the try, what a pity still not working.

  7. hanazair says:

    Thanks!! Your plug-in works great and make my life much easier! šŸ™‚

  8. Thanks for this plugin, it works well on standard pages, but I don’t know if you’re aware that it seems to get confused when there are shortcodes in use? For example I was trying to use

    <!-- Don't edit below this line -->
    [shortcode name foo="bar" /]

    and my output had the shortcode parsed, but above it I just had !RAWBLOCK0!

    I’ve done a bit of testing and can see that by the time it gets to the function wsh_insert_exclusions() it doesn’t have the original $text value, but the parsed content, so there are no rawblocks to then parse and replace the comment back in. Possibly just a running order issue?

  9. Brian says:

    whats up with the pro version?

  10. Rusty says:

    I was interested in the Pro version, but the link (http://wpplugins.com/plugin/850/raw-html-pro/) displays:
    “Sorry, we can’t find the content you’re looking for at this URL. Please try selecting a menu item from above or to the side of this message to get where you’d like to go.”
    =/ It’s kinda bad for business probably.
    Please let me know when you get it fixed–seems like a plugin worth spending some money on.
    Thanks!

  11. The Pro version is temporarily unavailable. I made a small change to its product page on WPPlugins.com a while ago, and, since each change needs to be approved by their staff, the page will be down until one of them gets around to reviewing the update. I’ve asked them why it’s taking so long they said they were doing some site updates, and would get around to it “soon” :/

    I’ll leave a note here when it becomes available again.

  12. Chris says:

    I have since uninstalled the free version and I have yet to be able to use my visual editor anymore.

    Is there something I can do? I stopped using the plugin because I didnt know what I was doing in the first place and some programmer told me to install it.

    But now that there is no need for it I cant get my regular visual editor to post pictures or video without pasting the raw html code into the file…

    What can I do to fix this so that my site works properly again?

    Thanks for taking the time…

  13. Mike says:

    Hi Janis,
    When I click edit on your plugin it takes me to raw-html/raw_html.php (active).
    This is your php page. The plugin is not working on my post and you recommend turning off smart quotes. If go to settings where it list the active plugins and you can edit, your plugin is not listed. I use hostgator and the file manager will only upload the zip foldler and not the unzip folder as you have instructed. Under my plugins in my Catalyst theme your plugin says activated. I cannot display the editor menu to turn off the smart quotes. I appreciate your advice.
    Thank you

  14. Mike says:

    Hi again,
    Disregard that last question. I disable the smart quotes. However, the raw html does not show only the anchor text shows. I am using a catalyst theme. Any suggestions, thank you,
    Mike

  15. @ Chris
    More details would be helpful. What specifically is the problem you’re having with the visual editor – does it display an error message when you try to add a picture, or does something else go wrong? Does the problem affect all post or only existing/new ones?

    If it only happens with old posts, check the HTML view for any remaining <!–raw–> tags or other plugin-related code. Maybe you’ve inadvertently added some HTML stuff that the visual editor can’t display properly and it’s messing up everything else as a result.

    @ Mike
    What is it that you’re trying to accomplish with the plugin? Post a sample of your code, if possible.

  16. Mike says:

    Thank you for your response Janis
    I am working on a new post. It is a tutorial style on optimzation. I have colored all the steps and I want it to show the raw html just like the example below but without the open and close raw. All I can get when I click save the post is the anchor text “internet marketers” not the raw html showing.
    This is what my html looks like before I save:
    internet marketers
    Here is what it looks like after I save: internet marketers (colored blue).
    Here is what I want it to look like on the finished post:
    internet marketers
    To see if I had un-necessary html, I opened a new add post page and under html edit just inserted the link as show at the top. Clicked save, view post, same results.
    Also I have checked the box “Disable wptexturize” for that new post.
    Thank you for your help,
    Mike

  17. Mike says:

    Hi again,
    When I clicked submit the same thing happened as in my post.
    Here is what my html looks like before:
    !–raw– a href=”http://aprofitsystemonline.com/?p=185″span style=”color: #1474ff;” internet marketers /span /a !–/raw–but with the greater than and less than characters.
    Here is what I want it look like on the finished post.
    a href=”http://aprofitsystemonline.com/?p=185″span style=”color: #1474ff;”internet marketers /span /a but with the greater than and less than characters.
    I apologize for the above post I forgot that your comment box would not be running your raw html plugin–little slow this morning.

  18. Ah, I see. RawHTML is not the right plugin for posting code samples. Instead, use something like WP-Syntax.

    Then you can use code like this:

    
    
    internet marketers

    To produce this:

    internet marketers

    Note: WP-Syntax is just what works for me. There are also other plugins for posting code in WordPress.

  19. […] The first issue can be handled with a plugin that allows you to insert pure HTML into your posts: Raw HTML Capability. If you have been struggling to put HTML or JavaScript in your WordPress posts this plugin works […]

Leave a Reply