1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
if(!function_exists('Baidu_Submit')){
function Baidu_Submit($post_ID) {
$WEB_TOKEN = 'xxxxxxxxxxxx'; //这里请换成你的网站的百度主动推送的token值
$WEB_DOMAIN = get_option('home');
//已成功推送的文章不再推送
if(get_post_meta($post_ID,'Baidusubmit',true) == 1) return;
$url = get_permalink($post_ID);
$api = 'http://data.zz.baidu.com/urls?site='.$WEB_DOMAIN.'&token='.$WEB_TOKEN;
$request = new WP_Http;
$result = $request->request( $api , array( 'method' => 'POST', 'body' => $url , 'headers' => 'Content-Type: text/plain') );
$result = json_decode($result['body'],true);
//如果推送成功则在文章新增自定义栏目Baidusubmit,值为1
if (array_key_exists('success',$result)) {
add_post_meta($post_ID, 'Baidusubmit', 1, true);
}
}
add_action('publish_post', 'Baidu_Submit', 0);
}
add_action( 'wp_footer', 'bdPushData', 999);
if(!function_exists('baidu_check_record')){
function baidu_check_record($url,$post_id){
$baidu_record = get_post_meta($post_id,'baidu_record',true);
if( $baidu_record != 1){
$url='http://www.baidu.com/s?wd='.$url;
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$rs=curl_exec($curl);
curl_close($curl);
if( BD_PUSH == 'yes' && !preg_match_all('/提交网址/u',$rs) && preg_match_all('/百度为您找到相关结果/u',$rs)){
update_post_meta($post_id, 'baidu_record', 1) || add_post_meta($post_id, 'baidu_record', 1, true);
return 1;
} else {
return 0;
}
} else {
return 1;
}
}
}
if(!function_exists('bdPushData')){
function bdPushData() {
global $wpdb;
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
$currentUrl = home_url(add_query_arg(array()));
//这里修改了下:给get_permalink指定了文章ID
if(baidu_check_record(get_permalink($post_id), $post_id) == 0 && $currentUrl == get_permalink($post_id)) {
echo "<script>(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
} else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(bp, s);
})();
(function(){
var src = (document.location.protocol == 'http:') ? 'http://js.passport.qihucdn.com/11.0.1.js?af9e600e6a4ba6d33cd7f1b088210cf7':'https://jspassport.ssl.qhimg.com/11.0.1.js?af9e600e6a4ba6d33cd7f1b088210cf7';
document.write('<script src="' + src + '" id="sozz"></script>');
})();</script>";
}
}
- 1001手机拍照技巧(手机拍照技巧从入门到精通)
- 1002如何\n使用“快速开始”\n设置新 iPhone苹果手机官网「如何\n使用“快速开始”\n设置新 iPhone」
- 1003amr转mp3手机铃声转换器 随意铃声格式转换手机转换器「amr转mp3手机铃声转换器 随意铃声格式转换」
- 1004揭秘深圳华强北那些著名的手机批发市场手机卖场「揭秘深圳华强北那些著名的手机批发市场」
- 1005请律师诉讼费一般多少钱,具体要怎么计算
- 1006oppo手机忘记密码怎么恢复出厂设置oppo手机忘记锁屏密码怎么办「oppo手机忘记密码怎么恢复出厂设置」
- 1007《故宫日历·2024年:汉英对照》手机日历「《故宫日历·2024年:汉英对照》」
- 1008原创有这4种情况请关掉手机,很大可能性你被“监听”了!望周知手机窃听「原创有这4种情况请关掉手机,很大可能性你被“监听”了!望周知」
- 1009我只花了 2799 就买到 16+1TB 的新神U 手机一加手机怎么样「我只花了 2799 就买到 16+1TB 的新神U 手机」