的functions.php里加入
一、禁止恶意 USER_AGENT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// 防采集 $ua = $_SERVER['HTTP_USER_AGENT']; $now_ua = array('FeedDemon ','ZmEu','Indy Library','oBot','jaunty'); // 将恶意 USER_AGENT 存入数组 if(!$ua) { // 禁止空 USER_AGENT header("Content-type: text/html; charset=utf-8"); wp_die('System Error!'); } else { foreach($now_ua as $value ) if(eregi($value,$ua)) { header("Content-type: text/html; charset=utf-8"); wp_die('System Error!'); } } add_filter('the_content','tedlfie_copyright'); |
二、关闭 Feed RSS
1 2 3 4 5 6 7 8 9 |
// 关闭 Feed RSS function tedlife_disable_feed() { wp_die(__('Feed OFF')); } add_action('do_feed', 'tedlife_disable_feed', 1); add_action('do_feed_rdf', 'tedlife_disable_feed', 1); add_action('do_feed_rss', 'tedlife_disable_feed', 1); add_action('do_feed_rss2', 'tedlife_disable_feed', 1); add_action('do_feed_atom', 'tedlife_disable_feed', 1); |
三、转载了也加个尾巴
1 2 3 4 5 6 7 |
// 内页添加转载请注明 function tedlfie_copyright($content) { if( is_singular("post") ){ $content.= '<p class="post-copy"><span style="color:#f00;">转载请注明:</span><a href="'.get_permalink().'" rel="external nofollow" target="_blank">'.get_the_title().'</a> - <a href="'.get_bloginfo('url').'" rel="external nofollow" target="_blank">'.get_bloginfo('name').'</a></p>'; } return $content; } |