Tag Archives: Plain Text Custom Post Type

Updated Plain Text CPT Plugin

Had to do a quick update for my Plain Text Custom Post Type WordPress plugin.

Right now I'm only using it one site, and I've never noticed a problem until this week. The JavaScript wasn't working from another computer. Turns out it was conflicting with the stats module in Jetpack. Jetpack inserts a bit of code in either wp_footer or the shutdown action to do the tracking. It never was an issue with me because Jetpack doesn't insert that code when logged in. Wasn't logged in on the other computer and that's when the conflict showed up for me.

So a quick remove_action to get the Jetpack action out of shutdown on the plain text posts and it appears to be working without a hitch now.

New version is up at the WordPress Plugin Site.

Tagged , ,

Plain Text Custom Post Type

Screen shot of the plain text post list page.

Just uploaded a plugin to the WordPress SVN that creates a plain text custom post type. It's a post that has absolutely no formatting, and even strips out the WordPress theme leaving just the text.

What's the point?

I'm playing around with a network installation of WordPress. One of the sites that I'm moving to the network was originally a Dreamweaver site and needs a JavaScript file that's specific to that site. But one of the advantages of moving this site to a WP network is that I don't have to do as much individually to an specific site so I didn't want to have to customize a theme for a single site. With this plugin I'm able to create a post that contains the contents of the external JavaScript file, I don't have to touch the theme files or, and any customization of that file doesn't affect any of the other sites on the network.

How's it work?

Plain Text Files added under the Pages tab

After activating the plugin a new menu item is added under the Pages tab. Adding a new Plain Text File post works just like any other post except there are fewer meta boxes on the page and Tiny MCE is disabled.

The other thing you might notice is that the tab key doesn't work like it's supposed to when typing in the text area. Instead of moving on to the next field like is normal for a web page, the tab key works like it does in a normal text editor.

Two new fields are added to the post meta box just above the Publish button.

The first allows you to pick what type of file you're editing; CSS, JavaScript, or plain text. This affects the Content-type header that is sent with your file. A CSS files gets text/css, JavaScript gets text/javascript, and plain text gets text/plain. For most browsers this won't matter, but it's done anyway.

Publish meta box for the plain text custom post type

Where it does matter is if you check the box to auto load your file. This will add a link to your plain text post into the head section of your theme. So if you create a JavaScript file and select automatic linking, WordPress will put a link to the post including the <script> tags. Same with CSS.

A plain text file will not link even if you check the box. Linking to a non-CSS, non-JavaScript file doesn't make sense in the header.

Need a demo?

Not much to see since it's just linking to an external JavaScript file, but the site I wrote this for is QuickCalcs.info.

Download

You can download Plain Text Custom Post Type from the WordPress plugin library or through WordPress.

Tagged , ,

A couple of new WordPress plugins

Had some free time this week and kicked out a couple new WordPress plugins for another site I'm working on.

Plain Text Custom Post Type adds a new custom post type to WordPress that outputs as just plain text.

What it was written for, and what I'm using it for, is to allow me to edit a JavaScript file from within WordPress. The site it's written for is a WordPress network site and I didn't want to have to worry about customizing a theme for just one blog or uploading through FTP.

You also have the option of automatically linking the files in the head section of your theme if it's a JavaScript or CSS file.

The other plugin is called Insert JavaScript and CSS. Similar to the other, but this one lets you put attach JavaScript or CSS to a post or page. Written for the same site as the other, there were pages that I needed to attach a bit of JavaScript to easily and none of the existing plugins I tried would do exactly what I wanted without a lot of overhead.

When I get a chance I'll put up a more detailed post on both of these, but if you follow the links above you can go to the WordPress plugin site and download from there.

Tagged , , ,