Skip to content

Commit

Permalink
Merge pull request #502 from WebDevStudios/sprint/20.06-2
Browse files Browse the repository at this point in the history
Release sprint/20.06-2 to master
  • Loading branch information
richaber authored Jul 29, 2020
2 parents 136f9f4 + 573ab62 commit 41d8ccb
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 210 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
= 1.8.7 =
* Improved: Implemented recommendations for improved accessibility.
* Improved: Avoid duplicate ID attributes when more than one form is present on a page.
* Fixed: Submit button targeting for recaptcha v2.

= 1.8.6 =
* Fixed: Removed invalid property being sent to the API, causing rejected requests.
* Fixed: Failure to log API errors for support purposes.
Expand Down
16 changes: 12 additions & 4 deletions assets/css/style.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/css/style.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/ctct-plugin-frontend.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assets/js/ctct-plugin-frontend/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
$( document ).ready( () => {

$( '#ctct-submitted' ).on( 'click', () => {
$( '.ctct-submitted' ).on( 'click', () => {
setTimeout( () => {
disableSendButton();
setTimeout( enableSendButton, 3000 );
Expand All @@ -25,7 +25,7 @@
* @return {mixed} jQuery if attribute is set, undefined if not.
*/
function disableSendButton() {
return $( '#ctct-submitted' ).attr( 'disabled', 'disabled' );
return $( '.ctct-submitted' ).attr( 'disabled', 'disabled' );
}

/**
Expand All @@ -37,7 +37,7 @@
* @return {mixed} jQuery if attribute is set, undefined if not.
*/
function enableSendButton() {
return $( '#ctct-submitted' ).attr( 'disabled', null );
return $( '.ctct-submitted' ).attr( 'disabled', null );
}

} ( window, jQuery ) );
33 changes: 22 additions & 11 deletions assets/js/ctct-plugin-frontend/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

var $form = $( form );

app.$c.$forms[ i ].$honeypot = $form.find( '#ctct_usage_field' );
app.$c.$forms[ i ].$honeypot = $form.find( '.ctct_usage_field' );
app.$c.$forms[ i ].$submitButton = $form.find( 'input[type=submit]' );
app.$c.$forms[ i ].$recaptcha = $form.find( '.g-recaptcha' );
} );
Expand Down Expand Up @@ -146,15 +146,26 @@
* @param {string} message The message content.
* @param {string} classes Optional. HTML classes to add to the message wrapper.
*/
app.showMessage = ( $form, message, classes = '' ) => {
app.showMessage = ( $form, message, classes = '', role = 'log' ) => {

const $wrapper = $form.parents( '.ctct-form-wrapper' );

$wrapper.find( 'p.ctct-message' ).remove();

var $p = $( '<p />', {
'class': 'ctct-message ' + classes,
'text': message
} );

$p.insertBefore( $form ).fadeIn( 200 ).delay( 5000 ).slideUp( 200, () => {
$p.remove();
'text': message,
'role': role
} ).prepend( $( '<button />', {
'class': 'button button-secondary ctct-dismiss ctct-dismiss-ajax-notice',
'html': '&#10005;',
'aria-label': 'Dismiss Notification'
} ) );

$p.insertBefore( $form ).fadeIn( 200 );

$wrapper.find( '.ctct-dismiss-ajax-notice' ).on( 'click', function() {
$( this ).parents( '.ctct-message' ).remove();
} );
};

Expand All @@ -168,7 +179,7 @@
*/
app.submitForm = ( $form ) => {

$form.find( '#ctct-submitted' ).prop( 'disabled', true );
$form.find( '.ctct-submitted' ).prop( 'disabled', true );

var ajaxData = {
'action': 'ctct_process_form',
Expand All @@ -177,7 +188,7 @@

$.post( window.ajaxurl, ajaxData, ( response ) => {

$form.find( '#ctct-submitted' ).prop( 'disabled', false );
$form.find( '.ctct-submitted' ).prop( 'disabled', false );

if ( 'undefined' === typeof( response.status ) ) {
return false;
Expand All @@ -190,14 +201,14 @@
app.setAllInputsValid();
response.errors.forEach( app.processError );
} else {
app.showMessage( $form, response.message, 'ctct-error' );
app.showMessage( $form, response.message, 'ctct-error', 'alert' );
}

return false;
}

// If we're here, the submission was a success; show message and reset form fields.
app.showMessage( $form, response.message, 'ctct-success' );
app.showMessage( $form, response.message, 'ctct-success', 'status' );
$form[0].reset();
} );
};
Expand Down
6 changes: 3 additions & 3 deletions assets/js/ctct-plugin-recaptcha-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ({
Expand All @@ -105,11 +105,11 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _rec
/*! no static exports found */
/***/ (function(module, exports) {

eval("var ctctEnableBtn = function ctctEnableBtn(index) {\n jQuery(jQuery(\".ctct-submit\")[index]).attr(\"disabled\", false);\n};\n\nwindow.ctctEnableBtn = ctctEnableBtn;\n\nvar ctctDisableBtn = function ctctDisableBtn(index) {\n jQuery(jQuery(\".ctct-submit\")[index]).attr(\"disabled\", \"disabled\");\n};\n\nwindow.ctctDisableBtn = ctctDisableBtn;\n\nvar renderReCaptcha = function renderReCaptcha() {\n jQuery('.g-recaptcha').each(function (index, el) {\n grecaptcha.render(el, {\n 'sitekey': jQuery(el).attr('data-sitekey'),\n 'size': jQuery(el).attr('data-size'),\n 'tabindex': jQuery(el).attr('data-tabindex'),\n 'callback': function callback() {\n window.ctctEnableBtn(index);\n },\n 'expired-callback': function expiredCallback() {\n window.ctctDisableBtn(index);\n },\n 'isolated': true\n });\n });\n};\n\nwindow.renderReCaptcha = renderReCaptcha;//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9hc3NldHMvanMvY3RjdC1wbHVnaW4tcmVjYXB0Y2hhLXYyL3JlY2FwdGNoYS5qcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Fzc2V0cy9qcy9jdGN0LXBsdWdpbi1yZWNhcHRjaGEtdjIvcmVjYXB0Y2hhLmpzPzlhNDQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGN0Y3R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mRleCApO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICdpc29sYXRlZCc6IHRydWUsXG4gICAgICAgIH0gKTtcbiAgICB9ICk7XG59O1xud2luZG93LnJlbmRlclJlQ2FwdGNoYSA9IHJlbmRlclJlQ2FwdGNoYTtcbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFWQTtBQVlBO0FBQ0E7QUFDQTtBQUFBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./assets/js/ctct-plugin-recaptcha-v2/recaptcha.js\n");
eval("/**\n * Enable submit button.\n *\n * @author Rebekah Van Epps <[email protected]>\n * @since 1.8.3\n *\n * @param {Object} submitBtn Submit DOM element.\n */\nvar ctctEnableBtn = function ctctEnableBtn(submitBtn) {\n jQuery(submitBtn).attr(\"disabled\", false);\n};\n\nwindow.ctctEnableBtn = ctctEnableBtn;\n/**\n * Disable submit button.\n *\n * @author Rebekah Van Epps <[email protected]>\n * @since 1.8.3\n *\n * @param {Object} submitBtn Submit DOM element.\n */\n\nvar ctctDisableBtn = function ctctDisableBtn(submitBtn) {\n jQuery(submitBtn).attr(\"disabled\", \"disabled\");\n};\n\nwindow.ctctDisableBtn = ctctDisableBtn;\n\nvar renderReCaptcha = function renderReCaptcha() {\n jQuery('.g-recaptcha').each(function (index, el) {\n var submitBtn = jQuery(el).siblings('.ctct-form-field-submit').find('.ctct-submit');\n grecaptcha.render(el, {\n 'sitekey': jQuery(el).attr('data-sitekey'),\n 'size': jQuery(el).attr('data-size'),\n 'tabindex': jQuery(el).attr('data-tabindex'),\n 'callback': function callback() {\n window.ctctEnableBtn(submitBtn);\n },\n 'expired-callback': function expiredCallback() {\n window.ctctDisableBtn(submitBtn);\n },\n 'isolated': true\n });\n });\n};\n\nwindow.renderReCaptcha = renderReCaptcha;//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9hc3NldHMvanMvY3RjdC1wbHVnaW4tcmVjYXB0Y2hhLXYyL3JlY2FwdGNoYS5qcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Fzc2V0cy9qcy9jdGN0LXBsdWdpbi1yZWNhcHRjaGEtdjIvcmVjYXB0Y2hhLmpzPzlhNDQiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFbmFibGUgc3VibWl0IGJ1dHRvbi5cbiAqXG4gKiBAYXV0aG9yIFJlYmVrYWggVmFuIEVwcHMgPHJlYmVrYWgudmFuZXBwc0B3ZWJkZXZzdHVkaW9zLmNvbT5cbiAqIEBzaW5jZSAgMS44LjNcbiAqXG4gKiBAcGFyYW0gIHtPYmplY3R9IHN1Ym1pdEJ0biBTdWJtaXQgRE9NIGVsZW1lbnQuXG4gKi9cbnZhciBjdGN0RW5hYmxlQnRuID0gZnVuY3Rpb24oIHN1Ym1pdEJ0biApIHtcbiAgICBqUXVlcnkoIHN1Ym1pdEJ0biApLmF0dHIoIFwiZGlzYWJsZWRcIiwgZmFsc2UgKTtcbn1cbndpbmRvdy5jdGN0RW5hYmxlQnRuID0gY3RjdEVuYWJsZUJ0bjtcblxuLyoqXG4gKiBEaXNhYmxlIHN1Ym1pdCBidXR0b24uXG4gKlxuICogQGF1dGhvciBSZWJla2FoIFZhbiBFcHBzIDxyZWJla2FoLnZhbmVwcHNAd2ViZGV2c3R1ZGlvcy5jb20+XG4gKiBAc2luY2UgIDEuOC4zXG4gKlxuICogQHBhcmFtICB7T2JqZWN0fSBzdWJtaXRCdG4gU3VibWl0IERPTSBlbGVtZW50LlxuICovXG52YXIgY3RjdERpc2FibGVCdG4gPSBmdW5jdGlvbiggc3VibWl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Y2hhID0gcmVuZGVyUmVDYXB0Y2hhO1xuIl0sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7QUFRQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBRUE7Ozs7Ozs7OztBQVFBO0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFWQTtBQVlBO0FBQ0E7QUFDQTtBQUFBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./assets/js/ctct-plugin-recaptcha-v2/recaptcha.js\n");

/***/ }),

/***/ 5:
/***/ 4:
/*!***********************************************************!*\
!*** multi ./assets/js/ctct-plugin-recaptcha-v2/index.js ***!
\***********************************************************/
Expand Down
30 changes: 24 additions & 6 deletions assets/js/ctct-plugin-recaptcha-v2/recaptcha.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
var ctctEnableBtn = function( index ) {
jQuery( jQuery( ".ctct-submit" )[ index ] ).attr( "disabled", false );
/**
* Enable submit button.
*
* @author Rebekah Van Epps <[email protected]>
* @since 1.8.3
*
* @param {Object} submitBtn Submit DOM element.
*/
var ctctEnableBtn = function( submitBtn ) {
jQuery( submitBtn ).attr( "disabled", false );
}
window.ctctEnableBtn = ctctEnableBtn;

var ctctDisableBtn = function( index ) {
jQuery( jQuery( ".ctct-submit" )[ index ] ).attr( "disabled", "disabled" );
/**
* Disable submit button.
*
* @author Rebekah Van Epps <[email protected]>
* @since 1.8.3
*
* @param {Object} submitBtn Submit DOM element.
*/
var ctctDisableBtn = function( submitBtn ) {
jQuery( submitBtn ).attr( "disabled", "disabled" );
}
window.ctctDisableBtn = ctctDisableBtn;

var renderReCaptcha = function() {
jQuery( '.g-recaptcha' ).each( function( index, el ) {
const submitBtn = jQuery( el ).siblings( '.ctct-form-field-submit' ).find( '.ctct-submit' );

grecaptcha.render( el, {
'sitekey': jQuery( el ).attr( 'data-sitekey' ),
'size': jQuery( el ).attr( 'data-size' ),
'tabindex': jQuery( el ).attr( 'data-tabindex' ),
'callback': function() {
window.ctctEnableBtn( index );
window.ctctEnableBtn( submitBtn );
},
'expired-callback': function() {
window.ctctDisableBtn( index );
window.ctctDisableBtn( submitBtn );
},
'isolated': true,
} );
Expand Down
8 changes: 8 additions & 0 deletions assets/sass/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,13 @@
border-color: $color-green;
color: darken( $color-success, 20% );
}

.ctct-dismiss-ajax-notice {
border-radius: 50%;
float: right;
line-height: 1;
padding: 0.85rem 1rem;
text-decoration: none;
}
}
}
6 changes: 3 additions & 3 deletions assets/sass/_inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
top: -9999px !important;
}

#ctct_usage {
.ctct_usage {
border: 0 none;
clip: rect( 0, 0, 0, 0 );
height: 1px;
Expand All @@ -88,7 +88,7 @@
width: 1px;
}

.no-recaptcha #ctct-submitted:disabled {
.no-recaptcha .ctct-submitted:disabled {
background-image: url('../images/oval.min.svg');
background-position: center;
background-repeat: no-repeat;
Expand All @@ -97,7 +97,7 @@
opacity: 0.3;
}

.has-recaptcha #ctct-submitted:disabled {
.has-recaptcha .ctct-submitted:disabled {
cursor: not-allowed;
}
}
4 changes: 2 additions & 2 deletions constant-contact-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Constant Contact Forms for WordPress
* Plugin URI: https://www.constantcontact.com
* Description: Be a better marketer. All it takes is Constant Contact email marketing.
* Version: 1.8.6
* Version: 1.8.7
* Author: Constant Contact
* Author URI: https://www.constantcontact.com/index?pn=miwordpress
* License: GPLv3
Expand Down Expand Up @@ -72,7 +72,7 @@ class Constant_Contact {
* @since 1.0.0
* @var string
*/
const VERSION = '1.8.6';
const VERSION = '1.8.7';

/**
* URL of plugin directory.
Expand Down
5 changes: 5 additions & 0 deletions includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,11 @@ public function add_contact( $new_contact = [], $form_id = 0 ) {
try {
$response = $this->cc()->contactService->getContacts( $api_token, [ 'email' => $email ] );

// Remove ctct-instance if present to avoid errors.
if ( array_key_exists( 'ctct-instance', $new_contact ) ) {
unset( $new_contact['ctct-instance'] );
}

if ( isset( $response->results ) && ! empty( $response->results ) ) {
constant_contact_maybe_log_it( 'API', 'Contact set to be updated', [ 'form' => get_the_title( $form_id ) ] );
$return_contact = $this->update_contact( $response, $api_token, $list, $new_contact, $form_id );
Expand Down
Loading

0 comments on commit 41d8ccb

Please sign in to comment.