Plugin Directory

fauxML

Developer FAQ / API

I want to write a plugin that uses fauxML for this cool new site, bobs-wonder-widgets.info. How do I do that?

Just register your fauxML parser with fauxML's wp_add_faux_ml( $your_faux_ml_name, $your_parsing_function ) function.

wp_add_faux_ml( 'bobs-wonder-widget', 'bobs_wonder_widget_parser' );

function bobs_wonder_widget_parser( $widget_data ) {
    $url = trim($widget_data);
    // $widget_markup = do some stuff after looking at $url;
    return $widget_markup;
}

Then when you type [bobs-wonder-widget some stuff] in a post, the text between [bobs-wonder-widget and ] will be sent to your parser function and the whole thing will be replaced by the output of that function.

There's only one restriction: $your_faux_ml_name may be made of letters, numbers and hyphens only.

But my fauxML is more complicated than just `[bobs-wonder-widget some stuff]`. Can't you help?

Yes! You can also register your fauxML parsing function with a regular expression instead of just a name. In this case, the argument sent to your parser is the array of regex matches from the regex you provided.

wp_add_faux_ml( '!\[bobs-(wonder|neato)-widget[ =](.*?)\]!i', 'bobs_wonder_and_neato_widget_parser' );

function bobs_wonder_and_neato_widget_parser( $regex_matches_array ) {
    // $widget_markup = do some stuff after looking at the regex matches;
    return $widget_markup;
}

Can FauxML be used elsewhere besides posts?

Yup! wp_add_faux_ml accepts a third argument: the name of the WordPress filter hook to which you want to add your FauxML (it defaults to the_content).

Too allow Bob's wonder widget FauxML parsing in comments, for example, add the following line to your plugin.

wp_add_faux_ml( 'bobs-wonder-widget', 'bobs_wonder_widget_parser', 'comment_text' );

Other Plugins

This plugin offers similar markup parsing for YouTube videos.

While these offer expanded presentational functionality.

And this plugin does something quasi-related.

Download

FYI

Compatibility beta

Your Setup

Log in to vote.

The Consensus

No data

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(2 ratings)