Paid Memberships Pro - Version 1.8.5.1

Version Description

  • ENHANCEMENT: Added the pmpro_get_addons_timeout and pmpro_license_check_key_timeout filters to change the default timeout during addon and license key checks.
  • BUG: Fixed error handling during addon and license key checks.
Download this release

Release Info

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

Code changes from version 1.8.5 to 1.8.5.1

adminpages/membershiplevels.php CHANGED
@@ -328,6 +328,7 @@
328
  <?php
329
  }
330
  ?>
 
331
  </div>
332
  </td>
333
  </tr>
@@ -679,4 +680,4 @@
679
 
680
  <?php
681
  require_once(dirname(__FILE__) . "/admin_footer.php");
682
- ?>
328
  <?php
329
  }
330
  ?>
331
+ <p>[ ] Include this message in the Membership Confirmation Email</p>
332
  </div>
333
  </td>
334
  </tr>
680
 
681
  <?php
682
  require_once(dirname(__FILE__) . "/admin_footer.php");
683
+ ?>
classes/gateways/class.pmprogateway_paypalexpress.php CHANGED
@@ -801,9 +801,7 @@
801
  {
802
  //get the subscription status
803
  $status = $order->getGatewaySubscriptionStatus();
804
-
805
- d($status);
806
-
807
  if(!empty($status) && !empty($status['NEXTBILLINGDATE']))
808
  {
809
  //found the next billing date at PayPal, going to use that
801
  {
802
  //get the subscription status
803
  $status = $order->getGatewaySubscriptionStatus();
804
+
 
 
805
  if(!empty($status) && !empty($status['NEXTBILLINGDATE']))
806
  {
807
  //found the next billing date at PayPal, going to use that
includes/addons.php CHANGED
@@ -13,6 +13,7 @@ function pmpro_setupAddonUpdateInfo()
13
  add_filter('plugins_api', 'pmpro_plugins_api', 10, 3);
14
  add_filter('pre_set_site_transient_update_plugins', 'pmpro_update_plugins_filter');
15
  add_filter('http_request_args', 'pmpro_http_request_args_for_addons', 10, 2);
 
16
  }
17
  add_action('init', 'pmpro_setupAddonUpdateInfo');
18
 
@@ -30,27 +31,35 @@ function pmpro_getAddons()
30
  //if no addons locally, we need to hit the server
31
  if(empty($addons) || !empty($_REQUEST['force-check']) || current_time('timestamp') > $addons_timestamp+86400)
32
  {
33
- //get em
34
- $remote_addons = wp_remote_get(PMPRO_LICENSE_SERVER . "/addons/");
35
-
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  //test response
37
- if(empty($remote_addons['response']) || $remote_addons['response']['code'] != '200')
38
- {
39
- //error
40
- pmpro_setMessage("Could not connect to the PMPro License Server to update addon information. Try again later.", "error");
41
-
42
- //make sure we have at least an array to pass back
43
- if(empty($addons))
44
- $addons = array();
45
- }
46
- else
47
- {
48
- //update addons in cache
49
- $addons = json_decode(wp_remote_retrieve_body($remote_addons), true);
50
- delete_option('pmpro_addons');
51
- add_option("pmpro_addons", $addons, NULL, 'no');
52
- }
53
-
54
  //save timestamp of last update
55
  delete_option('pmpro_addons_timestamp');
56
  add_option("pmpro_addons_timestamp", current_time('timestamp'), NULL, 'no');
@@ -174,12 +183,6 @@ function pmpro_plugins_api($api, $action = '', $args = null)
174
 
175
  // Create a new stdClass object and populate it with our plugin information.
176
  $api = pmpro_getPluginAPIObjectFromAddon($addon);
177
-
178
- //get license key if one is available
179
- $key = get_option("pmpro_license_key", "");
180
- if(!empty($key) && !empty($api->download_link))
181
- $api->download_link = add_query_arg("key", $key, $api->download_link);
182
-
183
  return $api;
184
  }
185
 
@@ -208,6 +211,31 @@ function pmpro_getPluginAPIObjectFromAddon($addon)
208
  $api->sections['changelog'] = isset( $addon['Changelog'] ) ? $addon['Changelog'] : '';
209
  $api->download_link = isset( $addon['Download'] ) ? $addon['Download'] : '';
210
  $api->package = isset( $addon['Download'] ) ? $addon['Download'] : '';
211
-
 
 
 
 
 
 
 
212
  return $api;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
13
  add_filter('plugins_api', 'pmpro_plugins_api', 10, 3);
14
  add_filter('pre_set_site_transient_update_plugins', 'pmpro_update_plugins_filter');
15
  add_filter('http_request_args', 'pmpro_http_request_args_for_addons', 10, 2);
16
+ add_action('update_option_pmpro_license_key', 'pmpro_reset_update_plugins_cache', 10, 3);
17
  }
18
  add_action('init', 'pmpro_setupAddonUpdateInfo');
19
 
31
  //if no addons locally, we need to hit the server
32
  if(empty($addons) || !empty($_REQUEST['force-check']) || current_time('timestamp') > $addons_timestamp+86400)
33
  {
34
+ /**
35
+ * Filter to change the timeout for this wp_remote_get() request.
36
+ *
37
+ * @since 1.8.5.1
38
+ *
39
+ * @param int $timeout The number of seconds before the request times out
40
+ */
41
+ $timeout = apply_filters("pmpro_get_addons_timeout", 5);
42
+
43
+ //get em
44
+ $remote_addons = wp_remote_get(PMPRO_LICENSE_SERVER . "/addons/", $timeout);
45
+
46
+ //make sure we have at least an array to pass back
47
+ if(empty($addons))
48
+ $addons = array();
49
+
50
  //test response
51
+ if(is_wp_error($remote_addons)) {
52
+ //error
53
+ pmpro_setMessage("Could not connect to the PMPro License Server to update addon information. Try again later.", "error");
54
+ }
55
+ elseif(!empty($r) && $r['response']['code'] == 200)
56
+ {
57
+ //update addons in cache
58
+ $addons = json_decode(wp_remote_retrieve_body($remote_addons), true);
59
+ delete_option('pmpro_addons');
60
+ add_option("pmpro_addons", $addons, NULL, 'no');
61
+ }
62
+
 
 
 
 
 
63
  //save timestamp of last update
64
  delete_option('pmpro_addons_timestamp');
65
  add_option("pmpro_addons_timestamp", current_time('timestamp'), NULL, 'no');
183
 
184
  // Create a new stdClass object and populate it with our plugin information.
185
  $api = pmpro_getPluginAPIObjectFromAddon($addon);
 
 
 
 
 
 
186
  return $api;
187
  }
188
 
211
  $api->sections['changelog'] = isset( $addon['Changelog'] ) ? $addon['Changelog'] : '';
212
  $api->download_link = isset( $addon['Download'] ) ? $addon['Download'] : '';
213
  $api->package = isset( $addon['Download'] ) ? $addon['Download'] : '';
214
+
215
+ //get license key if one is available
216
+ $key = get_option("pmpro_license_key", "");
217
+ if(!empty($key) && !empty($api->download_link))
218
+ $api->download_link = add_query_arg("key", $key, $api->download_link);
219
+ if(!empty($key) && !empty($api->package))
220
+ $api->package = add_query_arg("key", $key, $api->package);
221
+
222
  return $api;
223
+ }
224
+
225
+ /**
226
+ * Force update of plugin update data when the PMPro License key is updated
227
+ *
228
+ * @since 2.0
229
+ *
230
+ * @param array $args Array of request args.
231
+ * @param string $url The URL to be pinged.
232
+ * @return array $args Amended array of request args.
233
+ */
234
+ function pmpro_reset_update_plugins_cache($option, $old_value, $value)
235
+ {
236
+ if($option == "pmpro_license_key")
237
+ {
238
+ delete_option('pmpro_addons_timestamp');
239
+ delete_site_transient('update_themes');
240
+ }
241
  }
includes/license.php CHANGED
@@ -72,7 +72,7 @@ function pmpro_license_settings_page() {
72
  //get saved license
73
  $key = get_option("pmpro_license_key", "");
74
  $pmpro_license_check = get_option("pmpro_license_check", array("license"=>false, "enddate"=>0));
75
-
76
  //html for license settings page
77
  if(defined('PMPRO_DIR'))
78
  require_once(PMPRO_DIR . "/adminpages/admin_header.php");
@@ -189,9 +189,24 @@ function pmpro_license_check_key($key = NULL) {
189
  {
190
  //check license server
191
  $url = add_query_arg(array('license'=>$key, 'domain'=>site_url()), PMPRO_LICENSE_SERVER);
192
- $r = wp_remote_get($url);
193
-
194
- if(!empty($r) && $r['response']['code'] == 200)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  {
196
  $r = json_decode($r['body']);
197
 
@@ -215,13 +230,13 @@ function pmpro_license_check_key($key = NULL) {
215
 
216
  delete_option('pmpro_license_check');
217
  add_option('pmpro_license_check', array('license'=>false, 'enddate'=>0), NULL, 'no');
218
-
219
- return false;
220
  }
221
  }
222
  }
223
- else
224
- return false;
 
225
  }
226
  add_action('pmpro_license_check_key', 'pmpro_license_check_key');
227
 
@@ -255,7 +270,7 @@ function pmpro_license_nag() {
255
  //blocked by constant?
256
  if(defined('PMPRO_LICENSE_NAG') && !PMPRO_LICENSE_NAG)
257
  return;
258
-
259
  //valid license?
260
  if(pmpro_license_isValid())
261
  return;
72
  //get saved license
73
  $key = get_option("pmpro_license_key", "");
74
  $pmpro_license_check = get_option("pmpro_license_check", array("license"=>false, "enddate"=>0));
75
+
76
  //html for license settings page
77
  if(defined('PMPRO_DIR'))
78
  require_once(PMPRO_DIR . "/adminpages/admin_header.php");
189
  {
190
  //check license server
191
  $url = add_query_arg(array('license'=>$key, 'domain'=>site_url()), PMPRO_LICENSE_SERVER);
192
+
193
+ /**
194
+ * Filter to change the timeout for this wp_remote_get() request.
195
+ *
196
+ * @since 1.8.5.1
197
+ *
198
+ * @param int $timeout The number of seconds before the request times out
199
+ */
200
+ $timeout = apply_filters("pmpro_license_check_key_timeout", 5);
201
+
202
+ $r = wp_remote_get($url, array("timeout" => $timeout));
203
+
204
+ //test response
205
+ if(is_wp_error($r)) {
206
+ //error
207
+ pmpro_setMessage("Could not connect to the PMPro License Server to check key Try again later.", "error");
208
+ }
209
+ elseif(!empty($r) && $r['response']['code'] == 200)
210
  {
211
  $r = json_decode($r['body']);
212
 
230
 
231
  delete_option('pmpro_license_check');
232
  add_option('pmpro_license_check', array('license'=>false, 'enddate'=>0), NULL, 'no');
233
+
 
234
  }
235
  }
236
  }
237
+
238
+ //no key or there was an error
239
+ return false;
240
  }
241
  add_action('pmpro_license_check_key', 'pmpro_license_check_key');
242
 
270
  //blocked by constant?
271
  if(defined('PMPRO_LICENSE_NAG') && !PMPRO_LICENSE_NAG)
272
  return;
273
+
274
  //valid license?
275
  if(pmpro_license_isValid())
276
  return;
paid-memberships-pro.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Paid Memberships Pro
4
  Plugin URI: http://www.paidmembershipspro.com
5
  Description: Plugin to Handle Memberships
6
- Version: 1.8.5
7
  Author: Stranger Studios
8
  Author URI: http://www.strangerstudios.com
9
  */
@@ -13,7 +13,7 @@ Author URI: http://www.strangerstudios.com
13
  */
14
 
15
  //version constant
16
- define("PMPRO_VERSION", "1.8.5");
17
 
18
  //if the session has been started yet, start it (ignore if running from command line)
19
  if(defined('STDIN') )
3
  Plugin Name: Paid Memberships Pro
4
  Plugin URI: http://www.paidmembershipspro.com
5
  Description: Plugin to Handle Memberships
6
+ Version: 1.8.5.1
7
  Author: Stranger Studios
8
  Author URI: http://www.strangerstudios.com
9
  */
13
  */
14
 
15
  //version constant
16
+ define("PMPRO_VERSION", "1.8.5.1");
17
 
18
  //if the session has been started yet, start it (ignore if running from command line)
19
  if(defined('STDIN') )
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: strangerstudios
3
  Tags: memberships, membership, authorize.net, ecommerce, paypal, stripe, braintree, restrict access, restrict content, directory site, payflow
4
  Requires at least: 3.5
5
  Tested up to: 4.2.4
6
- Stable tag: 1.8.5
7
 
8
  The easiest way to GET PAID with your WordPress site. Flexible content control by Membership Level, Reports, Affiliates and Discounts
9
 
@@ -101,7 +101,11 @@ Not sure? You can find out by doing a bit a research.
101
  3. Members are WordPress Users. PMPro provides a unique interface to view, filter and search Members or export your Members List.
102
  4. Offer Membership Discounts with specific price rules (restricted by level, unique pricing for each level, # of uses, expiration date.)
103
 
104
- == Changelog ==
 
 
 
 
105
  = 1.8.5 =
106
  * BUG: Fixed bug where the subscription_transaction_id was not showing up in the orders CSV export.
107
  * BUG: Fixed bug where gateway subscriptions were not being cancelled when the "cancel at gateway" option was checked when changing a user's level on the edit user page.
3
  Tags: memberships, membership, authorize.net, ecommerce, paypal, stripe, braintree, restrict access, restrict content, directory site, payflow
4
  Requires at least: 3.5
5
  Tested up to: 4.2.4
6
+ Stable tag: 1.8.5.1
7
 
8
  The easiest way to GET PAID with your WordPress site. Flexible content control by Membership Level, Reports, Affiliates and Discounts
9
 
101
  3. Members are WordPress Users. PMPro provides a unique interface to view, filter and search Members or export your Members List.
102
  4. Offer Membership Discounts with specific price rules (restricted by level, unique pricing for each level, # of uses, expiration date.)
103
 
104
+ == Changelog ==
105
+ = 1.8.5.1 =
106
+ * ENHANCEMENT: Added the pmpro_get_addons_timeout and pmpro_license_check_key_timeout filters to change the default timeout during addon and license key checks.
107
+ * BUG: Fixed error handling during addon and license key checks.
108
+
109
  = 1.8.5 =
110
  * BUG: Fixed bug where the subscription_transaction_id was not showing up in the orders CSV export.
111
  * BUG: Fixed bug where gateway subscriptions were not being cancelled when the "cancel at gateway" option was checked when changing a user's level on the edit user page.