Contact Form Clean and Simple - Version 4.3.0

Version Description

  • Contact form is now filtered for spam when the Akismet plugin is present. Learn more.
Download this release

Release Info

Developer megnicholas
Plugin Icon wp plugin Contact Form Clean and Simple
Version 4.3.0
Comparing to
See all releases

Code changes from version 4.2.5 to 4.3.0

class.cscf.php CHANGED
@@ -30,6 +30,8 @@ class cscf
30
  'RegisterTextDomain'
31
  ));
32
 
 
 
33
  //create the settings page
34
  $settings = new cscf_settings();
35
 
@@ -176,5 +178,33 @@ class cscf
176
  }
177
  }
178
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  }
180
 
30
  'RegisterTextDomain'
31
  ));
32
 
33
+ add_filter('cscf_spamfilter',array($this,'SpamFilter'));
34
+
35
  //create the settings page
36
  $settings = new cscf_settings();
37
 
178
  }
179
  }
180
  }
181
+
182
+ /*
183
+ *This is all we need to do to weed out the spam.
184
+ *If akismet plugin is enabled then it will be hooked into these filters.
185
+ */
186
+ public
187
+ function SpamFilter($contact) {
188
+
189
+ $commentData = apply_filters('preprocess_comment', array(
190
+ 'comment_post_ID' => $contact->PostID,
191
+ 'comment_author' => $contact->Name,
192
+ 'comment_author_email' => $contact->Email,
193
+ 'comment_content' => $contact->Message,
194
+ 'comment_type' => 'contact-form',
195
+ ));
196
+
197
+ $commentData['comment_approved'] = apply_filters( 'pre_comment_approved', 0 , $commentData );
198
+
199
+ //If it is spam then log as a comment
200
+ if ( $commentData['comment_approved'] === 'spam' ) {
201
+ wp_insert_comment($commentData);
202
+ $contact->IsSpam = true;
203
+ }
204
+ else {
205
+ $contact->IsSpam = false;
206
+ }
207
+ return $contact;
208
+ }
209
  }
210
 
class.cscf_contact.php CHANGED
@@ -14,6 +14,8 @@ class cscf_Contact
14
  var $RecaptchaPublicKey;
15
  var $RecaptchaPrivateKey;
16
  var $Errors;
 
 
17
 
18
  function __construct()
19
  {
@@ -34,8 +36,13 @@ class cscf_Contact
34
  $this->ConfirmEmail = filter_var($cscf['confirm-email'], FILTER_SANITIZE_EMAIL);
35
  }
36
  $this->Message = filter_var($cscf['message'], FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES);
 
 
 
37
  unset($_POST['cscf']);
38
  }
 
 
39
  }
40
 
41
  public
@@ -88,9 +95,14 @@ class cscf_Contact
88
 
89
  return count($this->Errors) == 0;
90
  }
91
-
92
  public
93
  function SendMail() {
 
 
 
 
 
94
 
95
  $filters = new cscf_Filters;
96
 
@@ -120,4 +132,3 @@ class cscf_Contact
120
  return $result;
121
  }
122
  }
123
-
14
  var $RecaptchaPublicKey;
15
  var $RecaptchaPrivateKey;
16
  var $Errors;
17
+ var $PostID;
18
+ var $IsSpam;
19
 
20
  function __construct()
21
  {
36
  $this->ConfirmEmail = filter_var($cscf['confirm-email'], FILTER_SANITIZE_EMAIL);
37
  }
38
  $this->Message = filter_var($cscf['message'], FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES);
39
+ if (isset($_POST['post-id'])) {
40
+ $this->PostID = $_POST['post-id'];
41
+ }
42
  unset($_POST['cscf']);
43
  }
44
+
45
+ $this->IsSpam = false;
46
  }
47
 
48
  public
95
 
96
  return count($this->Errors) == 0;
97
  }
98
+
99
  public
