PluginProbe ʕ •ᴥ•ʔ
ReCaptcha v2 for Contact Form 7 / 1.5.0
ReCaptcha v2 for Contact Form 7 v1.5.0
trunk 1.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wpcf7-recaptcha / flamingo.php
wpcf7-recaptcha Last commit date
assets 3 weeks ago changelog.txt 3 weeks ago flamingo.php 3 weeks ago license.txt 3 weeks ago readme.txt 3 weeks ago recaptcha-v2.php 3 weeks ago wpcf7-recaptcha.php 3 weeks ago
flamingo.php
79 lines
1 <?php
2 /**
3 * This file works with reCaptcha v2 to prevent Spam submissions from being stored.
4 *
5 * Originally, submitting a form without interacting with the reCaptcha box would submit to Contact Form 7
6 * And end up being labelled as "Spam" by Flamingo.
7 * This update will only check a submission _after_ reCaptcha has been compelted.
8 */
9
10
11 defined( 'ABSPATH' ) or die( 'Hey, you\'re not a flamingo! Goodbye.' );
12
13
14 Class IQFix_Flamingo {
15
16
17 /**
18 * Class Registration, set up necessities
19 *
20 * @return void
21 */
22 public static function register() {
23
24 $selection = WPCF7::get_option( 'iqfix_recaptcha' );
25
26 if( empty( $selection ) ) {
27 return;
28 }
29
30 $class = new self();
31 $class->action_hooks();
32
33 }
34
35
36 /**
37 * Add any necessary action hooks
38 *
39 * @return void
40 */
41 private function action_hooks() {
42
43 // See: contact-form-7/modules/flamingo.php
44 // Run before priority 10 to shortcircut Flamingo hook
45 add_action( 'wpcf7_submit', array( $this, 'flamingo_acceptable_mail' ), 9, 2 );
46
47 }
48
49
50 /**
51 * Remove the flamingo submission hook if our form has a ReCaptcha and an empty ReCaptcha response
52 * @see contact-form-7/modules/flamingo.php LN7
53 *
54 * @param Array $types
55 *
56 * @return Array $types
57 */
58 public function flamingo_acceptable_mail( $wpcform, $result ) {
59
60 $recaptcha = $wpcform->scan_form_tags( array( 'type' => 'recaptcha' ) );
61
62 if( ! empty( $recaptcha ) ) {
63
64 if( empty( $_POST['g-recaptcha-response'] ) ) {
65
66 // Remove the Flamingo hook, don't run it until we have a successful recaptcha
67 remove_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10 );
68
69 }
70
71 }
72
73 }
74
75
76 } // END IQFix_Flamingo Class
77
78
79 IQFix_Flamingo::register();