Wikipedia-link WP

By 1 de mayo de 2008 PHP No Comments

Es tan simple y tan bueno y lo utilizo tan amenudo que he tenido que poner el fuente de este Plug-in para uso y disfrute del personal que utilice WordPress.

Ni está mantenido, ni esta en Codex de WordPress ni nada de nada, si alguien lo quiere adoptar....

pos ale :)

 < ?php
/*
Plugin Name: Wikipedia Link
Plugin URI: http://wordpress.org/#
Description: With this plugin, you can link to Wikipedia entries just like within Wikipedia by simply enclosing the word you want to link with  and , or optionally separate the linked word from the caption with |. Examples: knives, Austria
Version: 0.1
Author: Andreas Krennmair
Author URI: http://synflood.at/blog/
*/

function link_wikipedia_entries($text) {
$text = preg_replace('/[[([^][]*)\|([^][]*)]]/','<a href="http://es.wikipedia.org/wiki/$1">$2</a>',$text);
$text = preg_replace('/[[([^][]*)]]/','<a href="http://es.wikipedia.org/wiki/$1">$1</a>',$text);
$text = preg_replace('/\\[]]/',']',$text);
$text = preg_replace('/\\[[]/','[',$text);
return $text;
}

// Highlight text and comments:
add_filter('the_content', 'link_wikipedia_entries');
add_filter('comment_text', 'link_wikipedia_entries');

?>

Leave a Reply

Your email address will not be published.