Paid Memberships Pro - Version 2.5.2

Version Description

  • 2020-10-23 =
  • BUG FIX: Fixed issue where the RECAPTCHA library wasn't being loaded early enough to validate at checkout.
  • BUG FIX: Fixed issue where code in the Stripe class was unsetting some required fields, even if Stripe was not being used at checkout.
Download this release

Release Info

Developer strangerstudios
Plugin Icon 128x128 Paid Memberships Pro
Version 2.5.2
Comparing to
See all releases

Code changes from version 2.5.1 to 2.5.2

CHANGELOG.txt CHANGED
@@ -1,4 +1,8 @@
1
  == Changelog ==
 
 
 
 
2
  = 2.5.1 - 2020-10-16 =
3
  * SECURITY: Fixed XSS vulnerability on the Members List page of the dashboard. (Thanks, Ron Masas from Checkmarx.com)
4
  * ENHANCEMENT: Add Ukrainian Hryvnia currency. (Thanks, Mirco Babini)
1
  == Changelog ==
2
+ = 2.5.2 - 2020-10-23 =
3
+ * BUG FIX: Fixed issue where the RECAPTCHA library wasn't being loaded early enough to validate at checkout.
4
+ * BUG FIX: Fixed issue where code in the Stripe class was unsetting some required fields, even if Stripe was not being used at checkout.
5
+
6
  = 2.5.1 - 2020-10-16 =
7
  * SECURITY: Fixed XSS vulnerability on the Members List page of the dashboard. (Thanks, Ron Masas from Checkmarx.com)
8
  * ENHANCEMENT: Add Ukrainian Hryvnia currency. (Thanks, Mirco Babini)
