Exporting Textile2 Content with WordPress

A friend of mine approached me recently to help him out. He had tons of archives in his WordPress blog that had been created using the Textile2 plugin. Textile is a form of markup that is wiki-like. In other words, it’s not straight HTML. The Textile2 plugin interprets the markup and renders HTML that browsers can understand when the post is actually called.

I created a small plugin for him that, on WordPress export, translates Textiled content into standard HTML format. It depends on the Textile2 plugin, so if you are going to use this, make sure you have that.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/*
Plugin Name: Textile Friendly Export
Version: 1.0
Plugin URI: http://technosailor.com
Description: Translates Textile 2 Content to HTML on WXR Export
Author: Aaron Brazell
Author URI: http://technosailor.com
Disclaimer: This Plugin comes with no warranty, expressed or implied
*/

function textile2_export( $content )
{
    global $myTextile2;
   
    if( !class_exists('Textile2_New') )
        return $content;
   
    return $myTextile2->do_textile( $content );
}
add_filter( 'the_excerpt_export', 'textile2_export' );
add_filter( 'the_content_export', 'textile2_export' );
?>