Tag Archives: WordPress

Anthologize — Turn Your Blog into an eBook

Anthologize is an interesting new WordPress plugin that helps you compile an eBook using posts from your blog. It supports the PDF, ePub and TEI formats.

Anthologize is a free, open-source, plugin that transforms WordPress 3.0 into a platform for publishing electronic texts. Grab posts from your WordPress blog, import feeds from external sites, or create new content directly within Anthologize. Then outline, order, and edit your work, crafting it into a single volume for export in several formats, including—in this release—PDF, ePUB, TEI.

It sounds like Anthologize would be an easy way to take the content you’ve produced over a few years and use it as a basis for an eBook, which you could then distribute through Amazon or iTunes—or in print through somewhere like Lulu.

I’m also reminded of an old idea of mine… I’ve always thought it would be fun to write a “serial novel” in installments posted on a WordPress blog. (i.e. a chapter per post.) Anthologize would be useful in a situation like that, as the finished work could be easily converted to a form suitable for publication in print or through an eBook store.

WordPress to Finally Drop PHP4 Support

At long last, the WordPress project will be ending support for PHP 4. WordPress 3.1, to be released in late this year, will be the last version to support the legacy version of PHP.

For WordPress 3.2, due in the first half of 2011, we will be raising the minimum required PHP version to 5.2. Why 5.2? Because that’s what the vast majority of WordPress users are using, and it offers substantial improvements over earlier PHP 5 releases. It is also the minimum PHP version that the Drupal and Joomla projects will be supporting in their next versions, both due out this year.

The PHP developers themselves dropped support for PHP 4 back in 2008 in order to focus on the PHP 5 branch and beyond. PHP 5 was released six whole years ago and has many improvements over PHP 4.

Mark Jaquith in his announcement says that only 11% of WordPress installs are running versions of PHP under 5.2, and that the decision will likely give those few hosting providers the necessary kick.

Creating a Virtual Post in WordPress

One thing that plugin developers want to do sooner or later is create a “fake” post. (Maybe you have a statistics plugin that you want to display a public graph when someone visits example.org/traffic.) You need to create the equivalent of a Page on the fly.

Fortunately, someone has already figured out how to do just that.

The general idea is to

  1. Collect the page slug from the request
  2. See if it matches the URL we want our virtual Page to be located at
  3. Prepare the content and metadata for the fake Page
  4. Hijack the page retrieval by changing the values of some variables
  5. Display everything as usual

It seems to work pretty well, and nothing seems to break when running a plugin making use of the trick.

WordPress Administration Over SSL

Do you frequently log-in to your WordPress install over public WiFi networks? While it may seem like paranoia to some people, it’s really not a good idea to log into important sites over an unencrypted connection. There’s always a possibility that someone could be packet sniffing. If you run a high-profile blog, you might want to consider acquiring an SSL certificate. (A certificate is a sort of public key used to establish an encrypted connection.) With a certificate, you can log into WordPress with an HTTPS connection. This encrypts traffic between you and your server, making it impossible for anybody to intercept your password while you work from a café.

It’s a bit of a pain to set up SSL, but many web hosts will do it for you. WPWebHost, for instance, will configure SSL for you if you get a certificate. They run around $89/year (I know, what a racket…) from most certificate authorities, and some hosts will charge a small set-up fee. VPS.net, on the other hand, has a deal with Comodo where you can get a free SSL certificate as long as you are hosted by them. You have to set everything up on your own, though.

What do you do once you have a security certificate? There’s a Codex article on the subject. There are a couple of WordPress constants in wp-config.php that you can toggle on to force everything in the /wp-admin directory to be served over HTTPS, the login page most importantly.

You probably won’t ever have to worry about this, unless you run a very large blog or you like to work from a coffee shop across the street from a computer security convention. WordPress.com users are lucky; they can just go to https://wordpress.com/wp-login.php to log in securely.

Calculating Relative Time Stamps With PHP and WordPress

If you go to a social networking site like Twitter, you’ll note that status updates don’t have conventional timestamps on them. Instead of something overly informative (in most cases) like “Posted 2010/07/06 7:50 PM” they tend to show the much more human-friendly “Posted 2 days ago” format for recent dates. These relative time stamps are useful in many cases because of how people think about time. If someone tells you that a new book is going to be released on some date. You immediately think “that’s 3 weeks from today.” Relative time stamps take that extra step out.

Now what do you need to do to display relative time stamps? It’s very simple in WordPress, using the human_time_diff() function. Things are a little bit harder for other projects, where you don’t have the luxury of using the pre-existing WordPress functions.

