User Tools

Site Tools


BBCode Plugin Tips

Enabling Inline HTML

Inline HTML allows you to mix BBCode with HTML, without using the (deprecated) [html] tag.

Open fp-plugins/bbcode/plugin.bbcode.php and set BBCODE_ESCAPE_HTML to false

(versions newer than 0.812 have a control panel option, in the BBCode Config plugin section)

How to add custom tags

If you plan to add new bbcode tags, don't add them right in the core plugin, otherwise on the next update you'll loose all your changes!

You can create a new plugin with your very own tags by attaching the official one.

For more information on how the FP bbcode class works, see the official documentation.

In this example we will show you how to get an acronym tag expecting the acronym as a tag attribute, and the actual meaning as the tag content [acronym=CSS]Cascading Style Sheet[/acronym] 1) which in your page will look like this: CSS

// this will tell FlatPress to load the new tags at the very beginning 
add_filter('init', 'plugin_custombbcode_tags');
// here you define a function. In this case we're creating an acronym tag
function plugin_custombbcode_tags() {
        $bbcode = plugin_bbcode_init(); //import the "global" bbcode object into current function
                                         // this way 
                                         // a) parsing is done only once, and by the official plugin
                                         // b) you create only ONE object, and therefore computation is quicker
        $bbcode->addCode (
                    'acronym',  // tag name: this will go between square brackets
                    'callback_replace', // type of action: we'll use a callback function
                    'plugin_custombbcode_acronym', // name of the callback function
                    array('usecontent_param' => array ('default')), // supported parameters: "default" is [acronym=valore]
                    'inline', // type of the tag, inline or block, etc
                    array ('listitem', 'block', 'inline', 'link'), // type of elements in which you can use this tag
                    array ()); // type of elements where this tag CAN'T go (in this case, none, so it can go everywhere)
    $bbcode->setCodeFlag ('acronym', 'closetag', BBCODE_CLOSETAG_MUSTEXIST); // a closing tag is mandatory [/tag]
// $content is the text between the two tags, i.e. [tag]CONTAINED TEXT[/tag] $content='CONTAINED TEXT'
// $attributes is an associative array where keys are the tag properties. default is the [tagname=value] property
function plugin_custombbcode_acronym($action, $attributes, $content, $params, $node_object) { 
     if ($action == 'validate') {
        // not used for now
        return true;
    // [acronym=css]Cascading Style Sheet[/acronym]
    // will become <acronym title="Cascading Style Sheet">css</acronym>
    return "<acronym title=\"$content\">{$attributes['default']}</acronym>";

SEO Melbourne Melbourne Web Developer air spray gun Airless Spray

1) If you're wondering whether you can have the alternate syntax [acronym=Cascading Style Sheet]CSS[/acronym], then you can't for now. Multiple words are not allowed in tag attributes
doc/plugins/bbcode/tips.txt · Last modified: 2015/04/10 02:19 by justgerrardz