Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// return location from user ip
require 'IP.class.php';
$rip=$_SERVER["REMOTE_ADDR"];
$lar = Ip::find($rip);
$i = count($lar) - 1;
$loc = "地球";
while($i >=0 ){
if(strlen($lar[$i]) > 0 ) {
$loc = $lar[$i];
break;
}
$i --;
}
echo $loc;
<?php
/**
*Plugin Name: SomeMoreSentence
*Version: 0.1
*Plugin URI: http://argcv.com
*Description: append some more sentence after the end of your post
*Author: Yu Jing
*Author URI: http://argcv.com/about
*/
function SomeMoreSentence($outer){
if(!is_singular()){ return $outer; }
global $post;
$tmp = "<blockquote>来自<a id='remote_loc'></a>的你,很高兴你能看到这儿。若本文对你有所用处,或者内容有什么不足之处,敬请毫不犹豫给个回复。谢谢!</blockquote><script type='text/javascript'>
$(document).ready(function(){
$.get('/api/ip/', function(data,status){
$('#remote_loc').text(data);
});
});</script>";
$outer = $outer.$tmp;
return $outer;
}
add_filter('the_content', 'SomeMoreSentence');
//add_filter('the_content', 'SomeMoreSentence',11);// the bigger the number is ,the latter ..
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment