Changeset 2392339
- Timestamp:
- 10/02/2020 12:54:45 PM (6 years ago)
- Location:
- exact-match-disallowed-comment-contact-forms/trunk
- Files:
-
- 2 edited
-
blocklist-manager.php (modified) (5 diffs)
-
readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
exact-match-disallowed-comment-contact-forms/trunk/blocklist-manager.php
r2384723 r2392339 6 6 Author: Complete SEO 7 7 Author URI: https://www.completewebresources.com/ 8 Version: 1. 18 Version: 1.2 9 9 */ 10 10 … … 61 61 // CF7 handler 62 62 add_filter( 'wpcf7_submission_is_blacklisted', array( $this, 'cf7_blocklist_check'), 10, 2 ); 63 64 // Gravity Forms handler 65 add_filter( 'gform_entry_is_spam', array( $this, 'gf_blocklist_check' ), 10, 3 ); 63 66 } 64 67 … … 178 181 || preg_match( $pattern, $commentdata['comment_author_IP'] ) 179 182 ) { 180 return 0;183 return 'spam'; 181 184 } 182 185 } … … 188 191 $commentdata['comment_content'] = FrmEntriesHelper::entry_array_to_string( $values ); 189 192 $commentdata['comment_author_IP'] = FrmAppHelper::get_ip_address(); 190 $commentdata['comment_author_url'] = ' -';191 if ( ! $this->default_blocklist_check( false, $commentdata )) {193 $commentdata['comment_author_url'] = ''; 194 if ( $this->default_blocklist_check( false, $commentdata ) == 'spam' ) { 192 195 $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' ); 193 $this->save_spam_entry( 'Formidable Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_author_url']);196 $this->save_spam_entry( 'Formidable Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' ); 194 197 } 195 198 return $errors; … … 198 201 // CF7 check 199 202 public function cf7_blocklist_check( $approved, $obj ) { 200 $target = $obj->get_posted_data(); 201 $ip = $obj->get_meta( 'remote_ip' ); 202 $target = implode( "\n", $target ); 203 204 $mod_keys = self::get_disallowed_words(); 205 if ( '' == $mod_keys ) { 206 return false; // If moderation keys are empty. 207 } 208 209 // Ensure HTML tags are not being used to bypass the blocklist. 210 $target_without_html = wp_strip_all_tags( $target ); 211 212 $words = explode( "\n", $mod_keys ); 213 214 foreach ( (array) $words as $word ) { 215 $word = trim( $word ); 216 217 // Skip empty lines. 218 if ( empty( $word ) ) { 219 continue; } 220 221 // Do some escaping magic so that '#' chars 222 // in the spam words don't break things: 223 $word = preg_quote( $word, '~' ); 224 225 $pattern = "~\b$word\b~i"; 226 if ( preg_match( $pattern, $target ) 227 || preg_match( $pattern, $target_without_html ) 228 || preg_match( $pattern, $ip ) 229 ) { 230 $this->save_spam_entry( 'Contact Form 7', $target, $ip, '-' ); 231 return true; 203 $content = $obj->get_posted_data(); 204 $content = implode( "\n", $content ); 205 $commentdata['comment_content'] = $content; 206 $commentdata['comment_author_IP'] = $obj->get_meta( 'remote_ip' ); 207 $commentdata['comment_author_url'] = ''; 208 if ( $this->default_blocklist_check( false, $commentdata ) == 'spam' ) { 209 $this->save_spam_entry( 'Contact Form 7', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' ); 210 return true; 211 } 212 return false; 213 } 214 215 // Gravity Forms check 216 public function gf_blocklist_check( $is_spam, $form, $entry ) { 217 $content = ''; 218 foreach ( $entry as $k => $v ) { 219 if ( preg_match('/[1-9]+/', $k ) ) { 220 $content .= "\n" . $v; 232 221 } 233 222 } 234 return false; 223 $commentdata['comment_content'] = $content; 224 $commentdata['comment_author_IP'] = empty( $entry['ip'] ) ? GFFormsModel::get_ip() : $entry['ip']; 225 $commentdata['comment_author_url'] = ''; 226 if ( $this->default_blocklist_check( false, $commentdata ) == 'spam' ) { 227 $this->save_spam_entry( 'Gravity Forms', $commentdata['comment_content'], $commentdata['comment_author_IP'], '-' ); 228 $is_spam = true; 229 } 230 return $is_spam; 235 231 } 236 232 -
exact-match-disallowed-comment-contact-forms/trunk/readme.txt
r2384723 r2392339 2 2 3 3 Plugin URI: https://www.completewebresources.com/exact-match-disallowed-comment-contact-forms-wordpress-plugin/ 4 Tags: anti spam, formidable, contact form 7, blacklist, blocklist, comment spam, contact form spam4 Tags: anti spam, formidable, contact form 7, gravity forms, blacklist, blocklist, comment spam, contact form spam 5 5 Author URI: https://www.completewebresources.com/exact-match-disallowed-comment-contact-forms-wordpress-plugin/ 6 6 Author: Complete SEO … … 8 8 Requires PHP: 7.0 9 9 Tested up to: 5.5.1 10 Stable tag: 1. 111 Version: 1. 110 Stable tag: 1.2 11 Version: 1.2 12 12 License: GPLv3 13 13 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 21 21 If you try to use the WordPress comment blocklist for contact form entries, this can be hugely problematic. The first major issue is falsely identifying comments as spam so you risk blocking valid contact form entries. 22 22 23 Additionally, there 's no moderation queue built into Formidable or Contact Form 7for entries marked as spam. This plugin fixes those issues.23 Additionally, there’s no moderation queue built into Formidable Forms, Contact Form 7, or Gravity Forms for entries marked as spam. This plugin fixes those issues. 24 24 25 25 = Changing the default WordPress comment blocklist functionality = … … 33 33 = Important Notes / FAQ = 34 34 35 - For default comments in a post after submitting, if blocklisted, the comment will go to Pending status, awaiting moderationwhereas the default functionality would be to send that comment to the trash.36 - We 're currently configured to work with Contact Form 7 and Formidable.35 - For default comments in a post after submitting, if blocklisted, the comment will go to Spam status, whereas the default functionality would be to send that comment to the trash. 36 - We’re currently configured to work with Contact Form 7, Formidable Forms and Gravity Forms. 37 37 - Add keywords you want to block to the WordPress admin area under **Settings > Discussion > Disallowed Comment Keys** 38 38 - Upon activation, the plugin will automatically populate three keywords by default in the "Disallowed Comment Keys" field in the WP Admin area. This is so you know things are working. We leave it to the user to control their specific blocklist keywords. If you want a list of we'll known spam words as a starting point, check your preferred search engine for "ultimate comment blocklist" or "WordPress comment blocklist." … … 58 58 == Changelog == 59 59 60 = 1.2 = 61 62 * Now comments that include blocklist keywords become "Spam" instead of "Pending" 63 * Gravity Forms is integrated 64 60 65 = 1.1 = 61 66
Note: See TracChangeset
for help on using the changeset viewer.