如何阻止WordPress ping回来?

时间:2016-10-01 10:01:46

标签: javascript php jquery html wordpress

我是WordPress的初学者。我安装了WordPress但是我发现仪表板上有很多ping后台显示。我的问题是我想删除所有对我无用的ping后台。

1 个答案:

答案 0 :(得分:1)

作为Sagar,将其链接在他的答案中,你可以用代码来完成:

<?php
add_filter('wp_headers', function($headers, $wp_query){
    if(isset($headers['X-Pingback'])){
        unset($headers['X-Pingback']);
    }
    return $headers;
}, 11, 2);
add_filter('pre_option_enable_xmlrpc', function($state){
    return '0';
});
add_action('wp', function(){
    remove_action('wp_head', 'rsd_link');
}, 9);
add_filter('bloginfo_url', function($output, $property){
    return ($property == 'pingback_url') ? null : $output;
}, 11, 2);
add_action('xmlrpc_call', function($method){
    if($method != 'pingback.ping') return;
    wp_die(
        'Pingback functionality is disabled on this Blog.',
        'Pingback Disabled!',
        array('response' => 403)
    );
});
?>

将它放在 function.php 文件中。

如果您不想编码,可以使用a simple plugin执行此操作。