https://github.com/helloxz/wp-ip-query
一键查询wordpress访客IP归属地
https://github.com/helloxz/wp-ip-query
Last synced: 4 months ago
JSON representation
一键查询wordpress访客IP归属地
- Host: GitHub
- URL: https://github.com/helloxz/wp-ip-query
- Owner: helloxz
- Created: 2016-05-20T06:33:57.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-20T06:46:47.000Z (about 10 years ago)
- Last Synced: 2025-01-07T08:36:33.356Z (over 1 year ago)
- Size: 3.91 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wp-ip-query
一键查询wordpress访客IP归属地
WordPress后台评论功能会记录每一位访客IP地址,但是如果我们希望获取访客IP的具体归属地,虽然可以通过第三方IP查询工具手动输入IP查询,但是这样略显不便,于是小z博客利用淘宝IP接口对WordPress后台进行了略微的改动,使其可以一键查询访客IP的归属地。
### 引入Jquery库,并加载javascript函数
修改/wp-admin/admin-footer.php将下面的代码添加到body之前。
``` javascript
function ipquery(ip,num) {
var ip = ip;
$.get('./ip-query.php',{ip:ip},function(data,status){
var address = new Function('return' + data)();
var guojia = address['data']['country'];
var sheng = address['data']['region'];
var shi = address['data']['city'];
var isp = address['data']['isp'];
var ip_add = guojia + ' ' + sheng + ' ' + shi + ' ' + isp;
num = '#' + num;
$(num).html(ip_add);
});
}
```
### 添加ip-query接口查询文件
将下面的代码另存为:ip-query.php并上传到/wp-admin/目录下。
``` php
```
### 修改wordpress后台功能
找到wp-admin/includes/class-wp-comments-list-table.php这个文件,搜索关键词get_comment_author_IP在这句代码:printf( '%s', esc_url( $author_ip_url ), $author_ip );之后添加如下代码:
``` php
$num = 'abc'.rand(1000,9999);
echo " | 查询";
echo "
";
```
### 最后的效果

详细说明可以参考我的博客: