diff --git a/includes/class-ayecode-connect-turnstile-settings.php b/includes/class-ayecode-connect-turnstile-settings.php index 67cb4d8..18a3af4 100644 --- a/includes/class-ayecode-connect-turnstile-settings.php +++ b/includes/class-ayecode-connect-turnstile-settings.php @@ -355,59 +355,102 @@ public function settings_page() { if ( defined( 'UWP_MAILERLITE_VERSION' ) ) { $turnstile_protections['uwp_mailerlite_subscribe'] = [ - 'title' => __( 'UsersWP - MailerLite Subscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - MailerLite Subscribe Form', 'ayecode-connect' ), 'default' => true ]; $turnstile_protections['uwp_mailerlite_unsubscribe'] = [ - 'title' => __( 'UsersWP - MailerLite Unsubscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - MailerLite Unsubscribe Form', 'ayecode-connect' ), 'default' => true ]; } if ( defined( 'UWP_MC_VERSION' ) ) { $turnstile_protections['uwp_mc_subscribe'] = [ - 'title' => __( 'UsersWP - MailChimp Subscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - MailChimp Subscribe Form', 'ayecode-connect' ), 'default' => true ]; $turnstile_protections['uwp_mc_unsubscribe'] = [ - 'title' => __( 'UsersWP - MailChimp Unsubscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - MailChimp Unsubscribe Form', 'ayecode-connect' ), 'default' => true ]; } if ( defined( 'UWP_MAILPOET_VERSION' ) ) { $turnstile_protections['uwp_mailpoet_subscribe'] = [ - 'title' => __( 'UsersWP - Mailpoet Subscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - Mailpoet Subscribe Form', 'ayecode-connect' ), 'default' => true ]; $turnstile_protections['uwp_mailpoet_unsubscribe'] = [ - 'title' => __( 'UsersWP - Mailpoet Unsubscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - Mailpoet Unsubscribe Form', 'ayecode-connect' ), 'default' => true ]; } if ( defined( 'UWP_ACTIVECAMPAIGN_VERSION' ) ) { $turnstile_protections['uwp_active_campaign_subscribe'] = [ - 'title' => __( 'UsersWP - ActiveCampaign Subscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - ActiveCampaign Subscribe Form', 'ayecode-connect' ), 'default' => true ]; $turnstile_protections['uwp_active_campaign_unsubscribe'] = [ - 'title' => __( 'UsersWP - ActiveCampaign Unsubscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - ActiveCampaign Unsubscribe Form', 'ayecode-connect' ), 'default' => true ]; } if ( defined( 'UWP_BREVO_VERSION' ) ) { $turnstile_protections['uwp_brevo_subscribe'] = [ - 'title' => __( 'UsersWP - Brevo Subscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - Brevo Subscribe Form', 'ayecode-connect' ), 'default' => true ]; $turnstile_protections['uwp_brevo_unsubscribe'] = [ - 'title' => __( 'UsersWP - Brevo Unsubscribe Form', 'ayecode-connect' ), + 'title' => __( 'UsersWP - Brevo Unsubscribe Form', 'ayecode-connect' ), 'default' => true ]; } + if ( defined( 'UWP_GETRESPONSE_VERSION' ) ) { + $turnstile_protections['uwp_getresponse_subscribe'] = [ + 'title' => __( 'UsersWP - GetResponse Subscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + $turnstile_protections['uwp_getresponse_unsubscribe'] = [ + 'title' => __( 'UsersWP - GetResponse Unsubscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + } + + if ( defined( 'UWP_AWEBER_VERSION' ) ) { + $turnstile_protections['uwp_aweber_subscribe'] = [ + 'title' => __( 'UsersWP - Aweber Subscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + $turnstile_protections['uwp_aweber_unsubscribe'] = [ + 'title' => __( 'UsersWP - Aweber Unsubscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + } + + if ( defined( 'UWP_CC_VERSION' ) ) { + $turnstile_protections['uwp_cc_subscribe'] = [ + 'title' => __( 'UsersWP - Constant Contact Subscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + $turnstile_protections['uwp_cc_unsubscribe'] = [ + 'title' => __( 'UsersWP - Constant Contact Unsubscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + } + + if ( defined( 'UWP_NEWSLETTER_VERSION' ) ) { + $turnstile_protections['uwp_newsletter_subscribe'] = [ + 'title' => __( 'UsersWP - Newsletter Subscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + $turnstile_protections['uwp_newsletter_unsubscribe'] = [ + 'title' => __( 'UsersWP - Newsletter Unsubscribe Form', 'ayecode-connect' ), + 'default' => true + ]; + } // UWP Frontend Post Addon if ( defined( 'UWP_FRONTEND_POST_VERSION' ) ) { @@ -434,9 +477,6 @@ public function settings_page() { ]; } - - - $turnstile_protections = apply_filters( 'ayecode_turnstile_protections', $turnstile_protections ); if ( ! empty( $turnstile_protections ) ) { diff --git a/includes/class-ayecode-connect-turnstile.php b/includes/class-ayecode-connect-turnstile.php index 5b6edd2..1421c30 100644 --- a/includes/class-ayecode-connect-turnstile.php +++ b/includes/class-ayecode-connect-turnstile.php @@ -47,6 +47,14 @@ public function __construct() { 'uwp_active_campaign_unsubscribe' => 1, 'uwp_brevo_subscribe' => 1, 'uwp_brevo_unsubscribe' => 1, + 'uwp_getresponse_subscribe' => 1, + 'uwp_getresponse_unsubscribe' => 1, + 'uwp_aweber_subscribe' => 1, + 'uwp_aweber_unsubscribe' => 1, + 'uwp_cc_subscribe' => 1, + 'uwp_cc_unsubscribe' => 1, + 'uwp_newsletter_subscribe' => 1, + 'uwp_newsletter_unsubscribe' => 1, ) ); @@ -175,6 +183,26 @@ private function init_hooks() { add_action( 'uwp_brevo_form_validate', array( $this, 'verify_uwp_brevo_subscribe' ), 20,1 ); } + if ( ! empty( $this->options['protections']['uwp_getresponse_subscribe'] ) || ! empty( $this->options['protections']['uwp_getresponse_unsubscribe'] ) ) { + add_action( 'uwp_getresponse_subscribe_fields', array( $this, 'add_turnstile_uwp_getresponse_forms' ), 10, 1 ); + add_action( 'uwp_getresponse_form_validate', array( $this, 'verify_uwp_getresponse_subscribe' ), 20,1 ); + } + + if ( ! empty( $this->options['protections']['uwp_aweber_subscribe'] ) || ! empty( $this->options['protections']['uwp_aweber_unsubscribe'] ) ) { + add_action( 'uwp_aweber_subscribe_fields', array( $this, 'add_turnstile_uwp_aweber_forms' ), 10, 1 ); + add_action( 'uwp_aweber_form_validate', array( $this, 'verify_uwp_aweber_subscribe' ), 20,1 ); + } + + if ( ! empty( $this->options['protections']['uwp_cc_subscribe'] ) || ! empty( $this->options['protections']['uwp_cc_unsubscribe'] ) ) { + add_action( 'uwp_cc_subscribe_fields', array( $this, 'add_turnstile_uwp_cc_forms' ), 10, 1 ); + add_action( 'uwp_cc_form_validate', array( $this, 'verify_uwp_cc_subscribe' ), 20,1 ); + } + + if ( ! empty( $this->options['protections']['uwp_newsletter_subscribe'] ) || ! empty( $this->options['protections']['uwp_newsletter_unsubscribe'] ) ) { + add_action( 'uwp_newsletter_subscribe_fields', array( $this, 'add_turnstile_uwp_newsletter_forms' ), 10, 1 ); + add_action( 'uwp_newsletter_form_validate', array( $this, 'verify_uwp_newsletter_subscribe' ), 20,1 ); + } + // UWP Frontend Post Addon if ( ! empty( $this->options['protections']['uwp_frontend'] ) ) { add_action( 'uwp_frontend_post_after_form_fields', array( @@ -479,6 +507,126 @@ public function add_turnstile_uwp_brevo_forms( $args ) { } } + public function add_turnstile_uwp_getresponse_forms( $args ) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if ( $args['type'] == 'subscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_getresponse_subscribe'])) { + $this->add_turnstile_widget(); + } + + if ($args['type'] == 'unsubscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_getresponse_unsubscribe']) ) { + $this->add_turnstile_widget(); + } + } + + public function verify_uwp_getresponse_subscribe($data) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if(is_array($data)) { + if($data['action'] == 'uwp_getresponse_subscribe' && $ayecode_turnstile_options['protections']['uwp_getresponse_subscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_getresponse_subscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + if($data['action'] == 'uwp_getresponse_unsubscribe' && $ayecode_turnstile_options['protections']['uwp_getresponse_unsubscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_getresponse_unsubscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + } + return $data; + } + + public function add_turnstile_uwp_aweber_forms( $args ) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if ( $args['type'] == 'subscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_aweber_subscribe'])) { + $this->add_turnstile_widget(); + } + + if ($args['type'] == 'unsubscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_aweber_unsubscribe']) ) { + $this->add_turnstile_widget(); + } + } + + public function verify_uwp_aweber_subscribe($data) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if(is_array($data)) { + if($data['action'] == 'uwp_aweber_subscribe' && $ayecode_turnstile_options['protections']['uwp_aweber_subscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_aweber_subscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + if($data['action'] == 'uwp_aweber_unsubscribe' && $ayecode_turnstile_options['protections']['uwp_aweber_unsubscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_aweber_unsubscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + } + return $data; + } + + public function add_turnstile_uwp_cc_forms( $args ) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if ( $args['type'] == 'subscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_cc_subscribe'])) { + $this->add_turnstile_widget(); + } + + if ($args['type'] == 'unsubscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_cc_unsubscribe']) ) { + $this->add_turnstile_widget(); + } + } + + public function verify_uwp_cc_subscribe($data) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if(is_array($data)) { + if($data['action'] == 'uwp_cc_subscribe' && $ayecode_turnstile_options['protections']['uwp_cc_subscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_cc_subscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + if($data['action'] == 'uwp_cc_unsubscribe' && $ayecode_turnstile_options['protections']['uwp_cc_unsubscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_cc_unsubscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + } + return $data; + } + + public function add_turnstile_uwp_newsletter_forms( $args ) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if ( $args['type'] == 'subscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_newsletter_subscribe'])) { + $this->add_turnstile_widget(); + } + + if ($args['type'] == 'unsubscribe' && ! empty($ayecode_turnstile_options['protections']['uwp_newsletter_unsubscribe']) ) { + $this->add_turnstile_widget(); + } + } + + public function verify_uwp_newsletter_subscribe($data) { + $ayecode_turnstile_options = get_option( 'ayecode_turnstile_options'); + if(is_array($data)) { + if($data['action'] == 'uwp_newsletter_subscribe' && $ayecode_turnstile_options['protections']['uwp_newsletter_subscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_newsletter_subscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + if($data['action'] == 'uwp_newsletter_unsubscribe' && $ayecode_turnstile_options['protections']['uwp_newsletter_unsubscribe'] == true) { + $verify = $this->verify_turnstile( 'uwp_newsletter_unsubscribe' ); + if ( is_wp_error( $verify ) ) { + return $verify; + } + } + } + return $data; + } + /** * Add some CSS for the login form sizing. * diff --git a/readme.txt b/readme.txt index 1425010..21394e0 100755 --- a/readme.txt +++ b/readme.txt @@ -81,6 +81,12 @@ If your host runs "mod security" on your hosting and has some specific additiona == Changelog == += 1.4.16 - 2026-TBD = +* Turnstile captcha support for UWP Getresponse addon forms - ADDED +* Turnstile captcha support for UWP Aweber addon forms - ADDED +* Turnstile captcha support for UWP Constant Contact addon forms - ADDED +* Turnstile captcha support for UWP Newsletter addon forms - ADDED + = 1.4.15 - 2026-01-22 = * Merge AUI 0.2.43, SD 1.2.31 & AyeCode Connect Helper 1.0.5 - CHANGED