Last active
December 15, 2015 05:39
-
-
Save yuikns/5210906 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*Plugin Name: Wikipedia_Entry_Inserter | |
*Version: 0.1 | |
*Plugin URI: http://argcandargv.com | |
*Description: insert wikipedia entry with [wiki] and [/wiki] | |
*Author: Yu Jing | |
*Author URI: http://argcandargv.com/ | |
*/ | |
function Wikipedia_Entry_Inserter($outer){ | |
if(!is_singular()){ return $outer; } | |
$outer = preg_replace('/\[wiki\](.+?)\[\/wiki\]/','<a href="//en.wikipedia.org/wiki/$1" rel="nofollow" title="$1" target="_blank">$1</a>', $outer); | |
$outer = preg_replace('/\[wiki:zh\](.+?)\[\/wiki:zh\]/','<a href="//zh.wikipedia.org/wiki/$1" rel="nofollow" title="$1" target="_blank">$1</a>', $outer); | |
return $outer; | |
} | |
add_filter('the_content', 'Wikipedia_Entry_Inserter'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment