Contact Form Clean and Simple - Version 4.6.1

Version Description

  • Fixed untranslated strings. Thanks to Abdullah Manaz!
Download this release

Release Info

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

Code changes from version 4.6.0 to 4.6.1

class.cscf_contact.php CHANGED
@@ -4,169 +4,179 @@
4
  * class for holding and validating data captured from the contact form
5
  */
6
 
7
- class cscf_Contact
8
- {
9
- var $Name;
10
- var $Email;
11
- var $ConfirmEmail;
12
- var $Message;
13
- var $EmailToSender;
14
- var $ErrorMessage;
15
- var $RecaptchaPublicKey;
16
- var $RecaptchaPrivateKey;
17
- var $Errors;
18
- var $PostID;
19
- var $IsSpam;
20
-
21
- function __construct()
22
- {
23
- $this->Errors = array();
24
-
25
- if (cscf_PluginSettings::UseRecaptcha()) {
26
- $this->RecaptchaPublicKey = cscf_PluginSettings::PublicKey();
27
- $this->RecaptchaPrivateKey = cscf_PluginSettings::PrivateKey();
28
- }
29
-
30
- if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cscf'])) {
31
- $cscf = $_POST['cscf'];
32
- $this->Name = filter_var($cscf['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
33
- $this->Email = filter_var($cscf['email'], FILTER_SANITIZE_EMAIL);
34
-
35
- if (isset($cscf['confirm-email'])) {
36
- $this->ConfirmEmail = filter_var($cscf['confirm-email'], FILTER_SANITIZE_EMAIL);
37
- }
38
-
39
- $this->EmailToSender = isset($cscf['email-sender']);
40
-
41
- $this->Message = filter_var($cscf['message'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
42
- if (isset($_POST['post-id'])) {
43
- $this->PostID = $_POST['post-id'];
44
- }
45
- unset($_POST['cscf']);
46
- }
47
-
48
- $this->IsSpam = false;
49
- }
50
-
51
- public
52
- function IsValid()
53
- {
54
- $this->Errors = array();
55
-
56
- if ($_SERVER['REQUEST_METHOD'] != 'POST')
57
- return false;
58
-
59
- //check nonce
60
-
61
- if (!wp_verify_nonce($_POST['cscf_nonce'], 'cscf_contact'))
62
- return false;
63
-
64
- // email and confirm email are the same
65
- if (cscf_PluginSettings::ConfirmEmail()) {
66
- if ($this->Email != $this->ConfirmEmail) $this->Errors['confirm-email'] = __('Sorry the email addresses do not match.', 'clean-and-simple-contact-form-by-meg-nicholas');
67
- }
68
-
69
- //email
70
-
71
- if (strlen($this->Email) == 0) $this->Errors['email'] = __('Please give your email address.', 'clean-and-simple-contact-form-by-meg-nicholas');
72
-
73
- //confirm email
74
- if (cscf_PluginSettings::ConfirmEmail()) {
75
- if (strlen($this->ConfirmEmail) == 0) $this->Errors['confirm-email'] = __('Please confirm your email address.', 'clean-and-simple-contact-form-by-meg-nicholas');
76
- }
77
-
78
- //name
79
-
80
- if (strlen($this->Name) == 0) $this->Errors['name'] = __('Please give your name.', 'clean-and-simple-contact-form-by-meg-nicholas');
81
-
82
- //message
83
-
84
- if (strlen($this->Message) == 0) $this->Errors['message'] = __('Please enter a message.', 'clean-and-simple-contact-form-by-meg-nicholas');
85
-
86
- //email invalid address
87
-
88
- if (strlen($this->Email) > 0 && !filter_var($this->Email, FILTER_VALIDATE_EMAIL)) $this->Errors['email'] = __('Please enter a valid email address.', 'clean-and-simple-contact-form-by-meg-nicholas');
89
-
90
- //check recaptcha but only if we have keys
91
-
92
- if ($this->RecaptchaPublicKey <> '' && $this->RecaptchaPrivateKey <> '') {
93
- $resp = csf_RecaptchaV2::VerifyResponse($_SERVER["REMOTE_ADDR"],$this->RecaptchaPrivateKey,$_POST["g-recaptcha-response"] );
94
-
95
- if (!$resp->success) {
 
 
 
 
 
 
 
 
 
 
 
96
  // $this->Errors['recaptcha'] = __('Sorry the code wasn\'t entered correctly please try again.', 'clean-and-simple-contact-form-by-meg-nicholas');
97
- $this->Errors['recaptcha'] = __('Please solve the recaptcha to continue.', 'clean-and-simple-contact-form-by-meg-nicholas');
98
- }
99
- }
100
 
101
- return count($this->Errors) == 0;
102
- }
103
 
104
- public
105
- function SendMail()
106
- {
107
- apply_filters('cscf_spamfilter', $this);
108
 
109
- if ($this->IsSpam === true) {
110
- return true;
111
- }
112
 
113
- $filters = new cscf_Filters;
114
 
115
- if (cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "") {
116
- $filters->fromEmail = cscf_PluginSettings::FromEmail();
117
- } else {
118
- $filters->fromEmail = $this->Email;
119
- }
120
 
121
- $filters->fromName = $this->Name;
122
 
123
- //add filters
124
- $filters->add('wp_mail_from');
125
- $filters->add('wp_mail_from_name');
126
 
127
- //headers
128
- $header = "Reply-To: " . $this->Email . "\r\n";
129
 
130
- //message
131
- $message = "From: " . $this->Name . "\n\n";
132
- $message .= "Email: " . $this->Email . "\n\n";
133
- $message .= "Page URL: " . get_permalink($this->PostID) . "\n\n";
134
- $message .= "Message:\n\n" . $this->Message;
135
 
136
- $result = (wp_mail(cscf_PluginSettings::RecipientEmails(), cscf_PluginSettings::Subject(), stripslashes($message), $header));
137
 
138
- //remove filters (play nice)
139
- $filters->remove('wp_mail_from');
140
- $filters->remove('wp_mail_from_name');
141
 
142
- //send an email to the form-filler
143
- if ($this->EmailToSender) {
144
- $recipients = cscf_PluginSettings::RecipientEmails();
145
 
146
- if (cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "") {
147
- $filters->fromEmail = cscf_PluginSettings::FromEmail();
148
- } else {
149
- $filters->fromEmail = $recipients[0];
150
- }
151
 
152
- $filters->fromName = get_bloginfo('name');
153
 
154
- //add filters
155
- $filters->add('wp_mail_from');
156
- $filters->add('wp_mail_from_name');
157
 
158
- $header = "";
159
- $message = cscf_PluginSettings::SentMessageBody() . "\n\n";
160
- $message .= __("Here is a copy of your message :", "cleanandsimple") . "\n\n";
161
- $message .= $this->Message;
162
 
163
- $result = (wp_mail($this->Email, cscf_PluginSettings::Subject(), stripslashes($message), $header));
164
 
165
- //remove filters (play nice)
166
- $filters->remove('wp_mail_from');
167
- $filters->remove('wp_mail_from_name');
168
- }
169
 
170
- return $result;
171
- }
172
  }
4
  * class for holding and validating data captured from the contact form
5
  */
6
 
7
+ class cscf_Contact {
8
+ var $Name;
9
+ var $Email;
10
+ var $ConfirmEmail;
11
+ var $Message;
12
+ var $EmailToSender;
13
+ var $ErrorMessage;
14
+ var $RecaptchaPublicKey;
15
+ var $RecaptchaPrivateKey;
16
+ var $Errors;
17
+ var $PostID;
18
+ var $IsSpam;
19
+
20
+ function __construct() {
21
+ $this->Errors = array();
22
+
23
+ if ( cscf_PluginSettings::UseRecaptcha() ) {
24
+ $this->RecaptchaPublicKey = cscf_PluginSettings::PublicKey();
25
+ $this->RecaptchaPrivateKey = cscf_PluginSettings::PrivateKey();
26
+ }
27
+
28
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['cscf'] ) ) {
29
+ $cscf = $_POST['cscf'];
30
+ $this->Name = filter_var( $cscf['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
31
+ $this->Email = filter_var( $cscf['email'], FILTER_SANITIZE_EMAIL );
32
+
33
+ if ( isset( $cscf['confirm-email'] ) ) {
34
+ $this->ConfirmEmail = filter_var( $cscf['confirm-email'], FILTER_SANITIZE_EMAIL );
35
+ }
36
+
37
+ $this->EmailToSender = isset( $cscf['email-sender'] );
38
+
39
+ $this->Message = filter_var( $cscf['message'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES );
40
+ if ( isset( $_POST['post-id'] ) ) {
41
+ $this->PostID = $_POST['post-id'];
42
+ }
43
+ unset( $_POST['cscf'] );
44
+ }
45
+
46
+ $this->IsSpam = false;
47
+ }
48
+
49
+ public
50
+ function IsValid() {
51
+ $this->Errors = array();
52
+
53
+ if ( $_SERVER['REQUEST_METHOD'] != 'POST' ) {
54
+ return false;
55
+ }
56
+
57
+ //check nonce
58
+
59
+ if ( ! wp_verify_nonce( $_POST['cscf_nonce'], 'cscf_contact' ) ) {
60
+ return false;
61
+ }
62
+
63
+ // email and confirm email are the same
64
+ if ( cscf_PluginSettings::ConfirmEmail() ) {
65
+ if ( $this->Email != $this->ConfirmEmail ) {
66
+ $this->Errors['confirm-email'] = __( 'Sorry the email addresses do not match.', 'clean-and-simple-contact-form-by-meg-nicholas' );
67
+ }
68
+ }
69
+
70
+ //email
71
+
72
+ if ( strlen( $this->Email ) == 0 ) {
73
+ $this->Errors['email'] = __( 'Please give your email address.', 'clean-and-simple-contact-form-by-meg-nicholas' );
74
+ }
75
+
76
+ //confirm email
77
+ if ( cscf_PluginSettings::ConfirmEmail() ) {
78
+ if ( strlen( $this->ConfirmEmail ) == 0 ) {
79
+ $this->Errors['confirm-email'] = __( 'Please confirm your email address.', 'clean-and-simple-contact-form-by-meg-nicholas' );
80
+ }
81
+ }
82
+
83
+ //name
84
+
85
+ if ( strlen( $this->Name ) == 0 ) {
86
+ $this->Errors['name'] = __( 'Please give your name.', 'clean-and-simple-contact-form-by-meg-nicholas' );
87
+ }
88
+
89
+ //message
90
+
91
+ if ( strlen( $this->Message ) == 0 ) {
92
+ $this->Errors['message'] = __( 'Please enter a message.', 'clean-and-simple-contact-form-by-meg-nicholas' );
93
+ }
94
+
95
+ //email invalid address
96
+
97
+ if ( strlen( $this->Email ) > 0 && ! filter_var( $this->Email, FILTER_VALIDATE_EMAIL ) ) {
98
+ $this->Errors['email'] = __( 'Please enter a valid email address.', 'clean-and-simple-contact-form-by-meg-nicholas' );
99
+ }
100
+
101
+ //check recaptcha but only if we have keys
102
+
103
+ if ( $this->RecaptchaPublicKey <> '' && $this->RecaptchaPrivateKey <> '' ) {
104
+ $resp = csf_RecaptchaV2::VerifyResponse( $_SERVER["REMOTE_ADDR"], $this->RecaptchaPrivateKey, $_POST["g-recaptcha-response"] );
105
+
106
+ if ( ! $resp->success ) {
107
  // $this->Errors['recaptcha'] = __('Sorry the code wasn\'t entered correctly please try again.', 'clean-and-simple-contact-form-by-meg-nicholas');
108
+ $this->Errors['recaptcha'] = __( 'Please solve the recaptcha to continue.', 'clean-and-simple-contact-form-by-meg-nicholas' );
109
+ }
110
+ }
111
 
112
+ return count( $this->Errors ) == 0;
113
+ }
114
 
115
+ public
116
+ function SendMail() {
117
+ apply_filters( 'cscf_spamfilter', $this );
 
118
 
119
+ if ( $this->IsSpam === true ) {
120
+ return true;
121
+ }
122
 
123
+ $filters = new cscf_Filters;
124
 
125
+ if ( cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "" ) {
126
+ $filters->fromEmail = cscf_PluginSettings::FromEmail();
127
+ } else {
128
+ $filters->fromEmail = $this->Email;
129
+ }
130
 
131
+ $filters->fromName = $this->Name;
132
 
133
+ //add filters
134
+ $filters->add( 'wp_mail_from' );
135
+ $filters->add( 'wp_mail_from_name' );
136
 
137
+ //headers
138
+ $header = "Reply-To: " . $this->Email . "\r\n";
139
 
140
+ //message
141
+ $message = __( 'From: ', 'clean-and-simple-contact-form-by-meg-nicholas' ) . $this->Name . "\n\n";
142
+ $message .= __( 'Email: ', 'clean-and-simple-contact-form-by-meg-nicholas' ) . $this->Email . "\n\n";
143
+ $message .= __( 'Page URL: ', 'clean-and-simple-contact-form-by-meg-nicholas' ) . get_permalink( $this->PostID ) . "\n\n";
144
+ $message .= __( 'Message:', 'clean-and-simple-contact-form-by-meg-nicholas' ) . "\n\n" . $this->Message;
145
 
146
+ $result = ( wp_mail( cscf_PluginSettings::RecipientEmails(), cscf_PluginSettings::Subject(), stripslashes( $message ), $header ) );
147
 
148
+ //remove filters (play nice)
149
+ $filters->remove( 'wp_mail_from' );
150
+ $filters->remove( 'wp_mail_from_name' );
151
 
152
+ //send an email to the form-filler
153
+ if ( $this->EmailToSender ) {
154
+ $recipients = cscf_PluginSettings::RecipientEmails();
155
 
156
+ if ( cscf_PluginSettings::OverrideFrom() & cscf_PluginSettings::FromEmail() != "" ) {
157
+ $filters->fromEmail = cscf_PluginSettings::FromEmail();
158
+ } else {
159
+ $filters->fromEmail = $recipients[0];
160
+ }
161
 
162
+ $filters->fromName = get_bloginfo( 'name' );
163
 
164
+ //add filters
165
+ $filters->add( 'wp_mail_from' );
166
+ $filters->add( 'wp_mail_from_name' );
167
 
168
+ $header = "";
169
+ $message = cscf_PluginSettings::SentMessageBody() . "\n\n";
170
+ $message .= __( "Here is a copy of your message :", "clean-and-simple-contact-form-by-meg-nicholas" ) . "\n\n";
171
+ $message .= $this->Message;
172
 
173
+ $result = ( wp_mail( $this->Email, cscf_PluginSettings::Subject(), stripslashes( $message ), $header ) );
174
 
175
+ //remove filters (play nice)
176
+ $filters->remove( 'wp_mail_from' );
177
+ $filters->remove( 'wp_mail_from_name' );
178
+ }
179
 
180
+ return $result;
181
+ }
182
  }
class.cscf_settings.php CHANGED
@@ -44,12 +44,12 @@ class cscf_settings
44
  <div style="float:right;position: relative;width:250px;">
45
 
46
  <div style="border:1px solid;padding:5px;margin-bottom: 8px;text-align:center;">
47
- <h3><?php _e("Donate $10, $20 or $50!", "cleanandsimple"); ?></h3>
48
 
49
  <div>
50
- <p><?php _e("If you like this plugin, please donate to support development and maintenance of:", "cleanandsimple"); ?></p>
51
 
52
- <h3><?php _e("Clean and Simple Contact Form!", "cleanandsimple"); ?></h3>
53
 
54
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
55
  <input type="hidden" name="cmd" value="_s-xclick">
@@ -82,8 +82,8 @@ class cscf_settings
82
  </p>
83
  <?php } ?>
84
 
85
- <p class="howto"><?php _e("Please Note: To add the contact form to your page please add the text", "cleanandsimple"); ?>
86
- <code>[cscf-contact-form]</code> <?php _e("to your post or page.", "cleanandsimple"); ?></p>
87
 
88
  <form method="post" action="options.php">
89
  <?php
44
  <div style="float:right;position: relative;width:250px;">
45
 
46
  <div style="border:1px solid;padding:5px;margin-bottom: 8px;text-align:center;">
47
+ <h3><?php _e("Donate $10, $20 or $50!", "clean-and-simple-contact-form-by-meg-nicholas"); ?></h3>
48
 
49
  <div>
50
+ <p><?php _e("If you like this plugin, please donate to support development and maintenance of:", "clean-and-simple-contact-form-by-meg-nicholas"); ?></p>
51
 
52
+ <h3><?php _e("Clean and Simple Contact Form!", "clean-and-simple-contact-form-by-meg-nicholas"); ?></h3>
53
 
54
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
55
  <input type="hidden" name="cmd" value="_s-xclick">
82
  </p>
83
  <?php } ?>
84
 
85
+ <p class="howto"><?php _e("Please Note: To add the contact form to your page please add the text", "clean-and-simple-contact-form-by-meg-nicholas"); ?>
86
+ <code>[cscf-contact-form]</code> <?php _e("to your post or page.", "clean-and-simple-contact-form-by-meg-nicholas"); ?></p>
87
 
88
  <form method="post" action="options.php">
89
  <?php
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.6.0
11
  Author: Meghan Nicholas
12
  Author URI: http://www.megnicholas.co.uk
13
  License: GPLv2 or later
@@ -54,7 +54,7 @@ if (!defined('CSCF_PLUGIN_URL')) define('CSCF_PLUGIN_URL', WP_PLUGIN_URL . '/' .
54
 
55
  if (!defined('CSCF_VERSION_KEY')) define('CSCF_VERSION_KEY', 'cscf_version');
56
 
57
- if (!defined('CSCF_VERSION_NUM')) define('CSCF_VERSION_NUM', '4.6.0');
58
 
59
  if (!defined('CSCF_OPTIONS_KEY')) define('CSCF_OPTIONS_KEY', 'cscf_options');
60
 
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.6.1
11
  Author: Meghan Nicholas
12
  Author URI: http://www.megnicholas.co.uk
13
  License: GPLv2 or later
54
 
55
  if (!defined('CSCF_VERSION_KEY')) define('CSCF_VERSION_KEY', 'cscf_version');
56
 
57
+ if (!defined('CSCF_VERSION_NUM')) define('CSCF_VERSION_NUM', '4.6.1');
58
 
59
  if (!defined('CSCF_OPTIONS_KEY')) define('CSCF_OPTIONS_KEY', 'cscf_options');
60
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ 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: 4.4.1
9
- Stable tag: 4.6.0
10
 
11
  A clean and simple AJAX contact form with Google reCAPTCHA, Twitter Bootstrap markup and Akismet spam filtering.
12
 
@@ -203,6 +203,8 @@ the reCAPTCHA for the contact form will be displayed correctly but not in the co
203
  The comments form will never validate due to no supplied reCAPTCHA code.
204
 
205
  == Changelog ==
 
 
206
  = 4.6.0 =
207
  * Prevent multiple 'send message' clicks.
208
  * Changed text domain to plugin slug to allow for WP translation system import
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: 4.4.1
9
+ Stable tag: 4.6.1
10
 
11
  A clean and simple AJAX contact form with Google reCAPTCHA, Twitter Bootstrap markup and Akismet spam filtering.
12
 
203
  The comments form will never validate due to no supplied reCAPTCHA code.
204
 
205
  == Changelog ==
206
+ = 4.6.1 =
207
+ * Fixed untranslated strings. Thanks to Abdullah Manaz!
208
  = 4.6.0 =
209
  * Prevent multiple 'send message' clicks.
210
  * Changed text domain to plugin slug to allow for WP translation system import