classes/gateways/class.pmprogateway_stripe.php CHANGED
@@ -142,7 +142,12 @@ class PMProGateway_stripe extends PMProGateway {
142
  //old global RE showing billing address or not
143
  global $pmpro_stripe_lite;
144
  $pmpro_stripe_lite = apply_filters( "pmpro_stripe_lite", ! pmpro_getOption( "stripe_billingaddress" ) ); //default is oposite of the stripe_billingaddress setting
145
- add_filter( 'pmpro_required_billing_fields', array( 'PMProGateway_stripe', 'pmpro_required_billing_fields' ) );
 
 
 
 
 
146
 
147
  //updates cron
148
  add_action( 'pmpro_cron_stripe_subscription_updates', array(
142
  //old global RE showing billing address or not
143
  global $pmpro_stripe_lite;
144
  $pmpro_stripe_lite = apply_filters( "pmpro_stripe_lite", ! pmpro_getOption( "stripe_billingaddress" ) ); //default is oposite of the stripe_billingaddress setting
145
+
146
+ $gateway = pmpro_getGateway();
147
+ if($gateway == "stripe")
148
+ {
149
+ add_filter( 'pmpro_required_billing_fields', array( 'PMProGateway_stripe', 'pmpro_required_billing_fields' ) );
150
+ }
151
 
152
  //updates cron
153
  add_action( 'pmpro_cron_stripe_subscription_updates', array(
includes/init.php CHANGED
@@ -98,7 +98,7 @@ function pmpro_wp()
98
  }
99
  }
100
  }
101
- add_action("wp", "pmpro_wp", 1);
102
 
103
  /*
104
  Add PMPro page names to the BODY class.
98
  }
99
  }
100
  }
101
+ add_action("wp", "pmpro_wp", 2);
102
 
103
  /*
104
  Add PMPro page names to the BODY class.
includes/recaptcha.php CHANGED
@@ -28,91 +28,93 @@ function pmpro_init_recaptcha() {
28
 
29
  require_once(PMPRO_DIR . '/includes/lib/recaptchalib.php' );
30
 
31
- function pmpro_recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) {
 
32
 
33
- // Figure out language.
34
- $locale = get_locale();
35
- if(!empty($locale)) {
36
- $parts = explode("_", $locale);
37
- $lang = $parts[0];
38
- } else {
39
- $lang = "en";
40
- }
41
- $lang = apply_filters( 'pmpro_recaptcha_lang', $lang );
42
-
43
- // Check which version of ReCAPTCHA we are using.
44
- $recaptcha_version = pmpro_getOption( 'recaptcha_version' );
45
-
46
- if( $recaptcha_version == '3_invisible' ) { ?>
47
- <div class="g-recaptcha" data-sitekey="<?php echo $pubkey;?>" data-size="invisible" data-callback="onSubmit"></div>
48
- <script type="text/javascript">
49
- var pmpro_recaptcha_validated = false;
50
- var pmpro_recaptcha_onSubmit = function(token) {
51
- if ( pmpro_recaptcha_validated ) {
52
- jQuery('#pmpro_form').submit();
53
- return;
54
- } else {
55
- jQuery.ajax({
56
- url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
57
- type: 'GET',
58
- timeout: 30000,
59
- dataType: 'html',
60
- data: {
61
- 'action': 'pmpro_validate_recaptcha',
62
- 'g-recaptcha-response': token,
63
- },
64
- error: function(xml){
65
- alert('Error validating ReCAPTCHA.');
66
- },
67
- success: function(response){
68
- if ( response == '1' ) {
69
- pmpro_recaptcha_validated = true;
70
-
71
- //get a new token to be submitted with the form
72
- grecaptcha.execute();
73
- } else {
74
- pmpro_recaptcha_validated = false;
75
-
76
- //warn user validation failed
77
- alert( 'ReCAPTCHA validation failed. Try again.' );
78
-
79
- //get a new token to be submitted with the form
80
- grecaptcha.execute();
 
81
  }
82
- }
83
- });
84
- }
85
- };
86
-
87
- var pmpro_recaptcha_onloadCallback = function() {
88
- // Render on main submit button.
89
- grecaptcha.render('pmpro_btn-submit', {
90
- 'sitekey' : '<?php echo $pubkey;?>',
91
- 'callback' : pmpro_recaptcha_onSubmit
92
- });
93
-
94
- // Update other submit buttons.
95
- var submit_buttons = jQuery('.pmpro_btn-submit-checkout');
96
- submit_buttons.each(function() {
97
- if(jQuery(this).attr('id') != 'pmpro_btn-submit') {
98
- jQuery(this).click(function(event) {
99
- event.preventDefault();
100
- grecaptcha.execute();
101
  });
102
- }
103
- });
104
- };
105
- </script>
106
- <script type="text/javascript"
107
- src="https://www.google.com/recaptcha/api.js?onload=pmpro_recaptcha_onloadCallback&hl=<?php echo $lang;?>&render=explicit" async defer>
108
- </script>
109
- <?php } else { ?>
110
- <div class="g-recaptcha" data-sitekey="<?php echo $pubkey;?>"></div>
111
- <script type="text/javascript"
112
- src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>">
113
- </script>
114
- <?php }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  //for templates using the old recaptcha_get_html
118
  if( ! function_exists( 'recaptcha_get_html' ) ) {
@@ -125,7 +127,7 @@ function pmpro_init_recaptcha() {
125
  $recaptcha_privatekey = pmpro_getOption( 'recaptcha_privatekey' );
126
  }
127
  }
128
- add_action( 'wp', 'pmpro_init_recaptcha', 5 );
129
 
130
  /**
131
  * AJAX Method to Validate a ReCAPTCHA Response Token
28
 
29
  require_once(PMPRO_DIR . '/includes/lib/recaptchalib.php' );
30
 
31
+ if ( ! function_exists( 'pmpro_recaptcha_get_html' ) ) {
32
+ function pmpro_recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) {
33
 
34
+ // Figure out language.
35
+ $locale = get_locale();
36
+ if(!empty($locale)) {
37
+ $parts = explode("_", $locale);
38
+ $lang = $parts[0];
39
+ } else {
40
+ $lang = "en";
41
+ }
42
+ $lang = apply_filters( 'pmpro_recaptcha_lang', $lang );
43
+
44
+ // Check which version of ReCAPTCHA we are using.
45
+ $recaptcha_version = pmpro_getOption( 'recaptcha_version' );
46
+
47
+ if( $recaptcha_version == '3_invisible' ) { ?>
48
+ <div class="g-recaptcha" data-sitekey="<?php echo $pubkey;?>" data-size="invisible" data-callback="onSubmit"></div>
49
+ <script type="text/javascript">
50
+ var pmpro_recaptcha_validated = false;
51
+ var pmpro_recaptcha_onSubmit = function(token) {
52
+ if ( pmpro_recaptcha_validated ) {
53
+ jQuery('#pmpro_form').submit();
54
+ return;
55
+ } else {
56
+ jQuery.ajax({
57
+ url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
58
+ type: 'GET',
59
+ timeout: 30000,
60
+ dataType: 'html',
61
+ data: {
62
+ 'action': 'pmpro_validate_recaptcha',
63
+ 'g-recaptcha-response': token,
64
+ },
65
+ error: function(xml){
66
+ alert('Error validating ReCAPTCHA.');
67
+ },
68
+ success: function(response){
69
+ if ( response == '1' ) {
70
+ pmpro_recaptcha_validated = true;
71
+
72
+ //get a new token to be submitted with the form
73
+ grecaptcha.execute();
74
+ } else {
75
+ pmpro_recaptcha_validated = false;
76
+
77
+ //warn user validation failed
78
+ alert( 'ReCAPTCHA validation failed. Try again.' );
79
+
80
+ //get a new token to be submitted with the form
81
+ grecaptcha.execute();
82
+ }
83
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  });
85
+ }
86
+ };
87
+
88
+ var pmpro_recaptcha_onloadCallback = function() {
89
+ // Render on main submit button.
90
+ grecaptcha.render('pmpro_btn-submit', {
91
+ 'sitekey' : '<?php echo $pubkey;?>',
92
+ 'callback' : pmpro_recaptcha_onSubmit
93
+ });
94
+
95
+ // Update other submit buttons.
96
+ var submit_buttons = jQuery('.pmpro_btn-submit-checkout');
97
+ submit_buttons.each(function() {
98
+ if(jQuery(this).attr('id') != 'pmpro_btn-submit') {
99
+ jQuery(this).click(function(event) {
100
+ event.preventDefault();
101
+ grecaptcha.execute();
102
+ });
103
+ }
104
+ });
105
+ };
106
+ </script>
107
+ <script type="text/javascript"
108
+ src="https://www.google.com/recaptcha/api.js?onload=pmpro_recaptcha_onloadCallback&hl=<?php echo $lang;?>&render=explicit" async defer>
109
+ </script>
110
+ <?php } else { ?>
111
+ <div class="g-recaptcha" data-sitekey="<?php echo $pubkey;?>"></div>
112
+ <script type="text/javascript"
113
+ src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang;?>">
114
+ </script>
115
+ <?php }
116
+ }
117
+ }
118
 
119
  //for templates using the old recaptcha_get_html
120
  if( ! function_exists( 'recaptcha_get_html' ) ) {
127
  $recaptcha_privatekey = pmpro_getOption( 'recaptcha_privatekey' );
128
  }
129
  }
130
+ add_action( 'wp', 'pmpro_init_recaptcha', 1 );
131
 
132
  /**
133
  * AJAX Method to Validate a ReCAPTCHA Response Token
paid-memberships-pro.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Paid Memberships Pro
4
  * Plugin URI: https://www.paidmembershipspro.com
5
  * Description: The most complete member management and membership subscriptions plugin for WordPress.
6
- * Version: 2.5.1
7
  * Author: Stranger Studios
8
  * Author URI: https://www.strangerstudios.com
9
  * Text Domain: paid-memberships-pro
@@ -16,7 +16,7 @@
16
  */
17
 
18
  // version constant
19
- define( 'PMPRO_VERSION', '2.5.1' );
20
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
21
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
22
 
3
  * Plugin Name: Paid Memberships Pro
4
  * Plugin URI: https://www.paidmembershipspro.com
5
  * Description: The most complete member management and membership subscriptions plugin for WordPress.
6
+ * Version: 2.5.2
7
  * Author: Stranger Studios
8
  * Author URI: https://www.strangerstudios.com
9
  * Text Domain: paid-memberships-pro
16
  */
17
 
18
  // version constant
19
+ define( 'PMPRO_VERSION', '2.5.2' );
20
  define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
21
  define( 'PMPRO_MIN_PHP_VERSION', '5.6' );
22
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: strangerstudios, kimannwall, andrewza, dlparker1005, paidmembershi
3
  Tags: memberships, members, subscriptions, ecommerce, user registration, member, membership, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
  Tested up to: 5.5.3
6
- Stable tag: 2.5.1
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
@@ -153,6 +153,10 @@ Not sure? You can find out by doing a bit a research.
153
  9. Membership Account page, display all sections or show specific sections using shortcode attributes.
154
 
155
  == Changelog ==
 
 
 
 
156
  = 2.5.1 - 2020-10-16 =
157
  * SECURITY: Fixed XSS vulnerability on the Members List page of the dashboard. (Thanks, Ron Masas from Checkmarx.com)
158
  * ENHANCEMENT: Add Ukrainian Hryvnia currency. (Thanks, Mirco Babini)
3
  Tags: memberships, members, subscriptions, ecommerce, user registration, member, membership, e-commerce, paypal, stripe, braintree, authorize.net, payflow, restrict access, restrict content, directory
4
  Requires at least: 4
5
  Tested up to: 5.5.3
6
+ Stable tag: 2.5.2
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
153
  9. Membership Account page, display all sections or show specific sections using shortcode attributes.
154
 
155
  == Changelog ==
156
+ = 2.5.2 - 2020-10-23 =
157
+ * BUG FIX: Fixed issue where the RECAPTCHA library wasn't being loaded early enough to validate at checkout.
158
+ * BUG FIX: Fixed issue where code in the Stripe class was unsetting some required fields, even if Stripe was not being used at checkout.
159
+
160
  = 2.5.1 - 2020-10-16 =
161
  * SECURITY: Fixed XSS vulnerability on the Members List page of the dashboard. (Thanks, Ron Masas from Checkmarx.com)
162
  * ENHANCEMENT: Add Ukrainian Hryvnia currency. (Thanks, Mirco Babini)