jQuery and Ajax in WordPress Plugins – Administration Pages

This is a quick overview of how to use jQuery and its Ajax functions in WordPress. To get the point across, I’ll use a simple and contrived example. We’ll have an admin screen with a list of categories. Clicking on the name of one of the categories will fetch a list of titles of posts in that category and display them as a sub-list of that category. Continue reading “jQuery and Ajax in WordPress Plugins – Administration Pages”

Issue Manager WordPress Plugin

Since we started the Code4Lib Journal, we’ve had a persistent problem of editors accidentally publishing articles early (i.e., before the issue was officially published). Our first workaround for that was to remove the ‘publish_posts’ capability from the editor role. With that capability removed, only the administrator (i.e., me) could publish articles.

That worked, but it was a hassle, as it required me to do what should have been the coordinating editor’s job of publishing each article when it came time to publish a new issue. For that matter, even if permissions weren’t an issue, the publication process would still be cumbersome: open every article in the issue, change its status to “Published”, and save it, doing them all as fast as you can so people didn’t find a half-published issue when they came to the website.

It was to fix these and other problems that I created the Issue Manager WordPress plugin. It connects the publication status of an article to the category it’s in. You can designate a category as “Unpublished”, so that no articles in that category can be published. If you try to publish an article, it’s status changes to “Pending Review”. When it’s time to publish an issue, you change its category’s status to “Published”, which publishes all the “Pending Review” articles in that category. Continue reading “Issue Manager WordPress Plugin”

How to Install FCKeditor on Drupal

After some trouble lately getting everything working, I finally have the FCKeditor WYSIWYG editor installed and working on Drupal. The official documentation leaves a little to be desired, so it seems prudent to document and share what I had to do to make it work.

I’m using Drupal 6.2, the FCKeditor module 6.x-1.2-1, and FCKeditor 2.6. Continue reading “How to Install FCKeditor on Drupal”

Save My <pre> WordPress Plugin, or, WTF-8 My Whitespace

If you’ve tried to use code samples in WordPress, you might have noticed unexpected behavior from the WYSIWYG editor. It will edit the whitespace inside of <pre> tags, leaving you with some poorly formatted, hard-to-read code. Today, I set out to stop that.

What causes this?

Whenever the WYSIWYG editor opens, it sends the content of the post through a few filters. You can find most of these in wp-includes/formatting.php. The culprit here is the function wpautop. This function runs a long list of regular expressions to make your content a little prettier and better formatted. But we don’t want that to happen to our <pre> tags; they’re pre-formatted. We want those left alone. To do that, I had to find a way to keep the content of the <pre> element from going through that filter.

WordPress’s plugin system allows you to change its behavior without altering the core code, so you don’t have to re-alter it every time you upgrade. As easy as it would have been, in the short-term, to just edit wpautop to make it behave properly, I wanted a longer-term solution that would be easier to share with other WordPress users. Therefore, a plugin. Continue reading “Save My <pre> WordPress Plugin, or, WTF-8 My Whitespace”