Below you will find the code for version 0.2 of the Wikilink plugin by Auz. This is just a mirror of the most up to date code that is available here
<?php class NP_WikiLink extends NucleusPlugin { // name of plugin function getName() { return 'WikiLink'; } // author of plugin function getAuthor() { return 'Auz'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL() { return 'http://www.auzsoft.net/'; } // version of the plugin function getVersion() { return '0.3'; } // a description to be shown on the installed plugins listing function getDescription() { return 'Replaces [[Wiki]] and [[Wiki (site)|Wiki]] coding with links to Wikipedia'; } function getEventList() { return array('PreItem'); } function event_PreItem($data) { $this->currentItem = &$data["item"]; $this->currentItem->body = NP_WikiLink::wikiLink( $this->currentItem->body ); $this->currentItem->more = NP_WikiLink::wikiLink( $this->currentItem->more ); // $this->currentItem->body = preg_replace( "/\[\[(.+?)\|(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\2\">\\2</a>", $this->currentItem->body ); // $this->currentItem->more = preg_replace( "/\[\[(.+?)\|(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\2\">\\2</a>", $this->currentItem->more ); // $this->currentItem->body = preg_replace( "/\[\[(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\1\">\\1</a>", $this->currentItem->body ); // $this->currentItem->more = preg_replace( "/\[\[(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\1\">\\1</a>", $this->currentItem->more ); } function wikiLink( $text ) { $links = preg_match_all( "/(\[\[.+?\]\])/", $text, $wiki, PREG_SET_ORDER ); for( $i=0; $i<$links; $i++ ) { $link = preg_match( "/^\[\[(.+?)\]\]$/", $wiki[$i][0], $item ); //$info .= $item[1]; $split = explode( "|", $item[1] ); if ( count($split) == 2 ) { $linkage = "<a href=\"http://en.wikipedia.org/wiki/$split[0]\" target=\"_blank\" title=\"Wikipedia: $split[0]\">$split[1]</a>"; } else { $linkage = "<a href=\"http://en.wikipedia.org/wiki/$split[0]\" target=\"_blank\" title=\"Wikipedia: $split[0]\">$split[0]</a>"; } $text = str_replace( $item[0], $linkage, $text ); } return($text); } } ?>