Changeset 1414254
- Timestamp:
- 05/11/2016 12:12:50 AM (10 years ago)
- Location:
- mailermailer/trunk
- Files:
-
- 5 edited
-
class-mailermailer.php (modified) (4 diffs)
-
css/public.css (modified) (1 diff)
-
js/public.js (modified) (2 diffs)
-
mailermailer.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mailermailer/trunk/class-mailermailer.php
r1413348 r1414254 26 26 27 27 // Plugin version, used for cache-busting of style and script file references. 28 protected $version = '1.2. 1';28 protected $version = '1.2.2'; 29 29 30 30 // Unique identifier for your plugin. … … 239 239 $captcha_keys = get_option('mailermailer_captcha_keys'); 240 240 $recaptcha_enabled = !empty($captcha_keys['mm_public_captcha_key']) && !empty($captcha_keys['mm_private_captcha_key']); 241 $can_continue = true; // assume recaptcha is not enabled by default242 241 243 242 $opts_api = get_option('mailermailer_api'); … … 247 246 $valid = $this->is_recaptcha_valid($_POST['g-recaptcha-response']); 248 247 if (!$valid) { 249 $can_continue = false; 250 $message = '<span class="mm_display_error">reCAPTCHA is invalid</span>'; 251 } 252 } 253 254 if ($can_continue) { 255 // traverse through formfields and retrieve POST data 256 foreach ($formfields as $field) { 257 $name = 'mm_' . $field['fieldname']; 258 $user_input = array(); 259 if ($field['type'] == 'select') { // select 260 if ($field['attributes']['select_type'] == 'multi') { 261 foreach ($field['choices'] as $key => $value) { 262 if (isset($_POST[ $name . '_' . $key ])) { 263 array_push($user_input, $_POST[ $name . '_' . $key ]); 264 } 265 } 266 } else { 267 if (isset($_POST[ $name ])) { // select_type single 268 array_push($user_input, $_POST[ $name ]); 248 $missing[ 'mailermailer_captcha_container' ] = 'reCAPTCHA'; 249 } 250 } 251 252 // traverse through formfields and retrieve POST data 253 foreach ($formfields as $field) { 254 $name = 'mm_' . $field['fieldname']; 255 $user_input = array(); 256 if ($field['type'] == 'select') { // select 257 if ($field['attributes']['select_type'] == 'multi') { 258 foreach ($field['choices'] as $key => $value) { 259 if (isset($_POST[ $name . '_' . $key ])) { 260 array_push($user_input, $_POST[ $name . '_' . $key ]); 269 261 } 270 262 } 271 } elseif ($field['type'] == 'state') { // state272 if (isset($_POST[ $name ])) {273 $user_input = (preg_match("/Other/i", $_POST[ $name ])) ? $_POST[ $name . '_other' ] : $_POST[ $name ];274 }275 263 } else { 276 if (isset($_POST[ $name ])) { // open_text and country277 $user_input = $_POST[ $name ];264 if (isset($_POST[ $name ])) { // select_type single 265 array_push($user_input, $_POST[ $name ]); 278 266 } 279 267 } 280 281 if ( $field['required'] && (empty($user_input) || $user_input == "--" || $user_input[0] == "--")) {282 $ missing[ $name ] = $field['description'];268 } elseif ($field['type'] == 'state') { // state 269 if (isset($_POST[ $name ])) { 270 $user_input = (preg_match("/Other/i", $_POST[ $name ])) ? $_POST[ $name . '_other' ] : $_POST[ $name ]; 283 271 } 284 $member[ $field['fieldname'] ] = $user_input;285 }286 287 if (!empty($missing)) {288 // If we encounter missing fields no need to call API289 $message = '<span class="mm_display_error">Required data is missing.</span>';290 272 } else { 291 $mailapi = new MAILAPI_Client($opts_api['mm_apikey']); 292 293 $added = $mailapi->addMember($member); 294 295 if (MAILAPI_Error::isError($added)) { 296 $message = '<span class="mm_display_error">' . $this->errors($added) . '</span>'; 297 } else { 298 $message = '<span class="mm_display_success">Please check your e-mail for a confirmation message.</span>'; 273 if (isset($_POST[$name ])) { // open_text and country 274 $user_input = $_POST[ $name ]; 299 275 } 276 } 277 278 if ($field['required'] && (empty($user_input) || $user_input == "--" || $user_input[0] == "--")) { 279 $missing[ $name ] = $field['description']; 280 } 281 $member[ $field['fieldname'] ] = $user_input; 282 } 283 284 if (!empty($missing)) { 285 // If we encounter missing fields no need to call API 286 $message = '<span class="mm_display_error">Required data is missing.</span>'; 287 } else { 288 $mailapi = new MAILAPI_Client($opts_api['mm_apikey']); 289 290 $added = $mailapi->addMember($member); 291 292 if (MAILAPI_Error::isError($added)) { 293 $message = '<span class="mm_display_error">' . $this->errors($added) . '</span>'; 294 } else { 295 $message = '<span class="mm_display_success">Please check your e-mail for a confirmation message.</span>'; 300 296 } 301 297 } … … 304 300 'message' => $message, 305 301 'missing' => $missing, 306 'member' => $member, 307 'captcha_enabled' => $recaptcha_enabled 302 'member' => $member 308 303 ); 309 304 } -
mailermailer/trunk/css/public.css
r760804 r1414254 87 87 padding: 0; 88 88 } 89 90 form#mm_signup_form div.captcha-warning { 91 background-color: #f9f2f1; 92 border: 1px solid #fdcec4; 93 display: inline-block; 94 padding: 10px 7px 7px 13px; 95 } -
mailermailer/trunk/js/public.js
r1413322 r1414254 29 29 var message = data.message; 30 30 var member = data.member; 31 var captcha_ enabled = data.captcha_enabled;31 var captcha_container = 'mailermailer_captcha_container'; 32 32 var check_message = new RegExp('class="mm_display_success"', 'i'); 33 33 34 34 // display message 35 35 $('#mm_msg').html(message); … … 70 70 } 71 71 72 // reset captcha 73 if ($.trim($('#mailermailer_captcha_container').html()).length) { 74 grecaptcha.reset(); 72 if ($.trim($('#'+captcha_container).html()).length) { 73 // reset captcha 74 grecaptcha.reset(); 75 // highlight captcha if missing 76 if (missing.hasOwnProperty(captcha_container)) { 77 $('#'+captcha_container).addClass("captcha-warning"); 78 } else { 79 $('#'+captcha_container).removeClass("captcha-warning"); 80 } 75 81 } 76 82 -
mailermailer/trunk/mailermailer.php
r1413348 r1414254 4 4 Plugin URI: http://wordpress.org/extend/plugins/mailermailer/ 5 5 Description: The mailermailer plugin allows you to add your own signup form to your site. 6 Version: 1.2. 16 Version: 1.2.2 7 7 Author: mailermailer 8 8 Author URI: http://www.mailermailer.com/api/ -
mailermailer/trunk/readme.txt
r1413348 r1414254 4 4 Requires at least: 3.5 5 5 Tested up to: 4.5.2 6 Stable tag: 1.2. 16 Stable tag: 1.2.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 75 75 == Upgrade Notice == 76 76 77 = 1.2.2 = 78 * Fix quirky form field validation/highlighting 79 77 80 = 1.2.1 = 78 81 * Fix README.md and readme.txt accidentally introduced in 1.2.0
Note: See TracChangeset
for help on using the changeset viewer.