PHP Snippets has a copy-and-paste-able function that works in much the same way. It takes a UNIX timestamp as an input and uses the “granularity” option you set to find the difference between the times, then returns a string.

WordPress 3.0: The Beginning of WordPress Tumbleblogs?

A lot of people enjoy using the easy to use Tumblr service as a way to save and share links, quotes, videos, pictures, etc.. These “tumbleblogs,” as they are called, are a neat idea. It’s a similar concept to Twitter, posting quick updates instead of full-length blog posts. Out of the box, WordPress can be (and is) used in this manner. You don’t get the easy-to-use multimedia posting interface like Tumblr, though. Or the different styling for each type of post, either.

WordPress 3.0 has improved support for custom post types, which would make it very easy for someone to build Tumblr-like functionality into WordPress by way of a plugin.

Here’s a business idea for anyone enterprising enough to make it happen: Build a plugin that extends WordPress with Tumblr-style functionality. Add hooks and functions that themes could take advantage of. Give the plugin away for free, licensed under the GPL of course. Once that’s out of the way, you build a business selling themes that make use of the plugin. The plugin provides the framework, and then you can sell some low-cost themes that utilize the framework.

Lazy-Loading Images

You may have noticed that a lot of large blogs, like Smashing Magazine and the TUTS+ network, are “lazy-loading” images in their posts. Sometimes, as you scroll through a post full of images, you might catch an image fading in just as it comes onto the screen.

This technique is known as lazy-loading. It makes web pages appear faster, and can save a little server bandwidth. Instead of loading all of the large images on a page, you use JavaScript to delay their loading until they’re needed. This makes the initial page load faster. As the user scrolls down the page, the script loads the images just before they’re needed and places them in their spots.

There is a jQuery plugin you can use for lazy-loading images on any page.

For WordPress users, there is an easy to install WordPress plugin that implements the jQuery lazy-load plugin for you.

WordPress 3.0 Now Available

Just yesterday WordPress 3.0 was finally made available. Featuring the new default “Twenty Ten” theme and the long-awaited (by some) merging of WordPress and WordPress MU. The interface, also, has had some cosmetic changes. Everything is still in the same place, but it’s all “lighter” and bit different. (I can’t say I’m a fan of the new header. I prefer the dark gray to the light gray gradient…)

Matt Mullenweg, in his announcement, stated that work on WordPress 3.1 will not begin in the next development cycle, but in the one after. The team is going to work on improving WordPress.org instead.

Normally this is where I’d say we’re about to start work on 3.1, but we’re actually not. We’re going to take a release cycle off to focus on all of the things around WordPress. The growth of the community has been breathtaking, including over 10.3 million downloads of version 2.9, but so much of our effort has been focused on the core software it hasn’t left much time for anything else. Over the next three months we’re going to split into ninja/pirate teams focused on different areas of the around-WordPress experience, including the showcase, Codex, forums, profiles, update and compatibility APIs, theme directory, plugin directory, mailing lists, core plugins, wordcamp.org… the possibilities are endless.

WordPress JSON API Plugin

WordPress provides an RSS feed for just about every part of the website. You can get XML output for anything, from posts to tags to comments. But what if you’re working with JavaScript? Wouldn’t it be nice to have a JSON option? That’s what the JSON API plugin does. Appending ?json=1 to the end of any WordPress URL will work like the RSS option, but the feed will be formatted as JSON. It can even be used to submit comments, if you invoke the right method.

This plugin was created for The Museum of Modern Art, whose weblog Inside/Out appears within an existing structure built with Ruby on Rails. Instead of reimplementing the site templates as a WordPress theme, we opted for a Rails front-end that displays content served from a WordPress back-end. JSON API provides the necessary interface for retrieving content and accepting comment submissions.

I like Chris Coyier’s suggestion of using it in conjunction with the jQuery UI Autocomplete component in order to add a Google Suggest-type feature to your search form.

WordPress JSON API Plugin [Digging into WordPress]


Debugging WordPress

When working on a plugin or theme, have you ever went to your browser to test some changes, only to be greeted by the dreaded blank white screen? Sometimes the bug in your code is immediately apparent, but what about the times when it’s not? Wouldn’t it be useful if you could see the PHP errors, instead of a blank screen?

The good news is: you can. Just add this simple constant to your wp-config.php file:

define('WP_DEBUG_DISPLAY', true);

Be aware that it’s a bad idea to do this on a production server, as some errors may betray dangerous information, such as system paths or database credentials.

What if you need to see errors on a production server, or you need a record of the errors? You can have them output to a log file (wp-content/debug.log).

define('WP_DEBUG_LOG', true);

You can use either statement alone, or both at the same time.