有谁知道如何在Wordpress(2.9.2)中禁用重复的注释检测?我正在寻找一种方法来编程,而无需编辑核心文件.我们通过XMLRPC添加注释,wp-includes/comment.php(第494行)中的重复检测在测试期间导致问题.
谢谢!
小智 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
}
Run Code Online (Sandbox Code Playgroud)