有谁知道如何在Wordpress(2.9.2)中禁用重复的评论检测?我正在寻找一种方法来编程,而无需编辑核心文件。我们正在通过XMLRPC添加注释,并且wp-includes / comment.php(第494行)中的重复检测在测试期间导致问题。
谢谢!
答案 0 :(得分:12)
实际上,您无需编辑任何核心文件即可执行此操作。只需将这一个过滤器和两个小函数放在主题的functions.php
文件中,就不会再拒绝重复的注释。
add_filter( 'wp_die_handler', 'my_wp_die_handler_function', 9 ); //9 means you can unhook the default before it fires
function my_wp_die_handler_function($function) {
return 'my_skip_dupes_function'; //use our "die" handler instead (where we won't die)
}
//check to make sure we're only filtering out die requests for the "Duplicate" error we care about
function my_skip_dupes_function( $message, $title, $args ) {
if (strpos( $message, 'Duplicate comment detected' ) === 0 ) { //make sure we only prevent death on the $dupe check
remove_filter( 'wp_die_handler', '_default_wp_die_handler' ); //don't die
}
return; //nothing will happen
}
答案 1 :(得分:3)
目前,如果不编辑核心文件,就没有可用的钩子。
最好的方法是从wp-includes/comment.php
答案 2 :(得分:0)
$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' ";
if ( $comment_author_email )
$dupe .= "OR comment_author_email = '$comment_author_email' ";
$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";