Contact Form 7 Image Captcha - Version 3.3.0

Version Description

[11/15/2022] = * No more jQuery! Changed jQuery toggle function to JavaScript * Re-added localized language files due to issues with translate.wordpress.org working correctly

Download this release

Release Info

Developer KTC_88
Plugin Icon 128x128 Contact Form 7 Image Captcha
Version 3.3.0
Comparing to
See all releases

Code changes from version 3.2.5 to 3.3.0

Files changed (2) hide show
  1. cf7-image-captcha.php +24 -21
  2. readme.txt +9 -1
cf7-image-captcha.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Contact Form 7 Image Captcha
4
  * Plugin URI: https://wordpress.org/plugins/contact-form-7-image-captcha/
5
  * Description: Add a simple image captcha and Honeypot to contact form 7
6
- * Version: 3.2.5
7
  * Author: KC Computing
8
  * Author URI: https://profiles.wordpress.org/ktc_88
9
  * License: GNU General Public License v2
@@ -11,12 +11,7 @@
11
  * Text Domain: contact-form-7-image-captcha
12
  */
13
 
14
- /*
15
- * RESOURCE HELP
16
- * https://stackoverflow.com/questions/17541614/use-thumbnail-image-instead-of-radio-button
17
- * https://jsbin.com/pafifi/1/edit?html,css,output
18
- * https://jsbin.com/nenarugiwe/1/edit?html,css,output
19
- */
20
 
21
 
22
  /**
@@ -42,6 +37,7 @@ function cf7ic_load_textdomain() {
42
  }
43
 
44
 
 
45
  /**
46
  * Register/Enqueue CSS on initialization
47
  */
