Plugin Directory

Changeset 1414254


Ignore:
Timestamp:
05/11/2016 12:12:50 AM (10 years ago)
Author:
mailermailer
Message:

MM-13878

Update MailerMailer WP Module:

  • Fix quirky form field validation/highlighting
  • bump version to 1.2.2
Location:
mailermailer/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mailermailer/trunk/class-mailermailer.php

    r1413348 r1414254  
    2626
    2727  // Plugin version, used for cache-busting of style and script file references.
    28   protected $version = '1.2.1';
     28  protected $version = '1.2.2';
    2929
    3030  // Unique identifier for your plugin.
     
    239239    $captcha_keys = get_option('mailermailer_captcha_keys');
    240240    $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 default
    242241
    243242    $opts_api = get_option('mailermailer_api');
     
    247246      $valid = $this->is_recaptcha_valid($_POST['g-recaptcha-response']);
    248247      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 ]);
    269261            }
    270262          }
    271         } elseif ($field['type'] == 'state') { // state
    272           if (isset($_POST[ $name ])) {
    273             $user_input = (preg_match("/Other/i", $_POST[ $name ])) ? $_POST[ $name . '_other' ] : $_POST[ $name ];
    274           }
    275263        } else {
    276           if (isset($_POST[$name ])) { // open_text and country
    277             $user_input = $_POST[ $name ];
     264          if (isset($_POST[ $name ])) { // select_type single
     265            array_push($user_input, $_POST[ $name ]);
    278266          }
    279267        }
    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 ];
    283271        }
    284         $member[ $field['fieldname'] ] = $user_input;
    285       }
    286 
    287       if (!empty($missing)) {
    288         // If we encounter missing fields no need to call API
    289         $message = '<span class="mm_display_error">Required data is missing.</span>';
    290272      } 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 ];
    299275        }
     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>';
    300296      }
    301297    }
     
    304300      'message' => $message,
    305301      'missing' => $missing,
    306       'member' => $member,
    307       'captcha_enabled' => $recaptcha_enabled
     302      'member' => $member
    308303    );
    309304  }
  • mailermailer/trunk/css/public.css

    r760804 r1414254  
    8787  padding: 0;
    8888}
     89
     90form#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  
    2929    var message = data.message;
    3030    var member = data.member;
    31     var captcha_enabled = data.captcha_enabled;
     31    var captcha_container = 'mailermailer_captcha_container';
    3232    var check_message = new RegExp('class="mm_display_success"', 'i');
    33    
     33
    3434    // display message
    3535    $('#mm_msg').html(message);
     
    7070    }
    7171
    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      }
    7581    }
    7682
  • mailermailer/trunk/mailermailer.php

    r1413348 r1414254  
    44Plugin URI: http://wordpress.org/extend/plugins/mailermailer/
    55Description: The mailermailer plugin allows you to add your own signup form to your site.
    6 Version: 1.2.1
     6Version: 1.2.2
    77Author: mailermailer
    88Author URI: http://www.mailermailer.com/api/
  • mailermailer/trunk/readme.txt

    r1413348 r1414254  
    44Requires at least: 3.5
    55Tested up to: 4.5.2
    6 Stable tag: 1.2.1
     6Stable tag: 1.2.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7575== Upgrade Notice ==
    7676
     77= 1.2.2 =
     78* Fix quirky form field validation/highlighting
     79
    7780= 1.2.1 =
    7881* Fix README.md and readme.txt accidentally introduced in 1.2.0
Note: See TracChangeset for help on using the changeset viewer.