Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: {plugin request} – wow itemlinks

The most basic solution looks something like this:

function wow_item( $text ) {
$text = preg_replace('|(<item>)(.*?)(</item>)|', '<a href="http://www.wowhead.com/?search=s2">s2</a>', $text);
return $text;
}
function wow_item_allowed_tags( $tags ) {
$tags['item'] = array();
return $tags;
}
add_filter( 'bb_allowed_tags', 'wow_item_allowed_tags' );
add_filter( 'pre_post', 'wow_item' );

(replace the s2 with $2)

That would create <item> sudo-tags that link the name of the item to a Wowhead search. But that isn’t what you want: It just send a search query to Wowhead, without creating a tooltip.

Instead, such a plugin needs to go and ask Wowhead’s OpenSearch/RSS for a result, then come back and write out a complete item URL. Fortunately that query only needs to be done once, when the topic is first posted, not every time the post is displayed. Posting would get delayed, put probably only by a second, and only where the item tag was used. So there’s no need to cache the result. And 90% of the same code would work for anything with a OpenSearch output (most major sites).

This is something I’d like to have, and it’s been on my “to do” list for about a year… So, erm, soon! Maybe.

Skip to toolbar