Skip to content

Commit d10087e

Browse files
authored
Merge pull request #1404 from laterpay/develop
Tag 2.9.5
2 parents 65390ff + c67d36a commit d10087e

16 files changed

Lines changed: 106 additions & 87 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "laterpay/laterpay-wordpress-plugin",
33
"description": "This is the official LaterPay plugin for selling digital content with WordPress",
44
"license": "MIT",
5-
"version": "2.9.4",
5+
"version": "2.9.5",
66
"config": {
77
"vendor-dir": "laterpay/vendor",
88
"secure-http": true

composer.lock

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

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var gulp = require('gulp'),
3939
// OPTIONS -------------------------------------------------------------------------------------------------------------
4040
var gulpKnownOptions = {
4141
string: 'version',
42-
default: { version: '2.9.4' }
42+
default: { version: '2.9.5' }
4343
};
4444
var gulpOptions = minimist(process.argv.slice(2), gulpKnownOptions);
4545
gulpOptions.svn = {};

laterpay/README.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ Yes!
9090
7. The plugin provides a variety of advanced settings to customize the LaterPay plugin and adjust it to your needs.
9191

9292
== Changelog ==
93+
= 2.9.5 ( May 28, 2020 ) =
94+
* Added proper validation for custom voucher codes.
95+
* Fixes minor issue with cache validation message.
96+
9397
= 2.9.4 ( April 16, 2020 ) =
9498
* Disable additional requests on home page if disabled by merchant.
9599
* Validate account status before `/access` check to avoid unnecessary request.
@@ -710,8 +714,8 @@ KNOWN BUGS:
710714

711715
== Upgrade notice ==
712716

713-
= 2.9.4 =
714-
Reduces unnecessary API calls to `/validatesignature` and `/access` endpoint.
717+
= 2.9.5 =
718+
Added proper validation for custom voucher codes.
715719

716720
== Arbitrary section ==
717721

laterpay/application/Helper/Voucher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public static function get_all_global_vouchers() {
327327
$vouchers = get_option( self::GLOBAL_VOUCHER_CODES_OPTION );
328328
if ( ! $vouchers || ! is_array( $vouchers ) ) {
329329
update_option( self::GLOBAL_VOUCHER_CODES_OPTION, '' );
330-
$vouchers = [];
330+
$vouchers = [ [] ]; // Ticket #1397.
331331
}
332332

333333
// format prices.

laterpay/asset_sources/js/laterpay-backend-pricing.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,12 @@
432432

433433
// generate voucher code
434434
$o.timepass.editor
435-
.on('mousedown', $o.generateVoucherCode, function() {
436-
generateVoucherCode($(this).parents($o.timepass.wrapper));
435+
.on('mousedown', $o.generateVoucherCode, function(e) {
436+
if ( $(this).is('[disabled=disabled]') ) {
437+
e.preventDefault();
438+
return false;
439+
}
440+
generateVoucherCode($(this).parents($o.timepass.wrapper));
437441
})
438442
.on('click', $o.generateVoucherCode, function(e) {
439443
e.preventDefault();
@@ -551,8 +555,12 @@
551555

552556
// Generate voucher code.
553557
$o.subscription.editor
554-
.on('mousedown', $o.generateVoucherCode, function() {
555-
generateVoucherCode($(this).parents($o.subscription.wrapper));
558+
.on('mousedown', $o.generateVoucherCode, function(e) {
559+
if ( $(this).is('[disabled=disabled]') ) {
560+
e.preventDefault();
561+
return false;
562+
}
563+
generateVoucherCode($(this).parents($o.subscription.wrapper));
556564
})
557565
.on('click', $o.generateVoucherCode, function(e) {
558566
e.preventDefault();
@@ -692,8 +700,7 @@
692700
validateVoucherCode = function( voucherInput, $wrapper, type ) {
693701
var voucherCode = voucherInput.val();
694702

695-
if (voucherCode.length === 6) {
696-
703+
if (voucherCode.length === 6 ) {
697704
var globalVouchers = $o.globalVouchers.data.vouchers;
698705
if ( typeof $o.globalVouchers.data.vouchers === 'string' ) {
699706
globalVouchers = JSON.parse($o.globalVouchers.data.vouchers);
@@ -751,7 +758,8 @@
751758
return;
752759
}
753760
$($o.subscription.actions.save).removeAttr('disabled');
754-
$($o.subscription.actions.save).attr('href', '#');
761+
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
762+
$($o.subscription.actions.save).attr('href', 'javascript:void(0);');
755763
} else if ( isGlobal ) {
756764
if (true === voucherExists) {
757765
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.voucherExists);
@@ -761,7 +769,8 @@
761769
return;
762770
}
763771
$o.saveGlobalDefaultPrice.removeAttr('disabled');
764-
$o.saveGlobalDefaultPrice.attr('href', '#');
772+
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
773+
$o.saveGlobalDefaultPrice.attr('href', 'javascript:void(0);');
765774
} else {
766775
if (true === voucherExists) {
767776
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.voucherExists);
@@ -771,14 +780,18 @@
771780
return;
772781
}
773782
$($o.timepass.actions.save).removeAttr('disabled');
774-
$($o.timepass.actions.save).attr('href', '#');
783+
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
784+
$($o.timepass.actions.save).attr('href', 'javascript:void(0);');
775785
}
776786

777787
voucherInput.parent().attr('data-code', voucherCode);
778788
voucherInput.parent().find('input[name="voucher_code[]"]').val(voucherCode);
779789
} else {
780790
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.codeTooShort);
781791
$wrapper.find('.lp_js_voucher_msg').css('display', 'block');
792+
// Disabled save button if there are less than 6 characters. #1397
793+
$wrapper.find('.button-primary').attr('disabled', 'disabled');
794+
$wrapper.find($o.generateVoucherCode).attr('disabled', 'disabled');
782795
return;
783796
}
784797

laterpay/languages/laterpay-de_CH-laterpay-block-editor-assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@
12941294
"Congratulations, you are now accepting payments through LaterPay!": [
12951295
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
12961296
],
1297-
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
1297+
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
12981298
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
12991299
],
13001300
"Hide message.": [

laterpay/languages/laterpay-de_CH_informal-laterpay-block-editor-assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@
12941294
"Congratulations, you are now accepting payments through LaterPay!": [
12951295
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
12961296
],
1297-
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
1297+
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
12981298
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
12991299
],
13001300
"Hide message.": [

laterpay/languages/laterpay-de_DE-laterpay-block-editor-assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@
12941294
"Congratulations, you are now accepting payments through LaterPay!": [
12951295
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
12961296
],
1297-
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
1297+
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
12981298
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
12991299
],
13001300
"Hide message.": [

laterpay/languages/laterpay-de_DE.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3142,7 +3142,7 @@ msgstr "Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!
31423142
#, php-format
31433143
msgid ""
31443144
"We recommend %sclearing your cache%s in order to ensure that the paywall is "
3145-
"visible everyone."
3145+
"visible to everyone."
31463146
msgstr ""
31473147
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die "
31483148
"Paywall für alle sichtbar ist."

0 commit comments

Comments
 (0)