IT技术互动交流平台

wordpress后台不断出现spam

发布日期:2013-10-18 11:15:02

先上张图吧


 

solution:

在主题根目录下 functions.php 文件中添加下面代码:


// Kill the rewrite rules
add_filter( 'rewrite_rules_array', 'pmg_pk_filter_rewrites' );
function pmg_pk_filter_rewrites( $rules )
{
foreach( $rules as $rule => $rewrite )
{
if( preg_match( '/trackback\/\?\$$/i', $rule ) )
{
unset( $rules[$rule] );
}
}
return $rules;
}
// Kill bloginfo( 'pingback_url' )
add_filter( 'bloginfo_url', 'pmg_pk_kill_pingback_url', 10, 2 );
function pmg_pk_kill_pingback_url( $output, $show )
{
if( $show == 'pingback_url' )
{
$output = '';
}
return $output;
}
// hijack options for pingbacks
add_filter( 'pre_update_default_ping_status', '__return_false' );
add_filter( 'pre_option_default_ping_status', '__return_zero' );
add_filter( 'pre_update_default_pingback_flag', '__return_false' );
add_filter( 'pre_option_default_pingback_flag', '__return_zero' );
// Disable XMLRPC call
add_action( 'xmlrpc_call', 'pmg_pk_kill_xmlrpc' );
function pmg_pk_kill_xmlrpc( $action )
{
if( 'pingback.ping' === $action )
{
wp_die(
__( 'Pingbacks are not supported' ),
__( 'Not Allowed!' ),
array( 'response' => 403 )
);
}
}
// Flush rewrite rules on activation/deactivation so our trackback
// rules disappear or reappear on deactivation.
register_activation_hook( __FILE__ , 'flush_rewrite_rules' );
register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );

 

Tag标签: wordpress   spam  
  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规