@@ -96,9 +92,11 @@ function call_cf7ic( $tag ) {
96
 
97
  if($toggle == 'toggle') {
98
  $style = 'style="display: none;"';
99
- add_action('wp_footer', 'cf7ic_toggle');
 
100
  } else {
101
  $style = '';
 
102
  }
103
 
104
  $output = '
@@ -119,7 +117,7 @@ function call_cf7ic( $tag ) {
119
  <input type="text" name="kc_honeypot">
120
  </span>';
121
 
122
- return '<span class="wpcf7-form-control-wrap kc_captcha"><span class="wpcf7-form-control wpcf7-radio">'.$output.'</span></span>';
123
  }
124
 
125
 
@@ -140,11 +138,13 @@ function cf7ic_check_if_spam( $result, $tag ) {
140
 
141
  if(!empty($kc_val1) && $kc_val1 != 'kc_human' ) {
142
  $tag->name = "kc_captcha";
143
- $result->invalidate( $tag, __('Please select the correct icon.', 'contact-form-7-image-captcha') );
 
144
  }
145
  if(empty($kc_val1) ) {
146
  $tag->name = "kc_captcha";
147
- $result->invalidate( $tag, __('Please select an icon.', 'contact-form-7-image-captcha') );
 
148
  }
149
  if(!empty($kc_val2) ) {
150
  $tag->name = "kc_captcha";
@@ -156,6 +156,7 @@ function cf7ic_check_if_spam( $result, $tag ) {
156
  add_filter('wpcf7_validate','cf7ic_check_if_spam', 99, 2); // If "Contact Form 7 – Conditional Fields" plugin is installed and active
157
 
158
 
 
159
  // Add Contact Form Tag Generator Button
160
  add_action( 'wpcf7_admin_init', 'cf7ic_add_tag_generator', 55 );
161
 
@@ -184,17 +185,19 @@ function cf7ic_tag_generator( $contact_form, $args = '' ) {
184
 
185
  function cf7ic_toggle(){
186
  echo '<script type="text/javascript">
187
- jQuery(document).ready(function(){
188
- jQuery("body").on("focus", "form.wpcf7-form", function(){
189
- jQuery(this).find(".captcha-image").show();
190
- });
191
- })
192
-
193
- document.addEventListener( "wpcf7submit", function( event ) {
194
- if(jQuery(".wpcf7-mail-sent-ok").length) {
195
- jQuery(this).find(".captcha-image").hide();
196
- jQuery(":focus").blur()
197
  }
 
 
 
 
 
 
198
  }, false );
199
  </script>';
200
  };
3
  * Plugin Name: Contact Form 7 Image Captcha
4
  * Plugin URI: https://wordpress.org/plugins/contact-form-7-image-captcha/
5
  * Description: Add a simple image captcha and Honeypot to contact form 7
6
+ * Version: 3.3.0
7
  * Author: KC Computing
8
  * Author URI: https://profiles.wordpress.org/ktc_88
9
  * License: GNU General Public License v2
11
  * Text Domain: contact-form-7-image-captcha
12
  */
13
 
14
+
 
 
 
 
 
15
 
16
 
17
  /**
37
  }
38
 
39
 
40
+
41
  /**
42
  * Register/Enqueue CSS on initialization
43
  */
92
 
93
  if($toggle == 'toggle') {
94
  $style = 'style="display: none;"';
95
+ add_action('wp_footer', 'cf7ic_toggle');
96
+ $toggle_class = ' cf7ic-toggle';
97
  } else {
98
  $style = '';
99
+ $toggle_class = '';
100
  }
101
 
102
  $output = '
117
  <input type="text" name="kc_honeypot">
118
  </span>';
119
 
120
+ return '<span class="wpcf7-form-control-wrap kc_captcha'.$toggle_class.'" data-name="kc_captcha"><span class="wpcf7-form-control wpcf7-radio">'.$output.'</span></span>';
121
  }
122
 
123
 
138
 
139
  if(!empty($kc_val1) && $kc_val1 != 'kc_human' ) {
140
  $tag->name = "kc_captcha";
141
+ $error = __('Please select the correct icon.', 'contact-form-7-image-captcha');
142
+ $result->invalidate( $tag, $error );
143
  }
144
  if(empty($kc_val1) ) {
145
  $tag->name = "kc_captcha";
146
+ $error = __('Please select an icon.', 'contact-form-7-image-captcha');
147
+ $result->invalidate( $tag, $error );
148
  }
149
  if(!empty($kc_val2) ) {
150
  $tag->name = "kc_captcha";
156
  add_filter('wpcf7_validate','cf7ic_check_if_spam', 99, 2); // If "Contact Form 7 – Conditional Fields" plugin is installed and active
157
 
158
 
159
+
160
  // Add Contact Form Tag Generator Button
161
  add_action( 'wpcf7_admin_init', 'cf7ic_add_tag_generator', 55 );
162
 
185
 
186
  function cf7ic_toggle(){
187
  echo '<script type="text/javascript">
188
+ document.addEventListener("focusin", cf7ic_display);
189
+
190
+ function cf7ic_display(event){
191
+ if(event.target.form.querySelector(".cf7ic-toggle")) {
192
+ event.target.form.querySelector(".captcha-image").style.display = "block";
193
+ document.removeEventListener("focusin", cf7ic_display);
 
 
 
 
194
  }
195
+ }
196
+
197
+ document.addEventListener( "wpcf7mailsent", function( event ) {
198
+ event.target.querySelector(".captcha-image").style.display = "none";
199
+ document.activeElement.blur();
200
+ document.addEventListener("focusin", cf7ic_display);
201
  }, false );
202
  </script>';
203
  };
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: contact form 7, spam, captcha
5
  Requires at least: 4.7
6
  Requires PHP: 7.0
7
- Tested up to: 6.0
8
  Stable tag: trunk
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -101,6 +101,14 @@ If the styling does not look right, you may need to clear your browser cache. If
101
  3. Pro version settings page
102
 
103
  == Changelog ==
 
 
 
 
 
 
 
 
104
  = 3.2.5 [03/08/2022] =
105
  * Fixed iPhone bug where icon would not show focus state when touched
106
  * Removed some unused styling to help reduce the stylesheet file size
4
  Tags: contact form 7, spam, captcha
5
  Requires at least: 4.7
6
  Requires PHP: 7.0
7
+ Tested up to: 6.1
8
  Stable tag: trunk
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
101
  3. Pro version settings page
102
 
103
  == Changelog ==
104
+ = 3.3.0 [11/15/2022] =
105
+ * No more jQuery! Changed jQuery toggle function to JavaScript
106
+ * Re-added localized language files due to issues with translate.wordpress.org working correctly
107
+
108
+ = 3.2.6 [09/01/2022] =
109
+ * Fixed issue where validation errors were not showing due to the Contact Form 7 version 5.6 update
110
+ * Removed localized language files in favor of using translate.wordpress.org
111
+
112
  = 3.2.5 [03/08/2022] =
113
  * Fixed iPhone bug where icon would not show focus state when touched
114
  * Removed some unused styling to help reduce the stylesheet file size