Skip to:

{plugin request} – wow itemlinks

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have got it working by editing the header file, but would like a plugin version that also has an added bbcode for the item bbtag.

    The most basic solution looks something like this:

    function wow_item( $text ) {
    $text = preg_replace('|(<item>)(.*?)(</item>)|', '<a href="">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.

    There is an excellent WordPress plugin that I use for one of my blogs that might be a good starting point for making your own plugin for bbPress if you can’t just outright convert it for bbPress.

    First attempt at providing Wowhead item links. Please post any bugs or weirdness. This requires BBPress 1.0 RC 3+ and PHP 5+ . It has no cache, so may not be suited to ultra-high volume forums.

    Plugin Name: Simple Wowhead Item Links
    Plugin Description: Adds item sudo-html to create links to Wowhead.
    Author: Tim Howgego
    Author URI:
    Version: 0.1.rc


    * PHP 5 or above.
    * BBPress 1.0 RC3 or above.


    * Copy the file to the "my-plugins" directory.
    * Active the plugin within the Admin interface.


    * Default language is English. For other languages, edit $lang (in bb_wowhead_item_search) below.
    * Default will color items which are uncommon or rarer. To change this edit $commonest_color (in bb_wowhead_item_search) below.


    * Users must enter the following "sudo-HTML" code within their posts: <item>Name</item> - where name is the correct name of the item to be linked to.
    * Wowhead is queried each time a new link is posted. Once the link is created, it is stored as a complete link within the post. A cache should not be required given the amount of traffic on most forums.
    * If Wowhead is unavailable (often due to maintenance), or some other error occurs, the link created will simply point to a Wowhead search for the item.

    Thanks Drexle for some ideas.

    function bb_wowhead_item_search( $find ) {

    // Edit Options:
    $lang = 'www'; // Language: www (english), de, fr, es, ru.
    $commonest_color = 2; // Only color item qualities of this number or higher. 0 colors all items. 2 does not color white and grey items. 101 (or "high") colors nothing.
    // Stop Editing

    $f = trim ( $find );
    $s = 'http://'.$lang.''.esc_attr( str_replace(' ', '+', strtolower( $f ) ) ).'&xml';
    if ( function_exists("curl_init") ) {
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $s );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 3 );
    $output = curl_exec( $ch );
    curl_close( $ch );
    } else {
    $h = fopen( $s, "r" );
    while ( !feof( $h ) ) $output .= fread( $h, 8192 );
    fclose( $h );
    if ( $output and function_exists("simplexml_load_string") ) {
    $xml = simplexml_load_string( $output );
    $link = $xml->item->link;
    $name = $xml->item->name;
    if ( $link and $name ) {
    $quality = $xml->item->quality[id];
    $class = ( $quality and ( $quality >= $commonest_color ) ) ? ' class="q'.esc_attr( $quality ).'"' : ' class="nocolor"';
    $result = '<a href="'.esc_attr( $link ).'" title="Wowhead - '.esc_attr( $name ).'."'.$class.'>'.esc_html( $name ).'</a>';
    if ( $result ) return $result;
    else return '<a href="http://'.$lang.''.esc_attr( $f ).'" title="Wowhead - '.esc_attr( $f ).'.">'.esc_html( $f ).'</a>';

    function bb_wowhead_item_link( $text ) {
    $text = preg_replace('|(<item>)(.*?)(</item>)|e', "bb_wowhead_item_search('\2')", $text);
    return $text;

    function bb_wowhead_item_tags( $tags ) {
    $tags['item'] = array();
    $tags['a'] = array( 'href' => array(), 'title' => array(), 'class' => array(), 'rel' => array() );
    return $tags;

    function bb_wowhead_item_header() {
    echo '<script language="JavaScript" type="text/javascript" src=""></script>'."n";

    add_filter( 'bb_allowed_tags', 'bb_wowhead_item_tags' );
    add_filter( 'pre_post', 'bb_wowhead_item_link' );
    add_action( 'bb_head', 'bb_wowhead_item_header' ); // Comment this line out if the Wowhead javascript file already exists in the header


    Footnote: Due to Wowhead URL changes needs to become (just below the edit options section of the code). You can also change to , but that’s less critical.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar