Skip to content

Commit

Permalink
Adding ability to limit moderation by new comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldhuereca committed Aug 26, 2024
1 parent 7362264 commit a6bab11
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions includes/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ public static function ajax_save_comment() {
// Short circuit comment moderation filter.
add_filter( 'pre_option_comment_moderation', array( static::class, 'short_circuit_comment_moderation' ) );
add_filter( 'pre_option_comment_whitelist', array( static::class, 'short_circuit_comment_moderation' ) );
add_filter( 'option_comment_moderation', '__return_false' ); // Needed to bypass moderation.
if ( check_comment( $comment_to_save['comment_author'], $comment_to_save['comment_author_email'], $comment_to_save['comment_author_url'], $new_comment_content, $comment_to_save['comment_author_IP'], $comment_to_save['comment_agent'], $comment_to_save['comment_type'] ) ) {
$comment_to_save['comment_approved'] = 1;
} else {
$comment_to_save['comment_approved'] = 0;
}
remove_filter( 'option_comment_moderation', '__return_false' );
// Remove Short circuit comment moderation filter.
remove_filter( 'pre_option_comment_moderation', array( static::class, 'short_circuit_comment_moderation' ) );
remove_filter( 'pre_option_comment_whitelist', array( static::class, 'short_circuit_comment_moderation' ) );
Expand Down

0 comments on commit a6bab11

Please sign in to comment.