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.
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;
}
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' );
This plugin offers similar markup parsing for YouTube videos.
While these offer expanded presentational functionality.
And this plugin does something quasi-related.