100
  function SendMail() {
101
+ apply_filters('cscf_spamfilter',$this);
102
+
103
+ if ( $this->IsSpam === true ) {
104
+ return true;
105
+ }
106
 
107
  $filters = new cscf_Filters;
108
 
132
  return $result;
133
  }
134
  }
 
clean-and-simple-contact-form-by-meg-nicholas.php CHANGED
@@ -7,7 +7,7 @@
7
  Plugin Name: Clean and Simple Contact Form
8
  Plugin URI: http://www.megnicholas.co.uk/wordpress-plugins/clean-and-simple-contact-form
9
  Description: A clean and simple contact form with Google reCAPTCHA and Twitter Bootstrap markup.
10
- Version: 4.2.5
11
  Author: Meghan Nicholas
12
  Author URI: http://www.megnicholas.co.uk
13
  License: GPLv2 or later
@@ -52,7 +52,7 @@ if (!defined('CSCF_PLUGIN_URL')) define('CSCF_PLUGIN_URL', WP_PLUGIN_URL . '/' .
52
 
53
  if (!defined('CSCF_VERSION_KEY')) define('CSCF_VERSION_KEY', 'cscf_version');
54
 
55
- if (!defined('CSCF_VERSION_NUM')) define('CSCF_VERSION_NUM', '4.2.5');
56
 
57
  if (!defined('CSCF_OPTIONS_KEY')) define('CSCF_OPTIONS_KEY', 'cscf_options');
58
 
7
  Plugin Name: Clean and Simple Contact Form
8
  Plugin URI: http://www.megnicholas.co.uk/wordpress-plugins/clean-and-simple-contact-form
9
  Description: A clean and simple contact form with Google reCAPTCHA and Twitter Bootstrap markup.
10
+ Version: 4.3.0
11
  Author: Meghan Nicholas
12
  Author URI: http://www.megnicholas.co.uk
13
  License: GPLv2 or later
52
 
53
  if (!defined('CSCF_VERSION_KEY')) define('CSCF_VERSION_KEY', 'cscf_version');
54
 
55
+ if (!defined('CSCF_VERSION_NUM')) define('CSCF_VERSION_NUM', '4.3.0');
56
 
57
  if (!defined('CSCF_OPTIONS_KEY')) define('CSCF_OPTIONS_KEY', 'cscf_options');
58
 
readme.txt CHANGED
@@ -3,15 +3,15 @@ Contributors: megnicholas
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AKQM4KSBQ4H66
4
  License: GPLv2 or later
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
- Tags: simple, contact, form, contact button, contact form, contact form plugin, contacts, contacts form plugin, contact me, feedback form, bootstrap, twitter, google, reCAPTCHA, ajax, secure
7
  Requires at least: 3.3
8
  Tested up to: 3.7.1
9
- Stable tag: 4.2.5
10
 
11
- A clean and simple AJAX contact form with Google reCAPTCHA and Twitter Bootstrap markup.
12
 
13
  == Description ==
14
- A clean and simple contact form with Google reCAPTCHA and Twitter Bootstrap markup.
15
 
16
  * **Clean**: all user inputs are stripped in order to avoid cross-site scripting (XSS) vulnerabilities.
17
 
@@ -20,14 +20,25 @@ A clean and simple contact form with Google reCAPTCHA and Twitter Bootstrap mark
20
  * **Stylish**: Use the included stylesheet or switch it off and use your own for seamless integration with your website.
21
  Uses **Twitter Bootstrap** classes.
22
 
 
 
23
  This is a straightforward contact form for your WordPress site. There is very minimal set-up
24
  required. Simply install, activate, and then place the short code **[cscf-contact-form]** on your web page.
25
 
26
  A standard set of input boxes are provided, these include Email Address, Name, Message and a nice big ‘Send Message’ button.
27
 
28
- When your user has completed the form an email will be sent to you containing your user’s message. To reply simply click the ‘reply’ button on your email client. The email address used is the one you have set up in WordPress under ‘Settings’ -> ‘General’, so do check this is correct.
 
 
 
 
 
 
 
29
 
30
- To help prevent spam, this plugin allows you to add a ‘**reCAPTCHA**’. This adds a picture of a couple of words to the bottom of the form. Your user must correctly type the words before the form can be submitted, and in so doing, prove that they are human.
 
 
31
 
32
  = Why Choose This Plugin? =
33
  Granted there are many plugins of this type in existence already. Why use this one in-particular?
@@ -36,7 +47,10 @@ Here’s why:
36
 
37
  * Minimal setup. Simply activate the plugin and place the shortcode [cscf-contact-form] on any post or page.
38
 
39
- * **Safe**. All input entered by your user is stripped back to minimise as far as possible the likelihood of any malicious user attempting to inject a script into your website. You can turn on reCAPTCHA to avoid your form being abused by bots.
 
 
 
40
 
41
  * **Ajax enabled**. You have the option to turn on AJAX (client-side) validation and submission which gives your users an immediate response when completing the form without having to wait for the page to refresh.
42
 
@@ -48,7 +62,7 @@ Here’s why:
48
 
49
  * Works with the **latest version of WordPress**.
50
 
51
- * Written by an **experienced PHP programmer**, the code is rock solid, safe, and rigorously tested as standard practice.
52
 
53
  Hopefully this plugin will fulfil all your needs, if not [get in-touch](http://www.megnicholas.co.uk/contact-me "Get In Touch") and I will customise to your exact requirements.
54
 
@@ -187,6 +201,9 @@ the reCAPTCHA for the contact form will be displayed correctly but not in the co
187
  The comments form will never validate due to no supplied reCAPTCHA code.
188
 
189
  == Changelog ==
 
 
 
190
  = 4.2.5 =
191
  * Fixed bug that caused a PHP notice to be generated when 'Confirm Email Message' option is switched off.
192
  Thanks to MarrsAttax
@@ -276,6 +293,9 @@ Polish thanks to Patryk Peas
276
 
277
 
278
  == Upgrade Notice ==
 
 
 
279
  = 4.2.5 =
280
  Small bug fix
281
  = 4.2.4 =
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AKQM4KSBQ4H66
4
  License: GPLv2 or later
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
+ Tags: simple, contact, form, contact button, contact form, contact form plugin, akismet, contacts, contacts form plugin, contact me, feedback form, bootstrap, twitter, google, reCAPTCHA, ajax, secure
7
  Requires at least: 3.3
8
  Tested up to: 3.7.1
9
+ Stable tag: 4.3.0
10
 
11
+ A clean and simple AJAX contact form with Google reCAPTCHA, Twitter Bootstrap markup and Akismet spam filtering.
12
 
13
  == Description ==
14
+ A clean and simple AJAX contact form with Google reCAPTCHA, Twitter Bootstrap markup and Akismet spam filtering.
15
 
16
  * **Clean**: all user inputs are stripped in order to avoid cross-site scripting (XSS) vulnerabilities.
17
 
20
  * **Stylish**: Use the included stylesheet or switch it off and use your own for seamless integration with your website.
21
  Uses **Twitter Bootstrap** classes.
22
 
23
+ * **Safe**: All incoming data is scanned for spam with **Akismet**.
24
+
25
  This is a straightforward contact form for your WordPress site. There is very minimal set-up
26
  required. Simply install, activate, and then place the short code **[cscf-contact-form]** on your web page.
27
 
28
  A standard set of input boxes are provided, these include Email Address, Name, Message and a nice big ‘Send Message’ button.
29
 
30
+ When your user has completed the form an email will be sent to you containing your user’s message.
31
+ To reply simply click the ‘reply’ button on your email client.
32
+ The email address used is the one you have set up in WordPress under ‘Settings’ -> ‘General’, so do check this is correct.
33
+
34
+ To help prevent spam all data is scanned via Akismet.
35
+ For this to work you must have the [Akismet Plugin](http://wordpress.org/plugins/akismet/ "Akismet Plugin") installed and activated.
36
+ All spam will be placed in your 'comments' list which you can then review if you want to
37
+ [learn more](http://www.megnicholas.co.uk/articles/contact-form-plugin-can-detect-spam/ "Learn More").
38
 
39
+ For added piece of mind this plugin also allows you to add a ‘**reCAPTCHA**’.
40
+ This adds a picture of a couple of words to the bottom of the contact form.
41
+ Your user must correctly type the words before the form can be submitted, and in so doing, prove that they are human.
42
 
43
  = Why Choose This Plugin? =
44
  Granted there are many plugins of this type in existence already. Why use this one in-particular?
47
 
48
  * Minimal setup. Simply activate the plugin and place the shortcode [cscf-contact-form] on any post or page.
49
 
50
+ * **Safe**. All input entered by your user is stripped back to minimise as far as possible the likelihood of any
51
+ malicious user attempting to inject a script into your website.
52
+ If the Akismet plugin is activated all form data will be scanned for spam.
53
+ You can turn on reCAPTCHA to avoid your form being abused by bots.
54
 
55
  * **Ajax enabled**. You have the option to turn on AJAX (client-side) validation and submission which gives your users an immediate response when completing the form without having to wait for the page to refresh.
56
 
62
 
63
  * Works with the **latest version of WordPress**.
64
 
65
+ * Written by an **experienced PHP programmer**, the code is rock solid, safe, and rigorously tested as standard practice.
66
 
67
  Hopefully this plugin will fulfil all your needs, if not [get in-touch](http://www.megnicholas.co.uk/contact-me "Get In Touch") and I will customise to your exact requirements.
68
 
201
  The comments form will never validate due to no supplied reCAPTCHA code.
202
 
203
  == Changelog ==
204
+ = 4.3.0 =
205
+ * Contact form is now filtered for spam when the Akismet plugin is present.
206
+ [Learn more](http://www.megnicholas.co.uk/articles/contact-form-plugin-can-detect-spam/ "Learn More").
207
  = 4.2.5 =
208
  * Fixed bug that caused a PHP notice to be generated when 'Confirm Email Message' option is switched off.
209
  Thanks to MarrsAttax
293
 
294
 
295
  == Upgrade Notice ==
296
+ = 4.3.0 =
297
+ Contact form is now filtered for spam when the Akismet plugin is present.
298
+ [Learn more](http://www.megnicholas.co.uk/articles/contact-form-plugin-can-detect-spam/ "Learn More").
299
  = 4.2.5 =
300
  Small bug fix
301
  = 4.2.4 =
shortcodes/contact-form.php CHANGED
@@ -43,6 +43,7 @@ function cscf_ContactForm()
43
  $view->Set('message',cscf_PluginSettings::Message());
44
  $view->Set('version', CSCF_VERSION_NUM);
45
  $view->Set('confirmEmail', cscf_PluginSettings::ConfirmEmail());
 
46
 
47
 
48
  $view->Set('messageSentView',$messageSentView);
43
  $view->Set('message',cscf_PluginSettings::Message());
44
  $view->Set('version', CSCF_VERSION_NUM);
45
  $view->Set('confirmEmail', cscf_PluginSettings::ConfirmEmail());
46
+ $view->Set('postID', get_the_ID());
47
 
48
 
49
  $view->Set('messageSentView',$messageSentView);
views/contact-form.view.php CHANGED
@@ -12,6 +12,7 @@
12
  <p><?php echo $message; ?></p>
13
  <form role="form" id="frmCSCF" name="frmCSCF" method="post">
14
  <?php wp_nonce_field('cscf_contact','cscf_nonce'); ?>
 
15
 
16
  <?php if (isset($contact->Errors['recaptcha'])) { ?>
17
  <div class="control-group form-group">
12
  <p><?php echo $message; ?></p>
13
  <form role="form" id="frmCSCF" name="frmCSCF" method="post">
14
  <?php wp_nonce_field('cscf_contact','cscf_nonce'); ?>
15
+ <input type="hidden" name="post-id" value="<?php echo $postID; ?>">
16
 
17
  <?php if (isset($contact->Errors['recaptcha'])) { ?>
18
  <div class="control-group form-group">