Solusan

..:: Solusan - Otro blog más ::..

Wikipedia-link WP

Por Solusan el 01 de May de 2008 en PHP

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: [[knife|knives]], [[Austria]]
Version: 0.1
Author: Andreas Krennmair
Author URI: http://synflood.at/blog/
*/
 
function link_wikipedia_entries($text) {
$text = preg_replace('/\[\[([^\]\[]*)\|([^\]\[]*)\]\]/','&lt;a href="http://es.wikipedia.org/wiki/$1"&gt;$2&lt;/a&gt;',$text);
$text = preg_replace('/\[\[([^\]\[]*)\]\]/','&lt;a href="http://es.wikipedia.org/wiki/$1"&gt;$1&lt;/a&gt;',$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');
 
?>

Añade tu opinión

*

*