• install PEAR::Text_Wiki and PEAR::Text_Wiki_BBCode from https://pear.sourceforge.net/

    then put this in wp-plugins/text_wiki_bbcode.php

    <?php
    /*
    Plugin Name: BBCode (Twiki)
    Version: 1.0
    Plugin URI: https://www.ben-xo.com/wordpress-twiki-bbcode-plugin/
    Description: Allows BBCode markup to be used in the content, excerpt, and comments of WordPress. Uses PEAR_Twiki_BBCode, so make sure you install that.
    Author: Ben XO
    Author URI: https://www.ben-xo.com/
    */

    // Copyright (c) 2004 Jeff Moore
    // Portions Copyright (c) 1997-2003 The PHP Group
    // LICENSE: This source file is subject to version 2.02 of the PHP license.
    // This code contains a modified version of PEAR::HTML_BBCodeParser,
    // (original author Stijn de Reede <[email protected]>).
    // https://pear.php.net/package/HTML_BBCodeParser/docs

    if (!defined(‘CUSTOM_TAGS’)) {
    define(‘CUSTOM_TAGS’, TRUE);
    }

    require(“Text/Wiki/BBCode.php”);

    $allowedtags = array(
    ‘a’ => array(
    ‘href’ => array(),
    ‘title’ => array(),
    ‘rel’ => array()),
    ‘abbr’ => array(‘title’ => array()),
    ‘acronym’ => array(‘title’ => array()),
    ‘b’ => array(),
    ‘blockquote’ => array(‘cite’ => array()),
    ‘code’ => array(),
    ‘div’ => array(‘align’ => array()),
    ’em’ => array(),
    ‘font’ => array(
    ‘color’ => array(),
    ‘size’ => array(),
    ‘face’ => array()),
    ‘i’ => array(),
    ‘li’ => array(),
    ‘ol’ => array(),
    ‘strike’ => array(),
    ‘strong’ => array(),
    ‘sub’ => array(),
    ‘sup’ => array(),
    ‘ul’ => array(),
    );

    function BBCode($text) {
    $parser =& new Text_Wiki_BBCode();
    // $parser->setRenderConf();
    return $parser->transform($text,’xhtml’);
    }

    remove_filter(‘the_content’, ‘wptexturize’);
    remove_filter(‘the_excerpt’, ‘wptexturize’);
    remove_filter(‘comment_text’, ‘wptexturize’);

    add_filter(‘the_content’, ‘BBCode’, 5);
    add_filter(‘the_excerpt’, ‘BBCode’, 5);
    add_filter(‘comment_text’, ‘BBCode’, 5);

    ?>

    (i havent made a web page for it yet).

    Text_Wiki_BBCode is brand new, and doesn’t quite do all BBCode right yet. But all the major bugs are fixed in CVS, or at least, fixed on my hard disk (including not doing [size=(+/-)n]). You can expect this to continue to get updated for a while to come.

  • The topic ‘I’ve made a new BBCode plugin using PEAR::Text_Wiki_BBCode’ is closed to new replies.