Skip to content

Commit 41d8ccb

Browse files
authored
Merge pull request #502 from WebDevStudios/sprint/20.06-2
Release sprint/20.06-2 to master
2 parents 136f9f4 + 573ab62 commit 41d8ccb

15 files changed

+296
-210
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
= 1.8.7 =
2+
* Improved: Implemented recommendations for improved accessibility.
3+
* Improved: Avoid duplicate ID attributes when more than one form is present on a page.
4+
* Fixed: Submit button targeting for recaptcha v2.
5+
16
= 1.8.6 =
27
* Fixed: Removed invalid property being sent to the API, causing rejected requests.
38
* Fixed: Failure to log API errors for support purposes.

assets/css/style.css

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/style.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/ctct-plugin-frontend.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/ctct-plugin-frontend/util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
$( document ).ready( () => {
1010

11-
$( '#ctct-submitted' ).on( 'click', () => {
11+
$( '.ctct-submitted' ).on( 'click', () => {
1212
setTimeout( () => {
1313
disableSendButton();
1414
setTimeout( enableSendButton, 3000 );
@@ -25,7 +25,7 @@
2525
* @return {mixed} jQuery if attribute is set, undefined if not.
2626
*/
2727
function disableSendButton() {
28-
return $( '#ctct-submitted' ).attr( 'disabled', 'disabled' );
28+
return $( '.ctct-submitted' ).attr( 'disabled', 'disabled' );
2929
}
3030

3131
/**
@@ -37,7 +37,7 @@
3737
* @return {mixed} jQuery if attribute is set, undefined if not.
3838
*/
3939
function enableSendButton() {
40-
return $( '#ctct-submitted' ).attr( 'disabled', null );
40+
return $( '.ctct-submitted' ).attr( 'disabled', null );
4141
}
4242

4343
} ( window, jQuery ) );

assets/js/ctct-plugin-frontend/validation.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
var $form = $( form );
5858

59-
app.$c.$forms[ i ].$honeypot = $form.find( '#ctct_usage_field' );
59+
app.$c.$forms[ i ].$honeypot = $form.find( '.ctct_usage_field' );
6060
app.$c.$forms[ i ].$submitButton = $form.find( 'input[type=submit]' );
6161
app.$c.$forms[ i ].$recaptcha = $form.find( '.g-recaptcha' );
6262
} );
@@ -146,15 +146,26 @@
146146
* @param {string} message The message content.
147147
* @param {string} classes Optional. HTML classes to add to the message wrapper.
148148
*/
149-
app.showMessage = ( $form, message, classes = '' ) => {
149+
app.showMessage = ( $form, message, classes = '', role = 'log' ) => {
150+
151+
const $wrapper = $form.parents( '.ctct-form-wrapper' );
152+
153+
$wrapper.find( 'p.ctct-message' ).remove();
150154

151155
var $p = $( '<p />', {
152156
'class': 'ctct-message ' + classes,
153-
'text': message
154-
} );
155-
156-
$p.insertBefore( $form ).fadeIn( 200 ).delay( 5000 ).slideUp( 200, () => {
157-
$p.remove();
157+
'text': message,
158+
'role': role
159+
} ).prepend( $( '<button />', {
160+
'class': 'button button-secondary ctct-dismiss ctct-dismiss-ajax-notice',
161+
'html': '&#10005;',
162+
'aria-label': 'Dismiss Notification'
163+
} ) );
164+
165+
$p.insertBefore( $form ).fadeIn( 200 );
166+
167+
$wrapper.find( '.ctct-dismiss-ajax-notice' ).on( 'click', function() {
168+
$( this ).parents( '.ctct-message' ).remove();
158169
} );
159170
};
160171

@@ -168,7 +179,7 @@
168179
*/
169180
app.submitForm = ( $form ) => {
170181

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

173184
var ajaxData = {
174185
'action': 'ctct_process_form',
@@ -177,7 +188,7 @@
177188

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

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

182193
if ( 'undefined' === typeof( response.status ) ) {
183194
return false;
@@ -190,14 +201,14 @@
190201
app.setAllInputsValid();
191202
response.errors.forEach( app.processError );
192203
} else {
193-
app.showMessage( $form, response.message, 'ctct-error' );
204+
app.showMessage( $form, response.message, 'ctct-error', 'alert' );
194205
}
195206

196207
return false;
197208
}
198209

199210
// If we're here, the submission was a success; show message and reset form fields.
200-
app.showMessage( $form, response.message, 'ctct-success' );
211+
app.showMessage( $form, response.message, 'ctct-success', 'status' );
201212
$form[0].reset();
202213
} );
203214
};

assets/js/ctct-plugin-recaptcha-v2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
/******/
8282
/******/
8383
/******/ // Load entry module and return exports
84-
/******/ return __webpack_require__(__webpack_require__.s = 5);
84+
/******/ return __webpack_require__(__webpack_require__.s = 4);
8585
/******/ })
8686
/************************************************************************/
8787
/******/ ({
@@ -105,11 +105,11 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _rec
105105
/*! no static exports found */
106106
/***/ (function(module, exports) {
107107

108-
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9hc3NldHMvanMvY3RjdC1wbHVnaW4tcmVjYXB0Y2hhLXYyL3JlY2FwdGNoYS5qcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Fzc2V0cy9qcy9jdGN0LXBsdWdpbi1yZWNhcHRjaGEtdjIvcmVjYXB0Y2hhLmpzPzlhNDQiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIGN0Y3RFbmFibGVCdG4gPSBmdW5jdGlvbiggaW5kZXggKSB7XG4gICAgalF1ZXJ5KCBqUXVlcnkoIFwiLmN0Y3Qtc3VibWl0XCIgKVsgaW5kZXggXSApLmF0dHIoIFwiZGlzYWJsZWRcIiwgZmFsc2UgKTtcbn1cbndpbmRvdy5jdGN0RW5hYmxlQnRuID0gY3RjdEVuYWJsZUJ0bjtcblxudmFyIGN0Y3REaXNhYmxlQnRuID0gZnVuY3Rpb24oIGluZGV4ICkge1xuICAgIGpRdWVyeSggalF1ZXJ5KCBcIi5jdGN0LXN1Ym1pdFwiIClbIGluZGV4IF0gKS5hdHRyKCBcImRpc2FibGVkXCIsIFwiZGlzYWJsZWRcIiApO1xufVxud2luZG93LmN0Y3REaXNhYmxlQnRuID0gY3RjdERpc2FibGVCdG47XG5cbnZhciByZW5kZXJSZUNhcHRjaGEgPSBmdW5jdGlvbigpIHtcbiAgICBqUXVlcnkoICcuZy1yZWNhcHRjaGEnICkuZWFjaCggZnVuY3Rpb24oIGluZGV4LCBlbCApIHtcbiAgICAgICAgZ3JlY2FwdGNoYS5yZW5kZXIoIGVsLCB7XG4gICAgICAgICAgICAnc2l0ZWtleSc6IGpRdWVyeSggZWwgKS5hdHRyKCAnZGF0YS1zaXRla2V5JyApLFxuICAgICAgICAgICAgJ3NpemUnOiBqUXVlcnkoIGVsICkuYXR0ciggJ2RhdGEtc2l6ZScgKSxcbiAgICAgICAgICAgICd0YWJpbmRleCc6IGpRdWVyeSggZWwgKS5hdHRyKCAnZGF0YS10YWJpbmRleCcgKSxcbiAgICAgICAgICAgICdjYWxsYmFjayc6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHdpbmRvdy5jdGN0RW5hYmxlQnRuKCBpbmRleCApO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICdleHBpcmVkLWNhbGxiYWNrJzogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgd2luZG93LmN0Y3REaXNhYmxlQnRuKCBpbmRleCApO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICdpc29sYXRlZCc6IHRydWUsXG4gICAgICAgIH0gKTtcbiAgICB9ICk7XG59O1xud2luZG93LnJlbmRlclJlQ2FwdGNoYSA9IHJlbmRlclJlQ2FwdGNoYTtcbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFWQTtBQVlBO0FBQ0E7QUFDQTtBQUFBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./assets/js/ctct-plugin-recaptcha-v2/recaptcha.js\n");
108+
eval("/**\n * Enable submit button.\n *\n * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>\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 <rebekah.vanepps@webdevstudios.com>\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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9hc3NldHMvanMvY3RjdC1wbHVnaW4tcmVjYXB0Y2hhLXYyL3JlY2FwdGNoYS5qcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2Fzc2V0cy9qcy9jdGN0LXBsdWdpbi1yZWNhcHRjaGEtdjIvcmVjYXB0Y2hhLmpzPzlhNDQiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFbmFibGUgc3VibWl0IGJ1dHRvbi5cbiAqXG4gKiBAYXV0aG9yIFJlYmVrYWggVmFuIEVwcHMgPHJlYmVrYWgudmFuZXBwc0B3ZWJkZXZzdHVkaW9zLmNvbT5cbiAqIEBzaW5jZSAgMS44LjNcbiAqXG4gKiBAcGFyYW0gIHtPYmplY3R9IHN1Ym1pdEJ0biBTdWJtaXQgRE9NIGVsZW1lbnQuXG4gKi9cbnZhciBjdGN0RW5hYmxlQnRuID0gZnVuY3Rpb24oIHN1Ym1pdEJ0biApIHtcbiAgICBqUXVlcnkoIHN1Ym1pdEJ0biApLmF0dHIoIFwiZGlzYWJsZWR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sYmFjayc6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHdpbmRvdy5jdGN0RW5hYmxlQnRuKCBzdWJtaXRCdG4gKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAnZXhwaXJlZC1jYWxsYmFjayc6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHdpbmRvdy5jdGN0RGlzYWJsZUJ0biggc3VibWl0QnRuICk7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgJ2lzb2xhdGVkJzogdHJ1ZSxcbiAgICAgICAgfSApO1xuICAgIH0gKTtcbn07XG53aW5kb3cucmVuZGVyUmVDYXB0Y2hhID0gcmVuZGVyUmVDYXB0Y2hhO1xuIl0sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7QUFRQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBRUE7Ozs7Ozs7OztBQVFBO0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFWQTtBQVlBO0FBQ0E7QUFDQTtBQUFBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./assets/js/ctct-plugin-recaptcha-v2/recaptcha.js\n");
109109

110110
/***/ }),
111111

112-
/***/ 5:
112+
/***/ 4:
113113
/*!***********************************************************!*\
114114
!*** multi ./assets/js/ctct-plugin-recaptcha-v2/index.js ***!
115115
\***********************************************************/

assets/js/ctct-plugin-recaptcha-v2/recaptcha.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1-
var ctctEnableBtn = function( index ) {
2-
jQuery( jQuery( ".ctct-submit" )[ index ] ).attr( "disabled", false );
1+
/**
2+
* Enable submit button.
3+
*
4+
* @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
5+
* @since 1.8.3
6+
*
7+
* @param {Object} submitBtn Submit DOM element.
8+
*/
9+
var ctctEnableBtn = function( submitBtn ) {
10+
jQuery( submitBtn ).attr( "disabled", false );
311
}
412
window.ctctEnableBtn = ctctEnableBtn;
513

6-
var ctctDisableBtn = function( index ) {
7-
jQuery( jQuery( ".ctct-submit" )[ index ] ).attr( "disabled", "disabled" );
14+
/**
15+
* Disable submit button.
16+
*
17+
* @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
18+
* @since 1.8.3
19+
*
20+
* @param {Object} submitBtn Submit DOM element.
21+
*/
22+
var ctctDisableBtn = function( submitBtn ) {
23+
jQuery( submitBtn ).attr( "disabled", "disabled" );
824
}
925
window.ctctDisableBtn = ctctDisableBtn;
1026

1127
var renderReCaptcha = function() {
1228
jQuery( '.g-recaptcha' ).each( function( index, el ) {
29+
const submitBtn = jQuery( el ).siblings( '.ctct-form-field-submit' ).find( '.ctct-submit' );
30+
1331
grecaptcha.render( el, {
1432
'sitekey': jQuery( el ).attr( 'data-sitekey' ),
1533
'size': jQuery( el ).attr( 'data-size' ),
1634
'tabindex': jQuery( el ).attr( 'data-tabindex' ),
1735
'callback': function() {
18-
window.ctctEnableBtn( index );
36+
window.ctctEnableBtn( submitBtn );
1937
},
2038
'expired-callback': function() {
21-
window.ctctDisableBtn( index );
39+
window.ctctDisableBtn( submitBtn );
2240
},
2341
'isolated': true,
2442
} );

assets/sass/_global.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,13 @@
2323
border-color: $color-green;
2424
color: darken( $color-success, 20% );
2525
}
26+
27+
.ctct-dismiss-ajax-notice {
28+
border-radius: 50%;
29+
float: right;
30+
line-height: 1;
31+
padding: 0.85rem 1rem;
32+
text-decoration: none;
33+
}
2634
}
2735
}

assets/sass/_inputs.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
top: -9999px !important;
7878
}
7979

80-
#ctct_usage {
80+
.ctct_usage {
8181
border: 0 none;
8282
clip: rect( 0, 0, 0, 0 );
8383
height: 1px;
@@ -88,7 +88,7 @@
8888
width: 1px;
8989
}
9090

91-
.no-recaptcha #ctct-submitted:disabled {
91+
.no-recaptcha .ctct-submitted:disabled {
9292
background-image: url('../images/oval.min.svg');
9393
background-position: center;
9494
background-repeat: no-repeat;
@@ -97,7 +97,7 @@
9797
opacity: 0.3;
9898
}
9999

100-
.has-recaptcha #ctct-submitted:disabled {
100+
.has-recaptcha .ctct-submitted:disabled {
101101
cursor: not-allowed;
102102
}
103103
}

constant-contact-forms.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin Name: Constant Contact Forms for WordPress
1313
* Plugin URI: https://www.constantcontact.com
1414
* Description: Be a better marketer. All it takes is Constant Contact email marketing.
15-
* Version: 1.8.6
15+
* Version: 1.8.7
1616
* Author: Constant Contact
1717
* Author URI: https://www.constantcontact.com/index?pn=miwordpress
1818
* License: GPLv3
@@ -72,7 +72,7 @@ class Constant_Contact {
7272
* @since 1.0.0
7373
* @var string
7474
*/
75-
const VERSION = '1.8.6';
75+
const VERSION = '1.8.7';
7676

7777
/**
7878
* URL of plugin directory.

includes/class-api.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ public function add_contact( $new_contact = [], $form_id = 0 ) {
509509
try {
510510
$response = $this->cc()->contactService->getContacts( $api_token, [ 'email' => $email ] );
511511

512+
// Remove ctct-instance if present to avoid errors.
513+
if ( array_key_exists( 'ctct-instance', $new_contact ) ) {
514+
unset( $new_contact['ctct-instance'] );
515+
}
516+
512517
if ( isset( $response->results ) && ! empty( $response->results ) ) {
513518
constant_contact_maybe_log_it( 'API', 'Contact set to be updated', [ 'form' => get_the_title( $form_id ) ] );
514519
$return_contact = $this->update_contact( $response, $api_token, $list, $new_contact, $form_id );

0 commit comments

Comments
 (0)