I'm a huge fan of using Markdown for authoring web content. I've been on a big push as of late to see my clients publish their web material using Markdown. Many of the sites I build and maintain are based on WordPress. Markdown is not WordPress' standard editing method out of the box. WP-Markdown is a WordPress plugin which replaces the standard TinyMCE editor with a Markdown editor. It even allows Markdown editing in comments. It's a super handy plugin.

When I'm developing custom themes I often create snippet fields that are stored as plain text in WordPress options. In many cases I want to get the text from field and process it from Markdown into HTML.

WP-Markdown exposes two functions which can be used to convert to or from Markdown. These functions are found in the WP-Markdown source code.

I had a brief discussion with the plugin author in a Github issue about using WordPress' filters API to offer filters that process the Markdown. He felt that you could just use the functions. I see some advantages to doing things the WordPress way using filters.

The code I write will be more durable using filters. It provides a built-in fail safe in case the WP-Markdown plugin is not enabled. The Markdown won't be processed, but more importantly the theme won't generate a PHP error.

If a filter is used, additional filtering can be attached to that filter's tag by using lower priority. This could come in handy for custom theme development.

Here's what I am now adding to the functions.php.

This lets me use WordPress filters to process Markdown.

I find it to be a clean way to make use of WP-Markdown's Markdown processing feature.