Paid Memberships Pro - Version 2.3.4

Version Description

  • 2020-06-18 =
  • SECURITY: Better escaping of values on the billing and confirmation pages.
  • BUG FIX: Fixed issue where expiration dates could be set to 1 day in the past when editing a user in the dashboard if certain timezones were chosen in the General settings.
  • BUG FIX: Fixed issue where users were redirected back to the /login/ page if WordPress needed them to confirm their admin email address. Users will now be taken to the default WP login page with the form to confirm their email address.
  • BUG FIX: Fixed bug where the reset password link in the new user email was not filtered to go to the frontend login page if being used.
  • BUG FIX: Fixed issue where some errors were not being shown when password resets failed.
  • BUG FIX: Fixed bug with action links added to the orders table.
  • BUG FIX: Fixed issue where empty dates would show current date in the members list.
  • BUG FIX: Fixed fatal error that was happening when using some of the new API endpoints.
  • BUG FIX: Timestamps returned by the Stripe API when getting the next payment date needed to be adjusted based on the site's timezone setting.
  • BUG FIX: Fixed a bug where the change password form wouldn't show up sometimes when using the login shortcode.
  • BUG FIX: Fixed notice in the PayPal IPN handler when adding notes to an order.
  • BUG FIX: Fixed issue where PMPro would generate the wrong excerpt in some cases where the more tag was used but the excerpt was generated before the more tag code or blog was not yet converted to HTML. Specifically this fixes an issue with excerpts generated for AMP with the SchemaApp plugin.
  • BUG FIX/ENHANCEMENT: Added an advanced setting to "Uninstall PMPro on Deletion". You must check and save this option first or PMPro will not delete data from the DB when deleting from the plugins page. This keeps users from accidentally deleting orders and member data.
  • BUG FIX/ENHANCEMENT: Now hiding the profile and change password links on the membership account page if a frontend profile page is not set and users are locked from the WP dashboard by the advanced setting.
  • BUG FIX/ENHANCEMENT: Resetting the signups and cancellations report cache when there are new membership level changes.
  • ENHANCEMENT: Added a pmpro_get_element_class function and filter. We now use this function when adding classes to HTML elements in our templates. The filter can be used to alter or append to the classes used in the HTML tags. This will make it easier to create code and CSS to make PMPro look better with popular themes.
  • ENHANCEMENT: Added a pmpro_authorizenet_post_values filter to the Authorize.net class. An array of $post_values is passed in to be filtered along with a string for the API method about to be called.
  • ENHANCEMENT: Added a pmpro_member_profile_edit_user_object_fields filter to add or remove fields from the frontend edit profile page.
  • ENHANCEMENT: Now showing information about the current billing method on the update billing page. Can hide this information by having the pmpro_billing_show_payment_method filter return false.
  • ENHANCEMENT: No longer saying "Great Work!" in the admin digest emails. This was especially embarrassing if you didn't have any sales during the diget period.
  • REFACTOR: Refactored some code in the CSV exports to avoid false positives by malware scanners.
  • REFACTOR: Added a build_post_string method to the Authorize.net class to avoid redundant code.
  • REFACTOR: Added a cancelSubscriptionAtGateway method to the PayPal Express class. This is useful if you want to cancel the subscription without cancelling the membership. (Thanks, Mirco Babini)
Download this release

Release Info

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

Code changes from version 2.3.3 to 2.3.4

CHANGELOG.txt CHANGED
@@ -1,4 +1,29 @@
1
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  = 2.3.3 - 2020-05-13 =
3
  * SECURITY: Fixed SQL injection vulnerability when logged in as an administrator and adding new orders in the dashboard. JVN#20248858 (Thanks, Kenichi Okuno of Mitsui Bussan Secure Directions, Inc)
4
  * SECURITY: Making sure to properly escape all values on the add/edit order form in the dashboard.
1
  == Changelog ==
2
+ = 2.3.4 - 2020-06-18 =
3
+ * SECURITY: Better escaping of values on the billing and confirmation pages.
4
+ * BUG FIX: Fixed issue where expiration dates could be set to 1 day in the past when editing a user in the dashboard if certain timezones were chosen in the General settings.
5
+ * BUG FIX: Fixed issue where users were redirected back to the /login/ page if WordPress needed them to confirm their admin email address. Users will now be taken to the default WP login page with the form to confirm their email address.
6
+ * BUG FIX: Fixed bug where the reset password link in the new user email was not filtered to go to the frontend login page if being used.
7
+ * BUG FIX: Fixed issue where some errors were not being shown when password resets failed.
8
+ * BUG FIX: Fixed bug with action links added to the orders table.
9
+ * BUG FIX: Fixed issue where empty dates would show current date in the members list.
10
+ * BUG FIX: Fixed fatal error that was happening when using some of the new API endpoints.
11
+ * BUG FIX: Timestamps returned by the Stripe API when getting the next payment date needed to be adjusted based on the site's timezone setting.
12
+ * BUG FIX: Fixed a bug where the change password form wouldn't show up sometimes when using the login shortcode.
13
+ * BUG FIX: Fixed notice in the PayPal IPN handler when adding notes to an order.
14
+ * BUG FIX: Fixed issue where PMPro would generate the wrong excerpt in some cases where the more tag was used but the excerpt was generated before the more tag code or blog was not yet converted to HTML. Specifically this fixes an issue with excerpts generated for AMP with the SchemaApp plugin.
15
+ * BUG FIX/ENHANCEMENT: Added an advanced setting to "Uninstall PMPro on Deletion". You must check and save this option first or PMPro will not delete data from the DB when deleting from the plugins page. This keeps users from accidentally deleting orders and member data.
16
+ * BUG FIX/ENHANCEMENT: Now hiding the profile and change password links on the membership account page if a frontend profile page is not set and users are locked from the WP dashboard by the advanced setting.
17
+ * BUG FIX/ENHANCEMENT: Resetting the signups and cancellations report cache when there are new membership level changes.
18
+ * ENHANCEMENT: Added a pmpro_get_element_class function and filter. We now use this function when adding classes to HTML elements in our templates. The filter can be used to alter or append to the classes used in the HTML tags. This will make it easier to create code and CSS to make PMPro look better with popular themes.
19
+ * ENHANCEMENT: Added a pmpro_authorizenet_post_values filter to the Authorize.net class. An array of $post_values is passed in to be filtered along with a string for the API method about to be called.
20
+ * ENHANCEMENT: Added a pmpro_member_profile_edit_user_object_fields filter to add or remove fields from the frontend edit profile page.
21
+ * ENHANCEMENT: Now showing information about the current billing method on the update billing page. Can hide this information by having the pmpro_billing_show_payment_method filter return false.
22
+ * ENHANCEMENT: No longer saying "Great Work!" in the admin digest emails. This was especially embarrassing if you didn't have any sales during the diget period.
23
+ * REFACTOR: Refactored some code in the CSV exports to avoid false positives by malware scanners.
24
+ * REFACTOR: Added a build_post_string method to the Authorize.net class to avoid redundant code.
25
+ * REFACTOR: Added a cancelSubscriptionAtGateway method to the PayPal Express class. This is useful if you want to cancel the subscription without cancelling the membership. (Thanks, Mirco Babini)
26
+
27
  = 2.3.3 - 2020-05-13 =
28
  * SECURITY: Fixed SQL injection vulnerability when logged in as an administrator and adding new orders in the dashboard. JVN#20248858 (Thanks, Kenichi Okuno of Mitsui Bussan Secure Directions, Inc)
29
  * SECURITY: Making sure to properly escape all values on the add/edit order form in the dashboard.
adminpages/advancedsettings.php CHANGED
@@ -51,6 +51,7 @@
51
  pmpro_setOption("hideads");
52
  pmpro_setOption("hideadslevels");
53
  pmpro_setOption("redirecttosubscription");
 
54
 
55
  /**
56
  * Filter to add custom settings to the advanced settings page.
@@ -97,6 +98,7 @@
97
  if( is_multisite() ) {
98
  $redirecttosubscription = pmpro_getOption("redirecttosubscription");
99
  }
 
100
 
101
  // Default settings.
102
  if(!$nonmembertext)
@@ -460,6 +462,18 @@ if ( function_exists( 'pmpro_displayAds' ) && pmpro_displayAds() ) {
460
  }
461
  }
462
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
463
  </tbody>
464
  </table>
465
  <script>
51
  pmpro_setOption("hideads");
52
  pmpro_setOption("hideadslevels");
53
  pmpro_setOption("redirecttosubscription");
54
+ pmpro_setOption("uninstall");
55
 
56
  /**
57
  * Filter to add custom settings to the advanced settings page.
98
  if( is_multisite() ) {
99
  $redirecttosubscription = pmpro_getOption("redirecttosubscription");
100
  }
101
+ $uninstall = pmpro_getOption('uninstall');
102
 
103
  // Default settings.
104
  if(!$nonmembertext)
462
  }
463
  }
464
  ?>
465
+ <tr>
466
+ <th scope="row" valign="top">
467
+ <label for="showexcerpts"><?php _e('Uninstall PMPro on deletion?', 'paid-memberships-pro' );?></label>
468
+ </th>
469
+ <td>
470
+ <select id="uninstall" name="uninstall">
471
+ <option value="0" <?php if ( ! $uninstall ) { ?>selected="selected"<?php } ?>><?php _e( 'No', 'paid-memberships-pro' );?></option>
472
+ <option value="1" <?php if ( $uninstall == 1 ) { ?>selected="selected"<?php } ?>><?php _e( 'Yes - Delete all PMPro Data.', 'paid-memberships-pro' );?></option>
473
+ </select>
474
+ <p class="description"><?php esc_html_e( 'To delete all PMPro data from the database, set to Yes, deactivate PMPro, and then click to delete PMPro from the plugins page.' ); ?></p>
475
+ </td>
476
+ </tr>
477
  </tbody>
478
  </table>
479
  <script>
adminpages/memberslist-csv.php CHANGED
@@ -550,21 +550,18 @@
550
  ini_set('zlib.output_compression', 'Off');
551
  }
552
 
553
- if( function_exists('fpassthru') )
554
- {
555
- // open and send the file contents to the remote location
556
- $fh = fopen( $filename, 'rb' );
557
- fpassthru($fh);
558
- fclose($fh);
559
- }
560
- else
561
- {
562
  // use readfile() if fpassthru() is disabled (like on Flywheel Hosted)
563
- readfile($filename);
564
  }
565
 
566
  // remove the temp file
567
- unlink($filename);
568
  }
569
 
570
  //allow user to clean up after themselves
550
  ini_set('zlib.output_compression', 'Off');
551
  }
552
 
553
+ if( function_exists( 'fpassthru' ) ) {
554
+ // use fpassthru to output the csv
555
+ $csv_fh = fopen( $filename, 'rb' );
556
+ fpassthru( $csv_fh );
557
+ fclose( $csv_fh );
558
+ } else {
 
 
 
559
  // use readfile() if fpassthru() is disabled (like on Flywheel Hosted)
560
+ readfile( $filename );
561
  }
562
 
563
  // remove the temp file
564
+ unlink( $filename );
565
  }
566
 
567
  //allow user to clean up after themselves
adminpages/orders-csv.php CHANGED
@@ -585,17 +585,14 @@ function pmpro_transmit_order_content( $csv_fh, $filename, $headers = array() )
585
  ini_set( 'zlib.output_compression', 'Off' );
586
  }
587
 
588
- if( function_exists('fpassthru') )
589
- {
590
- // open and send the file contents to the remote location
591
- $fh = fopen( $filename, 'rb' );
592
- fpassthru($fh);
593
- fclose($fh);
594
- }
595
- else
596
- {
597
  // use readfile() if fpassthru() is disabled (like on Flywheel Hosted)
598
- readfile($filename);
599
  }
600
 
601
  // remove the temp file
585
  ini_set( 'zlib.output_compression', 'Off' );
586
  }
587
 
588
+ if( function_exists( 'fpassthru' ) ) {
589
+ // use fpassthru to output the csv
590
+ $csv_fh = fopen( $filename, 'rb' );
591
+ fpassthru( $csv_fh );
592
+ fclose( $csv_fh );
593
+ } else {
 
 
 
594
  // use readfile() if fpassthru() is disabled (like on Flywheel Hosted)
595
+ readfile( $filename );
596
  }
597
 
598
  // remove the temp file
adminpages/orders.php CHANGED
@@ -1353,7 +1353,7 @@ if ( function_exists( 'pmpro_add_email_order_modal' ) ) {
1353
  foreach ( $actions as $action => $link ) {
1354
  ++ $i;
1355
  ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1356
- $out .= "<span class='" . esc_attr( $action ) . "'>" . esc_html( $link ) . $sep . "</span>";
1357
  }
1358
  echo $out;
1359
  }
1353
  foreach ( $actions as $action => $link ) {
1354
  ++ $i;
1355
  ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1356
+ $out .= "<span class='" . esc_attr( $action ) . "'>" . $link . $sep . "</span>";
1357
  }
1358
  echo $out;
1359
  }
adminpages/reports/memberships.php CHANGED
@@ -120,7 +120,7 @@ function pmpro_report_memberships_widget() {
120
  jQuery('.pmpro_report_th ').click(function(event) {
121
  //prevent form submit onclick
122
  event.preventDefault();
123
-
124
  //toggle sub rows
125
  jQuery(this).closest('tbody').find('.pmpro_report_tr_sub').toggle();
126
 
@@ -207,8 +207,8 @@ function pmpro_report_memberships_page()
207
 
208
  //get data
209
  if (
210
- $type === "signup_v_cancel" ||
211
- $type === "signup_v_expiration" ||
212
  $type === "signup_v_all"
213
  ) {
214
  $sqlQuery = "SELECT $date_function(mu.startdate) as date, COUNT(DISTINCT mu.user_id) as signups
@@ -693,8 +693,9 @@ function pmpro_report_memberships_delete_transients()
693
  delete_transient("pmpro_report_memberships_cancellations");
694
  delete_transient("pmpro_report_memberships_signups");
695
  }
696
- add_action("pmpro_after_checkout", "pmpro_report_memberships_delete_transients");
697
  add_action("pmpro_updated_order", "pmpro_report_memberships_delete_transients");
 
 
698
 
699
 
700
  /**
120
  jQuery('.pmpro_report_th ').click(function(event) {
121
  //prevent form submit onclick
122
  event.preventDefault();
123
+
124
  //toggle sub rows
125
  jQuery(this).closest('tbody').find('.pmpro_report_tr_sub').toggle();
126
 
207
 
208
  //get data
209
  if (
210
+ $type === "signup_v_cancel" ||
211
+ $type === "signup_v_expiration" ||
212
  $type === "signup_v_all"
213
  ) {
214
  $sqlQuery = "SELECT $date_function(mu.startdate) as date, COUNT(DISTINCT mu.user_id) as signups
693
  delete_transient("pmpro_report_memberships_cancellations");
694
  delete_transient("pmpro_report_memberships_signups");
695
  }
 
696
  add_action("pmpro_updated_order", "pmpro_report_memberships_delete_transients");
697
+ add_action("pmpro_after_checkout", "pmpro_report_memberships_delete_transients");
698
+ add_action("pmpro_after_change_membership_level", "pmpro_report_memberships_delete_transients");
699
 
700
 
701
  /**
classes/class-pmpro-admin-activity-email.php CHANGED
@@ -130,7 +130,7 @@ class PMPro_Admin_Activity_Email extends PMProEmail {
130
  <?php
131
  $total_members = $wpdb->get_var( "SELECT COUNT( DISTINCT user_id ) FROM {$wpdb->pmpro_memberships_users} WHERE status IN ('active')" );
132
  ?>
133
- <h3 style="color:#2997c8;font-size:20px;line-height:30px;margin:0px 0px 5px 0px;padding:0px;"><span style="background:#2997c8;color:#FFFFFF;padding:5px 10px 5px 10px;"><?php esc_html_e( number_format_i18n( $total_members ) ); ?></span><?php esc_html_e( ' Total Members&mdash;great work!', 'paid-memberships-pro' ); ?></h3>
134
  <?php
135
  $members_per_level = $wpdb->get_results(
136
  "
130
  <?php
131
  $total_members = $wpdb->get_var( "SELECT COUNT( DISTINCT user_id ) FROM {$wpdb->pmpro_memberships_users} WHERE status IN ('active')" );
132
  ?>
133
+ <h3 style="color:#2997c8;font-size:20px;line-height:30px;margin:0px 0px 5px 0px;padding:0px;"><span style="background:#2997c8;color:#FFFFFF;padding:5px 10px 5px 10px;"><?php esc_html_e( number_format_i18n( $total_members ) ); ?></span><?php esc_html_e( ' Total Members', 'paid-memberships-pro' ); ?></h3>
134
  <?php
135
  $members_per_level = $wpdb->get_results(
136
  "
classes/class-pmpro-members-list-table.php CHANGED
@@ -570,6 +570,9 @@ class PMPro_Members_List_Table extends WP_List_Table {
570
  */
571
  public function column_joindate( $item ) {
572
  $joindate = $item[ 'joindate' ];
 
 
 
573
  return date_i18n( get_option('date_format'), $joindate );
574
  }
575
 
@@ -581,6 +584,9 @@ class PMPro_Members_List_Table extends WP_List_Table {
581
  */
582
  public function column_startdate( $item ) {
583
  $startdate = $item[ 'startdate' ];
 
 
 
584
  return date_i18n( get_option('date_format'), $startdate );
585
  }
586
 
570
  */
571
  public function column_joindate( $item ) {
572
  $joindate = $item[ 'joindate' ];
573
+ if ( empty( $joindate ) ) {
574
+ return;
575
+ }
576
  return date_i18n( get_option('date_format'), $joindate );
577
  }
578
 
584
  */
585
  public function column_startdate( $item ) {
586
  $startdate = $item[ 'startdate' ];
587
+ if ( empty( $startdate ) ) {
588
+ return;
589
+ }
590
  return date_i18n( get_option('date_format'), $startdate );
591
  }
592
 
classes/gateways/class.pmprogateway_authorizenet.php CHANGED
@@ -1,156 +1,203 @@
1
  <?php
2
- //include pmprogateway
3
- require_once(dirname(__FILE__) . "/class.pmprogateway.php");
4
 
5
- //load classes init method
6
- add_action('init', array('PMProGateway_authorizenet', 'init'));
7
 
8
- class PMProGateway_authorizenet extends PMProGateway
 
 
9
  {
10
- function __construct($gateway = NULL)
11
- {
12
- $this->gateway = $gateway;
13
- return $this->gateway;
14
- }
15
-
16
- /**
17
- * Run on WP init
18
- *
19
- * @since 1.8
20
- */
21
- static function init()
22
- {
23
- //make sure Authorize.net is a gateway option
24
- add_filter('pmpro_gateways', array('PMProGateway_authorizenet', 'pmpro_gateways'));
25
 
26
- //add fields to payment settings
27
- add_filter('pmpro_payment_options', array('PMProGateway_authorizenet', 'pmpro_payment_options'));
28
- add_filter('pmpro_payment_option_fields', array('PMProGateway_authorizenet', 'pmpro_payment_option_fields'), 10, 2);
 
 
 
 
 
 
29
 
30
- add_filter('pmpro_checkout_order', array('PMProGateway_authorizenet', 'pmpro_checkout_order'));
31
- add_filter('pmpro_billing_order', array('PMProGateway_authorizenet', 'pmpro_checkout_order'));
 
32
 
33
- }
 
34
 
35
- static function pmpro_checkout_order( $morder ) {
36
 
37
- if ( isset( $_REQUEST['CVV'] ) ) {
38
- $authorizenet_cvv = sanitize_text_field( $_REQUEST['CVV'] );
39
- } else {
40
- $authorizenet_cvv = '';
41
- }
42
 
43
- $morder->CVV2 = $authorizenet_cvv;
44
- return $morder;
 
 
45
  }
46
-
47
- /**
48
- * Make sure this gateway is in the gateways list
49
- *
50
- * @since 1.8
51
- */
52
- static function pmpro_gateways($gateways)
53
- {
54
- if(empty($gateways['authorizenet']))
55
- $gateways['authorizenet'] = __('Authorize.net', 'paid-memberships-pro' );
56
 
57
- return $gateways;
58
- }
 
 
 
 
 
 
 
 
 
 
 
59
 
60
- /**
61
- * Get a list of payment options that the this gateway needs/supports.
62
- *
63
- * @since 1.8
64
- */
65
- static function getGatewayOptions()
66
- {
67
- $options = array(
68
- 'sslseal',
69
- 'nuclear_HTTPS',
70
- 'gateway_environment',
71
- 'loginname',
72
- 'transactionkey',
73
- 'currency',
74
- 'use_ssl',
75
- 'tax_state',
76
- 'tax_rate',
77
- 'accepted_credit_cards',
78
- );
79
-
80
- return $options;
81
- }
82
 
83
- /**
84
- * Set payment options for payment settings page.
85
- *
86
- * @since 1.8
87
- */
88
- static function pmpro_payment_options($options)
89
- {
90
- //get stripe options
91
- $authorizenet_options = PMProGateway_authorizenet::getGatewayOptions();
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
- //merge with others.
94
- $options = array_merge($authorizenet_options, $options);
 
 
 
 
 
 
 
95
 
96
- return $options;
97
- }
98
 
99
- /**
100
- * Display fields for this gateway's options.
101
- *
102
- * @since 1.8
103
- */
104
- static function pmpro_payment_option_fields($values, $gateway)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  {
106
- ?>
107
- <tr class="pmpro_settings_divider gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
108
- <td colspan="2">
109
- <hr />
110
- <h2 class="title"><?php esc_html_e('Authorize.net Settings', 'paid-memberships-pro' ); ?></h2>
111
- </td>
112
- </tr>
113
- <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
114
- <th scope="row" valign="top">
115
- <label for="loginname"><?php _e('Login Name', 'paid-memberships-pro' );?>:</label>
116
- </th>
117
- <td>
118
- <input type="text" id="loginname" name="loginname" value="<?php echo esc_attr($values['loginname'])?>" class="regular-text code" />
119
- </td>
120
- </tr>
121
- <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
122
- <th scope="row" valign="top">
123
- <label for="transactionkey"><?php _e('Transaction Key', 'paid-memberships-pro' );?>:</label>
124
- </th>
125
- <td>
126
- <input type="text" id="transactionkey" name="transactionkey" value="<?php echo esc_attr($values['transactionkey'])?>" class="regular-text code" />
127
- </td>
128
- </tr>
129
- <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
130
- <th scope="row" valign="top">
131
- <label><?php _e('Silent Post URL', 'paid-memberships-pro' );?>:</label>
132
- </th>
133
- <td>
134
- <p><?php _e('To fully integrate with Authorize.net, be sure to set your Silent Post URL to', 'paid-memberships-pro' ); ?></p>
135
- <p><code><?php echo admin_url("admin-ajax.php") . "?action=authnet_silent_post";?></code></p>
136
- </td>
137
- </tr>
138
- <?php
139
- }
140
 
141
- /**
142
- * Process checkout.
143
- *
144
- */
145
- function process(&$order)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  {
147
- //check for initial payment
148
- if(floatval($order->InitialPayment) == 0)
149
  {
150
- //auth first, then process
151
- if($this->authorize($order))
152
  {
153
- $this->void($order);
154
  if(!pmpro_isLevelTrial($order->membership_level))
155
  {
156
  //subscription will start today with a 1 period trial
@@ -181,819 +228,749 @@
181
  }
182
 
183
  $order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
184
- return $this->subscribe($order);
185
- }
186
- else
187
- {
188
- if(empty($order->error))
189
- $order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
190
- return false;
191
- }
192
- }
193
- else
194
- {
195
- //charge first payment
196
- if($this->charge($order))
197
- {
198
- //set up recurring billing
199
- if(pmpro_isLevelRecurring($order->membership_level))
200
  {
201
- if(!pmpro_isLevelTrial($order->membership_level))
202
- {
203
- //subscription will start today with a 1 period trial
204
- $order->ProfileStartDate = date_i18n("Y-m-d") . "T0:0:0";
205
- $order->TrialBillingPeriod = $order->BillingPeriod;
206
- $order->TrialBillingFrequency = $order->BillingFrequency;
207
- $order->TrialBillingCycles = 1;
208
- $order->TrialAmount = 0;
209
-
210
- //add a billing cycle to make up for the trial, if applicable
211
- if(!empty($order->TotalBillingCycles))
212
- $order->TotalBillingCycles++;
213
- }
214
- elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
215
  {
216
- //it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
217
- $order->ProfileStartDate = date_i18n("Y-m-d") . "T0:0:0";
218
- $order->TrialBillingCycles++;
219
-
220
- //add a billing cycle to make up for the trial, if applicable
221
- if(!empty($order->TotalBillingCycles))
222
- $order->TotalBillingCycles++;
223
  }
224
  else
225
  {
226
- //add a period to the start date to account for the initial payment
227
- $order->ProfileStartDate = date_i18n("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
 
228
  }
229
 
230
- $order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
231
- if($this->subscribe($order))
232
- {
233
- return true;
234
- }
235
- else
236
- {
237
- if($this->void($order))
238
- {
239
- if(!$order->error)
240
- $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
241
- }
242
- else
243
- {
244
- if(!$order->error)
245
- $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
246
- $order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
247
- }
248
-
249
- return false;
250
- }
251
- }
252
- else
253
- {
254
- //only a one time charge
255
- $order->status = "success"; //saved on checkout page
256
- return true;
257
  }
258
  }
259
  else
260
  {
261
- if(empty($order->error))
262
- $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
263
-
264
- return false;
265
  }
266
  }
267
- }
268
-
269
- function authorize(&$order)
270
- {
271
- if(empty($order->code))
272
- $order->code = $order->getRandomCode();
273
-
274
- if(empty($order->gateway_environment))
275
- $gateway_environment = pmpro_getOption("gateway_environment");
276
  else
277
- $gateway_environment = $order->gateway_environment;
278
- if($gateway_environment == "live")
279
- $host = "secure.authorize.net";
280
- else
281
- $host = "test.authorize.net";
282
-
283
- $path = "/gateway/transact.dll";
284
- $post_url = "https://" . $host . $path;
285
-
286
- $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
287
-
288
- //what amount to authorize? just $1 to test
289
- $amount = "1.00";
290
-
291
- //combine address
292
- $address = $order->Address1;
293
- if(!empty($order->Address2))
294
- $address .= "\n" . $order->Address2;
295
-
296
- //customer stuff
297
- $customer_email = $order->Email;
298
- $customer_phone = $order->billing->phone;
299
-
300
- if(!isset($order->membership_level->name))
301
- $order->membership_level->name = "";
302
-
303
- $post_values = array(
304
-
305
- // the API Login ID and Transaction Key must be replaced with valid values
306
- "x_login" => pmpro_getOption("loginname"),
307
- "x_tran_key" => pmpro_getOption("transactionkey"),
308
-
309
- "x_version" => "3.1",
310
- "x_delim_data" => "TRUE",
311
- "x_delim_char" => "|",
312
- "x_relay_response" => "FALSE",
313
-
314
- "x_type" => "AUTH_ONLY",
315
- "x_method" => "CC",
316
- "x_card_type" => $order->cardtype,
317
- "x_card_num" => $order->accountnumber,
318
- "x_exp_date" => $order->ExpirationDate,
319
-
320
- "x_amount" => $amount,
321
- "x_description" => apply_filters( 'pmpro_authorizenet_level_description', substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), $order->membership_level->name, $order, get_bloginfo("name")),
322
-
323
- "x_first_name" => $order->FirstName,
324
- "x_last_name" => $order->LastName,
325
- "x_address" => $address,
326
- "x_city" => $order->billing->city,
327
- "x_state" => $order->billing->state,
328
- "x_zip" => $order->billing->zip,
329
- "x_country" => $order->billing->country,
330
- "x_invoice_num" => $order->code,
331
- "x_phone" => $customer_phone,
332
- "x_email" => $order->Email
333
- // Additional fields can be added here as outlined in the AIM integration
334
- // guide at: http://developer.authorize.net
335
- );
336
-
337
- if(!empty($order->CVV2))
338
- $post_values["x_card_code"] = $order->CVV2;
339
-
340
- // This section takes the input fields and converts them to the proper format
341
- // for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
342
- $post_string = "";
343
- foreach( $post_values as $key => $value )
344
- { $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
345
- $post_string = rtrim( $post_string, "& " );
346
-
347
- //curl
348
- $request = curl_init($post_url); // initiate curl object
349
- curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
350
- curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
351
- curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
352
- curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
353
- curl_setopt($request, CURLOPT_USERAGENT, PMPRO_USER_AGENT); // setting the user agent
354
- $post_response = curl_exec($request); // execute curl post and store results in $post_response
355
- // additional options may be required depending upon your server configuration
356
- // you can find documentation on curl options at http://www.php.net/curl_setopt
357
- curl_close ($request); // close curl object
358
-
359
- // This line takes the response and breaks it into an array using the specified delimiting character
360
- $response_array = explode($post_values["x_delim_char"],$post_response);
361
-
362
- if($response_array[0] == 1)
363
  {
364
- $order->payment_transaction_id = $response_array[6];
365
- $order->updateStatus("authorized");
366
 
367
- return true;
368
- }
369
- else
370
- {
371
- //$order->status = "error";
372
- $order->errorcode = $response_array[2];
373
- $order->error = $response_array[3];
374
- $order->shorterror = $response_array[3];
375
  return false;
376
  }
377
  }
 
378
 
379
- function void(&$order)
380
- {
381
- if(empty($order->payment_transaction_id))
382
- return false;
383
 
384
- if(empty($order->gateway_environment))
385
- $gateway_environment = pmpro_getOption("gateway_environment");
386
- else
387
- $gateway_environment = $order->gateway_environment;
388
- if($gateway_environment == "live")
389
  $host = "secure.authorize.net";
390
  else
391
  $host = "test.authorize.net";
392
 
393
- $path = "/gateway/transact.dll";
394
- $post_url = "https://" . $host . $path;
395
-
396
- $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
397
-
398
- $post_values = array(
399
-
400
- // the API Login ID and Transaction Key must be replaced with valid values
401
- "x_login" => pmpro_getOption("loginname"),
402
- "x_tran_key" => pmpro_getOption("transactionkey"),
403
-
404
- "x_version" => "3.1",
405
- "x_delim_data" => "TRUE",
406
- "x_delim_char" => "|",
407
- "x_relay_response" => "FALSE",
408
-
409
- "x_type" => "VOID",
410
- "x_trans_id" => $order->payment_transaction_id
411
- // Additional fields can be added here as outlined in the AIM integration
412
- // guide at: http://developer.authorize.net
413
- );
414
-
415
- // This section takes the input fields and converts them to the proper format
416
- // for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
417
- $post_string = "";
418
- foreach( $post_values as $key => $value )
419
- { $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
420
- $post_string = rtrim( $post_string, "& " );
421
-
422
- //curl
423
- $request = curl_init($post_url); // initiate curl object
424
- curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
425
- curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
426
- curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
427
- curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
428
- $post_response = curl_exec($request); // execute curl post and store results in $post_response
429
- // additional options may be required depending upon your server configuration
430
- // you can find documentation on curl options at http://www.php.net/curl_setopt
431
- curl_close ($request); // close curl object
432
-
433
- // This line takes the response and breaks it into an array using the specified delimiting character
434
- $response_array = explode($post_values["x_delim_char"],$post_response);
435
- if($response_array[0] == 1)
436
- {
437
- $order->payment_transaction_id = $response_array[4];
438
- $order->updateStatus("voided");
439
- return true;
440
- }
441
- else
442
- {
443
- //$order->status = "error";
444
- $order->errorcode = $response_array[2];
445
- $order->error = $response_array[3];
446
- $order->shorterror = $response_array[3];
447
- return false;
448
- }
449
- }
450
-
451
- function charge(&$order)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  {
453
- if(empty($order->code))
454
- $order->code = $order->getRandomCode();
455
-
456
- if(!empty($order->gateway_environment))
457
- $gateway_environment = $order->gateway_environment;
458
- if(empty($gateway_environment))
459
- $gateway_environment = pmpro_getOption("gateway_environment");
460
- if($gateway_environment == "live")
461
- $host = "secure.authorize.net";
462
- else
463
- $host = "test.authorize.net";
464
-
465
- $path = "/gateway/transact.dll";
466
- $post_url = "https://" . $host . $path;
467
 
468
- $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
469
-
470
- //what amount to charge?
471
- $amount = $order->InitialPayment;
 
 
 
 
 
 
 
472
 
473
- //tax
474
- $order->subtotal = $amount;
475
- $tax = $order->getTax(true);
476
- $amount = pmpro_round_price((float)$order->subtotal + (float)$tax);
477
 
478
- //combine address
479
- $address = $order->Address1;
480
- if(!empty($order->Address2))
481
- $address .= "\n" . $order->Address2;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
 
483
- //customer stuff
484
- $customer_email = $order->Email;
485
- $customer_phone = $order->billing->phone;
 
486
 
487
- if(!isset($order->membership_level->name))
488
- $order->membership_level->name = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
 
490
- $post_values = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
 
492
- // the API Login ID and Transaction Key must be replaced with valid values
493
- "x_login" => pmpro_getOption("loginname"),
494
- "x_tran_key" => pmpro_getOption("transactionkey"),
495
 
496
- "x_version" => "3.1",
497
- "x_delim_data" => "TRUE",
498
- "x_delim_char" => "|",
499
- "x_relay_response" => "FALSE",
500
 
501
- "x_type" => "AUTH_CAPTURE",
502
- "x_method" => "CC",
503
- "x_card_type" => $order->cardtype,
504
- "x_card_num" => $order->accountnumber,
505
- "x_exp_date" => $order->ExpirationDate,
506
 
507
- "x_amount" => $amount,
508
- "x_tax" => $tax,
509
- "x_description" => apply_filters( 'pmpro_authorizenet_level_description', substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), $order->membership_level->name, $order, get_bloginfo("name")),
 
 
 
 
 
510
 
511
- "x_first_name" => $order->FirstName,
512
- "x_last_name" => $order->LastName,
513
- "x_address" => $address,
514
- "x_city" => $order->billing->city,
515
- "x_state" => $order->billing->state,
516
- "x_zip" => $order->billing->zip,
517
- "x_country" => $order->billing->country,
518
- "x_invoice_num" => $order->code,
519
- "x_phone" => $customer_phone,
520
- "x_email" => $order->Email
521
 
522
- // Additional fields can be added here as outlined in the AIM integration
523
- // guide at: http://developer.authorize.net
524
- );
525
 
 
 
 
 
526
 
527
- if(!empty($order->CVV2) ) {
528
- $post_values["x_card_code"] = $order->CVV2;
529
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
- // This section takes the input fields and converts them to the proper format
532
- // for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
533
- $post_string = "";
534
- foreach( $post_values as $key => $value )
535
- { $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
536
- $post_string = rtrim( $post_string, "& " );
537
-
538
- //curl
539
- $request = curl_init($post_url); // initiate curl object
540
- curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
541
- curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
542
- curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
543
- curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
544
- $post_response = curl_exec($request); // execute curl post and store results in $post_response
545
- // additional options may be required depending upon your server configuration
546
- // you can find documentation on curl options at http://www.php.net/curl_setopt
547
- curl_close ($request); // close curl object
548
-
549
- // This line takes the response and breaks it into an array using the specified delimiting character
550
- $response_array = explode($post_values["x_delim_char"],$post_response);
551
- if($response_array[0] == 1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  {
553
- $order->payment_transaction_id = $response_array[6];
554
- $order->updateStatus("success");
555
  return true;
556
  }
557
  else
558
  {
559
- //$order->status = "error";
560
- $order->errorcode = $response_array[2];
561
- $order->error = $response_array[3];
562
- $order->shorterror = $response_array[3];
563
  return false;
564
  }
 
 
 
 
 
565
  }
 
566
 
567
- function subscribe(&$order)
568
- {
569
- //define variables to send
570
-
571
- if(empty($order->code))
572
- $order->code = $order->getRandomCode();
573
-
574
- //filter order before subscription. use with care.
575
- $order = apply_filters("pmpro_subscribe_order", $order, $this);
 
576
 
577
- if(!empty($order->gateway_environment))
578
- $gateway_environment = $order->gateway_environment;
579
- if(empty($gateway_environment))
580
- $gateway_environment = pmpro_getOption("gateway_environment");
581
- if($gateway_environment == "live")
582
- $host = "api.authorize.net";
583
- else
584
- $host = "apitest.authorize.net";
585
 
586
- $path = "/xml/v1/request.api";
 
587
 
588
- $loginname = pmpro_getOption("loginname");
589
- $transactionkey = pmpro_getOption("transactionkey");
 
590
 
591
- $amount = $order->PaymentAmount;
592
- $refId = $order->code;
593
- $name = $order->membership_name;
594
- $length = (int)$order->BillingFrequency;
595
 
596
- if($order->BillingPeriod == "Month")
597
- $unit = "months";
598
- elseif($order->BillingPeriod == "Day")
599
- $unit = "days";
600
- elseif($order->BillingPeriod == "Year" && $order->BillingFrequency == 1)
601
- {
602
- $unit = "months";
603
- $length = 12;
604
- }
605
- elseif($order->BillingPeriod == "Week")
606
- {
607
- $unit = "days";
608
- $length = $length * 7; //converting weeks to days
609
- }
610
- else
611
- return false; //authorize.net only supports months and days
612
-
613
- $startDate = substr($order->ProfileStartDate, 0, 10);
614
- if(!empty($order->TotalBillingCycles))
615
- $totalOccurrences = (int)$order->TotalBillingCycles;
616
- if(empty($totalOccurrences))
617
- $totalOccurrences = 9999;
618
- if(isset($order->TrialBillingCycles))
619
- $trialOccurrences = (int)$order->TrialBillingCycles;
620
- else
621
- $trialOccurrences = 0;
622
- if(isset($order->TrialAmount))
623
- $trialAmount = $order->TrialAmount;
624
- else
625
- $trialAmount = NULL;
626
 
627
- //taxes
628
- $amount_tax = $order->getTaxForPrice($amount);
629
- $trial_tax = $order->getTaxForPrice($trialAmount);
 
 
 
 
 
630
 
631
- $amount = pmpro_round_price((float)$amount + (float)$amount_tax);
632
- $trialAmount = pmpro_round_price((float)$trialAmount + (float)$trial_tax);
 
 
633
 
634
- //authorize.net doesn't support different periods between trial and actual
635
 
636
- if(!empty($order->TrialBillingPeriod) && $order->TrialBillingPeriod != $order->BillingPeriod)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  {
638
- echo "F";
639
- return false;
640
  }
641
-
642
- $cardNumber = $order->accountnumber;
643
- $expirationDate = $order->ExpirationDate_YdashM;
644
- $cardCode = $order->CVV2;
645
-
646
- $firstName = $order->FirstName;
647
- $lastName = $order->LastName;
648
-
649
- //do address stuff then?
650
- $address = $order->Address1;
651
- if(!empty($order->Address2))
652
- $address .= "\n" . $order->Address2;
653
- $city = $order->billing->city;
654
- $state = $order->billing->state;
655
- $zip = $order->billing->zip;
656
- $country = $order->billing->country;
657
-
658
- //customer stuff
659
- $customer_email = $order->Email;
660
- if(strpos($order->billing->phone, "+") === false)
661
- $customer_phone = $order->billing->phone;
662
  else
663
- $customer_phone = "";
664
-
665
- //make sure the phone is in an okay format
666
- $customer_phone = preg_replace("/[^0-9]/", "", $customer_phone);
667
- if(strlen($customer_phone) > 10)
668
- $customer_phone = "";
669
-
670
- //build xml to post
671
- $this->content =
672
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
673
- "<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
674
- "<merchantAuthentication>".
675
- "<name>" . $loginname . "</name>".
676
- "<transactionKey>" . $transactionkey . "</transactionKey>".
677
- "</merchantAuthentication>".
678
- "<refId><![CDATA[" . substr($refId, 0, 20) . "]]></refId>".
679
- "<subscription>".
680
- "<name><![CDATA[" . substr($name, 0, 50) . "]]></name>".
681
- "<paymentSchedule>".
682
- "<interval>".
683
- "<length>". $length ."</length>".
684
- "<unit>". $unit ."</unit>".
685
- "</interval>".
686
- "<startDate>" . $startDate . "</startDate>".
687
- "<totalOccurrences>". $totalOccurrences . "</totalOccurrences>";
688
- if(!empty($trialOccurrences))
689
- $this->content .=
690
- "<trialOccurrences>". $trialOccurrences . "</trialOccurrences>";
691
- $this->content .=
692
- "</paymentSchedule>".
693
- "<amount>". $amount ."</amount>";
694
- if(!empty($trialOccurrences))
695
- $this->content .=
696
- "<trialAmount>" . $trialAmount . "</trialAmount>";
697
- $this->content .=
698
- "<payment>".
699
- "<creditCard>".
700
- "<cardNumber>" . $cardNumber . "</cardNumber>".
701
- "<expirationDate>" . $expirationDate . "</expirationDate>";
702
- if(!empty($cardCode))
703
- $this->content .= "<cardCode>" . $cardCode . "</cardCode>";
704
- $this->content .=
705
- "</creditCard>".
706
- "</payment>".
707
- "<order><invoiceNumber>" . substr($order->code, 0, 20) . "</invoiceNumber></order>".
708
- "<customer>".
709
- "<email>". substr($customer_email, 0, 255) . "</email>".
710
- "<phoneNumber>". substr($customer_phone, 0, 25) . "</phoneNumber>".
711
- "</customer>".
712
- "<billTo>".
713
- "<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
714
- "<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
715
- "<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
716
- "<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
717
- "<state>". substr($state, 0, 2) . "</state>".
718
- "<zip>" . substr($zip, 0, 20) . "</zip>".
719
- "<country>". substr($country, 0, 60) . "</country>".
720
- "</billTo>".
721
- "</subscription>".
722
- "</ARBCreateSubscriptionRequest>";
723
-
724
- //send the xml via curl
725
- $this->response = $this->send_request_via_curl($host,$path,$this->content);
726
- //if curl is unavilable you can try using fsockopen
727
- /*
728
- $response = send_request_via_fsockopen($host,$path,$content);
729
- */
730
-
731
- if(!empty($this->response)) {
732
- list ($refId, $resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
733
- if($resultCode == "Ok")
734
- {
735
- $order->status = "success"; //saved on checkout page
736
- $order->subscription_transaction_id = $subscriptionId;
737
- return true;
738
- }
739
- else
740
- {
741
- $order->status = "error";
742
- $order->errorcode = $code;
743
- $order->error = $text;
744
- $order->shorterror = $text;
745
- return false;
746
- }
747
- } else {
748
  $order->status = "error";
749
- $order->error = "Could not connect to Authorize.net";
750
- $order->shorterror = "Could not connect to Authorize.net";
 
751
  return false;
752
  }
 
 
 
 
 
753
  }
 
754
 
755
- function update(&$order)
756
- {
757
- //define variables to send
758
- $gateway_environment = $order->gateway_environment;
759
- if(empty($gateway_environment))
760
- $gateway_environment = pmpro_getOption("gateway_environment");
761
- if($gateway_environment == "live")
762
- $host = "api.authorize.net";
763
- else
764
- $host = "apitest.authorize.net";
765
-
766
- $path = "/xml/v1/request.api";
767
-
768
- $loginname = pmpro_getOption("loginname");
769
- $transactionkey = pmpro_getOption("transactionkey");
770
-
771
- //$amount = $order->PaymentAmount;
772
- $refId = $order->code;
773
  $subscriptionId = $order->subscription_transaction_id;
 
 
 
 
774
 
775
- $cardNumber = $order->accountnumber;
776
- $expirationDate = $order->ExpirationDate_YdashM;
777
- $cardCode = $order->CVV2;
778
-
779
- $firstName = $order->FirstName;
780
- $lastName = $order->LastName;
781
-
782
- //do address stuff then?
783
- $address = $order->Address1;
784
- if(!empty($order->Address2))
785
- $address .= "\n" . $order->Address2;
786
- $city = $order->billing->city;
787
- $state = $order->billing->state;
788
- $zip = $order->billing->zip;
789
- $country = $order->billing->country;
790
-
791
- //customer stuff
792
- $customer_email = $order->Email;
793
- if(strpos($order->billing->phone, "+") === false)
794
- $customer_phone = $order->billing->phone;
795
-
796
-
797
- //build xml to post
798
- $this->content =
799
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
800
- "<ARBUpdateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
801
- "<merchantAuthentication>".
802
- "<name><![CDATA[" . $loginname . "]]></name>".
803
- "<transactionKey>" . $transactionkey . "</transactionKey>".
804
- "</merchantAuthentication>".
805
- "<refId>" . substr($refId, 0, 20) . "</refId>".
806
- "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
807
- "<subscription>".
808
- "<payment>".
809
- "<creditCard>".
810
- "<cardNumber>" . $cardNumber . "</cardNumber>".
811
- "<expirationDate>" . $expirationDate . "</expirationDate>";
812
- if(!empty($cardCode))
813
- $this->content .= "<cardCode>" . $cardCode . "</cardCode>";
814
- $this->content .=
815
- "</creditCard>".
816
- "</payment>".
817
- "<customer>".
818
- "<email>". substr($customer_email, 0, 255) . "</email>".
819
- "<phoneNumber>". substr(str_replace("1 (", "(", formatPhone($customer_phone)), 0, 25) . "</phoneNumber>".
820
- "</customer>".
821
- "<billTo>".
822
- "<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
823
- "<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
824
- "<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
825
- "<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
826
- "<state><![CDATA[". substr($state, 0, 2) . "]]></state>".
827
- "<zip>" . substr($zip, 0, 20) . "</zip>".
828
- "<country>". substr($country, 0, 60) . "</country>".
829
- "</billTo>".
830
- "</subscription>".
831
- "</ARBUpdateSubscriptionRequest>";
832
-
833
- //send the xml via curl
834
- $this->response = $this->send_request_via_curl($host,$path,$this->content);
835
- //if curl is unavilable you can try using fsockopen
836
- /*
837
- $response = send_request_via_fsockopen($host,$path,$order->content);
838
- */
839
-
840
-
841
- if(!empty($this->response)) {
842
- list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
843
-
844
- if($resultCode == "Ok" || $code == "Ok")
845
- {
846
- return true;
847
- }
848
- else
849
- {
850
- $order->status = "error";
851
- $order->errorcode = $code;
852
- $order->error = $text;
853
- $order->shorterror = $text;
854
- return false;
855
- }
856
- } else {
857
- $order->status = "error";
858
- $order->error = "Could not connect to Authorize.net";
859
- $order->shorterror = "Could not connect to Authorize.net";
860
- return false;
861
- }
862
- }
863
-
864
- function cancel(&$order)
865
  {
866
- //define variables to send
867
- if(!empty($order->subscription_transaction_id))
868
- $subscriptionId = $order->subscription_transaction_id;
869
- else
870
- $subscriptionId = "";
871
- $loginname = pmpro_getOption("loginname");
872
- $transactionkey = pmpro_getOption("transactionkey");
873
-
874
- if(!empty($order->gateway_environment))
875
- $gateway_environment = $order->gateway_environment;
876
- else
877
- $gateway_environment = pmpro_getOption("gateway_environment");
878
 
879
- if($gateway_environment == "live")
880
- $host = "api.authorize.net";
881
- else
882
- $host = "apitest.authorize.net";
883
-
884
- $path = "/xml/v1/request.api";
885
-
886
- if(!$subscriptionId || !$loginname || !$transactionkey)
887
- return false;
888
-
889
- //build xml to post
890
- $content =
891
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
892
- "<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
893
- "<merchantAuthentication>".
894
- "<name>" . $loginname . "</name>".
895
- "<transactionKey>" . $transactionkey . "</transactionKey>".
896
- "</merchantAuthentication>" .
897
- "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
898
- "</ARBCancelSubscriptionRequest>";
899
-
900
- //send the xml via curl
901
- $response = $this->send_request_via_curl($host,$path,$content);
902
- //if curl is unavilable you can try using fsockopen
903
- /*
904
- $response = send_request_via_fsockopen($host,$path,$content);
905
- */
906
-
907
- //if the connection and send worked $response holds the return from Authorize.net
908
- if ($response)
909
  {
910
- list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
911
-
912
- if($resultCode == "Ok" || $code == "Ok")
913
- {
914
- $order->updateStatus("cancelled");
915
- return true;
916
- }
917
- else
918
- {
919
- //$order->status = "error";
920
- $order->errorcode = $code;
921
- $order->error = $text;
922
- $order->shorterror = $text;
923
- return false;
924
- }
925
  }
926
  else
927
  {
928
- $order->status = "error";
929
- $order->error = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
930
- $order->shorterror = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
 
931
  return false;
932
  }
933
  }
934
-
935
- function getSubscriptionStatus(&$order)
936
  {
937
- //define variables to send
938
- if(!empty($order->subscription_transaction_id))
939
- $subscriptionId = $order->subscription_transaction_id;
940
- else
941
- $subscriptionId = "";
942
- $loginname = pmpro_getOption("loginname");
943
- $transactionkey = pmpro_getOption("transactionkey");
944
-
945
- if(!empty($order->gateway_environment))
946
- $gateway_environment = $order->gateway_environment;
947
- else
948
- $gateway_environment = pmpro_getOption("gateway_environment");
949
 
950
- if($gateway_environment == "live")
951
- $host = "api.authorize.net";
952
- else
953
- $host = "apitest.authorize.net";
 
 
 
 
 
954
 
955
- $path = "/xml/v1/request.api";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
956
 
957
- if(!$subscriptionId || !$loginname || !$transactionkey)
958
- return false;
959
 
960
- //build xml to post
961
- $content =
962
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
963
- "<ARBGetSubscriptionStatusRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
964
- "<merchantAuthentication>".
965
- "<name>" . $loginname . "</name>".
966
- "<transactionKey>" . $transactionkey . "</transactionKey>".
967
- "</merchantAuthentication>" .
968
- "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
969
- "</ARBGetSubscriptionStatusRequest>";
970
-
971
- //send the xml via curl
972
- $response = $this->send_request_via_curl($host,$path,$content);
973
-
974
- //if curl is unavilable you can try using fsockopen
975
- /*
976
- $response = send_request_via_fsockopen($host,$path,$content);
977
- */
978
-
979
- //if the connection and send worked $response holds the return from Authorize.net
980
- if($response)
981
  {
982
- list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
983
-
984
- $status = $this->substring_between($response,'<status>','</status>');
985
-
986
- if($resultCode == "Ok" || $code == "Ok")
987
- {
988
- return $status;
989
- }
990
- else
991
- {
992
- $order->status = "error";
993
- $order->errorcode = $resultCode;
994
- $order->error = $message;
995
- $order->shorterror = $text;
996
- }
997
  }
998
  else
999
  {
@@ -1003,85 +980,121 @@
1003
  $order->shorterror = $text;
1004
  }
1005
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1006
 
1007
- //Authorize.net Function
1008
- //function to send xml request via fsockopen
1009
- function send_request_via_fsockopen($host,$path,$content)
 
 
 
 
 
 
 
 
 
1010
  {
1011
- $posturl = "ssl://" . $host;
1012
- $header = "Host: $host\r\n";
1013
- $header .= "User-Agent: PHP Script\r\n";
1014
- $header .= "Content-Type: text/xml\r\n";
1015
- $header .= "Content-Length: ".strlen($content)."\r\n";
1016
- $header .= "Connection: close\r\n\r\n";
1017
- $fp = fsockopen($posturl, 443, $errno, $errstr, 30);
1018
- if (!$fp)
1019
- {
1020
- $response = false;
1021
- }
1022
- else
1023
  {
1024
- error_reporting(E_ERROR);
1025
- fputs($fp, "POST $path HTTP/1.1\r\n");
1026
- fputs($fp, $header.$content);
1027
- fwrite($fp, $out);
1028
- $response = "";
1029
- while (!feof($fp))
1030
- {
1031
- $response = $response . fgets($fp, 128);
1032
- }
1033
- fclose($fp);
1034
- error_reporting(E_ALL ^ E_NOTICE);
1035
  }
1036
- return $response;
 
1037
  }
 
 
1038
 
1039
- //Authorize.net Function
1040
- //function to send xml request via curl
1041
- function send_request_via_curl($host,$path,$content)
1042
- {
1043
- $posturl = "https://" . $host . $path;
1044
- $posturl = apply_filters("pmpro_authorizenet_post_url", $posturl, pmpro_getOption("gateway_environment"));
1045
- $ch = curl_init();
1046
- curl_setopt($ch, CURLOPT_URL, $posturl);
1047
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1048
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
1049
- curl_setopt($ch, CURLOPT_HEADER, 1);
1050
- curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
1051
- curl_setopt($ch, CURLOPT_POST, 1);
1052
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1053
- curl_setopt($ch, CURLOPT_USERAGENT, PMPRO_USER_AGENT); //set user agent
1054
- $response = curl_exec($ch);
1055
- return $response;
1056
- }
1057
 
1058
 
1059
- //Authorize.net Function
1060
- //function to parse Authorize.net response
1061
- function parse_return($content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1062
  {
1063
- $refId = $this->substring_between($content,'<refId>','</refId>');
1064
- $resultCode = $this->substring_between($content,'<resultCode>','</resultCode>');
1065
- $code = $this->substring_between($content,'<code>','</code>');
1066
- $text = $this->substring_between($content,'<text>','</text>');
1067
- $subscriptionId = $this->substring_between($content,'<subscriptionId>','</subscriptionId>');
1068
- return array ($refId, $resultCode, $code, $text, $subscriptionId);
1069
  }
1070
-
1071
- //Authorize.net Function
1072
- //helper function for parsing response
1073
- function substring_between($haystack,$start,$end)
1074
  {
1075
- if (strpos($haystack,$start) === false || strpos($haystack,$end) === false)
1076
- {
1077
- return false;
1078
- }
1079
- else
1080
- {
1081
- $start_position = strpos($haystack,$start)+strlen($start);
1082
- $end_position = strpos($haystack,$end);
1083
- return substr($haystack,$start_position,$end_position-$start_position);
1084
- }
1085
  }
1086
  }
1087
- ?>
1
  <?php
2
+ //include pmprogateway
3
+ require_once(dirname(__FILE__) . "/class.pmprogateway.php");
4
 
5
+ //load classes init method
6
+ add_action('init', array('PMProGateway_authorizenet', 'init'));
7
 
8
+ class PMProGateway_authorizenet extends PMProGateway
9
+ {
10
+ function __construct($gateway = NULL)
11
  {
12
+ $this->gateway = $gateway;
13
+ return $this->gateway;
14
+ }
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ /**
17
+ * Run on WP init
18
+ *
19
+ * @since 1.8
20
+ */
21
+ static function init()
22
+ {
23
+ //make sure Authorize.net is a gateway option
24
+ add_filter('pmpro_gateways', array('PMProGateway_authorizenet', 'pmpro_gateways'));
25
 
26
+ //add fields to payment settings
27
+ add_filter('pmpro_payment_options', array('PMProGateway_authorizenet', 'pmpro_payment_options'));
28
+ add_filter('pmpro_payment_option_fields', array('PMProGateway_authorizenet', 'pmpro_payment_option_fields'), 10, 2);
29
 
30
+ add_filter('pmpro_checkout_order', array('PMProGateway_authorizenet', 'pmpro_checkout_order'));
31
+ add_filter('pmpro_billing_order', array('PMProGateway_authorizenet', 'pmpro_checkout_order'));
32
 
33
+ }
34
 
35
+ static function pmpro_checkout_order( $morder ) {
 
 
 
 
36
 
37
+ if ( isset( $_REQUEST['CVV'] ) ) {
38
+ $authorizenet_cvv = sanitize_text_field( $_REQUEST['CVV'] );
39
+ } else {
40
+ $authorizenet_cvv = '';
41
  }
 
 
 
 
 
 
 
 
 
 
42
 
43
+ $morder->CVV2 = $authorizenet_cvv;
44
+ return $morder;
45
+ }
46
+
47
+ /**
48
+ * Make sure this gateway is in the gateways list
49
+ *
50
+ * @since 1.8
51
+ */
52
+ static function pmpro_gateways($gateways)
53
+ {
54
+ if(empty($gateways['authorizenet']))
55
+ $gateways['authorizenet'] = __('Authorize.net', 'paid-memberships-pro' );
56
 
57
+ return $gateways;
58
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ /**
61
+ * Get a list of payment options that the this gateway needs/supports.
62
+ *
63
+ * @since 1.8
64
+ */
65
+ static function getGatewayOptions()
66
+ {
67
+ $options = array(
68
+ 'sslseal',
69
+ 'nuclear_HTTPS',
70
+ 'gateway_environment',
71
+ 'loginname',
72
+ 'transactionkey',
73
+ 'currency',
74
+ 'use_ssl',
75
+ 'tax_state',
76
+ 'tax_rate',
77
+ 'accepted_credit_cards',
78
+ );
79
+
80
+ return $options;
81
+ }
82
 
83
+ /**
84
+ * Set payment options for payment settings page.
85
+ *
86
+ * @since 1.8
87
+ */
88
+ static function pmpro_payment_options($options)
89
+ {
90
+ //get stripe options
91
+ $authorizenet_options = PMProGateway_authorizenet::getGatewayOptions();
92
 
93
+ //merge with others.
94
+ $options = array_merge($authorizenet_options, $options);
95
 
96
+ return $options;
97
+ }
98
+
99
+ /**
100
+ * Display fields for this gateway's options.
101
+ *
102
+ * @since 1.8
103
+ */
104
+ static function pmpro_payment_option_fields($values, $gateway)
105
+ {
106
+ ?>
107
+ <tr class="pmpro_settings_divider gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
108
+ <td colspan="2">
109
+ <hr />
110
+ <h2 class="title"><?php esc_html_e('Authorize.net Settings', 'paid-memberships-pro' ); ?></h2>
111
+ </td>
112
+ </tr>
113
+ <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
114
+ <th scope="row" valign="top">
115
+ <label for="loginname"><?php _e('Login Name', 'paid-memberships-pro' );?>:</label>
116
+ </th>
117
+ <td>
118
+ <input type="text" id="loginname" name="loginname" value="<?php echo esc_attr($values['loginname'])?>" class="regular-text code" />
119
+ </td>
120
+ </tr>
121
+ <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
122
+ <th scope="row" valign="top">
123
+ <label for="transactionkey"><?php _e('Transaction Key', 'paid-memberships-pro' );?>:</label>
124
+ </th>
125
+ <td>
126
+ <input type="text" id="transactionkey" name="transactionkey" value="<?php echo esc_attr($values['transactionkey'])?>" class="regular-text code" />
127
+ </td>
128
+ </tr>
129
+ <tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
130
+ <th scope="row" valign="top">
131
+ <label><?php _e('Silent Post URL', 'paid-memberships-pro' );?>:</label>
132
+ </th>
133
+ <td>
134
+ <p><?php _e('To fully integrate with Authorize.net, be sure to set your Silent Post URL to', 'paid-memberships-pro' ); ?></p>
135
+ <p><code><?php echo admin_url("admin-ajax.php") . "?action=authnet_silent_post";?></code></p>
136
+ </td>
137
+ </tr>
138
+ <?php
139
+ }
140
+
141
+ /**
142
+ * Process checkout.
143
+ *
144
+ */
145
+ function process(&$order)
146
+ {
147
+ //check for initial payment
148
+ if(floatval($order->InitialPayment) == 0)
149
  {
150
+ //auth first, then process
151
+ if($this->authorize($order))
152
+ {
153
+ $this->void($order);
154
+ if(!pmpro_isLevelTrial($order->membership_level))
155
+ {
156
+ //subscription will start today with a 1 period trial
157
+ $order->ProfileStartDate = date_i18n("Y-m-d") . "T0:0:0";
158
+ $order->TrialBillingPeriod = $order->BillingPeriod;
159
+ $order->TrialBillingFrequency = $order->BillingFrequency;
160
+ $order->TrialBillingCycles = 1;
161
+ $order->TrialAmount = 0;
162
+
163
+ //add a billing cycle to make up for the trial, if applicable
164
+ if(!empty($order->TotalBillingCycles))
165
+ $order->TotalBillingCycles++;
166
+ }
167
+ elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
168
+ {
169
+ //it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
170
+ $order->ProfileStartDate = date_i18n("Y-m-d") . "T0:0:0";
171
+ $order->TrialBillingCycles++;
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
+ //add a billing cycle to make up for the trial, if applicable
174
+ if(!empty($order->TotalBillingCycles))
175
+ $order->TotalBillingCycles++;
176
+ }
177
+ else
178
+ {
179
+ //add a period to the start date to account for the initial payment
180
+ $order->ProfileStartDate = date_i18n("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
181
+ }
182
+
183
+ $order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
184
+ return $this->subscribe($order);
185
+ }
186
+ else
187
+ {
188
+ if(empty($order->error))
189
+ $order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
190
+ return false;
191
+ }
192
+ }
193
+ else
194
  {
195
+ //charge first payment
196
+ if($this->charge($order))
197
  {
198
+ //set up recurring billing
199
+ if(pmpro_isLevelRecurring($order->membership_level))
200
  {
 
201
  if(!pmpro_isLevelTrial($order->membership_level))
202
  {
203
  //subscription will start today with a 1 period trial
228
  }
229
 
230
  $order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
231
+ if($this->subscribe($order))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  {
233
+ return true;
234
+ }
235
+ else
236
+ {
237
+ if($this->void($order))
 
 
 
 
 
 
 
 
 
238
  {
239
+ if(!$order->error)
240
+ $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
 
 
 
 
 
241
  }
242
  else
243
  {
244
+ if(!$order->error)
245
+ $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
246
+ $order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
247
  }
248
 
249
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
  }
252
  else
253
  {
254
+ //only a one time charge
255
+ $order->status = "success"; //saved on checkout page
256
+ return true;
 
257
  }
258
  }
 
 
 
 
 
 
 
 
 
259
  else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  {
261
+ if(empty($order->error))
262
+ $order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
263
 
 
 
 
 
 
 
 
 
264
  return false;
265
  }
266
  }
267
+ }
268
 
269
+ function authorize(&$order)
270
+ {
271
+ if(empty($order->code))
272
+ $order->code = $order->getRandomCode();
273
 
274
+ if(empty($order->gateway_environment))
275
+ $gateway_environment = pmpro_getOption("gateway_environment");
276
+ else
277
+ $gateway_environment = $order->gateway_environment;
278
+ if($gateway_environment == "live")
279
  $host = "secure.authorize.net";
280
  else
281
  $host = "test.authorize.net";
282
 
283
+ $path = "/gateway/transact.dll";
284
+ $post_url = "https://" . $host . $path;
285
+
286
+ $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
287
+
288
+ //what amount to authorize? just $1 to test
289
+ $amount = "1.00";
290
+
291
+ //combine address
292
+ $address = $order->Address1;
293
+ if(!empty($order->Address2))
294
+ $address .= "\n" . $order->Address2;
295
+
296
+ //customer stuff
297
+ $customer_email = $order->Email;
298
+ $customer_phone = $order->billing->phone;
299
+
300
+ if(!isset($order->membership_level->name))
301
+ $order->membership_level->name = "";
302
+
303
+ $post_values = array(
304
+
305
+ // the API Login ID and Transaction Key must be replaced with valid values
306
+ "x_login" => pmpro_getOption("loginname"),
307
+ "x_tran_key" => pmpro_getOption("transactionkey"),
308
+
309
+ "x_version" => "3.1",
310
+ "x_delim_data" => "TRUE",
311
+ "x_delim_char" => "|",
312
+ "x_relay_response" => "FALSE",
313
+
314
+ "x_type" => "AUTH_ONLY",
315
+ "x_method" => "CC",
316
+ "x_card_type" => $order->cardtype,
317
+ "x_card_num" => $order->accountnumber,
318
+ "x_exp_date" => $order->ExpirationDate,
319
+
320
+ "x_amount" => $amount,
321
+ "x_description" => apply_filters( 'pmpro_authorizenet_level_description', substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), $order->membership_level->name, $order, get_bloginfo("name")),
322
+
323
+ "x_first_name" => $order->FirstName,
324
+ "x_last_name" => $order->LastName,
325
+ "x_address" => $address,
326
+ "x_city" => $order->billing->city,
327
+ "x_state" => $order->billing->state,
328
+ "x_zip" => $order->billing->zip,
329
+ "x_country" => $order->billing->country,
330
+ "x_invoice_num" => $order->code,
331
+ "x_phone" => $customer_phone,
332
+ "x_email" => $order->Email
333
+ // Additional fields can be added here as outlined in the AIM integration
334
+ // guide at: http://developer.authorize.net
335
+ );
336
+
337
+ if(!empty($order->CVV2))
338
+ $post_values["x_card_code"] = $order->CVV2;
339
+
340
+ $post_string = $this->build_post_string( $post_values, 'authorize' );
341
+
342
+ //curl
343
+ $request = curl_init($post_url); // initiate curl object
344
+ curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
345
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
346
+ curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
347
+ curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
348
+ curl_setopt($request, CURLOPT_USERAGENT, PMPRO_USER_AGENT); // setting the user agent
349
+ $post_response = curl_exec($request); // execute curl post and store results in $post_response
350
+ // additional options may be required depending upon your server configuration
351
+ // you can find documentation on curl options at http://www.php.net/curl_setopt
352
+ curl_close ($request); // close curl object
353
+
354
+ // This line takes the response and breaks it into an array using the specified delimiting character
355
+ $response_array = explode($post_values["x_delim_char"],$post_response);
356
+
357
+ if($response_array[0] == 1)
358
  {
359
+ $order->payment_transaction_id = $response_array[6];
360
+ $order->updateStatus("authorized");
 
 
 
 
 
 
 
 
 
 
 
 
361
 
362
+ return true;
363
+ }
364
+ else
365
+ {
366
+ //$order->status = "error";
367
+ $order->errorcode = $response_array[2];
368
+ $order->error = $response_array[3];
369
+ $order->shorterror = $response_array[3];
370
+ return false;
371
+ }
372
+ }
373
 
374
+ function void(&$order)
375
+ {
376
+ if(empty($order->payment_transaction_id))
377
+ return false;
378
 
379
+ if(empty($order->gateway_environment))
380
+ $gateway_environment = pmpro_getOption("gateway_environment");
381
+ else
382
+ $gateway_environment = $order->gateway_environment;
383
+ if($gateway_environment == "live")
384
+ $host = "secure.authorize.net";
385
+ else
386
+ $host = "test.authorize.net";
387
+
388
+ $path = "/gateway/transact.dll";
389
+ $post_url = "https://" . $host . $path;
390
+
391
+ $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
392
+
393
+ $post_values = array(
394
+
395
+ // the API Login ID and Transaction Key must be replaced with valid values
396
+ "x_login" => pmpro_getOption("loginname"),
397
+ "x_tran_key" => pmpro_getOption("transactionkey"),
398
+
399
+ "x_version" => "3.1",
400
+ "x_delim_data" => "TRUE",
401
+ "x_delim_char" => "|",
402
+ "x_relay_response" => "FALSE",
403
+
404
+ "x_type" => "VOID",
405
+ "x_trans_id" => $order->payment_transaction_id
406
+ // Additional fields can be added here as outlined in the AIM integration
407
+ // guide at: http://developer.authorize.net
408
+ );
409
+
410
+ $post_string = $this->build_post_string( $post_values, 'void' );
411
+
412
+ //curl
413
+ $request = curl_init($post_url); // initiate curl object
414
+ curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
415
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
416
+ curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
417
+ curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
418
+ $post_response = curl_exec($request); // execute curl post and store results in $post_response
419
+ // additional options may be required depending upon your server configuration
420
+ // you can find documentation on curl options at http://www.php.net/curl_setopt
421
+ curl_close ($request); // close curl object
422
+
423
+ // This line takes the response and breaks it into an array using the specified delimiting character
424
+ $response_array = explode($post_values["x_delim_char"],$post_response);
425
+ if($response_array[0] == 1)
426
+ {
427
+ $order->payment_transaction_id = $response_array[4];
428
+ $order->updateStatus("voided");
429
+ return true;
430
+ }
431
+ else
432
+ {
433
+ //$order->status = "error";
434
+ $order->errorcode = $response_array[2];
435
+ $order->error = $response_array[3];
436
+ $order->shorterror = $response_array[3];
437
+ return false;
438
+ }
439
+ }
440
 
441
+ function charge(&$order)
442
+ {
443
+ if(empty($order->code))
444
+ $order->code = $order->getRandomCode();
445
 
446
+ if(!empty($order->gateway_environment))
447
+ $gateway_environment = $order->gateway_environment;
448
+ if(empty($gateway_environment))
449
+ $gateway_environment = pmpro_getOption("gateway_environment");
450
+ if($gateway_environment == "live")
451
+ $host = "secure.authorize.net";
452
+ else
453
+ $host = "test.authorize.net";
454
+
455
+ $path = "/gateway/transact.dll";
456
+ $post_url = "https://" . $host . $path;
457
+
458
+ $post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
459
+
460
+ //what amount to charge?
461
+ $amount = $order->InitialPayment;
462
+
463
+ //tax
464
+ $order->subtotal = $amount;
465
+ $tax = $order->getTax(true);
466
+ $amount = pmpro_round_price((float)$order->subtotal + (float)$tax);
467
+
468
+ //combine address
469
+ $address = $order->Address1;
470
+ if(!empty($order->Address2))
471
+ $address .= "\n" . $order->Address2;
472
+
473
+ //customer stuff
474
+ $customer_email = $order->Email;
475
+ $customer_phone = $order->billing->phone;
476
+
477
+ if(!isset($order->membership_level->name))
478
+ $order->membership_level->name = "";
479
+
480
+ $post_values = array(
481
+
482
+ // the API Login ID and Transaction Key must be replaced with valid values
483
+ "x_login" => pmpro_getOption("loginname"),
484
+ "x_tran_key" => pmpro_getOption("transactionkey"),
485
+
486
+ "x_version" => "3.1",
487
+ "x_delim_data" => "TRUE",
488
+ "x_delim_char" => "|",
489
+ "x_relay_response" => "FALSE",
490
+
491
+ "x_type" => "AUTH_CAPTURE",
492
+ "x_method" => "CC",
493
+ "x_card_type" => $order->cardtype,
494
+ "x_card_num" => $order->accountnumber,
495
+ "x_exp_date" => $order->ExpirationDate,
496
+
497
+ "x_amount" => $amount,
498
+ "x_tax" => $tax,
499
+ "x_description" => apply_filters( 'pmpro_authorizenet_level_description', substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127), $order->membership_level->name, $order, get_bloginfo("name")),
500
+
501
+ "x_first_name" => $order->FirstName,
502
+ "x_last_name" => $order->LastName,
503
+ "x_address" => $address,
504
+ "x_city" => $order->billing->city,
505
+ "x_state" => $order->billing->state,
506
+ "x_zip" => $order->billing->zip,
507
+ "x_country" => $order->billing->country,
508
+ "x_invoice_num" => $order->code,
509
+ "x_phone" => $customer_phone,
510
+ "x_email" => $order->Email
511
+
512
+ // Additional fields can be added here as outlined in the AIM integration
513
+ // guide at: http://developer.authorize.net
514
+ );
515
+
516
+
517
+ if(!empty($order->CVV2) ) {
518
+ $post_values["x_card_code"] = $order->CVV2;
519
+ }
520
 
521
+ $post_string = $this->build_post_string( $post_values, 'charge' );
522
+
523
+ //curl
524
+ $request = curl_init($post_url); // initiate curl object
525
+ curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
526
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
527
+ curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
528
+ curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
529
+ $post_response = curl_exec($request); // execute curl post and store results in $post_response
530
+ // additional options may be required depending upon your server configuration
531
+ // you can find documentation on curl options at http://www.php.net/curl_setopt
532
+ curl_close ($request); // close curl object
533
+
534
+ // This line takes the response and breaks it into an array using the specified delimiting character
535
+ $response_array = explode($post_values["x_delim_char"],$post_response);
536
+ if($response_array[0] == 1)
537
+ {
538
+ $order->payment_transaction_id = $response_array[6];
539
+ $order->updateStatus("success");
540
+ return true;
541
+ }
542
+ else
543
+ {
544
+ //$order->status = "error";
545
+ $order->errorcode = $response_array[2];
546
+ $order->error = $response_array[3];
547
+ $order->shorterror = $response_array[3];
548
+ return false;
549
+ }
550
+ }
551
 
552
+ function subscribe(&$order)
553
+ {
554
+ //define variables to send
555
 
556
+ if(empty($order->code))
557
+ $order->code = $order->getRandomCode();
 
 
558
 
559
+ //filter order before subscription. use with care.
560
+ $order = apply_filters("pmpro_subscribe_order", $order, $this);
 
 
 
561
 
562
+ if(!empty($order->gateway_environment))
563
+ $gateway_environment = $order->gateway_environment;
564
+ if(empty($gateway_environment))
565
+ $gateway_environment = pmpro_getOption("gateway_environment");
566
+ if($gateway_environment == "live")
567
+ $host = "api.authorize.net";
568
+ else
569
+ $host = "apitest.authorize.net";
570
 
571
+ $path = "/xml/v1/request.api";
 
 
 
 
 
 
 
 
 
572
 
573
+ $loginname = pmpro_getOption("loginname");
574
+ $transactionkey = pmpro_getOption("transactionkey");
 
575
 
576
+ $amount = $order->PaymentAmount;
577
+ $refId = $order->code;
578
+ $name = $order->membership_name;
579
+ $length = (int)$order->BillingFrequency;
580
 
581
+ if($order->BillingPeriod == "Month")
582
+ $unit = "months";
583
+ elseif($order->BillingPeriod == "Day")
584
+ $unit = "days";
585
+ elseif($order->BillingPeriod == "Year" && $order->BillingFrequency == 1)
586
+ {
587
+ $unit = "months";
588
+ $length = 12;
589
+ }
590
+ elseif($order->BillingPeriod == "Week")
591
+ {
592
+ $unit = "days";
593
+ $length = $length * 7; //converting weeks to days
594
+ }
595
+ else
596
+ return false; //authorize.net only supports months and days
597
+
598
+ $startDate = substr($order->ProfileStartDate, 0, 10);
599
+ if(!empty($order->TotalBillingCycles))
600
+ $totalOccurrences = (int)$order->TotalBillingCycles;
601
+ if(empty($totalOccurrences))
602
+ $totalOccurrences = 9999;
603
+ if(isset($order->TrialBillingCycles))
604
+ $trialOccurrences = (int)$order->TrialBillingCycles;
605
+ else
606
+ $trialOccurrences = 0;
607
+ if(isset($order->TrialAmount))
608
+ $trialAmount = $order->TrialAmount;
609
+ else
610
+ $trialAmount = NULL;
611
+
612
+ //taxes
613
+ $amount_tax = $order->getTaxForPrice($amount);
614
+ $trial_tax = $order->getTaxForPrice($trialAmount);
615
+
616
+ $amount = pmpro_round_price((float)$amount + (float)$amount_tax);
617
+ $trialAmount = pmpro_round_price((float)$trialAmount + (float)$trial_tax);
618
+
619
+ //authorize.net doesn't support different periods between trial and actual
620
+
621
+ if(!empty($order->TrialBillingPeriod) && $order->TrialBillingPeriod != $order->BillingPeriod)
622
+ {
623
+ echo "F";
624
+ return false;
625
+ }
626
 
627
+ $cardNumber = $order->accountnumber;
628
+ $expirationDate = $order->ExpirationDate_YdashM;
629
+ $cardCode = $order->CVV2;
630
+
631
+ $firstName = $order->FirstName;
632
+ $lastName = $order->LastName;
633
+
634
+ //do address stuff then?
635
+ $address = $order->Address1;
636
+ if(!empty($order->Address2))
637
+ $address .= "\n" . $order->Address2;
638
+ $city = $order->billing->city;
639
+ $state = $order->billing->state;
640
+ $zip = $order->billing->zip;
641
+ $country = $order->billing->country;
642
+
643
+ //customer stuff
644
+ $customer_email = $order->Email;
645
+ if(strpos($order->billing->phone, "+") === false)
646
+ $customer_phone = $order->billing->phone;
647
+ else
648
+ $customer_phone = "";
649
+
650
+ //make sure the phone is in an okay format
651
+ $customer_phone = preg_replace("/[^0-9]/", "", $customer_phone);
652
+ if(strlen($customer_phone) > 10)
653
+ $customer_phone = "";
654
+
655
+ //build xml to post
656
+ $this->content =
657
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
658
+ "<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
659
+ "<merchantAuthentication>".
660
+ "<name>" . $loginname . "</name>".
661
+ "<transactionKey>" . $transactionkey . "</transactionKey>".
662
+ "</merchantAuthentication>".
663
+ "<refId><![CDATA[" . substr($refId, 0, 20) . "]]></refId>".
664
+ "<subscription>".
665
+ "<name><![CDATA[" . substr($name, 0, 50) . "]]></name>".
666
+ "<paymentSchedule>".
667
+ "<interval>".
668
+ "<length>". $length ."</length>".
669
+ "<unit>". $unit ."</unit>".
670
+ "</interval>".
671
+ "<startDate>" . $startDate . "</startDate>".
672
+ "<totalOccurrences>". $totalOccurrences . "</totalOccurrences>";
673
+ if(!empty($trialOccurrences))
674
+ $this->content .=
675
+ "<trialOccurrences>". $trialOccurrences . "</trialOccurrences>";
676
+ $this->content .=
677
+ "</paymentSchedule>".
678
+ "<amount>". $amount ."</amount>";
679
+ if(!empty($trialOccurrences))
680
+ $this->content .=
681
+ "<trialAmount>" . $trialAmount . "</trialAmount>";
682
+ $this->content .=
683
+ "<payment>".
684
+ "<creditCard>".
685
+ "<cardNumber>" . $cardNumber . "</cardNumber>".
686
+ "<expirationDate>" . $expirationDate . "</expirationDate>";
687
+ if(!empty($cardCode))
688
+ $this->content .= "<cardCode>" . $cardCode . "</cardCode>";
689
+ $this->content .=
690
+ "</creditCard>".
691
+ "</payment>".
692
+ "<order><invoiceNumber>" . substr($order->code, 0, 20) . "</invoiceNumber></order>".
693
+ "<customer>".
694
+ "<email>". substr($customer_email, 0, 255) . "</email>".
695
+ "<phoneNumber>". substr($customer_phone, 0, 25) . "</phoneNumber>".
696
+ "</customer>".
697
+ "<billTo>".
698
+ "<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
699
+ "<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
700
+ "<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
701
+ "<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
702
+ "<state>". substr($state, 0, 2) . "</state>".
703
+ "<zip>" . substr($zip, 0, 20) . "</zip>".
704
+ "<country>". substr($country, 0, 60) . "</country>".
705
+ "</billTo>".
706
+ "</subscription>".
707
+ "</ARBCreateSubscriptionRequest>";
708
+
709
+ //send the xml via curl
710
+ $this->response = $this->send_request_via_curl($host,$path,$this->content);
711
+ //if curl is unavilable you can try using fsockopen
712
+ /*
713
+ $response = send_request_via_fsockopen($host,$path,$content);
714
+ */
715
+
716
+ if(!empty($this->response)) {
717
+ list ($refId, $resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
718
+ if($resultCode == "Ok")
719
  {
720
+ $order->status = "success"; //saved on checkout page
721
+ $order->subscription_transaction_id = $subscriptionId;
722
  return true;
723
  }
724
  else
725
  {
726
+ $order->status = "error";
727
+ $order->errorcode = $code;
728
+ $order->error = $text;
729
+ $order->shorterror = $text;
730
  return false;
731
  }
732
+ } else {
733
+ $order->status = "error";
734
+ $order->error = "Could not connect to Authorize.net";
735
+ $order->shorterror = "Could not connect to Authorize.net";
736
+ return false;
737
  }
738
+ }
739
 
740
+ function update(&$order)
741
+ {
742
+ //define variables to send
743
+ $gateway_environment = $order->gateway_environment;
744
+ if(empty($gateway_environment))
745
+ $gateway_environment = pmpro_getOption("gateway_environment");
746
+ if($gateway_environment == "live")
747
+ $host = "api.authorize.net";
748
+ else
749
+ $host = "apitest.authorize.net";
750
 
751
+ $path = "/xml/v1/request.api";
 
 
 
 
 
 
 
752
 
753
+ $loginname = pmpro_getOption("loginname");
754
+ $transactionkey = pmpro_getOption("transactionkey");
755
 
756
+ //$amount = $order->PaymentAmount;
757
+ $refId = $order->code;
758
+ $subscriptionId = $order->subscription_transaction_id;
759
 
760
+ $cardNumber = $order->accountnumber;
761
+ $expirationDate = $order->ExpirationDate_YdashM;
762
+ $cardCode = $order->CVV2;
 
763
 
764
+ $firstName = $order->FirstName;
765
+ $lastName = $order->LastName;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
 
767
+ //do address stuff then?
768
+ $address = $order->Address1;
769
+ if(!empty($order->Address2))
770
+ $address .= "\n" . $order->Address2;
771
+ $city = $order->billing->city;
772
+ $state = $order->billing->state;
773
+ $zip = $order->billing->zip;
774
+ $country = $order->billing->country;
775
 
776
+ //customer stuff
777
+ $customer_email = $order->Email;
778
+ if(strpos($order->billing->phone, "+") === false)
779
+ $customer_phone = $order->billing->phone;
780
 
 
781
 
782
+ //build xml to post
783
+ $this->content =
784
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
785
+ "<ARBUpdateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
786
+ "<merchantAuthentication>".
787
+ "<name><![CDATA[" . $loginname . "]]></name>".
788
+ "<transactionKey>" . $transactionkey . "</transactionKey>".
789
+ "</merchantAuthentication>".
790
+ "<refId>" . substr($refId, 0, 20) . "</refId>".
791
+ "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
792
+ "<subscription>".
793
+ "<payment>".
794
+ "<creditCard>".
795
+ "<cardNumber>" . $cardNumber . "</cardNumber>".
796
+ "<expirationDate>" . $expirationDate . "</expirationDate>";
797
+ if(!empty($cardCode))
798
+ $this->content .= "<cardCode>" . $cardCode . "</cardCode>";
799
+ $this->content .=
800
+ "</creditCard>".
801
+ "</payment>".
802
+ "<customer>".
803
+ "<email>". substr($customer_email, 0, 255) . "</email>".
804
+ "<phoneNumber>". substr(str_replace("1 (", "(", formatPhone($customer_phone)), 0, 25) . "</phoneNumber>".
805
+ "</customer>".
806
+ "<billTo>".
807
+ "<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
808
+ "<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
809
+ "<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
810
+ "<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
811
+ "<state><![CDATA[". substr($state, 0, 2) . "]]></state>".
812
+ "<zip>" . substr($zip, 0, 20) . "</zip>".
813
+ "<country>". substr($country, 0, 60) . "</country>".
814
+ "</billTo>".
815
+ "</subscription>".
816
+ "</ARBUpdateSubscriptionRequest>";
817
+
818
+ //send the xml via curl
819
+ $this->response = $this->send_request_via_curl($host,$path,$this->content);
820
+ //if curl is unavilable you can try using fsockopen
821
+ /*
822
+ $response = send_request_via_fsockopen($host,$path,$order->content);
823
+ */
824
+
825
+
826
+ if(!empty($this->response)) {
827
+ list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
828
+
829
+ if($resultCode == "Ok" || $code == "Ok")
830
  {
831
+ return true;
 
832
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
  else
834
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
835
  $order->status = "error";
836
+ $order->errorcode = $code;
837
+ $order->error = $text;
838
+ $order->shorterror = $text;
839
  return false;
840
  }
841
+ } else {
842
+ $order->status = "error";
843
+ $order->error = "Could not connect to Authorize.net";
844
+ $order->shorterror = "Could not connect to Authorize.net";
845
+ return false;
846
  }
847
+ }
848
 
849
+ function cancel(&$order)
850
+ {
851
+ //define variables to send
852
+ if(!empty($order->subscription_transaction_id))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
  $subscriptionId = $order->subscription_transaction_id;
854
+ else
855
+ $subscriptionId = "";
856
+ $loginname = pmpro_getOption("loginname");
857
+ $transactionkey = pmpro_getOption("transactionkey");
858
 
859
+ if(!empty($order->gateway_environment))
860
+ $gateway_environment = $order->gateway_environment;
861
+ else
862
+ $gateway_environment = pmpro_getOption("gateway_environment");
863
+
864
+ if($gateway_environment == "live")
865
+ $host = "api.authorize.net";
866
+ else
867
+ $host = "apitest.authorize.net";
868
+
869
+ $path = "/xml/v1/request.api";
870
+
871
+ if(!$subscriptionId || !$loginname || !$transactionkey)
872
+ return false;
873
+
874
+ //build xml to post
875
+ $content =
876
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
877
+ "<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
878
+ "<merchantAuthentication>".
879
+ "<name>" . $loginname . "</name>".
880
+ "<transactionKey>" . $transactionkey . "</transactionKey>".
881
+ "</merchantAuthentication>" .
882
+ "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
883
+ "</ARBCancelSubscriptionRequest>";
884
+
885
+ //send the xml via curl
886
+ $response = $this->send_request_via_curl($host,$path,$content);
887
+ //if curl is unavilable you can try using fsockopen
888
+ /*
889
+ $response = send_request_via_fsockopen($host,$path,$content);
890
+ */
891
+
892
+ //if the connection and send worked $response holds the return from Authorize.net
893
+ if ($response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
  {
895
+ list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
 
 
 
 
 
 
 
 
 
 
 
896
 
897
+ if($resultCode == "Ok" || $code == "Ok")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
898
  {
899
+ $order->updateStatus("cancelled");
900
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
901
  }
902
  else
903
  {
904
+ //$order->status = "error";
905
+ $order->errorcode = $code;
906
+ $order->error = $text;
907
+ $order->shorterror = $text;
908
  return false;
909
  }
910
  }
911
+ else
 
912
  {
913
+ $order->status = "error";
914
+ $order->error = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
915
+ $order->shorterror = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
916
+ return false;
917
+ }
918
+ }
 
 
 
 
 
 
919
 
920
+ function getSubscriptionStatus(&$order)
921
+ {
922
+ //define variables to send
923
+ if(!empty($order->subscription_transaction_id))
924
+ $subscriptionId = $order->subscription_transaction_id;
925
+ else
926
+ $subscriptionId = "";
927
+ $loginname = pmpro_getOption("loginname");
928
+ $transactionkey = pmpro_getOption("transactionkey");
929
 
930
+ if(!empty($order->gateway_environment))
931
+ $gateway_environment = $order->gateway_environment;
932
+ else
933
+ $gateway_environment = pmpro_getOption("gateway_environment");
934
+
935
+ if($gateway_environment == "live")
936
+ $host = "api.authorize.net";
937
+ else
938
+ $host = "apitest.authorize.net";
939
+
940
+ $path = "/xml/v1/request.api";
941
+
942
+ if(!$subscriptionId || !$loginname || !$transactionkey)
943
+ return false;
944
+
945
+ //build xml to post
946
+ $content =
947
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>".
948
+ "<ARBGetSubscriptionStatusRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
949
+ "<merchantAuthentication>".
950
+ "<name>" . $loginname . "</name>".
951
+ "<transactionKey>" . $transactionkey . "</transactionKey>".
952
+ "</merchantAuthentication>" .
953
+ "<subscriptionId>" . $subscriptionId . "</subscriptionId>".
954
+ "</ARBGetSubscriptionStatusRequest>";
955
+
956
+ //send the xml via curl
957
+ $response = $this->send_request_via_curl($host,$path,$content);
958
+
959
+ //if curl is unavilable you can try using fsockopen
960
+ /*
961
+ $response = send_request_via_fsockopen($host,$path,$content);
962
+ */
963
+
964
+ //if the connection and send worked $response holds the return from Authorize.net
965
+ if($response)
966
+ {
967
+ list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
968
 
969
+ $status = $this->substring_between($response,'<status>','</status>');
 
970
 
971
+ if($resultCode == "Ok" || $code == "Ok")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
  {
973
+ return $status;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
974
  }
975
  else
976
  {
980
  $order->shorterror = $text;
981
  }
982
  }
983
+ else
984
+ {
985
+ $order->status = "error";
986
+ $order->errorcode = $resultCode;
987
+ $order->error = $message;
988
+ $order->shorterror = $text;
989
+ }
990
+ }
991
+
992
+ /**
993
+ * This function takes the post_values and converts them to the proper format
994
+ * for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
995
+ *
996
+ * @since 2.3.4
997
+ *
998
+ * @param array $post_values Values to be sent to the API
999
+ * @param string $action API action being performed.
1000
+ */
1001
+ function build_post_string( $post_values, $action ) {
1002
+ /**
1003
+ * Filters values to be sent to authorize.net.
1004
+ *
1005
+ * @since 2.3.4
1006
+ *
1007
+ * @param array $post_values that will be sent.
1008
+ * @param string $action being performed.
1009
+ */
1010
+ $post_values = apply_filters( 'pmpro_authorizenet_post_values', $post_values, $action );
1011
+
1012
+ $post_string = '';
1013
+ foreach( $post_values as $key => $value ) {
1014
+ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&";
1015
+ }
1016
+ $post_string = rtrim( $post_string, "& " );
1017
+
1018
+ return $post_string;
1019
+ }
1020
 
1021
+ //Authorize.net Function
1022
+ //function to send xml request via fsockopen
1023
+ function send_request_via_fsockopen($host,$path,$content)
1024
+ {
1025
+ $posturl = "ssl://" . $host;
1026
+ $header = "Host: $host\r\n";
1027
+ $header .= "User-Agent: PHP Script\r\n";
1028
+ $header .= "Content-Type: text/xml\r\n";
1029
+ $header .= "Content-Length: ".strlen($content)."\r\n";
1030
+ $header .= "Connection: close\r\n\r\n";
1031
+ $fp = fsockopen($posturl, 443, $errno, $errstr, 30);
1032
+ if (!$fp)
1033
  {
1034
+ $response = false;
1035
+ }
1036
+ else
1037
+ {
1038
+ error_reporting(E_ERROR);
1039
+ fputs($fp, "POST $path HTTP/1.1\r\n");
1040
+ fputs($fp, $header.$content);
1041
+ fwrite($fp, $out);
1042
+ $response = "";
1043
+ while (!feof($fp))
 
 
1044
  {
1045
+ $response = $response . fgets($fp, 128);
 
 
 
 
 
 
 
 
 
 
1046
  }
1047
+ fclose($fp);
1048
+ error_reporting(E_ALL ^ E_NOTICE);
1049
  }
1050
+ return $response;
1051
+ }
1052
 
1053
+ //Authorize.net Function
1054
+ //function to send xml request via curl
1055
+ function send_request_via_curl($host,$path,$content)
1056
+ {
1057
+ $posturl = "https://" . $host . $path;
1058
+ $posturl = apply_filters("pmpro_authorizenet_post_url", $posturl, pmpro_getOption("gateway_environment"));
1059
+ $ch = curl_init();
1060
+ curl_setopt($ch, CURLOPT_URL, $posturl);
1061
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1062
+ curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
1063
+ curl_setopt($ch, CURLOPT_HEADER, 1);
1064
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
1065
+ curl_setopt($ch, CURLOPT_POST, 1);
1066
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1067
+ curl_setopt($ch, CURLOPT_USERAGENT, PMPRO_USER_AGENT); //set user agent
1068
+ $response = curl_exec($ch);
1069
+ return $response;
1070
+ }
1071
 
1072
 
1073
+ //Authorize.net Function
1074
+ //function to parse Authorize.net response
1075
+ function parse_return($content)
1076
+ {
1077
+ $refId = $this->substring_between($content,'<refId>','</refId>');
1078
+ $resultCode = $this->substring_between($content,'<resultCode>','</resultCode>');
1079
+ $code = $this->substring_between($content,'<code>','</code>');
1080
+ $text = $this->substring_between($content,'<text>','</text>');
1081
+ $subscriptionId = $this->substring_between($content,'<subscriptionId>','</subscriptionId>');
1082
+ return array ($refId, $resultCode, $code, $text, $subscriptionId);
1083
+ }
1084
+
1085
+ //Authorize.net Function
1086
+ //helper function for parsing response
1087
+ function substring_between($haystack,$start,$end)
1088
+ {
1089
+ if (strpos($haystack,$start) === false || strpos($haystack,$end) === false)
1090
  {
1091
+ return false;
 
 
 
 
 
1092
  }
1093
+ else
 
 
 
1094
  {
1095
+ $start_position = strpos($haystack,$start)+strlen($start);
1096
+ $end_position = strpos($haystack,$end);
1097
+ return substr($haystack,$start_position,$end_position-$start_position);
 
 
 
 
 
 
 
1098
  }
1099
  }
1100
+ }
classes/gateways/class.pmprogateway_braintree.php CHANGED
@@ -449,35 +449,35 @@ use Braintree\WebhookNotification as Braintree_WebhookNotification;
449
 
450
  //include ours
451
  ?>
452
- <div id="pmpro_payment_information_fields" class="pmpro_checkout" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false) ) { ?>style="display: none;"<?php } ?>>
453
  <h3>
454
- <span class="pmpro_checkout-h3-name"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
455
- <span class="pmpro_checkout-h3-msg"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
456
  </h3>
457
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
458
  <?php if(!empty($sslseal)) { ?>
459
- <div class="pmpro_checkout-fields-display-seal">
460
  <?php } ?>
461
- <div class="pmpro_checkout-fields">
462
  <?php
463
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', true);
464
  if($pmpro_include_cardtype_field) { ?>
465
- <div class="pmpro_checkout-field pmpro_payment-card-type">
466
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
467
- <select id="CardType" name="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
468
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
469
  <option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
470
  <?php } ?>
471
  </select>
472
  </div>
473
  <?php } ?>
474
- <div class="pmpro_checkout-field pmpro_payment-account-number">
475
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
476
- <input id="AccountNumber" name="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" data-encrypted-name="number" autocomplete="off" />
477
  </div>
478
- <div class="pmpro_checkout-field pmpro_payment-expiration">
479
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
480
- <select id="ExpirationMonth" name="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
481
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
482
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
483
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
@@ -490,7 +490,7 @@ use Braintree\WebhookNotification as Braintree_WebhookNotification;
490
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
491
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
492
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
493
- </select>/<select id="ExpirationYear" name="ExpirationYear" class=" <?php echo pmpro_getClassForField("ExpirationYear");?>">
494
  <?php for($i = date_i18n("Y"); $i < date_i18n("Y") + 10; $i++) { ?>
495
  <option value="<?php echo $i?>" <?php if($ExpirationYear == $i) { ?>selected="selected"<?php } ?>><?php echo $i?></option>
496
  <?php } ?>
@@ -499,22 +499,22 @@ use Braintree\WebhookNotification as Braintree_WebhookNotification;
499
  <?php
500
  $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
501
  if($pmpro_show_cvv) { ?>
502
- <div class="pmpro_checkout-field pmpro_payment-cvv">
503
  <label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
504
- <input class="input" id="CVV" name="cvv" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr(sanitize_text_field($_REQUEST['CVV'])); }?>" class=" <?php echo pmpro_getClassForField("CVV");?>" data-encrypted-name="cvv" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
505
  </div>
506
  <?php } ?>
507
  <?php if($pmpro_show_discount_code) { ?>
508
- <div class="pmpro_checkout-field pmpro_payment-discount-code">
509
  <label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
510
- <input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
511
  <input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
512
- <p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
513
  </div>
514
  <?php } ?>
515
  </div> <!-- end pmpro_checkout-fields -->
516
  <?php if(!empty($sslseal)) { ?>
517
- <div class="pmpro_checkout-fields-rightcol pmpro_sslseal"><?php echo stripslashes($sslseal); ?></div>
518
  </div> <!-- end pmpro_checkout-fields-display-seal -->
519
  <?php } ?>
520
  </div> <!-- end pmpro_payment_information_fields -->
449
 
450
  //include ours
451
  ?>
452
+ <div id="pmpro_payment_information_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_payment_information_fields' ); ?>" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false) ) { ?>style="display: none;"<?php } ?>>
453
  <h3>
454
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
455
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
456
  </h3>
457
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
458
  <?php if(!empty($sslseal)) { ?>
459
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-display-seal' ); ?>">
460
  <?php } ?>
461
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
462
  <?php
463
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', true);
464
  if($pmpro_include_cardtype_field) { ?>
465
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-card-type', 'pmpro_payment-card-type' ); ?>">
466
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
467
+ <select id="CardType" name="CardType" class="<?php echo pmpro_get_element_class( 'CardType' ); ?>">
468
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
469
  <option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
470
  <?php } ?>
471
  </select>
472
  </div>
473
  <?php } ?>
474
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-account-number', 'pmpro_payment-account-number' ); ?>">
475
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
476
+ <input id="AccountNumber" name="AccountNumber" class="<?php echo pmpro_get_element_class( 'input', 'AccountNumber' ); ?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" data-encrypted-name="number" autocomplete="off" />
477
  </div>
478
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-expiration', 'pmpro_payment-expiration' ); ?>">
479
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
480
+ <select id="ExpirationMonth" name="ExpirationMonth" class="<?php echo pmpro_get_element_class( 'ExpirationMonth' ); ?>">
481
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
482
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
483
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
490
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
491
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
492
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
493
+ </select>/<select id="ExpirationYear" name="ExpirationYear" class="<?php echo pmpro_get_element_class( 'ExpirationYear' ); ?>">
494
  <?php for($i = date_i18n("Y"); $i < date_i18n("Y") + 10; $i++) { ?>
495
  <option value="<?php echo $i?>" <?php if($ExpirationYear == $i) { ?>selected="selected"<?php } ?>><?php echo $i?></option>
496
  <?php } ?>
499
  <?php
500
  $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
501
  if($pmpro_show_cvv) { ?>
502
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-cvv', 'pmpro_payment-cvv' ); ?>">
503
  <label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
504
+ <input id="CVV" name="cvv" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr(sanitize_text_field($_REQUEST['CVV'])); }?>" class="<?php echo pmpro_get_element_class( 'input', 'CVV' ); ?>" data-encrypted-name="cvv" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
505
  </div>
506
  <?php } ?>
507
  <?php if($pmpro_show_discount_code) { ?>
508
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-discount-code', 'pmpro_payment-discount-code' ); ?>">
509
  <label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
510
+ <input class="<?php echo pmpro_get_element_class( 'input', 'discount_code' ); ?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
511
  <input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
512
+ <p id="discount_code_message" class="<?php echo pmpro_get_element_class( 'pmpro_message' ); ?>" style="display: none;"></p>
513
  </div>
514
  <?php } ?>
515
  </div> <!-- end pmpro_checkout-fields -->
516
  <?php if(!empty($sslseal)) { ?>
517
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-rightcol pmpro_sslseal', 'pmpro_sslseal' ); ?>"><?php echo stripslashes($sslseal); ?></div>
518
  </div> <!-- end pmpro_checkout-fields-display-seal -->
519
  <?php } ?>
520
  </div> <!-- end pmpro_payment_information_fields -->
classes/gateways/class.pmprogateway_check.php CHANGED
@@ -150,7 +150,7 @@
150
 
151
  if($gateway == "check" && !pmpro_isLevelFree($pmpro_level)) {
152
  $instructions = pmpro_getOption("instructions");
153
- echo '<div class="pmpro_check_instructions">' . wpautop(wp_unslash( $instructions )) . '</div>';
154
  }
155
  }
156
 
150
 
151
  if($gateway == "check" && !pmpro_isLevelFree($pmpro_level)) {
152
  $instructions = pmpro_getOption("instructions");
153
+ echo '<div class="' . pmpro_get_element_class( 'pmpro_check_instructions' ) . '">' . wpautop(wp_unslash( $instructions )) . '</div>';
154
  }
155
  }
156
 
classes/gateways/class.pmprogateway_paypal.php CHANGED
@@ -278,13 +278,13 @@
278
  <?php if($gateway == "paypal" || $gateway == "paypalexpress" || $gateway == "paypalstandard") { ?>
279
  <span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
280
  <input type="hidden" name="submit-checkout" value="1" />
281
- <input type="image" id="pmpro_btn-submit-paypal" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> &raquo;" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
282
  </span>
283
  <?php } ?>
284
 
285
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
286
  <input type="hidden" name="submit-checkout" value="1" />
287
- <input type="submit" id="pmpro_btn-submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
288
  </span>
289
  <?php
290
 
278
  <?php if($gateway == "paypal" || $gateway == "paypalexpress" || $gateway == "paypalstandard") { ?>
279
  <span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
280
  <input type="hidden" name="submit-checkout" value="1" />
281
+ <input type="image" id="pmpro_btn-submit-paypal" class="<?php echo pmpro_get_element_class( 'pmpro_btn-submit-checkout' ); ?>" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> &raquo;" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
282
  </span>
283
  <?php } ?>
284
 
285
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
286
  <input type="hidden" name="submit-checkout" value="1" />
287
+ <input type="submit" id="pmpro_btn-submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
288
  </span>
289
  <?php
290
 
classes/gateways/class.pmprogateway_paypalexpress.php CHANGED
@@ -46,7 +46,7 @@
46
  add_filter('pmpro_payment_option_fields', array('PMProGateway_paypalexpress', 'pmpro_payment_option_fields'), 10, 2);
47
  $pmpro_payment_option_fields_for_paypal = true;
48
  }
49
-
50
  //code to add at checkout
51
  $gateway = pmpro_getGateway();
52
  if($gateway == "paypalexpress")
@@ -236,7 +236,7 @@
236
 
237
  return $fields;
238
  }
239
-
240
  /**
241
  * Code added to checkout preheader.
242
  *
@@ -434,7 +434,7 @@
434
  * Repurposed in v2.0. The old process() method is now confirm().
435
  */
436
  function process(&$order)
437
- {
438
  $order->payment_type = "PayPal Express";
439
  $order->cardtype = "";
440
  $order->ProfileStartDate = date_i18n("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod)) . "T0:0:0";
@@ -473,12 +473,12 @@
473
  ?>
474
  <span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
475
  <input type="hidden" name="submit-checkout" value="1" />
476
- <input type="image" id="pmpro_btn-submit-paypalexpress" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> &raquo;" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
477
  </span>
478
 
479
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
480
  <input type="hidden" name="submit-checkout" value="1" />
481
- <input type="submit" id="pmpro_btn-submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
482
  </span>
483
  <?php
484
 
@@ -760,15 +760,20 @@
760
  // Always cancel the order locally even if PayPal might fail
761
  $order->updateStatus("cancelled");
762
 
763
- // If we're processing an IPN request for this subscription, it's already cancelled at PayPal.
764
  if ( ( ! empty( $_POST['subscr_id'] ) && $_POST['subscr_id'] == $order->subscription_transaction_id ) ||
765
  ( ! empty( $_POST['recurring_payment_id'] ) && $_POST['recurring_payment_id'] == $order->subscription_transaction_id ) ) {
766
  // recurring_payment_failed transaction still need to be cancelled
767
  if ( $_POST['txn_type'] !== 'recurring_payment_failed' ) {
768
- return true;
769
  }
770
  }
771
 
 
 
 
 
 
772
  // Build the nvp string for PayPal API
773
  $nvpStr = "";
774
  $nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id) . "&ACTION=Cancel&NOTE=" . urlencode("User requested cancel.");
46
  add_filter('pmpro_payment_option_fields', array('PMProGateway_paypalexpress', 'pmpro_payment_option_fields'), 10, 2);
47
  $pmpro_payment_option_fields_for_paypal = true;
48
  }
49
+
50
  //code to add at checkout
51
  $gateway = pmpro_getGateway();
52
  if($gateway == "paypalexpress")
236
 
237
  return $fields;
238
  }
239
+
240
  /**
241
  * Code added to checkout preheader.
242
  *
434
  * Repurposed in v2.0. The old process() method is now confirm().
435
  */
436
  function process(&$order)
437
+ {
438
  $order->payment_type = "PayPal Express";
439
  $order->cardtype = "";
440
  $order->ProfileStartDate = date_i18n("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod)) . "T0:0:0";
473
  ?>
474
  <span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
475
  <input type="hidden" name="submit-checkout" value="1" />
476
+ <input type="image" id="pmpro_btn-submit-paypalexpress" class="<?php echo pmpro_get_element_class( 'pmpro_btn-submit-checkout' ); ?>" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> &raquo;" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
477
  </span>
478
 
479
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
480
  <input type="hidden" name="submit-checkout" value="1" />
481
+ <input type="submit" id="pmpro_btn-submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
482
  </span>
483
  <?php
484
 
760
  // Always cancel the order locally even if PayPal might fail
761
  $order->updateStatus("cancelled");
762
 
763
+ // If we're processing an IPN request for this subscription, it's already cancelled at PayPal.
764
  if ( ( ! empty( $_POST['subscr_id'] ) && $_POST['subscr_id'] == $order->subscription_transaction_id ) ||
765
  ( ! empty( $_POST['recurring_payment_id'] ) && $_POST['recurring_payment_id'] == $order->subscription_transaction_id ) ) {
766
  // recurring_payment_failed transaction still need to be cancelled
767
  if ( $_POST['txn_type'] !== 'recurring_payment_failed' ) {
768
+ return true;
769
  }
770
  }
771
 
772
+ // Cancel at gateway
773
+ return $this->cancelSubscriptionAtGateway($order);
774
+ }
775
+
776
+ function cancelSubscriptionAtGateway(&$order) {
777
  // Build the nvp string for PayPal API
778
  $nvpStr = "";
779
  $nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id) . "&ACTION=Cancel&NOTE=" . urlencode("User requested cancel.");
classes/gateways/class.pmprogateway_paypalstandard.php CHANGED
@@ -243,7 +243,7 @@
243
 
244
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
245
  <input type="hidden" name="submit-checkout" value="1" />
246
- <input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
247
  </span>
248
  <?php
249
 
243
 
244
  <span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
245
  <input type="hidden" name="submit-checkout" value="1" />
246
+ <input type="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
247
  </span>
248
  <?php
249
 
classes/gateways/class.pmprogateway_stripe.php CHANGED
@@ -538,23 +538,23 @@ class PMProGateway_stripe extends PMProGateway {
538
 
539
  //include ours
540
  ?>
541
- <div id="pmpro_payment_information_fields" class="pmpro_checkout"
542
  <?php if ( ! $pmpro_requirebilling || apply_filters( "pmpro_hide_payment_information_fields", false ) ) { ?>style="display: none;"<?php } ?>>
543
  <h3>
544
- <span class="pmpro_checkout-h3-name"><?php _e( 'Payment Information', 'paid-memberships-pro' ); ?></span>
545
- <span class="pmpro_checkout-h3-msg"><?php printf( __( 'We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string ); ?></span>
546
  </h3>
547
  <?php $sslseal = pmpro_getOption( "sslseal" ); ?>
548
  <?php if ( ! empty( $sslseal ) ) { ?>
549
- <div class="pmpro_checkout-fields-display-seal">
550
  <?php } ?>
551
  <div class="pmpro_checkout-fields<?php if ( ! empty( $sslseal ) ) { ?> pmpro_checkout-fields-leftcol<?php } ?>">
552
  <?php
553
  $pmpro_include_cardtype_field = apply_filters( 'pmpro_include_cardtype_field', false );
554
  if ( $pmpro_include_cardtype_field ) { ?>
555
- <div class="pmpro_checkout-field pmpro_payment-card-type">
556
  <label for="CardType"><?php _e( 'Card Type', 'paid-memberships-pro' ); ?></label>
557
- <select id="CardType" class=" <?php echo pmpro_getClassForField( "CardType" ); ?>">
558
  <?php foreach ( $pmpro_accepted_credit_cards as $cc ) { ?>
559
  <option value="<?php echo $cc ?>"
560
  <?php if ( $CardType == $cc ) { ?>selected="selected"<?php } ?>><?php echo $cc ?></option>
@@ -565,36 +565,36 @@ class PMProGateway_stripe extends PMProGateway {
565
  <input type="hidden" id="CardType" name="CardType"
566
  value="<?php echo esc_attr( $CardType ); ?>"/>
567
  <?php } ?>
568
- <div class="pmpro_checkout-field pmpro_payment-account-number">
569
  <label for="AccountNumber"><?php _e( 'Card Number', 'paid-memberships-pro' ); ?></label>
570
  <div id="AccountNumber"></div>
571
  </div>
572
- <div class="pmpro_checkout-field pmpro_payment-expiration">
573
  <label for="Expiry"><?php _e( 'Expiration Date', 'paid-memberships-pro' ); ?></label>
574
  <div id="Expiry"></div>
575
  </div>
576
  <?php
577
  $pmpro_show_cvv = apply_filters( "pmpro_show_cvv", true );
578
  if ( $pmpro_show_cvv ) { ?>
579
- <div class="pmpro_checkout-field pmpro_payment-cvv">
580
  <label for="CVV"><?php _e( 'CVC', 'paid-memberships-pro' ); ?></label>
581
  <div id="CVV"></div>
582
  </div>
583
  <?php } ?>
584
  <?php if ( $pmpro_show_discount_code ) { ?>
585
- <div class="pmpro_checkout-field pmpro_payment-discount-code">
586
  <label for="discount_code"><?php _e( 'Discount Code', 'paid-memberships-pro' ); ?></label>
587
- <input class="input <?php echo pmpro_getClassForField( "discount_code" ); ?>"
588
  id="discount_code" name="discount_code" type="text" size="10"
589
  value="<?php echo esc_attr( $discount_code ) ?>"/>
590
  <input type="button" id="discount_code_button" name="discount_code_button"
591
  value="<?php _e( 'Apply', 'paid-memberships-pro' ); ?>"/>
592
- <p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
593
  </div>
594
  <?php } ?>
595
  </div> <!-- end pmpro_checkout-fields -->
596
  <?php if ( ! empty( $sslseal ) ) { ?>
597
- <div class="pmpro_checkout-fields-rightcol pmpro_sslseal"><?php echo stripslashes( $sslseal ); ?></div>
598
  </div> <!-- end pmpro_checkout-fields-display-seal -->
599
  <?php } ?>
600
  </div> <!-- end pmpro_payment_information_fields -->
@@ -2004,11 +2004,13 @@ class PMProGateway_stripe extends PMProGateway {
2004
  if ( ! empty( $subscription ) ) {
2005
  $customer = $order->Gateway->getCustomer();
2006
  if ( ! $customer->delinquent && ! empty ( $subscription->current_period_end ) ) {
2007
- return $subscription->current_period_end;
 
2008
  } elseif ( $customer->delinquent && ! empty( $subscription->current_period_start ) ) {
2009
- return $subscription->current_period_start;
 
2010
  } else {
2011
- return $false; // shouldn't really get here
2012
  }
2013
  }
2014
  }
538
 
539
  //include ours
540
  ?>
541
+ <div id="pmpro_payment_information_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_payment_information_fields' ); ?>"
542
  <?php if ( ! $pmpro_requirebilling || apply_filters( "pmpro_hide_payment_information_fields", false ) ) { ?>style="display: none;"<?php } ?>>
543
  <h3>
544
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e( 'Payment Information', 'paid-memberships-pro' ); ?></span>
545
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php printf( __( 'We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string ); ?></span>
546
  </h3>
547
  <?php $sslseal = pmpro_getOption( "sslseal" ); ?>
548
  <?php if ( ! empty( $sslseal ) ) { ?>
549
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-display-seal' ); ?>">
550
  <?php } ?>
551
  <div class="pmpro_checkout-fields<?php if ( ! empty( $sslseal ) ) { ?> pmpro_checkout-fields-leftcol<?php } ?>">
552
  <?php
553
  $pmpro_include_cardtype_field = apply_filters( 'pmpro_include_cardtype_field', false );
554
  if ( $pmpro_include_cardtype_field ) { ?>
555
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-card-type', 'pmpro_payment-card-type' ); ?>">
556
  <label for="CardType"><?php _e( 'Card Type', 'paid-memberships-pro' ); ?></label>
557
+ <select id="CardType" class="<?php echo pmpro_get_element_class( 'CardType' ); ?>">
558
  <?php foreach ( $pmpro_accepted_credit_cards as $cc ) { ?>
559
  <option value="<?php echo $cc ?>"
560
  <?php if ( $CardType == $cc ) { ?>selected="selected"<?php } ?>><?php echo $cc ?></option>
565
  <input type="hidden" id="CardType" name="CardType"
566
  value="<?php echo esc_attr( $CardType ); ?>"/>
567
  <?php } ?>
568
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-account-number', 'pmpro_payment-account-number' ); ?>">
569
  <label for="AccountNumber"><?php _e( 'Card Number', 'paid-memberships-pro' ); ?></label>
570
  <div id="AccountNumber"></div>
571
  </div>
572
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-expiration', 'pmpro_payment-expiration' ); ?>">
573
  <label for="Expiry"><?php _e( 'Expiration Date', 'paid-memberships-pro' ); ?></label>
574
  <div id="Expiry"></div>
575
  </div>
576
  <?php
577
  $pmpro_show_cvv = apply_filters( "pmpro_show_cvv", true );
578
  if ( $pmpro_show_cvv ) { ?>
579
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-cvv', 'pmpro_payment-cvv' ); ?>">
580
  <label for="CVV"><?php _e( 'CVC', 'paid-memberships-pro' ); ?></label>
581
  <div id="CVV"></div>
582
  </div>
583
  <?php } ?>
584
  <?php if ( $pmpro_show_discount_code ) { ?>
585
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-discount-code', 'pmpro_payment-discount-code' ); ?>">
586
  <label for="discount_code"><?php _e( 'Discount Code', 'paid-memberships-pro' ); ?></label>
587
+ <input class="<?php echo pmpro_get_element_class( 'input', 'discount_code' ); ?>"
588
  id="discount_code" name="discount_code" type="text" size="10"
589
  value="<?php echo esc_attr( $discount_code ) ?>"/>
590
  <input type="button" id="discount_code_button" name="discount_code_button"
591
  value="<?php _e( 'Apply', 'paid-memberships-pro' ); ?>"/>
592
+ <p id="discount_code_message" class="<?php echo pmpro_get_element_class( 'pmpro_message' ); ?>" style="display: none;"></p>
593
  </div>
594
  <?php } ?>
595
  </div> <!-- end pmpro_checkout-fields -->
596
  <?php if ( ! empty( $sslseal ) ) { ?>
597
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-rightcol pmpro_sslseal', 'pmpro_sslseal' ); ?>"><?php echo stripslashes( $sslseal ); ?></div>
598
  </div> <!-- end pmpro_checkout-fields-display-seal -->
599
  <?php } ?>
600
  </div> <!-- end pmpro_payment_information_fields -->
2004
  if ( ! empty( $subscription ) ) {
2005
  $customer = $order->Gateway->getCustomer();
2006
  if ( ! $customer->delinquent && ! empty ( $subscription->current_period_end ) ) {
2007
+ $offset = get_option( 'gmt_offset' );
2008
+ $timestamp = $subscription->current_period_end + ( $offset * 3600 );
2009
  } elseif ( $customer->delinquent && ! empty( $subscription->current_period_start ) ) {
2010
+ $offset = get_option( 'gmt_offset' );
2011
+ $timestamp = $subscription->current_period_start + ( $offset * 3600 );
2012
  } else {
2013
+ $timestamp = $false; // shouldn't really get here
2014
  }
2015
  }
2016
  }
classes/gateways/class.pmprogateway_twocheckout.php CHANGED
@@ -202,7 +202,7 @@
202
  ?>
203
  <span id="pmpro_submit_span">
204
  <input type="hidden" name="submit-checkout" value="1" />
205
- <input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Check Out with 2Checkout', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
206
  </span>
207
  <?php
208
 
202
  ?>
203
  <span id="pmpro_submit_span">
204
  <input type="hidden" name="submit-checkout" value="1" />
205
+ <input type="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php if($pmpro_requirebilling) { _e('Check Out with 2Checkout', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
206
  </span>
207
  <?php
208
 
includes/admin.php CHANGED
@@ -27,10 +27,25 @@ add_action( 'admin_init', 'pmpro_admin_init_redirect_to_dashboard' );
27
  /**
28
  * Block Subscibers from accessing the WordPress Dashboard.
29
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  * @since 2.3
31
  */
32
  function pmpro_block_dashboard() {
33
  global $current_user;
 
34
  $block_dashboard = pmpro_getOption( 'block_dashboard' );
35
 
36
  if ( ! wp_doing_ajax()
@@ -44,9 +59,6 @@ function pmpro_block_dashboard() {
44
  $block = false;
45
  }
46
  $block = apply_filters( 'pmpro_block_dashboard', $block );
47
- if ( $block ) {
48
- wp_redirect( pmpro_url( 'account' ) );
49
- exit;
50
- }
51
  }
52
- add_action( 'admin_init', 'pmpro_block_dashboard', 9 );
27
  /**
28
  * Block Subscibers from accessing the WordPress Dashboard.
29
  *
30
+ * @since 2.3.4
31
+ */
32
+ function pmpro_block_dashboard_redirect() {
33
+ if ( pmpro_block_dashboard() ) {
34
+ wp_redirect( pmpro_url( 'account' ) );
35
+ exit;
36
+ }
37
+ }
38
+ add_action( 'admin_init', 'pmpro_block_dashboard_redirect', 9 );
39
+
40
+ /**
41
+ * Is the current user blocked from the dashboard
42
+ * per the advanced setting.
43
+ *
44
  * @since 2.3
45
  */
46
  function pmpro_block_dashboard() {
47
  global $current_user;
48
+
49
  $block_dashboard = pmpro_getOption( 'block_dashboard' );
50
 
51
  if ( ! wp_doing_ajax()
59
  $block = false;
60
  }
61
  $block = apply_filters( 'pmpro_block_dashboard', $block );
62
+
63
+ return $block;
 
 
64
  }
 
includes/content.php CHANGED
@@ -309,6 +309,18 @@ function pmpro_membership_content_filter($content, $skipcheck = false)
309
  //more link
310
  $content = preg_replace("/\<a.*class\=\"more\-link\".*\>.*\<\/a\>/", "", $content);
311
  }
 
 
 
 
 
 
 
 
 
 
 
 
312
  else
313
  {
314
  //auto generated excerpt. pulled from wp_trim_excerpt
@@ -356,7 +368,7 @@ function pmpro_membership_content_filter($content, $skipcheck = false)
356
  }
357
  }
358
 
359
- $pmpro_content_message_pre = '<div class="pmpro_content_message">';
360
  $pmpro_content_message_post = '</div>';
361
 
362
  $sr_search = array("!!levels!!", "!!referrer!!", "!!login_url!!", "!!login_page_url!!", "!!levels_url!!", "!!levels_page_url!!");
309
  //more link
310
  $content = preg_replace("/\<a.*class\=\"more\-link\".*\>.*\<\/a\>/", "", $content);
311
  }
312
+ elseif(strpos($content, "<!-- wp:more -->") !== false)
313
+ {
314
+ //more block
315
+ $pos = strpos($content, "<!-- wp:more -->");
316
+ $content = wpautop(substr($content, 0, $pos));
317
+ }
318
+ elseif(strpos($content, "<!--more-->") !== false)
319
+ {
320
+ //more tag
321
+ $pos = strpos($content, "<!--more-->");
322
+ $content = wpautop(substr($content, 0, $pos));
323
+ }
324
  else
325
  {
326
  //auto generated excerpt. pulled from wp_trim_excerpt
368
  }
369
  }
370
 
371
+ $pmpro_content_message_pre = '<div class="' . pmpro_get_element_class( 'pmpro_content_message' ) . '">';
372
  $pmpro_content_message_post = '</div>';
373
 
374
  $sr_search = array("!!levels!!", "!!referrer!!", "!!login_url!!", "!!login_page_url!!", "!!levels_url!!", "!!levels_page_url!!");
includes/deprecated.php CHANGED
@@ -31,6 +31,16 @@ function pmpro_init_check_for_deprecated_filters() {
31
  }
32
  add_action( 'init', 'pmpro_init_check_for_deprecated_filters', 99 );
33
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Redirect some old menu items to their new location
36
  */
31
  }
32
  add_action( 'init', 'pmpro_init_check_for_deprecated_filters', 99 );
33
 
34
+ /**
35
+ * Previously used function for class definitions for input fields to see if there was an error.
36
+ *
37
+ * To filter field values, we now recommend using the `pmpro_element_class` filter.
38
+ *
39
+ */
40
+ function pmpro_getClassForField( $field ) {
41
+ pmpro_get_element_class( '', $field );
42
+ }
43
+
44
  /**
45
  * Redirect some old menu items to their new location
46
  */
includes/functions.php CHANGED
@@ -2364,21 +2364,68 @@ function pmpro_showMessage() {
2364
 
2365
  if ( ! empty( $pmpro_msg ) ) {
2366
  ?>
2367
- <div class="<?php echo $pmpro_msgt; ?>">
2368
  <p><?php echo $pmpro_msg; ?></p>
2369
  </div>
2370
  <?php
2371
  }
2372
  }
2373
 
2374
- // used in class definitions for input fields to see if there was an error
2375
- function pmpro_getClassForField( $field ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2376
  global $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields;
2377
- $classes = array();
2378
 
2379
  // error on this field?
2380
- if ( ! empty( $pmpro_error_fields ) && in_array( $field, $pmpro_error_fields ) ) {
2381
- $classes[] = 'pmpro_error';
2382
  }
2383
 
2384
  if ( is_array( $pmpro_required_billing_fields ) && is_array( $pmpro_required_user_fields ) ) {
@@ -2392,18 +2439,16 @@ function pmpro_getClassForField( $field ) {
2392
  }
2393
 
2394
  // required?
2395
- if ( in_array( $field, $required_fields ) ) {
2396
- $classes[] = 'pmpro_required';
2397
  }
2398
 
2399
- $classes = apply_filters( 'pmpro_field_classes', $classes, $field );
 
2400
 
2401
- if ( ! empty( $classes ) ) {
2402
- return implode( ' ', $classes );
2403
- } else {
2404
- return '';
2405
- }
2406
  }
 
2407
 
2408
  // get a var from $_GET or $_POST
2409
  function pmpro_getParam( $index, $method = 'REQUEST', $default = '', $sanitize_function = 'sanitize_text_field' ) {
2364
 
2365
  if ( ! empty( $pmpro_msg ) ) {
2366
  ?>
2367
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_msg ' . $pmpro_msgt, $pmpro_msgt ); ?>">
2368
  <p><?php echo $pmpro_msg; ?></p>
2369
  </div>
2370
  <?php
2371
  }
2372
  }
2373
 
2374
+ /**
2375
+ * Return all CSS class names for the specified element and allow custom class names to be used via filter.
2376
+ *
2377
+ * @since 2.3.4
2378
+ *
2379
+ * @param mixed $class A string or array of element class names.
2380
+ * @param string $element The element to return class names for.
2381
+ *
2382
+ * @return string $class A string of class names separated by spaces.
2383
+ *
2384
+ */
2385
+ function pmpro_get_element_class( $class, $element = null ) {
2386
+ if ( empty( $element ) ) {
2387
+ $element = $class;
2388
+ }
2389
+
2390
+ // Convert class values to an array.
2391
+ if ( ! is_array( $class ) ) {
2392
+ $class = explode( ' ', trim( $class ) );
2393
+ }
2394
+
2395
+ // Escape elements of the array of class names.
2396
+ $class = array_map( 'esc_attr', $class );
2397
+
2398
+ /**
2399
+ * Filters the list of CSS class names for the current element.
2400
+ *
2401
+ * @since 2.3.4
2402
+ *
2403
+ * @param array $class An array of element class names.
2404
+ * @param string $element The element to return class names for.
2405
+ */
2406
+ $class = apply_filters( 'pmpro_element_class', $class, $element );
2407
+
2408
+ if ( ! empty( $class ) ) {
2409
+ $class = array_unique( $class );
2410
+ return implode( ' ', $class );
2411
+ } else {
2412
+ return '';
2413
+ }
2414
+ }
2415
+
2416
+ /**
2417
+ * Return field state-specific CSS class names for the field.
2418
+ *
2419
+ * @since 2.3.4
2420
+ *
2421
+ * Callback for the pmpro_element_class filter.
2422
+ */
2423
+ function pmpro_get_field_class( $class, $element ) {
2424
  global $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields;
 
2425
 
2426
  // error on this field?
2427
+ if ( ! empty( $pmpro_error_fields ) && in_array( $element, $pmpro_error_fields ) ) {
2428
+ $class[] = 'pmpro_error';
2429
  }
2430
 
2431
  if ( is_array( $pmpro_required_billing_fields ) && is_array( $pmpro_required_user_fields ) ) {
2439
  }
2440
 
2441
  // required?
2442
+ if ( in_array( $element, $required_fields ) ) {
2443
+ $class[] = 'pmpro_required';
2444
  }
2445
 
2446
+ // DEPRECATED: Use pmpro_element_class to filter classes instead.
2447
+ $class = apply_filters( 'pmpro_field_classes', $class, $element );
2448
 
2449
+ return $class;
 
 
 
 
2450
  }
2451
+ add_filter( 'pmpro_element_class', 'pmpro_get_field_class', 10, 2 );
2452
 
2453
  // get a var from $_GET or $_POST
2454
  function pmpro_getParam( $index, $method = 'REQUEST', $default = '', $sanitize_function = 'sanitize_text_field' ) {
includes/login.php CHANGED
@@ -108,6 +108,27 @@ function pmpro_login_url_filter( $login_url='', $redirect='' ) {
108
  }
109
  add_filter( 'login_url', 'pmpro_login_url_filter', 50, 2 );
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Get a link to the PMPro login page.
113
  * Or fallback to WP default.
@@ -348,7 +369,12 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
348
 
349
  // Get Errors from password reset.
350
  if ( isset( $_REQUEST['errors'] ) ) {
351
- switch ( sanitize_text_field( $_REQUEST['errors'] ) ) {
 
 
 
 
 
352
  case 'invalidcombo':
353
  $message = __( 'There is no account with that username or email address.', 'paid-memberships-pro' );
354
  $msgt = 'pmpro_error';
@@ -376,7 +402,7 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
376
 
377
  // Note we don't show messages on the widget form.
378
  if ( $message && $location !== 'widget' ) {
379
- echo '<div class="pmpro_message ' . esc_attr( $msgt ) . '">'. esc_html( $message ) .'</div>';
380
  }
381
 
382
  // Get the form title HTML tag.
@@ -407,7 +433,7 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
407
  $redirect_to = esc_url( site_url( $_SERVER['REQUEST_URI'] ) );
408
  }
409
  ?>
410
- <div class="pmpro_login_wrap">
411
  <?php
412
  if ( ! pmpro_is_login_page() ) {
413
  echo $before_title . esc_html( 'Log In', 'paid-memberships-pro' ) . $after_title;
@@ -429,13 +455,13 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
429
  } elseif ( $location !== 'widget' && ( $action === 'reset_pass' || ( $action === 'rp' && in_array( $_REQUEST['login'], array( 'invalidkey', 'expiredkey' ) ) ) ) ) {
430
  // Reset password form.
431
  ?>
432
- <div class="pmpro_lost_password_wrap">
433
  <?php
434
  if ( ! pmpro_is_login_page() ) {
435
  echo $before_title . esc_html( 'Password Reset', 'paid-memberships-pro' ) . $after_title;
436
  }
437
  ?>
438
- <p class="pmpro_lost_password-instructions">
439
  <?php
440
  esc_html_e( 'Please enter your username or email address. You will receive a link to create a new password via email.', 'paid-memberships-pro' );
441
  ?>
@@ -449,7 +475,7 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
449
  } elseif ( $location !== 'widget' && $action === 'rp' ) {
450
  // Password reset processing key.
451
  ?>
452
- <div class="pmpro_reset_password_wrap">
453
  <?php
454
  if ( ! pmpro_is_login_page() ) {
455
  echo $before_title . esc_html( 'Reset Password', 'paid-memberships-pro' ) . $after_title;
@@ -464,7 +490,7 @@ function pmpro_login_forms_handler( $show_menu = true, $show_logout_link = true,
464
  if ( isset( $_REQUEST['login'] ) && isset( $_REQUEST['key'] ) ) {
465
  esc_html_e( 'You are already signed in.', 'paid-memberships-pro' );
466
  } elseif ( ! empty( $display_if_logged_in ) ) { ?>
467
- <div class="pmpro_logged_in_welcome_wrap">
468
  <?php pmpro_logged_in_welcome( $show_menu, $show_logout_link ); ?>
469
  </div> <!-- end pmpro_logged_in_welcome_wrap -->
470
  <?php
@@ -494,15 +520,15 @@ function pmpro_login_form( $args = array() ) {
494
  * @since 2.3
495
  */
496
  function pmpro_lost_password_form() { ?>
497
- <form id="lostpasswordform" class="pmpro_form" action="<?php echo wp_lostpassword_url(); ?>" method="post">
498
- <div class="pmpro_lost_password-fields">
499
- <div class="pmpro_lost_password-field pmpro_lost_password-field-user_login">
500
  <label for="user_login"><?php esc_html_e( 'Username or Email Address', 'paid-memberships-pro' ); ?></label>
501
- <input type="text" name="user_login" id="user_login" class="input" size="20" />
502
  </div>
503
  </div> <!-- end pmpro_lost_password-fields -->
504
- <div class="pmpro_submit">
505
- <input type="submit" name="submit" class="pmpro_btn pmpro_btn-submit" value="<?php esc_attr_e( 'Get New Password', 'paid-memberships-pro' ); ?>" />
506
  </div>
507
  </form>
508
  <?php
@@ -581,23 +607,23 @@ function pmpro_reset_password_form() {
581
  if ( isset( $_REQUEST['error'] ) ) {
582
  $error_codes = explode( ',', sanitize_text_field( $_REQUEST['error'] ) );
583
  } ?>
584
- <form name="resetpassform" id="resetpassform" class="pmpro_form" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass' ) ); ?>" method="post" autocomplete="off">
585
  <input type="hidden" id="user_login" name="rp_login" value="<?php echo esc_attr( sanitize_text_field( $_REQUEST['login'] ) ); ?>" autocomplete="off" />
586
  <input type="hidden" name="rp_key" value="<?php echo esc_attr( sanitize_text_field( $_REQUEST['key'] ) ); ?>" />
587
- <div class="pmpro_reset_password-fields">
588
- <div class="pmpro_reset_password-field pmpro_reset_password-field-pass1">
589
  <label for="pass1"><?php esc_html_e( 'New Password', 'paid-memberships-pro' ) ?></label>
590
- <input type="password" name="pass1" id="pass1" class="input pass1" size="20" value="" autocomplete="off" />
591
  <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength Indicator', 'paid-memberships-pro' ); ?></div>
592
- <p class="lite"><?php echo wp_get_password_hint(); ?></p>
593
  </div>
594
- <div class="pmpro_reset_password-field pmpro_reset_password-field-pass2">
595
  <label for="pass2"><?php esc_html_e( 'Confirm New Password', 'paid-memberships-pro' ) ?></label>
596
- <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
597
  </div>
598
  </div> <!-- end pmpro_reset_password-fields -->
599
- <div class="pmpro_submit">
600
- <input type="submit" name="submit" id="resetpass-button" class="pmpro_btn pmpro_btn-submit" value="<?php esc_attr_e( 'Reset Password', 'paid-memberships-pro' ); ?>" />
601
  </div>
602
  </form>
603
  <?php
@@ -609,7 +635,7 @@ function pmpro_reset_password_form() {
609
  */
610
  function pmpro_login_forms_handler_nav( $pmpro_form ) { ?>
611
  <hr />
612
- <p class="pmpro_actions_nav">
613
  <?php
614
  // Build the links to return.
615
  $links = array();
@@ -717,7 +743,9 @@ add_action( 'login_form_rp', 'pmpro_do_password_reset' );
717
  add_action( 'login_form_resetpass', 'pmpro_do_password_reset' );
718
 
719
  /**
720
- * Replace the default URL inside the email with the membership account page login URL instead.
 
 
721
  * @since 2.3
722
  */
723
  function pmpro_password_reset_email_filter( $message, $key, $user_login, $user_data ) {
@@ -732,6 +760,24 @@ function pmpro_password_reset_email_filter( $message, $key, $user_login, $user_d
732
  }
733
  add_filter( 'retrieve_password_message', 'pmpro_password_reset_email_filter', 10, 4 );
734
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
  /**
736
  * Authenticate the frontend user login.
737
  *
@@ -817,7 +863,7 @@ function pmpro_logged_in_welcome( $show_menu = true, $show_logout_link = true )
817
  $user_account_link = '<a href="' . esc_url( admin_url( 'profile.php' ) ) . '">' . esc_html( preg_replace( '/\@.*/', '', $current_user->display_name ) ) . '</a>';
818
  }
819
  ?>
820
- <h3 class="pmpro_member_display_name">
821
  <?php
822
  /* translators: a generated link to the user's account or profile page */
823
  printf( esc_html__( 'Welcome, %s', 'paid-memberships-pro' ), $user_account_link );
@@ -854,7 +900,7 @@ function pmpro_logged_in_welcome( $show_menu = true, $show_logout_link = true )
854
  *
855
  */
856
  if ( ! empty ( $show_logout_link ) ) { ?>
857
- <div class="pmpro_member_log_out"><a href="<?php echo esc_url( wp_logout_url() ); ?>"><?php esc_html_e( 'Log Out', 'paid-memberships-pro' ); ?></a></div>
858
  <?php
859
  }
860
  }
108
  }
109
  add_filter( 'login_url', 'pmpro_login_url_filter', 50, 2 );
110
 
111
+ /**
112
+ * Make sure confirm_admin_email actions go to the default WP login page.
113
+ * Our login page is not set up to handle them.
114
+ */
115
+ function pmpro_use_default_login_for_confirm_admin_email( $location ) {
116
+ if ( strpos( $location, 'action=confirm_admin_email' ) !== false ) {
117
+ $login_url = wp_login_url();
118
+
119
+ remove_filter( 'login_url', 'pmpro_login_url_filter', 50, 2 );
120
+ $default_login_url = wp_login_url();
121
+ add_filter( 'login_url', 'pmpro_login_url_filter', 50, 2 );
122
+
123
+ if ( $login_url != $default_login_url ) {
124
+ $location = str_replace( $login_url, $default_login_url, $location );
125
+ }
126
+ }
127
+
128
+ return $location;
129
+ }
130
+ add_filter( 'wp_redirect', 'pmpro_use_default_login_for_confirm_admin_email' );
131
+
132
  /**
133
  * Get a link to the PMPro login page.
134
  * Or fallback to WP default.
369
 
370
  // Get Errors from password reset.
371
  if ( isset( $_REQUEST['errors'] ) ) {
372
+ $password_reset_errors = sanitize_text_field( $_REQUEST['errors'] );
373
+ } elseif ( isset( $_REQUEST['error'] ) ) {
374
+ $password_reset_errors = sanitize_text_field( $_REQUEST['error'] );
375
+ }
376
+ if ( isset( $password_reset_errors ) ) {
377
+ switch ( $password_reset_errors ) {
378
  case 'invalidcombo':
379
  $message = __( 'There is no account with that username or email address.', 'paid-memberships-pro' );
380
  $msgt = 'pmpro_error';
402
 
403
  // Note we don't show messages on the widget form.
404
  if ( $message && $location !== 'widget' ) {
405
+ echo '<div class="' . pmpro_get_element_class( 'pmpro_message ' . $msgt, esc_attr( $msgt ) ) . '">'. esc_html( $message ) .'</div>';
406
  }
407
 
408
  // Get the form title HTML tag.
433
  $redirect_to = esc_url( site_url( $_SERVER['REQUEST_URI'] ) );
434
  }
435
  ?>
436
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_login_wrap' ); ?>">
437
  <?php
438
  if ( ! pmpro_is_login_page() ) {
439
  echo $before_title . esc_html( 'Log In', 'paid-memberships-pro' ) . $after_title;
455
  } elseif ( $location !== 'widget' && ( $action === 'reset_pass' || ( $action === 'rp' && in_array( $_REQUEST['login'], array( 'invalidkey', 'expiredkey' ) ) ) ) ) {
456
  // Reset password form.
457
  ?>
458
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_lost_password_wrap' ); ?>">
459
  <?php
460
  if ( ! pmpro_is_login_page() ) {
461
  echo $before_title . esc_html( 'Password Reset', 'paid-memberships-pro' ) . $after_title;
462
  }
463
  ?>
464
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_lost_password-instructions' ); ?>">
465
  <?php
466
  esc_html_e( 'Please enter your username or email address. You will receive a link to create a new password via email.', 'paid-memberships-pro' );
467
  ?>
475
  } elseif ( $location !== 'widget' && $action === 'rp' ) {
476
  // Password reset processing key.
477
  ?>
478
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_reset_password_wrap' ); ?>">
479
  <?php
480
  if ( ! pmpro_is_login_page() ) {
481
  echo $before_title . esc_html( 'Reset Password', 'paid-memberships-pro' ) . $after_title;
490
  if ( isset( $_REQUEST['login'] ) && isset( $_REQUEST['key'] ) ) {
491
  esc_html_e( 'You are already signed in.', 'paid-memberships-pro' );
492
  } elseif ( ! empty( $display_if_logged_in ) ) { ?>
493
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_logged_in_welcome_wrap' ); ?>">
494
  <?php pmpro_logged_in_welcome( $show_menu, $show_logout_link ); ?>
495
  </div> <!-- end pmpro_logged_in_welcome_wrap -->
496
  <?php
520
  * @since 2.3
521
  */
522
  function pmpro_lost_password_form() { ?>
523
+ <form id="lostpasswordform" class="<?php echo pmpro_get_element_class( 'pmpro_form', 'lostpasswordform' ); ?>" action="<?php echo wp_lostpassword_url(); ?>" method="post">
524
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_lost_password-fields' ); ?>">
525
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_lost_password-field pmpro_lost_password-field-user_login', 'pmpro_lost_password-field-user_login' ); ?>">
526
  <label for="user_login"><?php esc_html_e( 'Username or Email Address', 'paid-memberships-pro' ); ?></label>
527
+ <input type="text" name="user_login" id="user_login" class="<?php echo pmpro_get_element_class( 'input', 'user_login' ); ?>" size="20" />
528
  </div>
529
  </div> <!-- end pmpro_lost_password-fields -->
530
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
531
+ <input type="submit" name="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit', 'pmpro_btn-submit' ); ?>" value="<?php esc_attr_e( 'Get New Password', 'paid-memberships-pro' ); ?>" />
532
  </div>
533
  </form>
534
  <?php
607
  if ( isset( $_REQUEST['error'] ) ) {
608
  $error_codes = explode( ',', sanitize_text_field( $_REQUEST['error'] ) );
609
  } ?>
610
+ <form name="resetpassform" id="resetpassform" class="<?php echo pmpro_get_element_class( 'pmpro_form', 'resetpassform' ); ?>" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass' ) ); ?>" method="post" autocomplete="off">
611
  <input type="hidden" id="user_login" name="rp_login" value="<?php echo esc_attr( sanitize_text_field( $_REQUEST['login'] ) ); ?>" autocomplete="off" />
612
  <input type="hidden" name="rp_key" value="<?php echo esc_attr( sanitize_text_field( $_REQUEST['key'] ) ); ?>" />
613
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_reset_password-fields' ); ?>">
614
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_reset_password-field pmpro_reset_password-field-pass1', 'pmpro_reset_password-field-pass1' ); ?>">
615
  <label for="pass1"><?php esc_html_e( 'New Password', 'paid-memberships-pro' ) ?></label>
616
+ <input type="password" name="pass1" id="pass1" class="<?php echo pmpro_get_element_class( 'input pass1', 'pass1' ); ?>" size="20" value="" autocomplete="off" />
617
  <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength Indicator', 'paid-memberships-pro' ); ?></div>
618
+ <p class="<?php echo pmpro_get_element_class( 'lite' ); ?>"><?php echo wp_get_password_hint(); ?></p>
619
  </div>
620
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_reset_password-field pmpro_reset_password-field-pass2', 'pmpro_reset_password-field-pass2' ); ?>">
621
  <label for="pass2"><?php esc_html_e( 'Confirm New Password', 'paid-memberships-pro' ) ?></label>
622
+ <input type="password" name="pass2" id="pass2" class="<?php echo pmpro_get_element_class( 'input', 'pass2' ); ?>" size="20" value="" autocomplete="off" />
623
  </div>
624
  </div> <!-- end pmpro_reset_password-fields -->
625
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
626
+ <input type="submit" name="submit" id="resetpass-button" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit', 'pmpro_btn-submit' ); ?>" value="<?php esc_attr_e( 'Reset Password', 'paid-memberships-pro' ); ?>" />
627
  </div>
628
  </form>
629
  <?php
635
  */
636
  function pmpro_login_forms_handler_nav( $pmpro_form ) { ?>
637
  <hr />
638
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
639
  <?php
640
  // Build the links to return.
641
  $links = array();
743
  add_action( 'login_form_resetpass', 'pmpro_do_password_reset' );
744
 
745
  /**
746
+ * Replace the default URL inside the password reset email
747
+ * with the membership account page login URL instead.
748
+ *
749
  * @since 2.3
750
  */
751
  function pmpro_password_reset_email_filter( $message, $key, $user_login, $user_data ) {
760
  }
761
  add_filter( 'retrieve_password_message', 'pmpro_password_reset_email_filter', 10, 4 );
762
 
763
+ /**
764
+ * Replace the default login URL in the new user notification email
765
+ * with the membership account page login URL instead.
766
+ *
767
+ * @since 2.3.4
768
+ */
769
+ function pmpro_new_user_notification_email_filter( $message, $user, $blogname ) {
770
+
771
+ $login_page_id = pmpro_getOption( 'login_page_id' );
772
+ if ( ! empty ( $login_page_id ) ) {
773
+ $login_url = get_permalink( $login_page_id );
774
+ $message = str_replace( network_site_url( 'wp-login.php' ), $login_url, $message );
775
+ }
776
+
777
+ return $message;
778
+ }
779
+ add_filter( 'wp_new_user_notification_email', 'pmpro_new_user_notification_email_filter', 10, 3 );
780
+
781
  /**
782
  * Authenticate the frontend user login.
783
  *
863
  $user_account_link = '<a href="' . esc_url( admin_url( 'profile.php' ) ) . '">' . esc_html( preg_replace( '/\@.*/', '', $current_user->display_name ) ) . '</a>';
864
  }
865
  ?>
866
+ <h3 class="<?php echo pmpro_get_element_class( 'pmpro_member_display_name' ); ?>">
867
  <?php
868
  /* translators: a generated link to the user's account or profile page */
869
  printf( esc_html__( 'Welcome, %s', 'paid-memberships-pro' ), $user_account_link );
900
  *
901
  */
902
  if ( ! empty ( $show_logout_link ) ) { ?>
903
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_member_log_out' ); ?>"><a href="<?php echo esc_url( wp_logout_url() ); ?>"><?php esc_html_e( 'Log Out', 'paid-memberships-pro' ); ?></a></div>
904
  <?php
905
  }
906
  }
includes/profile.php CHANGED
@@ -20,7 +20,7 @@ function pmpro_membership_level_profile_fields($user)
20
  if(!current_user_can($membership_level_capability))
21
  return false;
22
 
23
- global $wpdb;
24
  $user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
25
 
26
  $levels = $wpdb->get_results( "SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT );
@@ -89,29 +89,20 @@ function pmpro_membership_level_profile_fields($user)
89
  $user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
90
  $end_date = (!empty($user->membership_level) && !empty($user->membership_level->enddate)); // Returned as UTC timestamp
91
 
92
- // Convert UTC to local time
93
- if ( $end_date ) {
94
- $user->membership_level->enddate = strtotime( $wp_tz, $user->membership_level->enddate );
95
- }
96
-
97
  //some vars for the dates
98
- $current_day = date("j", current_time('timestamp'));
99
- if($end_date)
100
- $selected_expires_day = date("j", $user->membership_level->enddate);
101
- else
102
- $selected_expires_day = $current_day;
103
-
104
- $current_month = date("M", current_time('timestamp'));
105
- if($end_date)
106
- $selected_expires_month = date("m", $user->membership_level->enddate);
107
- else
108
- $selected_expires_month = date("m");
109
-
110
- $current_year = date("Y", current_time('timestamp'));
111
- if($end_date)
112
- $selected_expires_year = date("Y", $user->membership_level->enddate);
113
- else
114
- $selected_expires_year = (int)$current_year + 1;
115
  ?>
116
  <tr>
117
  <th><label for="expiration"><?php _e("Expires", 'paid-memberships-pro' ); ?></label></th>
@@ -127,7 +118,7 @@ function pmpro_membership_level_profile_fields($user)
127
  for($i = 1; $i < 13; $i++)
128
  {
129
  ?>
130
- <option value="<?php echo $i?>" <?php if($i == $selected_expires_month) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/15/" . $current_year, current_time("timestamp")))?></option>
131
  <?php
132
  }
133
  ?>
@@ -430,11 +421,11 @@ function pmpro_sanitize( $value ) {
430
  *
431
  * @since 2.3
432
  */
433
- function pmpro_member_profile_edit_form() {
434
  global $current_user;
435
 
436
  if ( ! is_user_logged_in() ) {
437
- echo '<div class="pmpro_message pmpro_alert"><a href="' . esc_url( pmpro_login_url() ) . '">' . esc_html__( 'Log in to edit your profile.', 'paid-memberships-pro' ) . '</a></div>';
438
  return;
439
  }
440
 
@@ -454,8 +445,8 @@ function pmpro_member_profile_edit_form() {
454
  $errors = array();
455
 
456
  // Get all values from the $_POST, sanitize them, and build the $user object.
457
- if ( isset( $_POST['email'] ) ) {
458
- $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
459
  }
460
  if ( isset( $_POST['first_name'] ) ) {
461
  $user->first_name = sanitize_text_field( $_POST['first_name'] );
@@ -472,12 +463,12 @@ function pmpro_member_profile_edit_form() {
472
  if ( empty( $user->display_name ) ) {
473
  $errors[] = __( 'Please enter a display name.', 'paid-memberships-pro' );
474
  }
475
-
476
  // Don't allow admins to change their email address.
477
  if ( current_user_can( 'manage_options' ) ) {
478
  $user->user_email = $current_user->user_email;
479
  }
480
-
481
  // Validate email address.
482
  if ( empty( $user->user_email ) ) {
483
  $errors[] = __( 'Please enter an email address.', 'paid-memberships-pro' );
@@ -492,7 +483,7 @@ function pmpro_member_profile_edit_form() {
492
 
493
  // Show error messages.
494
  if ( ! empty( $errors ) ) { ?>
495
- <div class="pmpro_message pmpro_error">
496
  <?php
497
  foreach ( $errors as $key => $value ) {
498
  echo '<p>' . $value . '</p>';
@@ -503,7 +494,7 @@ function pmpro_member_profile_edit_form() {
503
  // Save updated profile fields.
504
  wp_update_user( $user );
505
  ?>
506
- <div class="pmpro_message pmpro_success">
507
  <?php _e( 'Your profile has been updated.', 'paid-memberships-pro' ); ?>
508
  </div>
509
  <?php }
@@ -512,40 +503,35 @@ function pmpro_member_profile_edit_form() {
512
  $user = $current_user;
513
  }
514
  ?>
515
- <div class="pmpro_member_profile_edit_wrap">
516
- <form id="member-profile-edit" class="pmpro_form" action="" method="post">
517
 
518
  <?php wp_nonce_field( 'update-user_' . $current_user->ID, 'update_user_nonce' ); ?>
519
 
520
- <div class="pmpro_checkout_box-user">
521
- <div class="pmpro_member_profile_edit-fields">
522
- <div class="pmpro_member_profile_edit-field pmpro_member_profile_edit-field-first_name">
523
- <label for="first_name"><?php _e( 'First Name', 'paid-memberships-pro' ); ?></label>
524
- <input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $user->first_name ); ?>" class="input <?php echo pmpro_getClassForField( 'first_name' );?>" />
525
- </div> <!-- end pmpro_member_profile_edit-field-first_name -->
526
-
527
- <div class="pmpro_member_profile_edit-field pmpro_member_profile_edit-field-last_name">
528
- <label for="last_name"><?php _e( 'Last Name', 'paid-memberships-pro' ); ?></label>
529
- <input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $user->last_name ); ?>" class="input <?php echo pmpro_getClassForField( 'last_name' );?>" />
530
- </div> <!-- end pmpro_member_profile_edit-field-last_name -->
531
-
532
- <div class="pmpro_member_profile_edit-field pmpro_member_profile_edit-field-display_name">
533
- <label for="display_name"><?php _e( 'Display name publicly as', 'paid-memberships-pro' ); ?></label>
534
- <input type="text" name="display_name" id="display_name" value="<?php echo esc_attr( $user->display_name ); ?>" class="input <?php echo pmpro_getClassForField( 'display_name' );?>" />
535
- <span class="pmpro_asterisk"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
536
- </div> <!-- end pmpro_member_profile_edit-field-display_name -->
537
-
538
- <div class="pmpro_member_profile_edit-field pmpro_member_profile_edit-field-email">
539
- <label for="email"><?php _e( 'Email', 'paid-memberships-pro' ); ?></label>
540
-
541
- <?php if ( current_user_can( 'manage_options' ) ) { ?>
542
- <input type="text" readonly="readonly" name="email" id="email" value="<?php echo esc_attr( $user->user_email ); ?>" class="input <?php echo pmpro_getClassForField( 'email' );?>" />
543
- <p class="lite"><?php esc_html_e( 'Site administrators must use the WordPress dashboard to update their email address.', 'paid-memberships-pro' ); ?></p>
544
  <?php } else { ?>
545
- <input type="email" name="email" id="email" value="<?php echo esc_attr( $user->user_email ); ?>" class="input <?php echo pmpro_getClassForField( 'email' );?>" />
546
- <span class="pmpro_asterisk"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
547
  <?php } ?>
548
- </div>
 
549
  </div> <!-- end pmpro_member_profile_edit-fields -->
550
  </div> <!-- end pmpro_checkout_box-user -->
551
 
@@ -561,10 +547,10 @@ function pmpro_member_profile_edit_form() {
561
  ?>
562
  <input type="hidden" name="action" value="update-profile" />
563
  <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>" />
564
- <div class="pmpro_submit">
565
  <hr />
566
- <input type="submit" name="submit" class="pmpro_btn pmpro_btn-submit" value="<?php _e( 'Update Profile', 'paid-memberships-pro' );?>" />
567
- <input type="button" name="cancel" class="pmpro_btn pmpro_btn-cancel" value="<?php _e( 'Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo pmpro_url( 'account'); ?>';" />
568
  </div>
569
  </form>
570
  </div> <!-- end pmpro_member_profile_edit_wrap -->
@@ -579,23 +565,23 @@ function pmpro_member_profile_edit_form() {
579
  *
580
  * @since 2.3
581
  */
582
- function pmpro_change_password_process() {
583
  global $current_user;
584
-
585
  // Make sure we're on the right page.
586
  if ( empty( $_POST['action'] ) || $_POST['action'] != 'change-password' ) {
587
  return;
588
  }
589
-
590
  // Only let users change their own password.
591
  if ( empty( $current_user ) || empty( $_POST['user_id'] ) || $current_user->ID != $_POST['user_id'] ) {
592
  return;
593
  }
594
-
595
  // Check the nonce.
596
  if ( ! wp_verify_nonce( $_POST['change_password_user_nonce'], 'change-password-user_' . $current_user->ID ) ) {
597
  return;
598
- }
599
 
600
  // Get all password values from the $_POST.
601
  if ( ! empty( $_POST['password_current'] ) ) {
@@ -613,7 +599,7 @@ function pmpro_change_password_process() {
613
  } else {
614
  $pass2 = '';
615
  }
616
-
617
  // Check that all password information is correct.
618
  $error = false;
619
  if ( isset( $password_current ) && ( empty( $pass1 ) || empty( $pass2 ) ) ) {
@@ -625,15 +611,15 @@ function pmpro_change_password_process() {
625
  } elseif ( ! empty( $pass1 ) && ! wp_check_password( $password_current, $current_user->user_pass, $current_user->ID ) ) {
626
  $error = __( 'Your current password is incorrect.', 'paid-memberships-pro' );
627
  }
628
-
629
  // Change the password.
630
  if ( ! empty( $pass1 ) && empty( $error ) ) {
631
  wp_set_password( $pass1, $current_user->ID );
632
-
633
  //setting some cookies
634
  wp_set_current_user( $current_user->ID, $current_user->user_login );
635
  wp_set_auth_cookie( $current_user->ID, true, apply_filters( 'pmpro_checkout_signon_secure', force_ssl_admin() ) );
636
-
637
  pmpro_setMessage( __( 'Your password has been updated.', 'paid-memberships-pro' ), 'pmpro_success' );
638
  } else {
639
  pmpro_setMessage( $error, 'pmpro_error' );
@@ -647,48 +633,48 @@ add_action( 'init', 'pmpro_change_password_process' );
647
  *
648
  * @since 2.3
649
  */
650
- function pmpro_change_password_form() {
651
- global $current_user, $pmpro_msg, $pmpro_msgt;
652
  ?>
653
  <h2><?php _e( 'Change Password', 'paid-memberships-pro' ); ?></h2>
654
  <?php if ( ! empty( $pmpro_msg ) ) { ?>
655
- <div class="pmpro_message <?php echo esc_attr( $pmpro_msgt ); ?>">
656
  <?php echo esc_html( $pmpro_msg ); ?>
657
  </div>
658
  <?php } ?>
659
- <div class="pmpro_change_password_wrap">
660
- <form id="change-password" class="pmpro_form" action="" method="post">
661
 
662
  <?php wp_nonce_field( 'change-password-user_' . $current_user->ID, 'change_password_user_nonce' ); ?>
663
 
664
- <div class="pmpro_checkout_box-password">
665
- <div class="pmpro_change_password-fields">
666
- <div class="pmpro_change_password-field pmpro_change_password-field-password_current">
667
  <label for="password_current"><?php _e( 'Current Password', 'paid-memberships-pro' ); ?></label></th>
668
- <input type="password" name="password_current" id="password_current" value="" class="input <?php echo pmpro_getClassForField( 'password_current' );?>" />
669
- <span class="pmpro_asterisk"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
670
  </div> <!-- end pmpro_change_password-field-password_current -->
671
- <div class="pmpro_change_password-field pmpro_change_password-field-pass1">
672
  <label for="pass1"><?php _e( 'New Password', 'paid-memberships-pro' ); ?></label></th>
673
- <input type="password" name="pass1" id="pass1" value="" class="input pass1 <?php echo pmpro_getClassForField( 'pass1' );?>" autocomplete="off" />
674
- <span class="pmpro_asterisk"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
675
  <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength Indicator', 'paid-memberships-pro' ); ?></div>
676
- <p class="lite"><?php echo wp_get_password_hint(); ?></p>
677
  </div> <!-- end pmpro_change_password-field-pass1 -->
678
- <div class="pmpro_change_password-field pmpro_change_password-field-pass2">
679
  <label for="pass2"><?php _e( 'Confirm New Password', 'paid-memberships-pro' ); ?></label></th>
680
- <input type="password" name="pass2" id="pass2" value="" class="input <?php echo pmpro_getClassForField( 'pass2' );?>" autocomplete="off" />
681
- <span class="pmpro_asterisk"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
682
  </div> <!-- end pmpro_change_password-field-pass2 -->
683
  </div> <!-- end pmpro_change_password-fields -->
684
  </div> <!-- end pmpro_checkout_box-password -->
685
 
686
  <input type="hidden" name="action" value="change-password" />
687
  <input type="hidden" name="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
688
- <div class="pmpro_submit">
689
  <hr />
690
- <input type="submit" class="pmpro_btn pmpro_btn-submit" value="<?php esc_attr_e('Change Password', 'paid-memberships-pro' );?>" />
691
- <input type="button" name="cancel" class="pmpro_btn pmpro_btn-cancel" value="<?php esc_attr_e('Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo esc_url( pmpro_url( 'account') ); ?>';" />
692
  </div>
693
  </form>
694
  </div> <!-- end pmpro_change_password_wrap -->
20
  if(!current_user_can($membership_level_capability))
21
  return false;
22
 
23
+ global $wpdb;
24
  $user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
25
 
26
  $levels = $wpdb->get_results( "SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT );
89
  $user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
90
  $end_date = (!empty($user->membership_level) && !empty($user->membership_level->enddate)); // Returned as UTC timestamp
91
 
 
 
 
 
 
92
  //some vars for the dates
93
+ if( $end_date && 'UTC' === $wp_tz ) {
94
+ $selected_expires_day = date( 'j', $user->membership_level->enddate );
95
+ $selected_expires_month = date( 'm', $user->membership_level->enddate );
96
+ $selected_expires_year = date( 'Y', $user->membership_level->enddate );
97
+ } elseif( $end_date ) {
98
+ $selected_expires_day = get_gmt_from_date( date( 'Y-m-d H:i:s', $user->membership_level->enddate ), 'j' );
99
+ $selected_expires_month = get_gmt_from_date( date( 'Y-m-d H:i:s', $user->membership_level->enddate ), 'm' );
100
+ $selected_expires_year = get_gmt_from_date( date( 'Y-m-d H:i:s', $user->membership_level->enddate ), 'Y' );
101
+ } else {
102
+ $selected_expires_day = date( 'j', current_time('timestamp') );
103
+ $selected_expires_month = date( 'm', current_time('timestamp') );
104
+ $selected_expires_year = date( 'Y', current_time('timestamp') ) + 1;
105
+ }
 
 
 
 
106
  ?>
107
  <tr>
108
  <th><label for="expiration"><?php _e("Expires", 'paid-memberships-pro' ); ?></label></th>
118
  for($i = 1; $i < 13; $i++)
119
  {
120
  ?>
121
+ <option value="<?php echo $i?>" <?php if($i == $selected_expires_month) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/15/" . date("Y", current_time( 'timestamp' ) ), current_time("timestamp")))?></option>
122
  <?php
123
  }
124
  ?>
421
  *
422
  * @since 2.3
423
  */
424
+ function pmpro_member_profile_edit_form() {
425
  global $current_user;
426
 
427
  if ( ! is_user_logged_in() ) {
428
+ echo '<div class="' . pmpro_get_element_class( 'pmpro_message pmpro_alert', 'pmpro_alert' ) . '"><a href="' . esc_url( pmpro_login_url() ) . '">' . esc_html__( 'Log in to edit your profile.', 'paid-memberships-pro' ) . '</a></div>';
429
  return;
430
  }
431
 
445
  $errors = array();
446
 
447
  // Get all values from the $_POST, sanitize them, and build the $user object.
448
+ if ( isset( $_POST['user_email'] ) ) {
449
+ $user->user_email = sanitize_text_field( wp_unslash( $_POST['user_email'] ) );
450
  }
451
  if ( isset( $_POST['first_name'] ) ) {
452
  $user->first_name = sanitize_text_field( $_POST['first_name'] );
463
  if ( empty( $user->display_name ) ) {
464
  $errors[] = __( 'Please enter a display name.', 'paid-memberships-pro' );
465
  }
466
+
467
  // Don't allow admins to change their email address.
468
  if ( current_user_can( 'manage_options' ) ) {
469
  $user->user_email = $current_user->user_email;
470
  }
471
+
472
  // Validate email address.
473
  if ( empty( $user->user_email ) ) {
474
  $errors[] = __( 'Please enter an email address.', 'paid-memberships-pro' );
483
 
484
  // Show error messages.
485
  if ( ! empty( $errors ) ) { ?>
486
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message pmpro_error', 'pmpro_error' ); ?>">
487
  <?php
488
  foreach ( $errors as $key => $value ) {
489
  echo '<p>' . $value . '</p>';
494
  // Save updated profile fields.
495
  wp_update_user( $user );
496
  ?>
497
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message pmpro_success', 'pmpro_success' ); ?>">
498
  <?php _e( 'Your profile has been updated.', 'paid-memberships-pro' ); ?>
499
  </div>
500
  <?php }
503
  $user = $current_user;
504
  }
505
  ?>
506
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_member_profile_edit_wrap' ); ?>">
507
+ <form id="member-profile-edit" class="<?php echo pmpro_get_element_class( 'pmpro_form' ); ?>" action="" method="post">
508
 
509
  <?php wp_nonce_field( 'update-user_' . $current_user->ID, 'update_user_nonce' ); ?>
510
 
511
+ <?php
512
+ $user_fields = apply_filters( 'pmpro_member_profile_edit_user_object_fields',
513
+ array(
514
+ 'first_name' => __( 'First Name', 'paid-memberships-pro' ),
515
+ 'last_name' => __( 'Last Name', 'paid-memberships-pro' ),
516
+ 'display_name' => __( 'Display name publicly as', 'paid-memberships-pro' ),
517
+ 'user_email' => __( 'Email', 'paid-memberships-pro' ),
518
+ )
519
+ );
520
+ ?>
521
+
522
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout_box-user' ); ?>">
523
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_member_profile_edit-fields' ); ?>">
524
+ <?php foreach ( $user_fields as $field_key => $label ) { ?>
525
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_member_profile_edit-field pmpro_member_profile_edit-field- ' . $field_key, 'pmpro_member_profile_edit-field- ' . $field_key ); ?>">
526
+ <label for="<?php echo esc_attr( $field_key ); ?>"><?php esc_html_e( $label ); ?></label>
527
+ <?php if ( current_user_can( 'manage_options' ) && $field_key === 'user_email' ) { ?>
528
+ <input type="text" readonly="readonly" name="user_email" id="user_email" value="<?php echo esc_attr( $user->user_email ); ?>" class="<?php echo pmpro_get_element_class( 'input', 'user_email' ); ?>" />
529
+ <p class="<?php echo pmpro_get_element_class( 'lite' ); ?>"><?php esc_html_e( 'Site administrators must use the WordPress dashboard to update their email address.', 'paid-memberships-pro' ); ?></p>
 
 
 
 
 
530
  <?php } else { ?>
531
+ <input type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" value="<?php echo esc_attr( $user->{$field_key} ); ?>" class="<?php echo pmpro_get_element_class( 'input', $field_key ); ?>" />
 
532
  <?php } ?>
533
+ </div>
534
+ <?php } ?>
535
  </div> <!-- end pmpro_member_profile_edit-fields -->
536
  </div> <!-- end pmpro_checkout_box-user -->
537
 
547
  ?>
548
  <input type="hidden" name="action" value="update-profile" />
549
  <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>" />
550
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
551
  <hr />
552
+ <input type="submit" name="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit', 'pmpro_btn-submit' ); ?>" value="<?php _e( 'Update Profile', 'paid-memberships-pro' );?>" />
553
+ <input type="button" name="cancel" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-cancel', 'pmpro_btn-cancel' ); ?>" value="<?php _e( 'Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo pmpro_url( 'account'); ?>';" />
554
  </div>
555
  </form>
556
  </div> <!-- end pmpro_member_profile_edit_wrap -->
565
  *
566
  * @since 2.3
567
  */
568
+ function pmpro_change_password_process() {
569
  global $current_user;
570
+
571
  // Make sure we're on the right page.
572
  if ( empty( $_POST['action'] ) || $_POST['action'] != 'change-password' ) {
573
  return;
574
  }
575
+
576
  // Only let users change their own password.
577
  if ( empty( $current_user ) || empty( $_POST['user_id'] ) || $current_user->ID != $_POST['user_id'] ) {
578
  return;
579
  }
580
+
581
  // Check the nonce.
582
  if ( ! wp_verify_nonce( $_POST['change_password_user_nonce'], 'change-password-user_' . $current_user->ID ) ) {
583
  return;
584
+ }
585
 
586
  // Get all password values from the $_POST.
587
  if ( ! empty( $_POST['password_current'] ) ) {
599
  } else {
600
  $pass2 = '';
601
  }
602
+
603
  // Check that all password information is correct.
604
  $error = false;
605
  if ( isset( $password_current ) && ( empty( $pass1 ) || empty( $pass2 ) ) ) {
611
  } elseif ( ! empty( $pass1 ) && ! wp_check_password( $password_current, $current_user->user_pass, $current_user->ID ) ) {
612
  $error = __( 'Your current password is incorrect.', 'paid-memberships-pro' );
613
  }
614
+
615
  // Change the password.
616
  if ( ! empty( $pass1 ) && empty( $error ) ) {
617
  wp_set_password( $pass1, $current_user->ID );
618
+
619
  //setting some cookies
620
  wp_set_current_user( $current_user->ID, $current_user->user_login );
621
  wp_set_auth_cookie( $current_user->ID, true, apply_filters( 'pmpro_checkout_signon_secure', force_ssl_admin() ) );
622
+
623
  pmpro_setMessage( __( 'Your password has been updated.', 'paid-memberships-pro' ), 'pmpro_success' );
624
  } else {
625
  pmpro_setMessage( $error, 'pmpro_error' );
633
  *
634
  * @since 2.3
635
  */
636
+ function pmpro_change_password_form() {
637
+ global $current_user, $pmpro_msg, $pmpro_msgt;
638
  ?>
639
  <h2><?php _e( 'Change Password', 'paid-memberships-pro' ); ?></h2>
640
  <?php if ( ! empty( $pmpro_msg ) ) { ?>
641
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>">
642
  <?php echo esc_html( $pmpro_msg ); ?>
643
  </div>
644
  <?php } ?>
645
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_change_password_wrap' ); ?>">
646
+ <form id="change-password" class="<?php echo pmpro_get_element_class( 'pmpro_form', 'change-password' ); ?>" action="" method="post">
647
 
648
  <?php wp_nonce_field( 'change-password-user_' . $current_user->ID, 'change_password_user_nonce' ); ?>
649
 
650
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout_box-password' ); ?>">
651
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_change_password-fields' ); ?>">
652
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_change_password-field pmpro_change_password-field-password_current', 'pmpro_change_password-field-password_current' ); ?>">
653
  <label for="password_current"><?php _e( 'Current Password', 'paid-memberships-pro' ); ?></label></th>
654
+ <input type="password" name="password_current" id="password_current" value="" class="<?php echo pmpro_get_element_class( 'input', 'password_current' ); ?>" />
655
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_asterisk' ); ?>"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
656
  </div> <!-- end pmpro_change_password-field-password_current -->
657
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_change_password-field pmpro_change_password-field-pass1', 'pmpro_change_password-field-pass1' ); ?>">
658
  <label for="pass1"><?php _e( 'New Password', 'paid-memberships-pro' ); ?></label></th>
659
+ <input type="password" name="pass1" id="pass1" value="" class="<?php echo pmpro_get_element_class( 'input pass1', 'pass1' ); ?>" autocomplete="off" />
660
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_asterisk' ); ?>"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
661
  <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength Indicator', 'paid-memberships-pro' ); ?></div>
662
+ <p class="<?php echo pmpro_get_element_class( 'lite' ); ?>"><?php echo wp_get_password_hint(); ?></p>
663
  </div> <!-- end pmpro_change_password-field-pass1 -->
664
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_change_password-field pmpro_change_password-field-pass2', 'pmpro_change_password-field-pass2' ); ?>">
665
  <label for="pass2"><?php _e( 'Confirm New Password', 'paid-memberships-pro' ); ?></label></th>
666
+ <input type="password" name="pass2" id="pass2" value="" class="<?php echo pmpro_get_element_class( 'input', 'pass2' ); ?>" autocomplete="off" />
667
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_asterisk' ); ?>"> <abbr title="<?php _e( 'Required Field', 'paid-memberships-pro' ); ?>">*</abbr></span>
668
  </div> <!-- end pmpro_change_password-field-pass2 -->
669
  </div> <!-- end pmpro_change_password-fields -->
670
  </div> <!-- end pmpro_checkout_box-password -->
671
 
672
  <input type="hidden" name="action" value="change-password" />
673
  <input type="hidden" name="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
674
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
675
  <hr />
676
+ <input type="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit', 'pmpro_btn-submit' ); ?>" value="<?php esc_attr_e('Change Password', 'paid-memberships-pro' );?>" />
677
+ <input type="button" name="cancel" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-cancel', 'pmpro_btn-cancel' ); ?>" value="<?php esc_attr_e('Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo esc_url( pmpro_url( 'account') ); ?>';" />
678
  </div>
679
  </form>
680
  </div> <!-- end pmpro_change_password_wrap -->
includes/rest-api.php CHANGED
@@ -470,10 +470,10 @@ if ( class_exists( 'WP_REST_Controller' ) ) {
470
  *
471
  * @since 2.3
472
  */
473
- function pmpro_rest_api_get_permissions_check($request) {
474
 
475
  $method = $request->get_method();
476
- $endpoint = $request->get_endpoint();
477
 
478
  // default permissions to 'read' (subscriber)
479
  $permissions = current_user_can('read');
@@ -482,7 +482,7 @@ if ( class_exists( 'WP_REST_Controller' ) ) {
482
  }
483
 
484
  // Is the request method allowed?
485
- if ( ! in_array( $method, pmpro_get_rest_api_methods( $endpoint ) ) ) {
486
  $permissions = false;
487
  }
488
 
@@ -519,8 +519,8 @@ if ( class_exists( 'WP_REST_Controller' ) ) {
519
  * To enable DELETE, hook into this filter.
520
  * @since 2.3
521
  */
522
- function pmpro_get_rest_api_methods( $endpoint = NULL ) {
523
  $methods = array( 'GET', 'POST', 'PUT', 'PATCH' );
524
- $methods = apply_filters( 'pmpro_rest_api_methods', $methods, $endpoint );
525
  return $methods;
526
  }
470
  *
471
  * @since 2.3
472
  */
473
+ function pmpro_rest_api_get_permissions_check( $request ) {
474
 
475
  $method = $request->get_method();
476
+ $route = $request->get_route();
477
 
478
  // default permissions to 'read' (subscriber)
479
  $permissions = current_user_can('read');
482
  }
483
 
484
  // Is the request method allowed?
485
+ if ( ! in_array( $method, pmpro_get_rest_api_methods( $route ) ) ) {
486
  $permissions = false;
487
  }
488
 
519
  * To enable DELETE, hook into this filter.
520
  * @since 2.3
521
  */
522
+ function pmpro_get_rest_api_methods( $route = NULL ) {
523
  $methods = array( 'GET', 'POST', 'PUT', 'PATCH' );
524
+ $methods = apply_filters( 'pmpro_rest_api_methods', $methods, $route );
525
  return $methods;
526
  }
pages/billing.php CHANGED
@@ -1,4 +1,4 @@
1
- <div class="pmpro_billing_wrap">
2
  <?php
3
  global $wpdb, $current_user, $pmpro_msg, $pmpro_msgt, $show_check_payment_instructions, $show_paypal_link;
4
  global $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $bconfirmemail, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
@@ -23,7 +23,7 @@
23
 
24
  $levels = $current_user->membership_levels;
25
  $has_recurring_levels = pmpro_has_recurring_level();
26
-
27
  //Make sure the $level object is a valid level definition
28
  if(!empty($levels) ) {
29
  $level = $levels[0];
@@ -48,7 +48,7 @@
48
  * @param {objects} {$level} {Passes the $level object}
49
  */
50
  do_action('pmpro_billing_bullets_top', $level);?>
51
-
52
  <?php foreach( $levels as $level ) {
53
  if ( $has_recurring_levels != pmpro_isLevelRecurring( $level ) ) {
54
  continue;
@@ -75,6 +75,21 @@
75
  <?php if($level->billing_limit) { ?>
76
  <li><strong><?php _e("Duration", 'paid-memberships-pro' );?>:</strong> <?php echo $level->billing_limit.' '.sornot($level->cycle_period,$level->billing_limit)?></li>
77
  <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  <?php
79
  /**
80
  * pmpro_billing_bullets_top hook allows you to add information to the billing list (at the bottom).
@@ -91,26 +106,26 @@
91
  <?php if ( $has_recurring_levels ) {
92
  if ( $show_check_payment_instructions ) {
93
  $instructions = pmpro_getOption("instructions"); ?>
94
- <div class="pmpro_check_instructions"><?php echo wpautop( wp_unslash( $instructions ) ); ?></div>
95
  <hr />
96
- <p class="pmpro_actions_nav">
97
- <span class="pmpro_actions_nav-right"><a href="<?php echo pmpro_url( 'account' )?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
98
  </p> <!-- end pmpro_actions_nav -->
99
  <?php } elseif ( $show_paypal_link ) { ?>
100
  <p><?php _e('Your payment subscription is managed by PayPal. Please <a href="http://www.paypal.com">login to PayPal here</a> to update your billing information.', 'paid-memberships-pro' );?></p>
101
  <hr />
102
- <p class="pmpro_actions_nav">
103
- <span class="pmpro_actions_nav-right"><a href="<?php echo pmpro_url( 'account' )?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
104
  </p> <!-- end pmpro_actions_nav -->
105
  <?php } else { ?>
106
- <div id="pmpro_level-<?php echo $level->id; ?>" class="<?php echo $pmpro_billing_gateway_class; ?>">
107
- <form id="pmpro_form" class="pmpro_form" action="<?php echo pmpro_url("billing", "", "https")?>" method="post">
108
 
109
  <input type="hidden" name="level" value="<?php echo esc_attr($level->id);?>" />
110
  <?php if($pmpro_msg)
111
  {
112
  ?>
113
- <div class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
114
  <?php
115
  }
116
  ?>
@@ -120,27 +135,29 @@
120
  if($pmpro_include_billing_address_fields)
121
  {
122
  ?>
123
- <div id="pmpro_billing_address_fields" class="pmpro_checkout">
124
  <hr />
125
  <h3>
126
- <span class="pmpro_checkout-h3-name"><?php _e('Billing Address', 'paid-memberships-pro' );?></span>
127
  </h3>
128
- <div class="pmpro_checkout-fields">
129
- <div class="pmpro_checkout-field pmpro_checkout-field-bfirstname">
130
  <label for="bfirstname"><?php _e('First Name', 'paid-memberships-pro' );?></label>
131
- <input id="bfirstname" name="bfirstname" type="text" class="input <?php echo pmpro_getClassForField("bfirstname");?>" size="30" value="<?php echo esc_attr($bfirstname);?>" />
132
  </div> <!-- end pmpro_checkout-field-bfirstname -->
133
- <div class="pmpro_checkout-field pmpro_checkout-field-blastname">
134
  <label for="blastname"><?php _e('Last Name', 'paid-memberships-pro' );?></label>
135
- <input id="blastname" name="blastname" type="text" class="input <?php echo pmpro_getClassForField("blastname");?>" size="30" value="<?php echo esc_attr($blastname);?>" />
 
 
136
  </div> <!-- end pmpro_checkout-field-blastname -->
137
- <div class="pmpro_checkout-field pmpro_checkout-field-baddress1">
138
  <label for="baddress1"><?php _e('Address 1', 'paid-memberships-pro' );?></label>
139
- <input id="baddress1" name="baddress1" type="text" class="input <?php echo pmpro_getClassForField("baddress1");?>" size="30" value="<?php echo esc_attr($baddress1);?>" />
140
  </div> <!-- end pmpro_checkout-field-baddress1 -->
141
- <div class="pmpro_checkout-field pmpro_checkout-field-baddress2">
142
  <label for="baddress2"><?php _e('Address 2', 'paid-memberships-pro' );?></label>
143
- <input id="baddress2" name="baddress2" type="text" class="input <?php echo pmpro_getClassForField("baddress2");?>" size="30" value="<?php echo esc_attr($baddress2);?>" /> <small class="lite">(<?php _e('optional', 'paid-memberships-pro' );?>)</small>
144
  </div> <!-- end pmpro_checkout-field-baddress2 -->
145
 
146
  <?php
@@ -148,33 +165,33 @@
148
  if($longform_address)
149
  {
150
  ?>
151
- <div class="pmpro_checkout-field pmpro_checkout-field-bcity">
152
  <label for="bcity"><?php _e('City', 'paid-memberships-pro' );?></label>
153
- <input id="bcity" name="bcity" type="text" class="input <?php echo pmpro_getClassForField("bcity");?>" size="30" value="<?php echo esc_attr($bcity)?>" />
154
  </div> <!-- end pmpro_checkout-field-bcity -->
155
- <div class="pmpro_checkout-field pmpro_checkout-field-bstate">
156
  <label for="bstate"><?php _e('State', 'paid-memberships-pro' );?></label>
157
- <input id="bstate" name="bstate" type="text" class="input <?php echo pmpro_getClassForField("bstate");?>" size="30" value="<?php echo esc_attr($bstate)?>" />
158
  </div> <!-- end pmpro_checkout-field-bstate -->
159
- <div class="pmpro_checkout-field pmpro_checkout-field-bzipcode">
160
  <label for="bzipcode"><?php _e('Postal Code', 'paid-memberships-pro' );?></label>
161
- <input id="bzipcode" name="bzipcode" type="text" class="input <?php echo pmpro_getClassForField("bzipcode");?>" size="30" value="<?php echo esc_attr($bzipcode)?>" />
162
  </div> <!-- end pmpro_checkout-field-bzipcode -->
163
  <?php
164
  }
165
  else
166
  {
167
  ?>
168
- <div class="pmpro_checkout-field pmpro_checkout-field-bcity_state_zip">
169
  <label for="bcity_state_zip"><?php _e('City, State Zip', 'paid-memberships-pro' );?></label>
170
- <input id="bcity" name="bcity" type="text" class="input <?php echo pmpro_getClassForField("bcity");?>" size="14" value="<?php echo esc_attr($bcity)?>" />,
171
  <?php
172
  $state_dropdowns = apply_filters("pmpro_state_dropdowns", false);
173
  if($state_dropdowns === true || $state_dropdowns == "names")
174
  {
175
  global $pmpro_states;
176
  ?>
177
- <select name="bstate" class="<?php echo pmpro_getClassForField("bstate");?>">
178
  <option value="">--</option>
179
  <?php
180
  foreach($pmpro_states as $ab => $st)
@@ -189,7 +206,7 @@
189
  {
190
  global $pmpro_states_abbreviations;
191
  ?>
192
- <select name="bstate" class="<?php echo pmpro_getClassForField("bstate");?>">
193
  <option value="">--</option>
194
  <?php
195
  foreach($pmpro_states_abbreviations as $ab)
@@ -203,11 +220,11 @@
203
  else
204
  {
205
  ?>
206
- <input id="bstate" name="bstate" type="text" class="input <?php echo pmpro_getClassForField("bstate");?>" size="2" value="<?php echo esc_attr($bstate)?>" />
207
  <?php
208
  }
209
  ?>
210
- <input id="bzipcode" name="bzipcode" type="text" class="input <?php echo pmpro_getClassForField("bzipcode");?>" size="5" value="<?php echo esc_attr($bzipcode)?>" />
211
  </div> <!-- end pmpro_checkout-field-bcity_state_zip -->
212
  <?php
213
  }
@@ -218,9 +235,9 @@
218
  if($show_country)
219
  {
220
  ?>
221
- <div class="pmpro_checkout-field pmpro_checkout-field-bcountry">
222
  <label for="bcountry"><?php _e('Country', 'paid-memberships-pro' );?></label>
223
- <select name="bcountry" class="<?php echo pmpro_getClassForField("bcountry");?>">
224
  <?php
225
  global $pmpro_countries, $pmpro_default_country;
226
  foreach($pmpro_countries as $abbr => $country)
@@ -243,9 +260,9 @@
243
  <?php
244
  }
245
  ?>
246
- <div class="pmpro_checkout-field pmpro_checkout-field-bphone">
247
  <label for="bphone"><?php _e('Phone', 'paid-memberships-pro' );?></label>
248
- <input id="bphone" name="bphone" type="text" class="input <?php echo pmpro_getClassForField("bphone");?>" size="30" value="<?php echo esc_attr($bphone)?>" />
249
  </div> <!-- end pmpro_checkout-field-bphone -->
250
  <?php if($current_user->ID) { ?>
251
  <?php
@@ -254,13 +271,13 @@
254
  if(!$bconfirmemail && $current_user->user_email)
255
  $bconfirmemail = $current_user->user_email;
256
  ?>
257
- <div class="pmpro_checkout-field pmpro_checkout-field-bemail">
258
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
259
- <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bemail");?>" size="30" value="<?php echo esc_attr($bemail)?>" />
260
  </div> <!-- end pmpro_checkout-field-bemail -->
261
- <div class="pmpro_checkout-field pmpro_checkout-field-bconfirmemail">
262
  <label for="bconfirmemail"><?php _e('Confirm Email', 'paid-memberships-pro' );?></label>
263
- <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bconfirmemail");?>" size="30" value="<?php echo esc_attr($bconfirmemail)?>" />
264
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
265
  <?php } ?>
266
  </div> <!-- end pmpro_checkout-fields -->
@@ -280,22 +297,22 @@
280
  $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
281
  $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
282
  ?>
283
- <div id="pmpro_payment_information_fields" class="pmpro_checkout">
284
  <h3>
285
- <span class="pmpro_checkout-h3-name"><?php _e('Credit Card Information', 'paid-memberships-pro' );?></span>
286
- <span class="pmpro_checkout-h3-msg"><?php printf(__('We accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
287
  </h3>
288
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
289
  <?php if(!empty($sslseal)) { ?>
290
- <div class="pmpro_checkout-fields-display-seal">
291
  <?php } ?>
292
- <div class="pmpro_checkout-fields">
293
  <?php
294
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', false);
295
  if($pmpro_include_cardtype_field) { ?>
296
- <div class="pmpro_checkout-field pmpro_payment-card-type">
297
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
298
- <select id="CardType" name="CardType" class="<?php echo pmpro_getClassForField("CardType");?>">
299
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
300
  <option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
301
  <?php } ?>
@@ -331,13 +348,13 @@
331
  <?php
332
  }
333
  ?>
334
- <div class="pmpro_checkout-field pmpro_payment-account-number">
335
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
336
- <input id="AccountNumber" name="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" autocomplete="off" />
337
  </div>
338
- <div class="pmpro_checkout-field pmpro_payment-expiration">
339
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
340
- <select id="ExpirationMonth" name="ExpirationMonth">
341
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
342
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
343
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
@@ -350,7 +367,7 @@
350
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
351
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
352
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
353
- </select>/<select id="ExpirationYear" name="ExpirationYear">
354
  <?php
355
  for($i = date_i18n("Y"); $i < date_i18n("Y") + 10; $i++)
356
  {
@@ -370,9 +387,9 @@
370
  $cvv_template = plugins_url( 'paid-memberships-pro/pages/popup-cvv.html', PMPRO_DIR );
371
  }
372
  ?>
373
- <div class="pmpro_checkout-field pmpro_payment-cvv">
374
  <label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
375
- <input id="CVV" name="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="input <?php echo pmpro_getClassForField("CVV");?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter($cvv_template); ?>','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
376
  </div>
377
  <?php } ?>
378
  </div> <!-- end pmpro_checkout-fields -->
@@ -383,11 +400,11 @@
383
 
384
  <?php do_action("pmpro_billing_before_submit_button"); ?>
385
 
386
- <div class="pmpro_submit">
387
  <hr />
388
  <input type="hidden" name="update-billing" value="1" />
389
- <input type="submit" class="pmpro_btn pmpro_btn-submit" value="<?php _e('Update', 'paid-memberships-pro' );?>" />
390
- <input type="button" name="cancel" class="pmpro_btn pmpro_btn-cancel" value="<?php _e('Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo pmpro_url("account")?>';" />
391
  </div>
392
  </form>
393
  <script>
@@ -415,7 +432,7 @@
415
  if ( empty( $level ) || ! $level->allow_signups ) {
416
  $default_level_id = apply_filters( 'pmpro_default_level', 0 );
417
  }
418
-
419
  // Show the correct checkout link.
420
  if ( ! empty( $level ) && ! empty( $level->allow_signups ) ) {
421
  $url = pmpro_url( 'checkout', '?level=' . $level->id );
@@ -432,4 +449,3 @@
432
  <?php }
433
  } ?>
434
  </div> <!-- end pmpro_billing_wrap -->
435
-
1
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_billing_wrap' ); ?>">
2
  <?php
3
  global $wpdb, $current_user, $pmpro_msg, $pmpro_msgt, $show_check_payment_instructions, $show_paypal_link;
4
  global $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $bconfirmemail, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
23
 
24
  $levels = $current_user->membership_levels;
25
  $has_recurring_levels = pmpro_has_recurring_level();
26
+
27
  //Make sure the $level object is a valid level definition
28
  if(!empty($levels) ) {
29
  $level = $levels[0];
48
  * @param {objects} {$level} {Passes the $level object}
49
  */
50
  do_action('pmpro_billing_bullets_top', $level);?>
51
+
52
  <?php foreach( $levels as $level ) {
53
  if ( $has_recurring_levels != pmpro_isLevelRecurring( $level ) ) {
54
  continue;
75
  <?php if($level->billing_limit) { ?>
76
  <li><strong><?php _e("Duration", 'paid-memberships-pro' );?>:</strong> <?php echo $level->billing_limit.' '.sornot($level->cycle_period,$level->billing_limit)?></li>
77
  <?php } ?>
78
+
79
+ <?php
80
+ $pmpro_billing_show_payment_method = apply_filters( 'pmpro_billing_show_payment_method'
81
+ , true);
82
+ if ( $pmpro_billing_show_payment_method && ! empty( $CardType ) ) { ?>
83
+ <li><strong><?php _e( 'Payment Method', 'paid-memberships-pro' ); ?>: </strong>
84
+ <?php echo esc_html( ucwords( $CardType ) ); ?>
85
+ <?php _e('ending in', 'paid-memberships-pro' ); ?>
86
+ <?php echo esc_html( last4( get_user_meta( $current_user->ID, 'pmpro_AccountNumber', true ) ) ); ?>.
87
+ <?php _e('Expiration', 'paid-memberships-pro' );?>: <?php echo esc_html( $ExpirationMonth ); ?>/<?php echo esc_html( $ExpirationYear ); ?>
88
+ </li>
89
+ <?php
90
+ }
91
+ ?>
92
+
93
  <?php
94
  /**
95
  * pmpro_billing_bullets_top hook allows you to add information to the billing list (at the bottom).
106
  <?php if ( $has_recurring_levels ) {
107
  if ( $show_check_payment_instructions ) {
108
  $instructions = pmpro_getOption("instructions"); ?>
109
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_check_instructions' ); ?>"><?php echo wpautop( wp_unslash( $instructions ) ); ?></div>
110
  <hr />
111
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
112
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav-right' ); ?>"><a href="<?php echo pmpro_url( 'account' )?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
113
  </p> <!-- end pmpro_actions_nav -->
114
  <?php } elseif ( $show_paypal_link ) { ?>
115
  <p><?php _e('Your payment subscription is managed by PayPal. Please <a href="http://www.paypal.com">login to PayPal here</a> to update your billing information.', 'paid-memberships-pro' );?></p>
116
  <hr />
117
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
118
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav-right' ); ?>"><a href="<?php echo pmpro_url( 'account' )?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
119
  </p> <!-- end pmpro_actions_nav -->
120
  <?php } else { ?>
121
+ <div id="pmpro_level-<?php echo $level->id; ?>" class="<?php echo pmpro_get_element_class( $pmpro_billing_gateway_class, 'pmpro_level-' . $level->id ); ?>">
122
+ <form id="pmpro_form" class="<?php echo pmpro_get_element_class( 'pmpro_form' ); ?>" action="<?php echo pmpro_url("billing", "", "https")?>" method="post">
123
 
124
  <input type="hidden" name="level" value="<?php echo esc_attr($level->id);?>" />
125
  <?php if($pmpro_msg)
126
  {
127
  ?>
128
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg?></div>
129
  <?php
130
  }
131
  ?>
135
  if($pmpro_include_billing_address_fields)
136
  {
137
  ?>
138
+ <div id="pmpro_billing_address_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_billing_address_fields' ); ?>">
139
  <hr />
140
  <h3>
141
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Billing Address', 'paid-memberships-pro' );?></span>
142
  </h3>
143
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
144
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bfirstname', 'pmpro_checkout-field-bfirstname' ); ?>">
145
  <label for="bfirstname"><?php _e('First Name', 'paid-memberships-pro' );?></label>
146
+ <input id="bfirstname" name="bfirstname" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bfirstname' ); ?>" size="30" value="<?php echo esc_attr($bfirstname);?>" />
147
  </div> <!-- end pmpro_checkout-field-bfirstname -->
148
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-blastname', 'pmpro_checkout-field-blastname' ); ?>">
149
  <label for="blastname"><?php _e('Last Name', 'paid-memberships-pro' );?></label>
150
+ <input id="blastname" name="blastname" type="text"
151
+
152
+ class="<?php echo pmpro_get_element_class( 'input', 'blastname' ); ?>" size="30" value="<?php echo esc_attr($blastname);?>" />
153
  </div> <!-- end pmpro_checkout-field-blastname -->
154
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-baddress1', 'pmpro_checkout-field-baddress1' ); ?>">
155
  <label for="baddress1"><?php _e('Address 1', 'paid-memberships-pro' );?></label>
156
+ <input id="baddress1" name="baddress1" type="text" class="<?php echo pmpro_get_element_class( 'input', 'baddress1' ); ?>" size="30" value="<?php echo esc_attr($baddress1);?>" />
157
  </div> <!-- end pmpro_checkout-field-baddress1 -->
158
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-baddress2', 'pmpro_checkout-field-baddress2' ); ?>">
159
  <label for="baddress2"><?php _e('Address 2', 'paid-memberships-pro' );?></label>
160
+ <input id="baddress2" name="baddress2" type="text" class="<?php echo pmpro_get_element_class( 'input', 'baddress2' ); ?>" size="30" value="<?php echo esc_attr($baddress2);?>" /> <small class="<?php echo pmpro_get_element_class( 'lite' ); ?>">(<?php _e('optional', 'paid-memberships-pro' );?>)</small>
161
  </div> <!-- end pmpro_checkout-field-baddress2 -->
162
 
163
  <?php
165
  if($longform_address)
166
  {
167
  ?>
168
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcity', 'pmpro_checkout-field-bcity' ); ?>">
169
  <label for="bcity"><?php _e('City', 'paid-memberships-pro' );?></label>
170
+ <input id="bcity" name="bcity" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bcity' ); ?>" size="30" value="<?php echo esc_attr($bcity)?>" />
171
  </div> <!-- end pmpro_checkout-field-bcity -->
172
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bstate', 'pmpro_checkout-field-bstate' ); ?>">
173
  <label for="bstate"><?php _e('State', 'paid-memberships-pro' );?></label>
174
+ <input id="bstate" name="bstate" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bstate' ); ?>" size="30" value="<?php echo esc_attr($bstate)?>" />
175
  </div> <!-- end pmpro_checkout-field-bstate -->
176
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bzipcode', 'pmpro_checkout-field-bzipcode' ); ?>">
177
  <label for="bzipcode"><?php _e('Postal Code', 'paid-memberships-pro' );?></label>
178
+ <input id="bzipcode" name="bzipcode" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bzipcode' ); ?>" size="30" value="<?php echo esc_attr($bzipcode)?>" />
179
  </div> <!-- end pmpro_checkout-field-bzipcode -->
180
  <?php
181
  }
182
  else
183
  {
184
  ?>
185
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcity_state_zip', 'pmpro_checkout-field-bcity_state_zip' ); ?>">
186
  <label for="bcity_state_zip"><?php _e('City, State Zip', 'paid-memberships-pro' );?></label>
187
+ <input id="bcity" name="bcity" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bcity' ); ?>" size="14" value="<?php echo esc_attr($bcity)?>" />,
188
  <?php
189
  $state_dropdowns = apply_filters("pmpro_state_dropdowns", false);
190
  if($state_dropdowns === true || $state_dropdowns == "names")
191
  {
192
  global $pmpro_states;
193
  ?>
194
+ <select name="bstate" class="<?php echo pmpro_get_element_class( '', 'bstate' ); ?>">
195
  <option value="">--</option>
196
  <?php
197
  foreach($pmpro_states as $ab => $st)
206
  {
207
  global $pmpro_states_abbreviations;
208
  ?>
209
+ <select name="bstate" class="<?php echo pmpro_get_element_class( '', 'bstate' ); ?>">
210
  <option value="">--</option>
211
  <?php
212
  foreach($pmpro_states_abbreviations as $ab)
220
  else
221
  {
222
  ?>
223
+ <input id="bstate" name="bstate" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bstate' ); ?>" size="2" value="<?php echo esc_attr($bstate)?>" />
224
  <?php
225
  }
226
  ?>
227
+ <input id="bzipcode" name="bzipcode" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bzipcode' ); ?>" size="5" value="<?php echo esc_attr($bzipcode)?>" />
228
  </div> <!-- end pmpro_checkout-field-bcity_state_zip -->
229
  <?php
230
  }
235
  if($show_country)
236
  {
237
  ?>
238
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcountry', 'pmpro_checkout-field-bcountry' ); ?>">
239
  <label for="bcountry"><?php _e('Country', 'paid-memberships-pro' );?></label>
240
+ <select name="bcountry" class="<?php echo pmpro_get_element_class( '', 'bcountry' );?>">
241
  <?php
242
  global $pmpro_countries, $pmpro_default_country;
243
  foreach($pmpro_countries as $abbr => $country)
260
  <?php
261
  }
262
  ?>
263
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bphone', 'pmpro_checkout-field-bphone' ); ?>">
264
  <label for="bphone"><?php _e('Phone', 'paid-memberships-pro' );?></label>
265
+ <input id="bphone" name="bphone" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bphone' ); ?>" size="30" value="<?php echo esc_attr($bphone)?>" />
266
  </div> <!-- end pmpro_checkout-field-bphone -->
267
  <?php if($current_user->ID) { ?>
268
  <?php
271
  if(!$bconfirmemail && $current_user->user_email)
272
  $bconfirmemail = $current_user->user_email;
273
  ?>
274
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bemail', 'pmpro_checkout-field-bemail' ); ?>">
275
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
276
+ <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bemail' ); ?>" size="30" value="<?php echo esc_attr($bemail)?>" />
277
  </div> <!-- end pmpro_checkout-field-bemail -->
278
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bconfirmemail', 'pmpro_checkout-field-bconfirmemail' ); ?>">
279
  <label for="bconfirmemail"><?php _e('Confirm Email', 'paid-memberships-pro' );?></label>
280
+ <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bconfirmemail' ); ?>" size="30" value="<?php echo esc_attr($bconfirmemail)?>" />
281
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
282
  <?php } ?>
283
  </div> <!-- end pmpro_checkout-fields -->
297
  $pmpro_accepted_credit_cards = explode(",", $pmpro_accepted_credit_cards);
298
  $pmpro_accepted_credit_cards_string = pmpro_implodeToEnglish($pmpro_accepted_credit_cards);
299
  ?>
300
+ <div id="pmpro_payment_information_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_payment_information_fields' ); ?>">
301
  <h3>
302
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Credit Card Information', 'paid-memberships-pro' );?></span>
303
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php printf(__('We accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
304
  </h3>
305
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
306
  <?php if(!empty($sslseal)) { ?>
307
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-display-seal' ); ?>">
308
  <?php } ?>
309
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
310
  <?php
311
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', false);
312
  if($pmpro_include_cardtype_field) { ?>
313
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-card-type', 'pmpro_payment-card-type' ); ?>">
314
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
315
+ <select id="CardType" name="CardType" class="<?php echo pmpro_get_element_class( '', 'CardType' );?>">
316
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
317
  <option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
318
  <?php } ?>
348
  <?php
349
  }
350
  ?>
351
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-account-number', 'pmpro_payment-account-number' ); ?>">
352
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
353
+ <input id="AccountNumber" name="AccountNumber" class="<?php echo pmpro_get_element_class( 'input', 'AccountNumber' );?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" autocomplete="off" />
354
  </div>
355
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-expiration', 'pmpro_payment-expiration' ); ?>">
356
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
357
+ <select id="ExpirationMonth" name="ExpirationMonth" class="<?php echo pmpro_get_element_class( '', 'ExpirationMonth' ); ?>">
358
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
359
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
360
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
367
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
368
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
369
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
370
+ </select>/<select id="ExpirationYear" name="ExpirationYear" class="<?php echo pmpro_get_element_class( '', 'ExpirationYear' ); ?>">
371
  <?php
372
  for($i = date_i18n("Y"); $i < date_i18n("Y") + 10; $i++)
373
  {
387
  $cvv_template = plugins_url( 'paid-memberships-pro/pages/popup-cvv.html', PMPRO_DIR );
388
  }
389
  ?>
390
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-cvv', 'pmpro_payment-cvv' ); ?>">
391
  <label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
392
+ <input id="CVV" name="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="<?php echo pmpro_get_element_class( 'input', 'CVV ');?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter($cvv_template); ?>','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
393
  </div>
394
  <?php } ?>
395
  </div> <!-- end pmpro_checkout-fields -->
400
 
401
  <?php do_action("pmpro_billing_before_submit_button"); ?>
402
 
403
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
404
  <hr />
405
  <input type="hidden" name="update-billing" value="1" />
406
+ <input type="submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit', 'pmpro_btn-submit' ); ?>" value="<?php _e('Update', 'paid-memberships-pro' );?>" />
407
+ <input type="button" name="cancel" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-cancel', 'pmpro_btn-cancel' ); ?>" value="<?php _e('Cancel', 'paid-memberships-pro' );?>" onclick="location.href='<?php echo pmpro_url("account")?>';" />
408
  </div>
409
  </form>
410
  <script>
432
  if ( empty( $level ) || ! $level->allow_signups ) {
433
  $default_level_id = apply_filters( 'pmpro_default_level', 0 );
434
  }
435
+
436
  // Show the correct checkout link.
437
  if ( ! empty( $level ) && ! empty( $level->allow_signups ) ) {
438
  $url = pmpro_url( 'checkout', '?level=' . $level->id );
449
  <?php }
450
  } ?>
451
  </div> <!-- end pmpro_billing_wrap -->
 
pages/cancel.php CHANGED
@@ -14,12 +14,12 @@
14
  $old_level_ids = false;
15
  }
16
  ?>
17
- <div id="pmpro_cancel" class="pmpro_cancel_wrap">
18
  <?php
19
  if($pmpro_msg)
20
  {
21
  ?>
22
- <div class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
23
  <?php
24
  }
25
  ?>
@@ -42,9 +42,9 @@
42
  <?php
43
  }
44
  ?>
45
- <div class="pmpro_actionlinks">
46
- <a class="pmpro_btn pmpro_yeslink yeslink" href="<?php echo pmpro_url("cancel", "?levelstocancel=" . esc_attr($_REQUEST['levelstocancel']) . "&confirm=true")?>"><?php _e('Yes, cancel this membership', 'paid-memberships-pro' );?></a>
47
- <a class="pmpro_btn pmpro_btn-cancel pmpro_nolink nolink" href="<?php echo pmpro_url("account")?>"><?php _e('No, keep this membership', 'paid-memberships-pro' );?></a>
48
  </div>
49
  <?php
50
  }
@@ -54,7 +54,7 @@
54
  {
55
  ?>
56
  <h2><?php _e("My Memberships", 'paid-memberships-pro' );?></h2>
57
- <table class="pmpro_table" width="100%" cellpadding="0" cellspacing="0" border="0">
58
  <thead>
59
  <tr>
60
  <th><?php _e("Level", 'paid-memberships-pro' );?></th>
@@ -68,10 +68,10 @@
68
  foreach($current_user->membership_levels as $level) {
69
  ?>
70
  <tr>
71
- <td class="pmpro_cancel-membership-levelname">
72
  <?php echo $level->name?>
73
  </td>
74
- <td class="pmpro_cancel-membership-expiration">
75
  <?php
76
  if($level->enddate)
77
  echo date_i18n(get_option('date_format'), $level->enddate);
@@ -79,7 +79,7 @@
79
  echo "---";
80
  ?>
81
  </td>
82
- <td class="pmpro_cancel-membership-cancel">
83
  <a href="<?php echo pmpro_url("cancel", "?levelstocancel=" . $level->id)?>"><?php _e("Cancel", 'paid-memberships-pro' );?></a>
84
  </td>
85
  </tr>
@@ -88,7 +88,7 @@
88
  ?>
89
  </tbody>
90
  </table>
91
- <div class="pmpro_actions_nav">
92
  <a href="<?php echo pmpro_url("cancel", "?levelstocancel=all"); ?>"><?php _e("Cancel All Memberships", 'paid-memberships-pro' );?></a>
93
  </div>
94
  <?php
@@ -98,7 +98,7 @@
98
  else
99
  {
100
  ?>
101
- <p><a href="<?php echo get_home_url()?>"><?php _e('Click here to go to the home page.', 'paid-memberships-pro' );?></a></p>
102
  <?php
103
  }
104
  ?>
14
  $old_level_ids = false;
15
  }
16
  ?>
17
+ <div id="pmpro_cancel" class="<?php echo pmpro_get_element_class( 'pmpro_cancel_wrap', 'pmpro_cancel' ); ?>">
18
  <?php
19
  if($pmpro_msg)
20
  {
21
  ?>
22
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg?></div>
23
  <?php
24
  }
25
  ?>
42
  <?php
43
  }
44
  ?>
45
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actionlinks' ); ?>">
46
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit pmpro_yeslink yeslink', 'pmpro_btn-submit' ); ?>" href="<?php echo pmpro_url("cancel", "?levelstocancel=" . esc_attr($_REQUEST['levelstocancel']) . "&confirm=true")?>"><?php _e('Yes, cancel this membership', 'paid-memberships-pro' );?></a>
47
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-cancel pmpro_nolink nolink', 'pmpro_btn-cancel' ); ?>" href="<?php echo pmpro_url("account")?>"><?php _e('No, keep this membership', 'paid-memberships-pro' );?></a>
48
  </div>
49
  <?php
50
  }
54
  {
55
  ?>
56
  <h2><?php _e("My Memberships", 'paid-memberships-pro' );?></h2>
57
+ <table class="<?php echo pmpro_get_element_class( 'pmpro_table' ); ?>" width="100%" cellpadding="0" cellspacing="0" border="0">
58
  <thead>
59
  <tr>
60
  <th><?php _e("Level", 'paid-memberships-pro' );?></th>
68
  foreach($current_user->membership_levels as $level) {
69
  ?>
70
  <tr>
71
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_cancel-membership-levelname' ); ?>">
72
  <?php echo $level->name?>
73
  </td>
74
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_cancel-membership-expiration' ); ?>">
75
  <?php
76
  if($level->enddate)
77
  echo date_i18n(get_option('date_format'), $level->enddate);
79
  echo "---";
80
  ?>
81
  </td>
82
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_cancel-membership-cancel' ); ?>">
83
  <a href="<?php echo pmpro_url("cancel", "?levelstocancel=" . $level->id)?>"><?php _e("Cancel", 'paid-memberships-pro' );?></a>
84
  </td>
85
  </tr>
88
  ?>
89
  </tbody>
90
  </table>
91
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
92
  <a href="<?php echo pmpro_url("cancel", "?levelstocancel=all"); ?>"><?php _e("Cancel All Memberships", 'paid-memberships-pro' );?></a>
93
  </div>
94
  <?php
98
  else
99
  {
100
  ?>
101
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_cancel_return_home' ); ?>"><a href="<?php echo get_home_url()?>"><?php _e('Click here to go to the home page.', 'paid-memberships-pro' );?></a></p>
102
  <?php
103
  }
104
  ?>
pages/checkout.php CHANGED
@@ -19,19 +19,19 @@
19
  $pmpro_checkout_gateway_class = 'pmpro_checkout_gateway-' . $default_gateway;
20
  }
21
  ?>
22
- <div id="pmpro_level-<?php echo $pmpro_level->id; ?>" class="<?php echo $pmpro_checkout_gateway_class; ?>">
23
- <form id="pmpro_form" class="pmpro_form" action="<?php if(!empty($_REQUEST['review'])) echo pmpro_url("checkout", "?level=" . $pmpro_level->id); ?>" method="post">
24
 
25
  <input type="hidden" id="level" name="level" value="<?php echo esc_attr($pmpro_level->id) ?>" />
26
  <input type="hidden" id="checkjavascript" name="checkjavascript" value="1" />
27
  <?php if ($discount_code && $pmpro_review) { ?>
28
- <input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="hidden" size="20" value="<?php echo esc_attr($discount_code) ?>" />
29
  <?php } ?>
30
 
31
  <?php if($pmpro_msg) { ?>
32
- <div id="pmpro_message" class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
33
  <?php } else { ?>
34
- <div id="pmpro_message" class="pmpro_message" style="display: none;"></div>
35
  <?php } ?>
36
 
37
  <?php if($pmpro_review) { ?>
@@ -42,12 +42,12 @@
42
  $include_pricing_fields = apply_filters( 'pmpro_include_pricing_fields', true );
43
  if ( $include_pricing_fields ) {
44
  ?>
45
- <div id="pmpro_pricing_fields" class="pmpro_checkout">
46
  <h3>
47
- <span class="pmpro_checkout-h3-name"><?php _e('Membership Level', 'paid-memberships-pro' );?></span>
48
- <?php if(count($pmpro_levels) > 1) { ?><span class="pmpro_checkout-h3-msg"><a href="<?php echo pmpro_url("levels"); ?>"><?php _e('change', 'paid-memberships-pro' );?></a></span><?php } ?>
49
  </h3>
50
- <div class="pmpro_checkout-fields">
51
  <p>
52
  <?php printf(__('You have selected the <strong>%s</strong> membership level.', 'paid-memberships-pro' ), $pmpro_level->name);?>
53
  </p>
@@ -66,7 +66,7 @@
66
 
67
  <div id="pmpro_level_cost">
68
  <?php if($discount_code && pmpro_checkDiscountCode($discount_code)) { ?>
69
- <?php printf(__('<p class="pmpro_level_discount_applied">The <strong>%s</strong> code has been applied to your order.</p>', 'paid-memberships-pro' ), $discount_code);?>
70
  <?php } ?>
71
  <?php echo wpautop(pmpro_getLevelCost($pmpro_level)); ?>
72
  <?php echo wpautop(pmpro_getLevelExpiration($pmpro_level)); ?>
@@ -76,9 +76,9 @@
76
 
77
  <?php if($pmpro_show_discount_code) { ?>
78
  <?php if($discount_code && !$pmpro_review) { ?>
79
- <p id="other_discount_code_p" class="pmpro_small"><a id="other_discount_code_a" href="#discount_code"><?php _e('Click here to change your discount code.', 'paid-memberships-pro' );?></a></p>
80
  <?php } elseif(!$pmpro_review) { ?>
81
- <p id="other_discount_code_p" class="pmpro_small"><?php _e('Do you have a discount code?', 'paid-memberships-pro' );?> <a id="other_discount_code_a" href="#discount_code"><?php _e('Click here to enter your discount code', 'paid-memberships-pro' );?></a>.</p>
82
  <?php } elseif($pmpro_review && $discount_code) { ?>
83
  <p><strong><?php _e('Discount Code', 'paid-memberships-pro' );?>:</strong> <?php echo $discount_code?></p>
84
  <?php } ?>
@@ -87,7 +87,7 @@
87
  <?php if($pmpro_show_discount_code) { ?>
88
  <div id="other_discount_code_tr" style="display: none;">
89
  <label for="other_discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
90
- <input id="other_discount_code" name="other_discount_code" type="text" class="input <?php echo pmpro_getClassForField("other_discount_code");?>" size="20" value="<?php echo esc_attr($discount_code); ?>" />
91
  <input type="button" name="other_discount_code_button" id="other_discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
92
  </div>
93
  <?php } ?>
@@ -107,33 +107,33 @@
107
  // Get discount code from URL parameter, so if the user logs in it will keep it applied.
108
  $discount_code_link = !empty( $discount_code) ? '&discount_code=' . $discount_code : '';
109
  ?>
110
- <div id="pmpro_user_fields" class="pmpro_checkout">
111
  <hr />
112
  <h3>
113
- <span class="pmpro_checkout-h3-name"><?php _e('Account Information', 'paid-memberships-pro' );?></span>
114
- <span class="pmpro_checkout-h3-msg"><?php _e('Already have an account?', 'paid-memberships-pro' );?> <a href="<?php echo wp_login_url( apply_filters( 'pmpro_checkout_login_redirect', pmpro_url("checkout", "?level=" . $pmpro_level->id . $discount_code_link) ) ); ?>"><?php _e('Log in here', 'paid-memberships-pro' );?></a></span>
115
  </h3>
116
- <div class="pmpro_checkout-fields">
117
- <div class="pmpro_checkout-field pmpro_checkout-field-username">
118
  <label for="username"><?php _e('Username', 'paid-memberships-pro' );?></label>
119
- <input id="username" name="username" type="text" class="input <?php echo pmpro_getClassForField("username");?>" size="30" value="<?php echo esc_attr($username); ?>" />
120
  </div> <!-- end pmpro_checkout-field-username -->
121
 
122
  <?php
123
  do_action('pmpro_checkout_after_username');
124
  ?>
125
 
126
- <div class="pmpro_checkout-field pmpro_checkout-field-password">
127
  <label for="password"><?php _e('Password', 'paid-memberships-pro' );?></label>
128
- <input id="password" name="password" type="password" class="input <?php echo pmpro_getClassForField("password");?>" size="30" value="<?php echo esc_attr($password); ?>" />
129
  </div> <!-- end pmpro_checkout-field-password -->
130
 
131
  <?php
132
  $pmpro_checkout_confirm_password = apply_filters("pmpro_checkout_confirm_password", true);
133
  if($pmpro_checkout_confirm_password) { ?>
134
- <div class="pmpro_checkout-field pmpro_checkout-field-password2">
135
  <label for="password2"><?php _e('Confirm Password', 'paid-memberships-pro' );?></label>
136
- <input id="password2" name="password2" type="password" class="input <?php echo pmpro_getClassForField("password2");?>" size="30" value="<?php echo esc_attr($password2); ?>" />
137
  </div> <!-- end pmpro_checkout-field-password2 -->
138
  <?php } else { ?>
139
  <input type="hidden" name="password2_copy" value="1" />
@@ -144,17 +144,17 @@
144
  do_action('pmpro_checkout_after_password');
145
  ?>
146
 
147
- <div class="pmpro_checkout-field pmpro_checkout-field-bemail">
148
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
149
- <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bemail");?>" size="30" value="<?php echo esc_attr($bemail); ?>" />
150
  </div> <!-- end pmpro_checkout-field-bemail -->
151
 
152
  <?php
153
  $pmpro_checkout_confirm_email = apply_filters("pmpro_checkout_confirm_email", true);
154
  if($pmpro_checkout_confirm_email) { ?>
155
- <div class="pmpro_checkout-field pmpro_checkout-field-bconfirmemail">
156
  <label for="bconfirmemail"><?php _e('Confirm Email Address', 'paid-memberships-pro' );?></label>
157
- <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bconfirmemail");?>" size="30" value="<?php echo esc_attr($bconfirmemail); ?>" />
158
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
159
  <?php } else { ?>
160
  <input type="hidden" name="bconfirmemail_copy" value="1" />
@@ -165,12 +165,12 @@
165
  do_action('pmpro_checkout_after_email');
166
  ?>
167
 
168
- <div class="pmpro_hidden">
169
  <label for="fullname"><?php _e('Full Name', 'paid-memberships-pro' );?></label>
170
- <input id="fullname" name="fullname" type="text" class="input <?php echo pmpro_getClassForField("fullname");?>" size="30" value="" autocomplete="off"/> <strong><?php _e('LEAVE THIS BLANK', 'paid-memberships-pro' );?></strong>
171
  </div> <!-- end pmpro_hidden -->
172
 
173
- <div class="pmpro_checkout-field pmpro_captcha">
174
  <?php
175
  global $recaptcha, $recaptcha_publickey;
176
  if($recaptcha == 2 || ($recaptcha == 1 && pmpro_isLevelFree($pmpro_level))) {
@@ -185,7 +185,7 @@
185
  </div> <!-- end pmpro_checkout-fields -->
186
  </div> <!-- end pmpro_user_fields -->
187
  <?php } elseif($current_user->ID && !$pmpro_review) { ?>
188
- <div id="pmpro_account_loggedin" class="pmpro_message pmpro_alert">
189
  <?php printf(__('You are logged in as <strong>%s</strong>. If you would like to use a different account for this membership, <a href="%s">log out now</a>.', 'paid-memberships-pro' ), $current_user->user_login, wp_logout_url($_SERVER['REQUEST_URI'])); ?>
190
  </div> <!-- end pmpro_account_loggedin -->
191
  <?php } ?>
@@ -199,19 +199,19 @@
199
  ?>
200
 
201
  <?php if(pmpro_getGateway() == "paypal" && empty($pmpro_review) && true == apply_filters('pmpro_include_payment_option_for_paypal', true ) ) { ?>
202
- <div id="pmpro_payment_method" class="pmpro_checkout" <?php if(!$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
203
  <hr />
204
  <h3>
205
- <span class="pmpro_checkout-h3-name"><?php _e('Choose your Payment Method', 'paid-memberships-pro' ); ?></span>
206
  </h3>
207
- <div class="pmpro_checkout-fields">
208
- <span class="gateway_paypal">
209
  <input type="radio" name="gateway" value="paypal" <?php if(!$gateway || $gateway == "paypal") { ?>checked="checked"<?php } ?> />
210
- <a href="javascript:void(0);" class="pmpro_radio"><?php _e('Check Out with a Credit Card Here', 'paid-memberships-pro' );?></a>
211
  </span>
212
- <span class="gateway_paypalexpress">
213
  <input type="radio" name="gateway" value="paypalexpress" <?php if($gateway == "paypalexpress") { ?>checked="checked"<?php } ?> />
214
- <a href="javascript:void(0);" class="pmpro_radio"><?php _e('Check Out with PayPal', 'paid-memberships-pro' );?></a>
215
  </span>
216
  </div> <!-- end pmpro_checkout-fields -->
217
  </div> <!-- end pmpro_payment_method -->
@@ -220,53 +220,53 @@
220
  <?php
221
  $pmpro_include_billing_address_fields = apply_filters('pmpro_include_billing_address_fields', true);
222
  if($pmpro_include_billing_address_fields) { ?>
223
- <div id="pmpro_billing_address_fields" class="pmpro_checkout" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_billing_address_fields", false) ){ ?>style="display: none;"<?php } ?>>
224
  <hr />
225
  <h3>
226
- <span class="pmpro_checkout-h3-name"><?php _e('Billing Address', 'paid-memberships-pro' );?></span>
227
  </h3>
228
- <div class="pmpro_checkout-fields">
229
- <div class="pmpro_checkout-field pmpro_checkout-field-bfirstname">
230
  <label for="bfirstname"><?php _e('First Name', 'paid-memberships-pro' );?></label>
231
- <input id="bfirstname" name="bfirstname" type="text" class="input <?php echo pmpro_getClassForField("bfirstname");?>" size="30" value="<?php echo esc_attr($bfirstname); ?>" />
232
  </div> <!-- end pmpro_checkout-field-bfirstname -->
233
- <div class="pmpro_checkout-field pmpro_checkout-field-blastname">
234
  <label for="blastname"><?php _e('Last Name', 'paid-memberships-pro' );?></label>
235
- <input id="blastname" name="blastname" type="text" class="input <?php echo pmpro_getClassForField("blastname");?>" size="30" value="<?php echo esc_attr($blastname); ?>" />
236
  </div> <!-- end pmpro_checkout-field-blastname -->
237
- <div class="pmpro_checkout-field pmpro_checkout-field-baddress1">
238
  <label for="baddress1"><?php _e('Address 1', 'paid-memberships-pro' );?></label>
239
- <input id="baddress1" name="baddress1" type="text" class="input <?php echo pmpro_getClassForField("baddress1");?>" size="30" value="<?php echo esc_attr($baddress1); ?>" />
240
  </div> <!-- end pmpro_checkout-field-baddress1 -->
241
- <div class="pmpro_checkout-field pmpro_checkout-field-baddress2">
242
  <label for="baddress2"><?php _e('Address 2', 'paid-memberships-pro' );?></label>
243
- <input id="baddress2" name="baddress2" type="text" class="input <?php echo pmpro_getClassForField("baddress2");?>" size="30" value="<?php echo esc_attr($baddress2); ?>" />
244
  </div> <!-- end pmpro_checkout-field-baddress2 -->
245
  <?php
246
  $longform_address = apply_filters("pmpro_longform_address", true);
247
  if($longform_address) { ?>
248
- <div class="pmpro_checkout-field pmpro_checkout-field-bcity">
249
  <label for="bcity"><?php _e('City', 'paid-memberships-pro' );?></label>
250
- <input id="bcity" name="bcity" type="text" class="input <?php echo pmpro_getClassForField("bcity");?>" size="30" value="<?php echo esc_attr($bcity); ?>" />
251
  </div> <!-- end pmpro_checkout-field-bcity -->
252
- <div class="pmpro_checkout-field pmpro_checkout-field-bstate">
253
  <label for="bstate"><?php _e('State', 'paid-memberships-pro' );?></label>
254
- <input id="bstate" name="bstate" type="text" class="input <?php echo pmpro_getClassForField("bstate");?>" size="30" value="<?php echo esc_attr($bstate); ?>" />
255
  </div> <!-- end pmpro_checkout-field-bstate -->
256
- <div class="pmpro_checkout-field pmpro_checkout-field-bzipcode">
257
  <label for="bzipcode"><?php _e('Postal Code', 'paid-memberships-pro' );?></label>
258
- <input id="bzipcode" name="bzipcode" type="text" class="input <?php echo pmpro_getClassForField("bzipcode");?>" size="30" value="<?php echo esc_attr($bzipcode); ?>" />
259
  </div> <!-- end pmpro_checkout-field-bzipcode -->
260
  <?php } else { ?>
261
- <div class="pmpro_checkout-field pmpro_checkout-field-bcity_state_zip">
262
- <label for="bcity_state_zip"><?php _e('City, State Zip', 'paid-memberships-pro' );?></label>
263
- <input id="bcity" name="bcity" type="text" class="input <?php echo pmpro_getClassForField("bcity");?>" size="14" value="<?php echo esc_attr($bcity); ?>" />,
264
  <?php
265
  $state_dropdowns = apply_filters("pmpro_state_dropdowns", false);
266
  if($state_dropdowns === true || $state_dropdowns == "names") {
267
  global $pmpro_states;
268
  ?>
269
- <select name="bstate" class="<?php echo pmpro_getClassForField("bstate");?>">
270
  <option value="">--</option>
271
  <?php
272
  foreach($pmpro_states as $ab => $st) { ?>
@@ -276,7 +276,7 @@
276
  <?php } elseif($state_dropdowns == "abbreviations") {
277
  global $pmpro_states_abbreviations;
278
  ?>
279
- <select name="bstate" class="<?php echo pmpro_getClassForField("bstate");?>">
280
  <option value="">--</option>
281
  <?php
282
  foreach($pmpro_states_abbreviations as $ab)
@@ -286,18 +286,18 @@
286
  <?php } ?>
287
  </select>
288
  <?php } else { ?>
289
- <input id="bstate" name="bstate" type="text" class="input <?php echo pmpro_getClassForField("bstate");?>" size="2" value="<?php echo esc_attr($bstate); ?>" />
290
  <?php } ?>
291
- <input id="bzipcode" name="bzipcode" type="text" class="input <?php echo pmpro_getClassForField("bzipcode");?>" size="5" value="<?php echo esc_attr($bzipcode); ?>" />
292
  </div> <!-- end pmpro_checkout-field-bcity_state_zip -->
293
  <?php } ?>
294
 
295
  <?php
296
  $show_country = apply_filters("pmpro_international_addresses", true);
297
  if($show_country) { ?>
298
- <div class="pmpro_checkout-field pmpro_checkout-field-bcountry">
299
  <label for="bcountry"><?php _e('Country', 'paid-memberships-pro' );?></label>
300
- <select name="bcountry" id="bcountry" class="<?php echo pmpro_getClassForField("bcountry");?>">
301
  <?php
302
  global $pmpro_countries, $pmpro_default_country;
303
  if(!$bcountry) {
@@ -311,9 +311,9 @@
311
  <?php } else { ?>
312
  <input type="hidden" name="bcountry" value="US" />
313
  <?php } ?>
314
- <div class="pmpro_checkout-field pmpro_checkout-field-bphone">
315
  <label for="bphone"><?php _e('Phone', 'paid-memberships-pro' );?></label>
316
- <input id="bphone" name="bphone" type="text" class="input <?php echo pmpro_getClassForField("bphone");?>" size="30" value="<?php echo esc_attr(formatPhone($bphone)); ?>" />
317
  </div> <!-- end pmpro_checkout-field-bphone -->
318
  <?php if($skip_account_fields) { ?>
319
  <?php
@@ -326,16 +326,16 @@
326
  }
327
  }
328
  ?>
329
- <div class="pmpro_checkout-field pmpro_checkout-field-bemail">
330
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
331
- <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bemail");?>" size="30" value="<?php echo esc_attr($bemail); ?>" />
332
  </div> <!-- end pmpro_checkout-field-bemail -->
333
  <?php
334
  $pmpro_checkout_confirm_email = apply_filters("pmpro_checkout_confirm_email", true);
335
  if($pmpro_checkout_confirm_email) { ?>
336
- <div class="pmpro_checkout-field pmpro_checkout-field-bconfirmemail">
337
  <label for="bconfirmemail"><?php _e('Confirm Email', 'paid-memberships-pro' );?></label>
338
- <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="input <?php echo pmpro_getClassForField("bconfirmemail");?>" size="30" value="<?php echo esc_attr($bconfirmemail); ?>" />
339
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
340
  <?php } else { ?>
341
  <input type="hidden" name="bconfirmemail_copy" value="1" />
@@ -356,23 +356,23 @@
356
  <?php
357
  $pmpro_include_payment_information_fields = apply_filters("pmpro_include_payment_information_fields", true);
358
  if($pmpro_include_payment_information_fields) { ?>
359
- <div id="pmpro_payment_information_fields" class="pmpro_checkout" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false) ) { ?>style="display: none;"<?php } ?>>
360
  <hr />
361
  <h3>
362
- <span class="pmpro_checkout-h3-name"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
363
- <span class="pmpro_checkout-h3-msg"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
364
  </h3>
365
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
366
  <?php if(!empty($sslseal)) { ?>
367
- <div class="pmpro_checkout-fields-display-seal">
368
  <?php } ?>
369
- <div class="pmpro_checkout-fields">
370
  <?php
371
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', false);
372
  if($pmpro_include_cardtype_field) { ?>
373
- <div class="pmpro_checkout-field pmpro_payment-card-type">
374
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
375
- <select id="CardType" name="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
376
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
377
  <option value="<?php echo $cc; ?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc; ?></option>
378
  <?php } ?>
@@ -381,13 +381,13 @@
381
  <?php } else { ?>
382
  <input type="hidden" id="CardType" name="CardType" value="<?php echo esc_attr($CardType);?>" />
383
  <?php } ?>
384
- <div class="pmpro_checkout-field pmpro_payment-account-number">
385
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
386
- <input id="AccountNumber" name="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="30" value="<?php echo esc_attr($AccountNumber); ?>" data-encrypted-name="number" autocomplete="off" />
387
  </div>
388
- <div class="pmpro_checkout-field pmpro_payment-expiration">
389
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
390
- <select id="ExpirationMonth" name="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
391
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
392
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
393
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
@@ -400,7 +400,7 @@
400
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
401
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
402
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
403
- </select>/<select id="ExpirationYear" name="ExpirationYear" class=" <?php echo pmpro_getClassForField("ExpirationYear");?>">
404
  <?php
405
  $num_years = apply_filters( 'pmpro_num_expiration_years', 10 );
406
 
@@ -416,22 +416,22 @@
416
  <?php
417
  $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
418
  if($pmpro_show_cvv) { ?>
419
- <div class="pmpro_checkout-field pmpro_payment-cvv">
420
  <label for="CVV"><?php _e('Security Code (CVC)', 'paid-memberships-pro' );?></label>
421
- <input id="CVV" name="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="input <?php echo pmpro_getClassForField("CVV");?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL); ?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
422
  </div>
423
  <?php } ?>
424
  <?php if($pmpro_show_discount_code) { ?>
425
- <div class="pmpro_checkout-field pmpro_payment-discount-code">
426
  <label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
427
- <input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="10" value="<?php echo esc_attr($discount_code); ?>" />
428
  <input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
429
- <p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
430
  </div>
431
  <?php } ?>
432
  </div> <!-- end pmpro_checkout-fields -->
433
  <?php if(!empty($sslseal)) { ?>
434
- <div class="pmpro_checkout-fields-rightcol pmpro_sslseal"><?php echo stripslashes($sslseal); ?></div>
435
  </div> <!-- end pmpro_checkout-fields-display-seal -->
436
  <?php } ?>
437
  </div> <!-- end pmpro_payment_information_fields -->
@@ -440,13 +440,13 @@
440
  <?php do_action('pmpro_checkout_after_payment_information_fields'); ?>
441
 
442
  <?php if($tospage && !$pmpro_review) { ?>
443
- <div id="pmpro_tos_fields" class="pmpro_checkout">
444
  <hr />
445
  <h3>
446
- <span class="pmpro_checkout-h3-name"><?php echo esc_html( $tospage->post_title );?></span>
447
  </h3>
448
- <div class="pmpro_checkout-fields">
449
- <div id="pmpro_license" class="pmpro_checkout-field">
450
  <?php echo wpautop(do_shortcode($tospage->post_content));?>
451
  </div> <!-- end pmpro_license -->
452
  <?php
@@ -456,7 +456,7 @@
456
  $tos = "";
457
  }
458
  ?>
459
- <input type="checkbox" name="tos" value="1" id="tos" <?php checked( 1, $tos ); ?> /> <label class="pmpro_label-inline pmpro_clickable" for="tos"><?php printf(__('I agree to the %s', 'paid-memberships-pro' ), $tospage->post_title);?></label>
460
  </div> <!-- end pmpro_checkout-fields -->
461
  </div> <!-- end pmpro_tos_fields -->
462
  <?php
@@ -467,12 +467,12 @@
467
 
468
  <?php do_action("pmpro_checkout_before_submit_button"); ?>
469
 
470
- <div class="pmpro_submit">
471
  <hr />
472
  <?php if ( $pmpro_msg ) { ?>
473
- <div id="pmpro_message_bottom" class="pmpro_message <?php echo $pmpro_msgt; ?>"><?php echo $pmpro_msg; ?></div>
474
  <?php } else { ?>
475
- <div id="pmpro_message_bottom" class="pmpro_message" style="display: none;"></div>
476
  <?php } ?>
477
 
478
  <?php if($pmpro_review) { ?>
@@ -481,7 +481,7 @@
481
  <input type="hidden" name="confirm" value="1" />
482
  <input type="hidden" name="token" value="<?php echo esc_attr($pmpro_paypal_token); ?>" />
483
  <input type="hidden" name="gateway" value="<?php echo esc_attr($gateway); ?>" />
484
- <input type="submit" id="pmpro_btn-submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php _e('Complete Payment', 'paid-memberships-pro' );?> &raquo;" />
485
  </span>
486
 
487
  <?php } else { ?>
@@ -493,7 +493,7 @@
493
  ?>
494
  <span id="pmpro_submit_span">
495
  <input type="hidden" name="submit-checkout" value="1" />
496
- <input type="submit" id="pmpro_btn-submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
497
  </span>
498
  <?php
499
  }
19
  $pmpro_checkout_gateway_class = 'pmpro_checkout_gateway-' . $default_gateway;
20
  }
21
  ?>
22
+ <div id="pmpro_level-<?php echo $pmpro_level->id; ?>" class="<?php echo pmpro_get_element_class( $pmpro_checkout_gateway_class, 'pmpro_level-' . $pmpro_level->id ); ?>">
23
+ <form id="pmpro_form" class="<?php echo pmpro_get_element_class( 'pmpro_form' ); ?>" action="<?php if(!empty($_REQUEST['review'])) echo pmpro_url("checkout", "?level=" . $pmpro_level->id); ?>" method="post">
24
 
25
  <input type="hidden" id="level" name="level" value="<?php echo esc_attr($pmpro_level->id) ?>" />
26
  <input type="hidden" id="checkjavascript" name="checkjavascript" value="1" />
27
  <?php if ($discount_code && $pmpro_review) { ?>
28
+ <input class="<?php echo pmpro_get_element_class( 'input', 'discount_code' ); ?>" id="discount_code" name="discount_code" type="hidden" size="20" value="<?php echo esc_attr($discount_code) ?>" />
29
  <?php } ?>
30
 
31
  <?php if($pmpro_msg) { ?>
32
+ <div id="pmpro_message" class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg?></div>
33
  <?php } else { ?>
34
+ <div id="pmpro_message" class="<?php echo pmpro_get_element_class( 'pmpro_message' ); ?>" style="display: none;"></div>
35
  <?php } ?>
36
 
37
  <?php if($pmpro_review) { ?>
42
  $include_pricing_fields = apply_filters( 'pmpro_include_pricing_fields', true );
43
  if ( $include_pricing_fields ) {
44
  ?>
45
+ <div id="pmpro_pricing_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_pricing_fields' ); ?>">
46
  <h3>
47
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Membership Level', 'paid-memberships-pro' );?></span>
48
+ <?php if(count($pmpro_levels) > 1) { ?><span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><a href="<?php echo pmpro_url("levels"); ?>"><?php _e('change', 'paid-memberships-pro' );?></a></span><?php } ?>
49
  </h3>
50
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
51
  <p>
52
  <?php printf(__('You have selected the <strong>%s</strong> membership level.', 'paid-memberships-pro' ), $pmpro_level->name);?>
53
  </p>
66
 
67
  <div id="pmpro_level_cost">
68
  <?php if($discount_code && pmpro_checkDiscountCode($discount_code)) { ?>
69
+ <?php printf(__('<p class="' . pmpro_get_element_class( 'pmpro_level_discount_applied' ) . '">The <strong>%s</strong> code has been applied to your order.</p>', 'paid-memberships-pro' ), $discount_code);?>
70
  <?php } ?>
71
  <?php echo wpautop(pmpro_getLevelCost($pmpro_level)); ?>
72
  <?php echo wpautop(pmpro_getLevelExpiration($pmpro_level)); ?>
76
 
77
  <?php if($pmpro_show_discount_code) { ?>
78
  <?php if($discount_code && !$pmpro_review) { ?>
79
+ <p id="other_discount_code_p" class="<?php echo pmpro_get_element_class( 'pmpro_small', 'other_discount_code_p' ); ?>"><a id="other_discount_code_a" href="#discount_code"><?php _e('Click here to change your discount code.', 'paid-memberships-pro' );?></a></p>
80
  <?php } elseif(!$pmpro_review) { ?>
81
+ <p id="other_discount_code_p" class="<?php echo pmpro_get_element_class( 'pmpro_small', 'other_discount_code_p' ); ?>"><?php _e('Do you have a discount code?', 'paid-memberships-pro' );?> <a id="other_discount_code_a" href="#discount_code"><?php _e('Click here to enter your discount code', 'paid-memberships-pro' );?></a>.</p>
82
  <?php } elseif($pmpro_review && $discount_code) { ?>
83
  <p><strong><?php _e('Discount Code', 'paid-memberships-pro' );?>:</strong> <?php echo $discount_code?></p>
84
  <?php } ?>
87
  <?php if($pmpro_show_discount_code) { ?>
88
  <div id="other_discount_code_tr" style="display: none;">
89
  <label for="other_discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
90
+ <input id="other_discount_code" name="other_discount_code" type="text" class="<?php echo pmpro_get_element_class( 'input', 'other_discount_code' ); ?>" size="20" value="<?php echo esc_attr($discount_code); ?>" />
91
  <input type="button" name="other_discount_code_button" id="other_discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
92
  </div>
93
  <?php } ?>
107
  // Get discount code from URL parameter, so if the user logs in it will keep it applied.
108
  $discount_code_link = !empty( $discount_code) ? '&discount_code=' . $discount_code : '';
109
  ?>
110
+ <div id="pmpro_user_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_user_fields' ); ?>">
111
  <hr />
112
  <h3>
113
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Account Information', 'paid-memberships-pro' );?></span>
114
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php _e('Already have an account?', 'paid-memberships-pro' );?> <a href="<?php echo wp_login_url( apply_filters( 'pmpro_checkout_login_redirect', pmpro_url("checkout", "?level=" . $pmpro_level->id . $discount_code_link) ) ); ?>"><?php _e('Log in here', 'paid-memberships-pro' );?></a></span>
115
  </h3>
116
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
117
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-username', 'pmpro_checkout-field-username' ); ?>">
118
  <label for="username"><?php _e('Username', 'paid-memberships-pro' );?></label>
119
+ <input id="username" name="username" type="text" class="<?php echo pmpro_get_element_class( 'input', 'username' ); ?>" size="30" value="<?php echo esc_attr($username); ?>" />
120
  </div> <!-- end pmpro_checkout-field-username -->
121
 
122
  <?php
123
  do_action('pmpro_checkout_after_username');
124
  ?>
125
 
126
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-password', 'pmpro_checkout-field-password' ); ?>">
127
  <label for="password"><?php _e('Password', 'paid-memberships-pro' );?></label>
128
+ <input id="password" name="password" type="password" class="<?php echo pmpro_get_element_class( 'input', 'password' ); ?>" size="30" value="<?php echo esc_attr($password); ?>" />
129
  </div> <!-- end pmpro_checkout-field-password -->
130
 
131
  <?php
132
  $pmpro_checkout_confirm_password = apply_filters("pmpro_checkout_confirm_password", true);
133
  if($pmpro_checkout_confirm_password) { ?>
134
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-password2', 'pmpro_checkout-field-password2' ); ?>">
135
  <label for="password2"><?php _e('Confirm Password', 'paid-memberships-pro' );?></label>
136
+ <input id="password2" name="password2" type="password" class="<?php echo pmpro_get_element_class( 'input', 'password2' ); ?>" size="30" value="<?php echo esc_attr($password2); ?>" />
137
  </div> <!-- end pmpro_checkout-field-password2 -->
138
  <?php } else { ?>
139
  <input type="hidden" name="password2_copy" value="1" />
144
  do_action('pmpro_checkout_after_password');
145
  ?>
146
 
147
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bemail', 'pmpro_checkout-field-bemail' ); ?>">
148
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
149
+ <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bemail' ); ?>" size="30" value="<?php echo esc_attr($bemail); ?>" />
150
  </div> <!-- end pmpro_checkout-field-bemail -->
151
 
152
  <?php
153
  $pmpro_checkout_confirm_email = apply_filters("pmpro_checkout_confirm_email", true);
154
  if($pmpro_checkout_confirm_email) { ?>
155
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bconfirmemail', 'pmpro_checkout-field-bconfirmemail' ); ?>">
156
  <label for="bconfirmemail"><?php _e('Confirm Email Address', 'paid-memberships-pro' );?></label>
157
+ <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bconfirmemail' ); ?>" size="30" value="<?php echo esc_attr($bconfirmemail); ?>" />
158
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
159
  <?php } else { ?>
160
  <input type="hidden" name="bconfirmemail_copy" value="1" />
165
  do_action('pmpro_checkout_after_email');
166
  ?>
167
 
168
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_hidden' ); ?>">
169
  <label for="fullname"><?php _e('Full Name', 'paid-memberships-pro' );?></label>
170
+ <input id="fullname" name="fullname" type="text" class="<?php echo pmpro_get_element_class( 'input', 'fullname' ); ?>" size="30" value="" autocomplete="off"/> <strong><?php _e('LEAVE THIS BLANK', 'paid-memberships-pro' );?></strong>
171
  </div> <!-- end pmpro_hidden -->
172
 
173
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_captcha', 'pmpro_captcha' ); ?>">
174
  <?php
175
  global $recaptcha, $recaptcha_publickey;
176
  if($recaptcha == 2 || ($recaptcha == 1 && pmpro_isLevelFree($pmpro_level))) {
185
  </div> <!-- end pmpro_checkout-fields -->
186
  </div> <!-- end pmpro_user_fields -->
187
  <?php } elseif($current_user->ID && !$pmpro_review) { ?>
188
+ <div id="pmpro_account_loggedin" class="<?php echo pmpro_get_element_class( 'pmpro_message pmpro_alert', 'pmpro_account_loggedin' ); ?>">
189
  <?php printf(__('You are logged in as <strong>%s</strong>. If you would like to use a different account for this membership, <a href="%s">log out now</a>.', 'paid-memberships-pro' ), $current_user->user_login, wp_logout_url($_SERVER['REQUEST_URI'])); ?>
190
  </div> <!-- end pmpro_account_loggedin -->
191
  <?php } ?>
199
  ?>
200
 
201
  <?php if(pmpro_getGateway() == "paypal" && empty($pmpro_review) && true == apply_filters('pmpro_include_payment_option_for_paypal', true ) ) { ?>
202
+ <div id="pmpro_payment_method" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_payment_method' ); ?>" <?php if(!$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
203
  <hr />
204
  <h3>
205
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Choose your Payment Method', 'paid-memberships-pro' ); ?></span>
206
  </h3>
207
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
208
+ <span class="<?php echo pmpro_get_element_class( 'gateway_paypal' ); ?>">
209
  <input type="radio" name="gateway" value="paypal" <?php if(!$gateway || $gateway == "paypal") { ?>checked="checked"<?php } ?> />
210
+ <a href="javascript:void(0);" class="<?php echo pmpro_get_element_class( 'pmpro_radio' ); ?>"><?php _e('Check Out with a Credit Card Here', 'paid-memberships-pro' );?></a>
211
  </span>
212
+ <span class="<?php echo pmpro_get_element_class( 'gateway_paypalexpress' ); ?>">
213
  <input type="radio" name="gateway" value="paypalexpress" <?php if($gateway == "paypalexpress") { ?>checked="checked"<?php } ?> />
214
+ <a href="javascript:void(0);" class="<?php echo pmpro_get_element_class( 'pmpro_radio' ); ?>"><?php _e('Check Out with PayPal', 'paid-memberships-pro' );?></a>
215
  </span>
216
  </div> <!-- end pmpro_checkout-fields -->
217
  </div> <!-- end pmpro_payment_method -->
220
  <?php
221
  $pmpro_include_billing_address_fields = apply_filters('pmpro_include_billing_address_fields', true);
222
  if($pmpro_include_billing_address_fields) { ?>
223
+ <div id="pmpro_billing_address_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_billing_address_fields' ); ?>" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_billing_address_fields", false) ){ ?>style="display: none;"<?php } ?>>
224
  <hr />
225
  <h3>
226
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Billing Address', 'paid-memberships-pro' );?></span>
227
  </h3>
228
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
229
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bfirstname', 'pmpro_checkout-field-bfirstname' ); ?>">
230
  <label for="bfirstname"><?php _e('First Name', 'paid-memberships-pro' );?></label>
231
+ <input id="bfirstname" name="bfirstname" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bfirstname' ); ?>" size="30" value="<?php echo esc_attr($bfirstname); ?>" />
232
  </div> <!-- end pmpro_checkout-field-bfirstname -->
233
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-blastname', 'pmpro_checkout-field-blastname' ); ?>">
234
  <label for="blastname"><?php _e('Last Name', 'paid-memberships-pro' );?></label>
235
+ <input id="blastname" name="blastname" type="text" class="<?php echo pmpro_get_element_class( 'input', 'blastname' ); ?>" size="30" value="<?php echo esc_attr($blastname); ?>" />
236
  </div> <!-- end pmpro_checkout-field-blastname -->
237
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-baddress1', 'pmpro_checkout-field-baddress1' ); ?>">
238
  <label for="baddress1"><?php _e('Address 1', 'paid-memberships-pro' );?></label>
239
+ <input id="baddress1" name="baddress1" type="text" class="<?php echo pmpro_get_element_class( 'input', 'baddress1' ); ?>" size="30" value="<?php echo esc_attr($baddress1); ?>" />
240
  </div> <!-- end pmpro_checkout-field-baddress1 -->
241
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-baddress2', 'pmpro_checkout-field-baddress2' ); ?>">
242
  <label for="baddress2"><?php _e('Address 2', 'paid-memberships-pro' );?></label>
243
+ <input id="baddress2" name="baddress2" type="text" class="<?php echo pmpro_get_element_class( 'input', 'baddress2' ); ?>" size="30" value="<?php echo esc_attr($baddress2); ?>" />
244
  </div> <!-- end pmpro_checkout-field-baddress2 -->
245
  <?php
246
  $longform_address = apply_filters("pmpro_longform_address", true);
247
  if($longform_address) { ?>
248
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcity', 'pmpro_checkout-field-bcity' ); ?>">
249
  <label for="bcity"><?php _e('City', 'paid-memberships-pro' );?></label>
250
+ <input id="bcity" name="bcity" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bcity' ); ?>" size="30" value="<?php echo esc_attr($bcity); ?>" />
251
  </div> <!-- end pmpro_checkout-field-bcity -->
252
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bstate', 'pmpro_checkout-field-bstate' ); ?>">
253
  <label for="bstate"><?php _e('State', 'paid-memberships-pro' );?></label>
254
+ <input id="bstate" name="bstate" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bstate' ); ?>" size="30" value="<?php echo esc_attr($bstate); ?>" />
255
  </div> <!-- end pmpro_checkout-field-bstate -->
256
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bzipcode', 'pmpro_checkout-field-bzipcode' ); ?>">
257
  <label for="bzipcode"><?php _e('Postal Code', 'paid-memberships-pro' );?></label>
258
+ <input id="bzipcode" name="bzipcode" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bzipcode' ); ?>" size="30" value="<?php echo esc_attr($bzipcode); ?>" />
259
  </div> <!-- end pmpro_checkout-field-bzipcode -->
260
  <?php } else { ?>
261
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcity_state_zip', 'pmpro_checkout-field-bcity_state_zip' ); ?>">
262
+ <label for="bcity_state_zip' ); ?>"><?php _e('City, State Zip', 'paid-memberships-pro' );?></label>
263
+ <input id="bcity" name="bcity" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bcity' ); ?>" size="14" value="<?php echo esc_attr($bcity); ?>" />,
264
  <?php
265
  $state_dropdowns = apply_filters("pmpro_state_dropdowns", false);
266
  if($state_dropdowns === true || $state_dropdowns == "names") {
267
  global $pmpro_states;
268
  ?>
269
+ <select name="bstate" class="<?php echo pmpro_get_element_class( '', 'bstate' ); ?>">
270
  <option value="">--</option>
271
  <?php
272
  foreach($pmpro_states as $ab => $st) { ?>
276
  <?php } elseif($state_dropdowns == "abbreviations") {
277
  global $pmpro_states_abbreviations;
278
  ?>
279
+ <select name="bstate" class="<?php echo pmpro_get_element_class( '', 'bstate' ); ?>">
280
  <option value="">--</option>
281
  <?php
282
  foreach($pmpro_states_abbreviations as $ab)
286
  <?php } ?>
287
  </select>
288
  <?php } else { ?>
289
+ <input id="bstate" name="bstate" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bstate' ); ?>" size="2" value="<?php echo esc_attr($bstate); ?>" />
290
  <?php } ?>
291
+ <input id="bzipcode" name="bzipcode" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bzipcode' ); ?>" size="5" value="<?php echo esc_attr($bzipcode); ?>" />
292
  </div> <!-- end pmpro_checkout-field-bcity_state_zip -->
293
  <?php } ?>
294
 
295
  <?php
296
  $show_country = apply_filters("pmpro_international_addresses", true);
297
  if($show_country) { ?>
298
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bcountry', 'pmpro_checkout-field-bcountry' ); ?>">
299
  <label for="bcountry"><?php _e('Country', 'paid-memberships-pro' );?></label>
300
+ <select name="bcountry" id="bcountry" class="<?php echo pmpro_get_element_class( '', 'bcountry' ); ?>">
301
  <?php
302
  global $pmpro_countries, $pmpro_default_country;
303
  if(!$bcountry) {
311
  <?php } else { ?>
312
  <input type="hidden" name="bcountry" value="US" />
313
  <?php } ?>
314
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bphone', 'pmpro_checkout-field-bphone' ); ?>">
315
  <label for="bphone"><?php _e('Phone', 'paid-memberships-pro' );?></label>
316
+ <input id="bphone" name="bphone" type="text" class="<?php echo pmpro_get_element_class( 'input', 'bphone' ); ?>" size="30" value="<?php echo esc_attr(formatPhone($bphone)); ?>" />
317
  </div> <!-- end pmpro_checkout-field-bphone -->
318
  <?php if($skip_account_fields) { ?>
319
  <?php
326
  }
327
  }
328
  ?>
329
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bemail', 'pmpro_checkout-field-bemail' ); ?>">
330
  <label for="bemail"><?php _e('Email Address', 'paid-memberships-pro' );?></label>
331
+ <input id="bemail" name="bemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bemail' ); ?>" size="30" value="<?php echo esc_attr($bemail); ?>" />
332
  </div> <!-- end pmpro_checkout-field-bemail -->
333
  <?php
334
  $pmpro_checkout_confirm_email = apply_filters("pmpro_checkout_confirm_email", true);
335
  if($pmpro_checkout_confirm_email) { ?>
336
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-bconfirmemail', 'pmpro_checkout-field-bconfirmemail' ); ?>">
337
  <label for="bconfirmemail"><?php _e('Confirm Email', 'paid-memberships-pro' );?></label>
338
+ <input id="bconfirmemail" name="bconfirmemail" type="<?php echo ($pmpro_email_field_type ? 'email' : 'text'); ?>" class="<?php echo pmpro_get_element_class( 'input', 'bconfirmemail' ); ?>" size="30" value="<?php echo esc_attr($bconfirmemail); ?>" />
339
  </div> <!-- end pmpro_checkout-field-bconfirmemail -->
340
  <?php } else { ?>
341
  <input type="hidden" name="bconfirmemail_copy" value="1" />
356
  <?php
357
  $pmpro_include_payment_information_fields = apply_filters("pmpro_include_payment_information_fields", true);
358
  if($pmpro_include_payment_information_fields) { ?>
359
+ <div id="pmpro_payment_information_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_payment_information_fields' ); ?>" <?php if(!$pmpro_requirebilling || apply_filters("pmpro_hide_payment_information_fields", false) ) { ?>style="display: none;"<?php } ?>>
360
  <hr />
361
  <h3>
362
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
363
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
364
  </h3>
365
  <?php $sslseal = pmpro_getOption("sslseal"); ?>
366
  <?php if(!empty($sslseal)) { ?>
367
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-display-seal' ); ?>">
368
  <?php } ?>
369
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
370
  <?php
371
  $pmpro_include_cardtype_field = apply_filters('pmpro_include_cardtype_field', false);
372
  if($pmpro_include_cardtype_field) { ?>
373
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-card-type', 'pmpro_payment-card-type' ); ?>">
374
  <label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
375
+ <select id="CardType" name="CardType" class="<?php echo pmpro_get_element_class( '', 'CardType' ); ?>">
376
  <?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
377
  <option value="<?php echo $cc; ?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc; ?></option>
378
  <?php } ?>
381
  <?php } else { ?>
382
  <input type="hidden" id="CardType" name="CardType" value="<?php echo esc_attr($CardType);?>" />
383
  <?php } ?>
384
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-account-number', 'pmpro_payment-account-number' ); ?>">
385
  <label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
386
+ <input id="AccountNumber" name="AccountNumber" class="<?php echo pmpro_get_element_class( 'input', 'AccountNumber' ); ?>" type="text" size="30" value="<?php echo esc_attr($AccountNumber); ?>" data-encrypted-name="number" autocomplete="off" />
387
  </div>
388
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-expiration', 'pmpro_payment-expiration' ); ?>">
389
  <label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
390
+ <select id="ExpirationMonth" name="ExpirationMonth" class="<?php echo pmpro_get_element_class( '', 'ExpirationMonth' ); ?>">
391
  <option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
392
  <option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
393
  <option value="03" <?php if($ExpirationMonth == "03") { ?>selected="selected"<?php } ?>>03</option>
400
  <option value="10" <?php if($ExpirationMonth == "10") { ?>selected="selected"<?php } ?>>10</option>
401
  <option value="11" <?php if($ExpirationMonth == "11") { ?>selected="selected"<?php } ?>>11</option>
402
  <option value="12" <?php if($ExpirationMonth == "12") { ?>selected="selected"<?php } ?>>12</option>
403
+ </select>/<select id="ExpirationYear" name="ExpirationYear" class="<?php echo pmpro_get_element_class( '', 'ExpirationYear' ); ?>">
404
  <?php
405
  $num_years = apply_filters( 'pmpro_num_expiration_years', 10 );
406
 
416
  <?php
417
  $pmpro_show_cvv = apply_filters("pmpro_show_cvv", true);
418
  if($pmpro_show_cvv) { ?>
419
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-cvv', 'pmpro_payment-cvv' ); ?>">
420
  <label for="CVV"><?php _e('Security Code (CVC)', 'paid-memberships-pro' );?></label>
421
+ <input id="CVV" name="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="<?php echo pmpro_get_element_class( 'input', 'CVV' ); ?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL); ?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
422
  </div>
423
  <?php } ?>
424
  <?php if($pmpro_show_discount_code) { ?>
425
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_payment-discount-code', 'pmpro_payment-discount-code' ); ?>">
426
  <label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
427
+ <input class="<?php echo pmpro_get_element_class( 'input', 'discount_code' ); ?>" id="discount_code" name="discount_code" type="text" size="10" value="<?php echo esc_attr($discount_code); ?>" />
428
  <input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
429
+ <p id="discount_code_message" class="<?php echo pmpro_get_element_class( 'pmpro_message', 'discount_code_message' ); ?>" style="display: none;"></p>
430
  </div>
431
  <?php } ?>
432
  </div> <!-- end pmpro_checkout-fields -->
433
  <?php if(!empty($sslseal)) { ?>
434
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields-rightcol pmpro_sslseal', 'pmpro_sslseal' ); ?>"><?php echo stripslashes($sslseal); ?></div>
435
  </div> <!-- end pmpro_checkout-fields-display-seal -->
436
  <?php } ?>
437
  </div> <!-- end pmpro_payment_information_fields -->
440
  <?php do_action('pmpro_checkout_after_payment_information_fields'); ?>
441
 
442
  <?php if($tospage && !$pmpro_review) { ?>
443
+ <div id="pmpro_tos_fields" class="<?php echo pmpro_get_element_class( 'pmpro_checkout', 'pmpro_tos_fields' ); ?>">
444
  <hr />
445
  <h3>
446
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php echo esc_html( $tospage->post_title );?></span>
447
  </h3>
448
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>">
449
+ <div id="pmpro_license" class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field', 'pmpro_license' ); ?>">
450
  <?php echo wpautop(do_shortcode($tospage->post_content));?>
451
  </div> <!-- end pmpro_license -->
452
  <?php
456
  $tos = "";
457
  }
458
  ?>
459
+ <input type="checkbox" name="tos" value="1" id="tos" <?php checked( 1, $tos ); ?> /> <label class="<?php echo pmpro_get_element_class( 'pmpro_label-inline pmpro_clickable', 'tos' ); ?>" for="tos"><?php printf(__('I agree to the %s', 'paid-memberships-pro' ), $tospage->post_title);?></label>
460
  </div> <!-- end pmpro_checkout-fields -->
461
  </div> <!-- end pmpro_tos_fields -->
462
  <?php
467
 
468
  <?php do_action("pmpro_checkout_before_submit_button"); ?>
469
 
470
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_submit' ); ?>">
471
  <hr />
472
  <?php if ( $pmpro_msg ) { ?>
473
+ <div id="pmpro_message_bottom" class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg; ?></div>
474
  <?php } else { ?>
475
+ <div id="pmpro_message_bottom" class="<?php echo pmpro_get_element_class( 'pmpro_message' ); ?>" style="display: none;"></div>
476
  <?php } ?>
477
 
478
  <?php if($pmpro_review) { ?>
481
  <input type="hidden" name="confirm" value="1" />
482
  <input type="hidden" name="token" value="<?php echo esc_attr($pmpro_paypal_token); ?>" />
483
  <input type="hidden" name="gateway" value="<?php echo esc_attr($gateway); ?>" />
484
+ <input type="submit" id="pmpro_btn-submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php _e('Complete Payment', 'paid-memberships-pro' );?> &raquo;" />
485
  </span>
486
 
487
  <?php } else { ?>
493
  ?>
494
  <span id="pmpro_submit_span">
495
  <input type="hidden" name="submit-checkout" value="1" />
496
+ <input type="submit" id="pmpro_btn-submit" class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ); ?>" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> &raquo;" />
497
  </span>
498
  <?php
499
  }
pages/confirmation.php CHANGED
@@ -1,36 +1,36 @@
1
- <div class="pmpro_confirmation_wrap">
2
- <?php
3
  global $wpdb, $current_user, $pmpro_invoice, $pmpro_msg, $pmpro_msgt;
4
-
5
  if($pmpro_msg)
6
  {
7
  ?>
8
- <div class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
9
  <?php
10
  }
11
-
12
  if(empty($current_user->membership_level))
13
  $confirmation_message = "<p>" . __('Your payment has been submitted. Your membership will be activated shortly.', 'paid-memberships-pro' ) . "</p>";
14
  else
15
- $confirmation_message = "<p>" . sprintf(__('Thank you for your membership to %s. Your %s membership is now active.', 'paid-memberships-pro' ), get_bloginfo("name"), $current_user->membership_level->name) . "</p>";
16
-
17
  //confirmation message for this level
18
  $level_message = $wpdb->get_var("SELECT l.confirmation FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON l.id = mu.membership_id WHERE mu.status = 'active' AND mu.user_id = '" . $current_user->ID . "' LIMIT 1");
19
  if(!empty($level_message))
20
  $confirmation_message .= "\n" . stripslashes($level_message) . "\n";
21
- ?>
 
 
22
 
23
- <?php if(!empty($pmpro_invoice) && !empty($pmpro_invoice->id)) { ?>
24
-
25
  <?php
26
  $pmpro_invoice->getUser();
27
- $pmpro_invoice->getMembershipLevel();
28
-
29
  $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account and a receipt for your initial membership invoice. A welcome email with a copy of your initial membership invoice has been sent to %s.', 'paid-memberships-pro' ), $pmpro_invoice->user->user_email) . "</p>";
30
 
31
  // Check instructions
32
  if ( $pmpro_invoice->gateway == "check" && ! pmpro_isLevelFree( $pmpro_invoice->membership_level ) ) {
33
- $confirmation_message .= '<div class="pmpro_payment_instructions">' . wpautop( wp_unslash( pmpro_getOption("instructions") ) ) . '</div>';
34
  }
35
 
36
  /**
@@ -39,54 +39,54 @@
39
  * @param string $confirmation_message The confirmation message.
40
  * @param object $pmpro_invoice The PMPro Invoice/Order object.
41
  */
42
- $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, $pmpro_invoice);
43
-
44
- echo $confirmation_message;
45
  ?>
46
  <h3>
47
- <?php printf(__('Invoice #%s on %s', 'paid-memberships-pro' ), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->timestamp));?>
48
  </h3>
49
- <a class="pmpro_a-print" href="javascript:window.print()"><?php _e('Print', 'paid-memberships-pro' );?></a>
50
  <ul>
51
  <?php do_action("pmpro_invoice_bullets_top", $pmpro_invoice); ?>
52
- <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo $current_user->display_name?> (<?php echo $current_user->user_email?>)</li>
53
- <li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php echo $current_user->membership_level->name?></li>
54
  <?php if($current_user->membership_level->enddate) { ?>
55
  <li><strong><?php _e('Membership Expires', 'paid-memberships-pro' );?>:</strong> <?php echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate)?></li>
56
  <?php } ?>
57
  <?php if($pmpro_invoice->getDiscountCode()) { ?>
58
- <li><strong><?php _e('Discount Code', 'paid-memberships-pro' );?>:</strong> <?php echo $pmpro_invoice->discount_code->code?></li>
59
  <?php } ?>
60
  <?php do_action("pmpro_invoice_bullets_bottom", $pmpro_invoice); ?>
61
  </ul>
62
- <hr />
63
- <div class="pmpro_invoice_details">
64
  <?php if(!empty($pmpro_invoice->billing->name)) { ?>
65
- <div class="pmpro_invoice-billing-address">
66
  <strong><?php _e('Billing Address', 'paid-memberships-pro' );?></strong>
67
- <p><?php echo $pmpro_invoice->billing->name?><br />
68
- <?php echo $pmpro_invoice->billing->street?><br />
69
  <?php if($pmpro_invoice->billing->city && $pmpro_invoice->billing->state) { ?>
70
- <?php echo $pmpro_invoice->billing->city?>, <?php echo $pmpro_invoice->billing->state?> <?php echo $pmpro_invoice->billing->zip?> <?php echo $pmpro_invoice->billing->country?><br />
71
  <?php } ?>
72
  <?php echo formatPhone($pmpro_invoice->billing->phone)?>
73
  </p>
74
  </div> <!-- end pmpro_invoice-billing-address -->
75
  <?php } ?>
76
-
77
  <?php if ( ! empty( $pmpro_invoice->accountnumber ) || ! empty( $pmpro_invoice->payment_type ) ) { ?>
78
- <div class="pmpro_invoice-payment-method">
79
  <strong><?php _e('Payment Method', 'paid-memberships-pro' );?></strong>
80
  <?php if($pmpro_invoice->accountnumber) { ?>
81
- <p><?php echo ucwords( $pmpro_invoice->cardtype ); ?> <?php _e('ending in', 'paid-memberships-pro' );?> <?php echo last4($pmpro_invoice->accountnumber)?></p>
82
- <p><?php _e('Expiration', 'paid-memberships-pro' );?>: <?php echo $pmpro_invoice->expirationmonth?>/<?php echo $pmpro_invoice->expirationyear?></p>
83
  <?php } else { ?>
84
- <p><?php echo $pmpro_invoice->payment_type; ?></p>
85
  <?php } ?>
86
  </div> <!-- end pmpro_invoice-payment-method -->
87
  <?php } ?>
88
 
89
- <div class="pmpro_invoice-total">
90
  <strong><?php _e('Total Billed', 'paid-memberships-pro' );?></strong>
91
  <p><?php if($pmpro_invoice->total != '0.00') { ?>
92
  <?php if(!empty($pmpro_invoice->tax)) { ?>
@@ -98,37 +98,37 @@
98
  <strong><?php _e('Total', 'paid-memberships-pro' );?>: <?php echo pmpro_formatPrice($pmpro_invoice->total);?></strong>
99
  <?php } else { ?>
100
  <?php echo pmpro_formatPrice($pmpro_invoice->total);?>
101
- <?php } ?>
102
  <?php } else { ?>
103
- <small class="pmpro_grey"><?php echo pmpro_formatPrice(0);?></small>
104
  <?php } ?></p>
105
  </div> <!-- end pmpro_invoice-total -->
106
 
107
  </div> <!-- end pmpro_invoice -->
108
  <hr />
109
- <?php
110
- }
111
- else
112
  {
113
  $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account. A welcome email has been sent to %s.', 'paid-memberships-pro' ), $current_user->user_email) . "</p>";
114
-
115
  /**
116
  * All devs to filter the confirmation message.
117
  * Documented above.
118
- * We also have a function in includes/filters.php that applies the the_content filters to this message.
119
  */
120
  $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, false);
121
-
122
- echo $confirmation_message;
123
- ?>
124
  <ul>
125
- <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo $current_user->display_name?> (<?php echo $current_user->user_email?>)</li>
126
- <li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php if(!empty($current_user->membership_level)) echo $current_user->membership_level->name; else _e("Pending", 'paid-memberships-pro' );?></li>
127
- </ul>
128
- <?php
129
- }
130
  ?>
131
- <p class="pmpro_actions_nav">
132
  <?php if ( ! empty( $current_user->membership_level ) ) { ?>
133
  <a href="<?php echo pmpro_url( 'account' ); ?>"><?php _e( 'View Your Membership Account &rarr;', 'paid-memberships-pro' ); ?></a>
134
  <?php } else { ?>
1
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_confirmation_wrap' ); ?>">
2
+ <?php
3
  global $wpdb, $current_user, $pmpro_invoice, $pmpro_msg, $pmpro_msgt;
4
+
5
  if($pmpro_msg)
6
  {
7
  ?>
8
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo wp_kses_post( $pmpro_msg );?></div>
9
  <?php
10
  }
11
+
12
  if(empty($current_user->membership_level))
13
  $confirmation_message = "<p>" . __('Your payment has been submitted. Your membership will be activated shortly.', 'paid-memberships-pro' ) . "</p>";
14
  else
15
+ $confirmation_message = "<p>" . sprintf(__('Thank you for your membership to %s. Your %s membership is now active.', 'paid-memberships-pro' ), get_bloginfo("name"), $current_user->membership_level->name) . "</p>";
16
+
17
  //confirmation message for this level
18
  $level_message = $wpdb->get_var("SELECT l.confirmation FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON l.id = mu.membership_id WHERE mu.status = 'active' AND mu.user_id = '" . $current_user->ID . "' LIMIT 1");
19
  if(!empty($level_message))
20
  $confirmation_message .= "\n" . stripslashes($level_message) . "\n";
21
+ ?>
22
+
23
+ <?php if(!empty($pmpro_invoice) && !empty($pmpro_invoice->id)) { ?>
24
 
 
 
25
  <?php
26
  $pmpro_invoice->getUser();
27
+ $pmpro_invoice->getMembershipLevel();
28
+
29
  $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account and a receipt for your initial membership invoice. A welcome email with a copy of your initial membership invoice has been sent to %s.', 'paid-memberships-pro' ), $pmpro_invoice->user->user_email) . "</p>";
30
 
31
  // Check instructions
32
  if ( $pmpro_invoice->gateway == "check" && ! pmpro_isLevelFree( $pmpro_invoice->membership_level ) ) {
33
+ $confirmation_message .= '<div class="' . pmpro_get_element_class( 'pmpro_payment_instructions' ) . '">' . wpautop( wp_unslash( pmpro_getOption("instructions") ) ) . '</div>';
34
  }
35
 
36
  /**
39
  * @param string $confirmation_message The confirmation message.
40
  * @param object $pmpro_invoice The PMPro Invoice/Order object.
41
  */
42
+ $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, $pmpro_invoice);
43
+
44
+ echo wp_kses_post( $confirmation_message );
45
  ?>
46
  <h3>
47
+ <?php printf(__('Invoice #%s on %s', 'paid-memberships-pro' ), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->timestamp));?>
48
  </h3>
49
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_a-print' ); ?>" href="javascript:window.print()"><?php _e('Print', 'paid-memberships-pro' );?></a>
50
  <ul>
51
  <?php do_action("pmpro_invoice_bullets_top", $pmpro_invoice); ?>
52
+ <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->display_name );?> (<?php echo esc_html( $current_user->user_email );?>)</li>
53
+ <li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->membership_level->name);?></li>
54
  <?php if($current_user->membership_level->enddate) { ?>
55
  <li><strong><?php _e('Membership Expires', 'paid-memberships-pro' );?>:</strong> <?php echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate)?></li>
56
  <?php } ?>
57
  <?php if($pmpro_invoice->getDiscountCode()) { ?>
58
+ <li><strong><?php _e('Discount Code', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $pmpro_invoice->discount_code->code );?></li>
59
  <?php } ?>
60
  <?php do_action("pmpro_invoice_bullets_bottom", $pmpro_invoice); ?>
61
  </ul>
62
+ <hr />
63
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice_details' ); ?>">
64
  <?php if(!empty($pmpro_invoice->billing->name)) { ?>
65
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-billing-address' ); ?>">
66
  <strong><?php _e('Billing Address', 'paid-memberships-pro' );?></strong>
67
+ <p><?php echo esc_html( $pmpro_invoice->billing->name );?><br />
68
+ <?php echo esc_html( $pmpro_invoice->billing->street );?><br />
69
  <?php if($pmpro_invoice->billing->city && $pmpro_invoice->billing->state) { ?>
70
+ <?php echo esc_html( $pmpro_invoice->billing->city );?>, <?php echo esc_html( $pmpro_invoice->billing->state );?> <?php echo esc_html( $pmpro_invoice->billing->zip );?> <?php echo esc_html( $pmpro_invoice->billing->country );?><br />
71
  <?php } ?>
72
  <?php echo formatPhone($pmpro_invoice->billing->phone)?>
73
  </p>
74
  </div> <!-- end pmpro_invoice-billing-address -->
75
  <?php } ?>
76
+
77
  <?php if ( ! empty( $pmpro_invoice->accountnumber ) || ! empty( $pmpro_invoice->payment_type ) ) { ?>
78
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-payment-method' ); ?>">
79
  <strong><?php _e('Payment Method', 'paid-memberships-pro' );?></strong>
80
  <?php if($pmpro_invoice->accountnumber) { ?>
81
+ <p><?php echo esc_html( ucwords( $pmpro_invoice->cardtype ) ); ?> <?php _e('ending in', 'paid-memberships-pro' );?> <?php echo esc_html( last4($pmpro_invoice->accountnumber ) );?></p>
82
+ <p><?php _e('Expiration', 'paid-memberships-pro' );?>: <?php echo esc_html( $pmpro_invoice->expirationmonth );?>/<?php echo esc_html( $pmpro_invoice->expirationyear );?></p>
83
  <?php } else { ?>
84
+ <p><?php echo esc_html( $pmpro_invoice->payment_type ); ?></p>
85
  <?php } ?>
86
  </div> <!-- end pmpro_invoice-payment-method -->
87
  <?php } ?>
88
 
89
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-total' ); ?>">
90
  <strong><?php _e('Total Billed', 'paid-memberships-pro' );?></strong>
91
  <p><?php if($pmpro_invoice->total != '0.00') { ?>
92
  <?php if(!empty($pmpro_invoice->tax)) { ?>
98
  <strong><?php _e('Total', 'paid-memberships-pro' );?>: <?php echo pmpro_formatPrice($pmpro_invoice->total);?></strong>
99
  <?php } else { ?>
100
  <?php echo pmpro_formatPrice($pmpro_invoice->total);?>
101
+ <?php } ?>
102
  <?php } else { ?>
103
+ <small class="<?php echo pmpro_get_element_class( 'pmpro_grey' ); ?>"><?php echo esc_html( pmpro_formatPrice(0) );?></small>
104
  <?php } ?></p>
105
  </div> <!-- end pmpro_invoice-total -->
106
 
107
  </div> <!-- end pmpro_invoice -->
108
  <hr />
109
+ <?php
110
+ }
111
+ else
112
  {
113
  $confirmation_message .= "<p>" . sprintf(__('Below are details about your membership account. A welcome email has been sent to %s.', 'paid-memberships-pro' ), $current_user->user_email) . "</p>";
114
+
115
  /**
116
  * All devs to filter the confirmation message.
117
  * Documented above.
118
+ * We also have a function in includes/filters.php that applies the the_content filters to this message.
119
  */
120
  $confirmation_message = apply_filters("pmpro_confirmation_message", $confirmation_message, false);
121
+
122
+ echo wp_kses_post( $confirmation_message );
123
+ ?>
124
  <ul>
125
+ <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo esc_html( $current_user->display_name );?> (<?php echo esc_html( $current_user->user_email );?>)</li>
126
+ <li><strong><?php _e('Membership Level', 'paid-memberships-pro' );?>:</strong> <?php if(!empty($current_user->membership_level)) echo esc_html( $current_user->membership_level->name ); else _e("Pending", 'paid-memberships-pro' );?></li>
127
+ </ul>
128
+ <?php
129
+ }
130
  ?>
131
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
132
  <?php if ( ! empty( $current_user->membership_level ) ) { ?>
133
  <a href="<?php echo pmpro_url( 'account' ); ?>"><?php _e( 'View Your Membership Account &rarr;', 'paid-memberships-pro' ); ?></a>
134
  <?php } else { ?>
pages/invoice.php CHANGED
@@ -1,11 +1,11 @@
1
- <div class="pmpro_invoice_wrap">
2
  <?php
3
  global $wpdb, $pmpro_invoice, $pmpro_msg, $pmpro_msgt, $current_user;
4
 
5
  if($pmpro_msg)
6
  {
7
  ?>
8
- <div class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
9
  <?php
10
  }
11
  ?>
@@ -19,7 +19,7 @@
19
  $pmpro_invoice->getMembershipLevel();
20
  ?>
21
  <h3><?php printf(__('Invoice #%s on %s', 'paid-memberships-pro' ), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->timestamp));?></h3>
22
- <a class="pmpro_a-print" href="javascript:window.print()"><?php _e('Print', 'paid-memberships-pro' ); ?></a>
23
  <ul>
24
  <?php do_action("pmpro_invoice_bullets_top", $pmpro_invoice); ?>
25
  <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo $pmpro_invoice->user->display_name?> (<?php echo $pmpro_invoice->user->user_email?>)</li>
@@ -37,14 +37,14 @@
37
  <?php
38
  // Check instructions
39
  if ( $pmpro_invoice->gateway == "check" && ! pmpro_isLevelFree( $pmpro_invoice->membership_level ) ) {
40
- echo '<div class="pmpro_payment_instructions">' . wpautop( wp_unslash( pmpro_getOption("instructions") ) ) . '</div>';
41
  }
42
  ?>
43
 
44
  <hr />
45
- <div class="pmpro_invoice_details">
46
  <?php if(!empty($pmpro_invoice->billing->name)) { ?>
47
- <div class="pmpro_invoice-billing-address">
48
  <strong><?php _e('Billing Address', 'paid-memberships-pro' );?></strong>
49
  <p><?php echo $pmpro_invoice->billing->name?><br />
50
  <?php echo $pmpro_invoice->billing->street?><br />
@@ -57,7 +57,7 @@
57
  <?php } ?>
58
 
59
  <?php if ( ! empty( $pmpro_invoice->accountnumber ) || ! empty( $pmpro_invoice->payment_type ) ) { ?>
60
- <div class="pmpro_invoice-payment-method">
61
  <strong><?php _e('Payment Method', 'paid-memberships-pro' );?></strong>
62
  <?php if($pmpro_invoice->accountnumber) { ?>
63
  <p><?php echo ucwords( $pmpro_invoice->cardtype ); ?> <?php _e('ending in', 'paid-memberships-pro' );?> <?php echo last4($pmpro_invoice->accountnumber)?></p>
@@ -68,7 +68,7 @@
68
  </div> <!-- end pmpro_invoice-payment-method -->
69
  <?php } ?>
70
 
71
- <div class="pmpro_invoice-total">
72
  <strong><?php _e('Total Billed', 'paid-memberships-pro' );?></strong>
73
  <p><?php if($pmpro_invoice->total != '0.00') { ?>
74
  <?php if(!empty($pmpro_invoice->tax)) { ?>
@@ -82,7 +82,7 @@
82
  <?php echo pmpro_formatPrice($pmpro_invoice->total);?>
83
  <?php } ?>
84
  <?php } else { ?>
85
- <small class="pmpro_grey"><?php echo pmpro_formatPrice(0);?></small>
86
  <?php } ?></p>
87
  </div> <!-- end pmpro_invoice-total -->
88
  </div> <!-- end pmpro_invoice_details -->
@@ -96,7 +96,7 @@
96
  if($invoices)
97
  {
98
  ?>
99
- <table id="pmpro_invoices_table" class="pmpro_table pmpro_invoice" width="100%" cellpadding="0" cellspacing="0" border="0">
100
  <thead>
101
  <tr>
102
  <th><?php _e('Date', 'paid-memberships-pro' ); ?></th>
@@ -131,10 +131,10 @@
131
  }
132
  }
133
  ?>
134
- <p class="pmpro_actions_nav">
135
- <span class="pmpro_actions_nav-right"><a href="<?php echo pmpro_url("account")?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
136
  <?php if ( $pmpro_invoice ) { ?>
137
- <span class="pmpro_actions_nav-left"><a href="<?php echo pmpro_url("invoice")?>"><?php _e('&larr; View All Invoices', 'paid-memberships-pro' );?></a></span>
138
  <?php } ?>
139
  </p> <!-- end pmpro_actions_nav -->
140
  </div> <!-- end pmpro_invoice_wrap -->
1
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice_wrap' ); ?>">
2
  <?php
3
  global $wpdb, $pmpro_invoice, $pmpro_msg, $pmpro_msgt, $current_user;
4
 
5
  if($pmpro_msg)
6
  {
7
  ?>
8
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg?></div>
9
  <?php
10
  }
11
  ?>
19
  $pmpro_invoice->getMembershipLevel();
20
  ?>
21
  <h3><?php printf(__('Invoice #%s on %s', 'paid-memberships-pro' ), $pmpro_invoice->code, date_i18n(get_option('date_format'), $pmpro_invoice->timestamp));?></h3>
22
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_a-print' ); ?>" href="javascript:window.print()"><?php _e('Print', 'paid-memberships-pro' ); ?></a>
23
  <ul>
24
  <?php do_action("pmpro_invoice_bullets_top", $pmpro_invoice); ?>
25
  <li><strong><?php _e('Account', 'paid-memberships-pro' );?>:</strong> <?php echo $pmpro_invoice->user->display_name?> (<?php echo $pmpro_invoice->user->user_email?>)</li>
37
  <?php
38
  // Check instructions
39
  if ( $pmpro_invoice->gateway == "check" && ! pmpro_isLevelFree( $pmpro_invoice->membership_level ) ) {
40
+ echo '<div class="' . pmpro_get_element_class( 'pmpro_payment_instructions' ) . '">' . wpautop( wp_unslash( pmpro_getOption("instructions") ) ) . '</div>';
41
  }
42
  ?>
43
 
44
  <hr />
45
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice_details' ); ?>">
46
  <?php if(!empty($pmpro_invoice->billing->name)) { ?>
47
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-billing-address' ); ?>">
48
  <strong><?php _e('Billing Address', 'paid-memberships-pro' );?></strong>
49
  <p><?php echo $pmpro_invoice->billing->name?><br />
50
  <?php echo $pmpro_invoice->billing->street?><br />
57
  <?php } ?>
58
 
59
  <?php if ( ! empty( $pmpro_invoice->accountnumber ) || ! empty( $pmpro_invoice->payment_type ) ) { ?>
60
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-payment-method' ); ?>">
61
  <strong><?php _e('Payment Method', 'paid-memberships-pro' );?></strong>
62
  <?php if($pmpro_invoice->accountnumber) { ?>
63
  <p><?php echo ucwords( $pmpro_invoice->cardtype ); ?> <?php _e('ending in', 'paid-memberships-pro' );?> <?php echo last4($pmpro_invoice->accountnumber)?></p>
68
  </div> <!-- end pmpro_invoice-payment-method -->
69
  <?php } ?>
70
 
71
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_invoice-total' ); ?>">
72
  <strong><?php _e('Total Billed', 'paid-memberships-pro' );?></strong>
73
  <p><?php if($pmpro_invoice->total != '0.00') { ?>
74
  <?php if(!empty($pmpro_invoice->tax)) { ?>
82
  <?php echo pmpro_formatPrice($pmpro_invoice->total);?>
83
  <?php } ?>
84
  <?php } else { ?>
85
+ <small class="<?php echo pmpro_get_element_class( 'pmpro_grey' ); ?>"><?php echo pmpro_formatPrice(0);?></small>
86
  <?php } ?></p>
87
  </div> <!-- end pmpro_invoice-total -->
88
  </div> <!-- end pmpro_invoice_details -->
96
  if($invoices)
97
  {
98
  ?>
99
+ <table id="pmpro_invoices_table" class="<?php echo pmpro_get_element_class( 'pmpro_table pmpro_invoice', 'pmpro_invoices_table' ); ?>" width="100%" cellpadding="0" cellspacing="0" border="0">
100
  <thead>
101
  <tr>
102
  <th><?php _e('Date', 'paid-memberships-pro' ); ?></th>
131
  }
132
  }
133
  ?>
134
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
135
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav-right' ); ?>"><a href="<?php echo pmpro_url("account")?>"><?php _e('View Your Membership Account &rarr;', 'paid-memberships-pro' );?></a></span>
136
  <?php if ( $pmpro_invoice ) { ?>
137
+ <span class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav-left' ); ?>"><a href="<?php echo pmpro_url("invoice")?>"><?php _e('&larr; View All Invoices', 'paid-memberships-pro' );?></a></span>
138
  <?php } ?>
139
  </p> <!-- end pmpro_actions_nav -->
140
  </div> <!-- end pmpro_invoice_wrap -->
pages/levels.php CHANGED
@@ -25,11 +25,11 @@ $pmpro_levels = apply_filters("pmpro_levels_array", $pmpro_levels);
25
  if($pmpro_msg)
26
  {
27
  ?>
28
- <div class="pmpro_message <?php echo $pmpro_msgt?>"><?php echo $pmpro_msg?></div>
29
  <?php
30
  }
31
  ?>
32
- <table id="pmpro_levels_table" class="pmpro_table pmpro_checkout">
33
  <thead>
34
  <tr>
35
  <th><?php _e('Level', 'paid-memberships-pro' );?></th>
@@ -66,20 +66,20 @@ if($pmpro_msg)
66
  </td>
67
  <td>
68
  <?php if(empty($current_user->membership_level->ID)) { ?>
69
- <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a>
70
  <?php } elseif ( !$current_level ) { ?>
71
- <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a>
72
  <?php } elseif($current_level) { ?>
73
 
74
  <?php
75
  //if it's a one-time-payment level, offer a link to renew
76
  if( pmpro_isLevelExpiringSoon( $current_user->membership_level) && $current_user->membership_level->allow_signups ) {
77
  ?>
78
- <a class="pmpro_btn pmpro_btn-select" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Renew', 'paid-memberships-pro' );?></a>
79
  <?php
80
  } else {
81
  ?>
82
- <a class="pmpro_btn disabled" href="<?php echo pmpro_url("account")?>"><?php _e('Your&nbsp;Level', 'paid-memberships-pro' );?></a>
83
  <?php
84
  }
85
  ?>
@@ -92,7 +92,7 @@ if($pmpro_msg)
92
  ?>
93
  </tbody>
94
  </table>
95
- <p class="pmpro_actions_nav">
96
  <?php if(!empty($current_user->membership_level->ID)) { ?>
97
  <a href="<?php echo pmpro_url("account")?>" id="pmpro_levels-return-account"><?php _e('&larr; Return to Your Account', 'paid-memberships-pro' );?></a>
98
  <?php } else { ?>
25
  if($pmpro_msg)
26
  {
27
  ?>
28
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_message ' . $pmpro_msgt, $pmpro_msgt ); ?>"><?php echo $pmpro_msg?></div>
29
  <?php
30
  }
31
  ?>
32
+ <table id="pmpro_levels_table" class="<?php echo pmpro_get_element_class( 'pmpro_table pmpro_checkout', 'pmpro_levels_table' ); ?>">
33
  <thead>
34
  <tr>
35
  <th><?php _e('Level', 'paid-memberships-pro' );?></th>
66
  </td>
67
  <td>
68
  <?php if(empty($current_user->membership_level->ID)) { ?>
69
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a>
70
  <?php } elseif ( !$current_level ) { ?>
71
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a>
72
  <?php } elseif($current_level) { ?>
73
 
74
  <?php
75
  //if it's a one-time-payment level, offer a link to renew
76
  if( pmpro_isLevelExpiringSoon( $current_user->membership_level) && $current_user->membership_level->allow_signups ) {
77
  ?>
78
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Renew', 'paid-memberships-pro' );?></a>
79
  <?php
80
  } else {
81
  ?>
82
+ <a class="<?php echo pmpro_get_element_class( 'pmpro_btn disabled', 'pmpro_btn' ); ?>" href="<?php echo pmpro_url("account")?>"><?php _e('Your&nbsp;Level', 'paid-memberships-pro' );?></a>
83
  <?php
84
  }
85
  ?>
92
  ?>
93
  </tbody>
94
  </table>
95
+ <p class="<?php echo pmpro_get_element_class( 'pmpro_actions_nav' ); ?>">
96
  <?php if(!empty($current_user->membership_level->ID)) { ?>
97
  <a href="<?php echo pmpro_url("account")?>" id="pmpro_levels-return-account"><?php _e('&larr; Return to Your Account', 'paid-memberships-pro' );?></a>
98
  <?php } else { ?>
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.3.3
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.3.3' );
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.3.4
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.3.4' );
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
@@ -2,8 +2,8 @@
2
  Contributors: strangerstudios, kimannwall, andrewza, dlparker1005
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.4.1
6
- Stable tag: 2.3.3
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,31 @@ Not sure? You can find out by doing a bit a research.
153
  8. Membership Account page, display all sections or show specific sections using shortcode attributes.
154
 
155
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  = 2.3.3 - 2020-05-13 =
157
  * SECURITY: Fixed SQL injection vulnerability when logged in as an administrator and adding new orders in the dashboard. JVN#20248858 (Thanks, Kenichi Okuno of Mitsui Bussan Secure Directions, Inc)
158
  * SECURITY: Making sure to properly escape all values on the add/edit order form in the dashboard.
2
  Contributors: strangerstudios, kimannwall, andrewza, dlparker1005
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.4.2
6
+ Stable tag: 2.3.4
7
 
8
  Get Paid with Paid Memberships Pro: The most complete member management and membership subscriptions plugin for your WordPress site.
9
 
153
  8. Membership Account page, display all sections or show specific sections using shortcode attributes.
154
 
155
  == Changelog ==
156
+ = 2.3.4 - 2020-06-18 =
157
+ * SECURITY: Better escaping of values on the billing and confirmation pages.
158
+ * BUG FIX: Fixed issue where expiration dates could be set to 1 day in the past when editing a user in the dashboard if certain timezones were chosen in the General settings.
159
+ * BUG FIX: Fixed issue where users were redirected back to the /login/ page if WordPress needed them to confirm their admin email address. Users will now be taken to the default WP login page with the form to confirm their email address.
160
+ * BUG FIX: Fixed bug where the reset password link in the new user email was not filtered to go to the frontend login page if being used.
161
+ * BUG FIX: Fixed issue where some errors were not being shown when password resets failed.
162
+ * BUG FIX: Fixed bug with action links added to the orders table.
163
+ * BUG FIX: Fixed issue where empty dates would show current date in the members list.
164
+ * BUG FIX: Fixed fatal error that was happening when using some of the new API endpoints.
165
+ * BUG FIX: Timestamps returned by the Stripe API when getting the next payment date needed to be adjusted based on the site's timezone setting.
166
+ * BUG FIX: Fixed a bug where the change password form wouldn't show up sometimes when using the login shortcode.
167
+ * BUG FIX: Fixed notice in the PayPal IPN handler when adding notes to an order.
168
+ * BUG FIX: Fixed issue where PMPro would generate the wrong excerpt in some cases where the more tag was used but the excerpt was generated before the more tag code or blog was not yet converted to HTML. Specifically this fixes an issue with excerpts generated for AMP with the SchemaApp plugin.
169
+ * BUG FIX/ENHANCEMENT: Added an advanced setting to "Uninstall PMPro on Deletion". You must check and save this option first or PMPro will not delete data from the DB when deleting from the plugins page. This keeps users from accidentally deleting orders and member data.
170
+ * BUG FIX/ENHANCEMENT: Now hiding the profile and change password links on the membership account page if a frontend profile page is not set and users are locked from the WP dashboard by the advanced setting.
171
+ * BUG FIX/ENHANCEMENT: Resetting the signups and cancellations report cache when there are new membership level changes.
172
+ * ENHANCEMENT: Added a pmpro_get_element_class function and filter. We now use this function when adding classes to HTML elements in our templates. The filter can be used to alter or append to the classes used in the HTML tags. This will make it easier to create code and CSS to make PMPro look better with popular themes.
173
+ * ENHANCEMENT: Added a pmpro_authorizenet_post_values filter to the Authorize.net class. An array of $post_values is passed in to be filtered along with a string for the API method about to be called.
174
+ * ENHANCEMENT: Added a pmpro_member_profile_edit_user_object_fields filter to add or remove fields from the frontend edit profile page.
175
+ * ENHANCEMENT: Now showing information about the current billing method on the update billing page. Can hide this information by having the pmpro_billing_show_payment_method filter return false.
176
+ * ENHANCEMENT: No longer saying "Great Work!" in the admin digest emails. This was especially embarrassing if you didn't have any sales during the diget period.
177
+ * REFACTOR: Refactored some code in the CSV exports to avoid false positives by malware scanners.
178
+ * REFACTOR: Added a build_post_string method to the Authorize.net class to avoid redundant code.
179
+ * REFACTOR: Added a cancelSubscriptionAtGateway method to the PayPal Express class. This is useful if you want to cancel the subscription without cancelling the membership. (Thanks, Mirco Babini)
180
+
181
  = 2.3.3 - 2020-05-13 =
182
  * SECURITY: Fixed SQL injection vulnerability when logged in as an administrator and adding new orders in the dashboard. JVN#20248858 (Thanks, Kenichi Okuno of Mitsui Bussan Secure Directions, Inc)
183
  * SECURITY: Making sure to properly escape all values on the add/edit order form in the dashboard.
services/ipnhandler.php CHANGED
@@ -768,7 +768,7 @@ function pmpro_ipnSaveOrder( $txn_id, $last_order ) {
768
  $ipn_id = isset($_POST['ipn_track_id']) ? sanitize_text_field( $_POST['ipn_track_id'] ) : null;
769
 
770
  // Allow extraction of the IPN Track ID from the order notes (if needed)
771
- $morder->notes = "{$morder->notes} [IPN_ID]{$ipn_id}[/IPN_ID]";
772
 
773
  /**
774
  * Post processing for a specific subscription related IPN event ID
768
  $ipn_id = isset($_POST['ipn_track_id']) ? sanitize_text_field( $_POST['ipn_track_id'] ) : null;
769
 
770
  // Allow extraction of the IPN Track ID from the order notes (if needed)
771
+ $morder->notes = "[IPN_ID]{$ipn_id}[/IPN_ID]";
772
 
773
  /**
774
  * Post processing for a specific subscription related IPN event ID
shortcodes/pmpro_account.php CHANGED
@@ -33,10 +33,10 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
33
  ?>
34
  <div id="pmpro_account">
35
  <?php if(in_array('membership', $sections) || in_array('memberships', $sections)) { ?>
36
- <div id="pmpro_account-membership" class="pmpro_box">
37
 
38
  <h3><?php _e("My Memberships", 'paid-memberships-pro' );?></h3>
39
- <table class="pmpro_table" width="100%" cellpadding="0" cellspacing="0" border="0">
40
  <thead>
41
  <tr>
42
  <th><?php _e("Level", 'paid-memberships-pro' );?></th>
@@ -81,9 +81,9 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
81
  foreach($mylevels as $level) {
82
  ?>
83
  <tr>
84
- <td class="pmpro_account-membership-levelname">
85
  <?php echo $level->name?>
86
- <div class="pmpro_actionlinks">
87
  <?php do_action("pmpro_member_action_links_before"); ?>
88
 
89
  <?php
@@ -122,10 +122,10 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
122
  <?php do_action("pmpro_member_action_links_after"); ?>
123
  </div> <!-- end pmpro_actionlinks -->
124
  </td>
125
- <td class="pmpro_account-membership-levelfee">
126
  <p><?php echo pmpro_getLevelCost($level, true, true);?></p>
127
  </td>
128
- <td class="pmpro_account-membership-expiration">
129
  <?php
130
  if($level->enddate)
131
  $expiration_text = date_i18n( get_option( 'date_format' ), $level->enddate );
@@ -140,7 +140,7 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
140
  </tbody>
141
  </table>
142
  <?php //Todo: If there are multiple levels defined that aren't all in the same group defined as upgrades/downgrades ?>
143
- <div class="pmpro_actionlinks">
144
  <a id="pmpro_actionlink-levels" href="<?php echo pmpro_url("levels")?>"><?php _e("View all Membership Options", 'paid-memberships-pro' );?></a>
145
  </div>
146
 
@@ -148,7 +148,7 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
148
  <?php } ?>
149
 
150
  <?php if(in_array('profile', $sections)) { ?>
151
- <div id="pmpro_account-profile" class="pmpro_box">
152
  <?php wp_get_current_user(); ?>
153
  <h3><?php _e("My Account", 'paid-memberships-pro' );?></h3>
154
  <?php if($current_user->user_firstname) { ?>
@@ -160,21 +160,27 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
160
  <li><strong><?php _e("Email", 'paid-memberships-pro' );?>:</strong> <?php echo $current_user->user_email?></li>
161
  <?php do_action('pmpro_account_bullets_bottom');?>
162
  </ul>
163
- <div class="pmpro_actionlinks">
164
  <?php
165
- // Get the edit profile and change password linkds if 'Member Profile Edit Page' is set.
166
  if ( ! empty( pmpro_getOption( 'member_profile_edit_page_id' ) ) ) {
167
  $edit_profile_url = pmpro_url( 'member_profile_edit' );
168
  $change_password_url = add_query_arg( 'view', 'change-password', pmpro_url( 'member_profile_edit' ) );
169
- } else {
170
  $edit_profile_url = admin_url( 'profile.php' );
171
  $change_password_url = admin_url( 'profile.php' );
172
  }
173
 
174
  // Build the links to return.
175
  $pmpro_profile_action_links = array();
176
- $pmpro_profile_action_links['edit-profile'] = sprintf( '<a id="pmpro_actionlink-profile" href="%s">%s</a>', esc_url( $edit_profile_url ), esc_html__( 'Edit Profile', 'paid-memberships-pro' ) );
177
- $pmpro_profile_action_links['change-password'] = sprintf( '<a id="pmpro_actionlink-change-password" href="%s">%s</a>', esc_url( $change_password_url ), esc_html__( 'Change Password', 'paid-memberships-pro' ) );
 
 
 
 
 
 
178
  $pmpro_profile_action_links['logout'] = sprintf( '<a id="pmpro_actionlink-logout" href="%s">%s</a>', esc_url( wp_logout_url() ), esc_html__( 'Log Out', 'paid-memberships-pro' ) );
179
 
180
  $pmpro_profile_action_links = apply_filters( 'pmpro_account_profile_action_links', $pmpro_profile_action_links );
@@ -195,9 +201,9 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
195
  <?php } ?>
196
 
197
  <?php if(in_array('invoices', $sections) && !empty($invoices)) { ?>
198
- <div id="pmpro_account-invoices" class="pmpro_box">
199
  <h3><?php _e("Past Invoices", 'paid-memberships-pro' );?></h3>
200
- <table class="pmpro_table" width="100%" cellpadding="0" cellspacing="0" border="0">
201
  <thead>
202
  <tr>
203
  <th><?php _e("Date", 'paid-memberships-pro' ); ?></th>
@@ -241,13 +247,13 @@ function pmpro_shortcode_account($atts, $content=null, $code="")
241
  </tbody>
242
  </table>
243
  <?php if($count == 6) { ?>
244
- <div class="pmpro_actionlinks"><a id="pmpro_actionlink-invoices" href="<?php echo pmpro_url("invoice"); ?>"><?php _e("View All Invoices", 'paid-memberships-pro' );?></a></div>
245
  <?php } ?>
246
  </div> <!-- end pmpro_account-invoices -->
247
  <?php } ?>
248
 
249
  <?php if(in_array('links', $sections) && (has_filter('pmpro_member_links_top') || has_filter('pmpro_member_links_bottom'))) { ?>
250
- <div id="pmpro_account-links" class="pmpro_box">
251
  <h3><?php _e("Member Links", 'paid-memberships-pro' );?></h3>
252
  <ul>
253
  <?php
33
  ?>
34
  <div id="pmpro_account">
35
  <?php if(in_array('membership', $sections) || in_array('memberships', $sections)) { ?>
36
+ <div id="pmpro_account-membership" class="<?php echo pmpro_get_element_class( 'pmpro_box', 'pmpro_account-membership' ); ?>">
37
 
38
  <h3><?php _e("My Memberships", 'paid-memberships-pro' );?></h3>
39
+ <table class="<?php echo pmpro_get_element_class( 'pmpro_table' ); ?>" width="100%" cellpadding="0" cellspacing="0" border="0">
40
  <thead>
41
  <tr>
42
  <th><?php _e("Level", 'paid-memberships-pro' );?></th>
81
  foreach($mylevels as $level) {
82
  ?>
83
  <tr>
84
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_account-membership-levelname' ); ?>">
85
  <?php echo $level->name?>
86
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actionlinks' ); ?>">
87
  <?php do_action("pmpro_member_action_links_before"); ?>
88
 
89
  <?php
122
  <?php do_action("pmpro_member_action_links_after"); ?>
123
  </div> <!-- end pmpro_actionlinks -->
124
  </td>
125
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_account-membership-levelfee' ); ?>">
126
  <p><?php echo pmpro_getLevelCost($level, true, true);?></p>
127
  </td>
128
+ <td class="<?php echo pmpro_get_element_class( 'pmpro_account-membership-expiration' ); ?>">
129
  <?php
130
  if($level->enddate)
131
  $expiration_text = date_i18n( get_option( 'date_format' ), $level->enddate );
140
  </tbody>
141
  </table>
142
  <?php //Todo: If there are multiple levels defined that aren't all in the same group defined as upgrades/downgrades ?>
143
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actionlinks' ); ?>">
144
  <a id="pmpro_actionlink-levels" href="<?php echo pmpro_url("levels")?>"><?php _e("View all Membership Options", 'paid-memberships-pro' );?></a>
145
  </div>
146
 
148
  <?php } ?>
149
 
150
  <?php if(in_array('profile', $sections)) { ?>
151
+ <div id="pmpro_account-profile" class="<?php echo pmpro_get_element_class( 'pmpro_box', 'pmpro_account-profile' ); ?>">
152
  <?php wp_get_current_user(); ?>
153
  <h3><?php _e("My Account", 'paid-memberships-pro' );?></h3>
154
  <?php if($current_user->user_firstname) { ?>
160
  <li><strong><?php _e("Email", 'paid-memberships-pro' );?>:</strong> <?php echo $current_user->user_email?></li>
161
  <?php do_action('pmpro_account_bullets_bottom');?>
162
  </ul>
163
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actionlinks' ); ?>">
164
  <?php
165
+ // Get the edit profile and change password links if 'Member Profile Edit Page' is set.
166
  if ( ! empty( pmpro_getOption( 'member_profile_edit_page_id' ) ) ) {
167
  $edit_profile_url = pmpro_url( 'member_profile_edit' );
168
  $change_password_url = add_query_arg( 'view', 'change-password', pmpro_url( 'member_profile_edit' ) );
169
+ } elseif ( ! pmpro_block_dashboard() ) {
170
  $edit_profile_url = admin_url( 'profile.php' );
171
  $change_password_url = admin_url( 'profile.php' );
172
  }
173
 
174
  // Build the links to return.
175
  $pmpro_profile_action_links = array();
176
+ if ( ! empty( $edit_profile_url) ) {
177
+ $pmpro_profile_action_links['edit-profile'] = sprintf( '<a id="pmpro_actionlink-profile" href="%s">%s</a>', esc_url( $edit_profile_url ), esc_html__( 'Edit Profile', 'paid-memberships-pro' ) );
178
+ }
179
+
180
+ if ( ! empty( $change_password_url ) ) {
181
+ $pmpro_profile_action_links['change-password'] = sprintf( '<a id="pmpro_actionlink-change-password" href="%s">%s</a>', esc_url( $change_password_url ), esc_html__( 'Change Password', 'paid-memberships-pro' ) );
182
+ }
183
+
184
  $pmpro_profile_action_links['logout'] = sprintf( '<a id="pmpro_actionlink-logout" href="%s">%s</a>', esc_url( wp_logout_url() ), esc_html__( 'Log Out', 'paid-memberships-pro' ) );
185
 
186
  $pmpro_profile_action_links = apply_filters( 'pmpro_account_profile_action_links', $pmpro_profile_action_links );
201
  <?php } ?>
202
 
203
  <?php if(in_array('invoices', $sections) && !empty($invoices)) { ?>
204
+ <div id="pmpro_account-invoices" class="<?php echo pmpro_get_element_class( 'pmpro_box', 'pmpro_account-invoices' ); ?>">
205
  <h3><?php _e("Past Invoices", 'paid-memberships-pro' );?></h3>
206
+ <table class="<?php echo pmpro_get_element_class( 'pmpro_table' ); ?>" width="100%" cellpadding="0" cellspacing="0" border="0">
207
  <thead>
208
  <tr>
209
  <th><?php _e("Date", 'paid-memberships-pro' ); ?></th>
247
  </tbody>
248
  </table>
249
  <?php if($count == 6) { ?>
250
+ <div class="<?php echo pmpro_get_element_class( 'pmpro_actionlinks' ); ?>"><a id="pmpro_actionlink-invoices" href="<?php echo pmpro_url("invoice"); ?>"><?php _e("View All Invoices", 'paid-memberships-pro' );?></a></div>
251
  <?php } ?>
252
  </div> <!-- end pmpro_account-invoices -->
253
  <?php } ?>
254
 
255
  <?php if(in_array('links', $sections) && (has_filter('pmpro_member_links_top') || has_filter('pmpro_member_links_bottom'))) { ?>
256
+ <div id="pmpro_account-links" class="<?php echo pmpro_get_element_class( 'pmpro_box', 'pmpro_account-links' ); ?>">
257
  <h3><?php _e("Member Links", 'paid-memberships-pro' );?></h3>
258
  <ul>
259
  <?php
shortcodes/pmpro_member_profile_edit.php CHANGED
@@ -19,7 +19,7 @@ function pmpro_shortcode_member_profile_edit( $atts, $content=null, $code='' ) {
19
  $view = NULL;
20
  }
21
 
22
- if ( ! empty( $view ) && $view = 'change-pasword' ) {
23
  // Display the Change Password form.
24
  pmpro_change_password_form();
25
  } else {
19
  $view = NULL;
20
  }
21
 
22
+ if ( ! empty( $view ) && $view == 'change-password' ) {
23
  // Display the Change Password form.
24
  pmpro_change_password_form();
25
  } else {
uninstall.php CHANGED
@@ -8,55 +8,57 @@
8
  if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN'))
9
  exit();
10
 
11
- // otherwise remove pages
12
- $pmpro_pages = array(
13
- 'account' => get_option( 'pmpro_account_page_id' ),
14
- 'billing' => get_option( 'pmpro_billing_page_id' ),
15
- 'cancel' =>get_option( 'pmpro_cancel_page_id' ),
16
- 'checkout' => get_option( 'pmpro_checkout_page_id' ),
17
- 'confirmation' => get_option( 'pmpro_confirmation_page_id' ),
18
- 'invoice' => get_option( 'pmpro_invoice_page_id' ),
19
- 'levels' => get_option( 'pmpro_levels_page_id' ),
20
- 'login' => get_option( 'pmpro_login_page_id' ),
21
- 'member_profile_edit' => get_option( 'pmpro_member_profile_edit_page_id' )
22
- );
23
-
24
- foreach ( $pmpro_pages as $pmpro_page_id => $pmpro_page ) {
25
- $shortcode_prefix = 'pmpro_';
26
- $shortcode = '[' . $shortcode_prefix . $pmpro_page_id . ']';
27
- $post = get_post( $pmpro_page );
28
-
29
- // If shortcode is found at the beginning of the page content and it is the only content that exists, remove the page
30
- if ( strpos( $post->post_content, $shortcode ) === 0 && strcmp( $post->post_content, $shortcode ) === 0 )
31
- wp_delete_post( $post->ID, true ); // Force delete (no trash)
32
- }
33
 
34
- // otherwise remove db tables
35
- global $wpdb;
36
-
37
- $tables = array(
38
- 'pmpro_discount_codes',
39
- 'pmpro_discount_codes_levels',
40
- 'pmpro_discount_codes_uses',
41
- 'pmpro_memberships_categories',
42
- 'pmpro_memberships_pages',
43
- 'pmpro_memberships_users',
44
- 'pmpro_membership_levels',
45
- 'pmpro_membership_orders'
46
- );
47
-
48
- foreach($tables as $table){
49
- $delete_table = $wpdb->prefix . $table;
50
- // setup sql query
51
- $sql = "DROP TABLE `$delete_table`";
52
- // run the query
53
- $wpdb->query($sql);
54
- }
55
 
56
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
57
- dbDelta($sql);
 
 
 
 
 
 
 
 
58
 
59
- //delete options
60
- global $wpdb;
61
- $sqlQuery = "DELETE FROM $wpdb->options WHERE option_name LIKE 'pmpro_%'";
62
- $wpdb->query($sqlQuery);
 
 
 
 
 
 
 
 
 
 
 
 
8
  if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN'))
9
  exit();
10
 
11
+ if ( get_option( 'pmpro_uninstall', 0 ) ) {
12
+ // otherwise remove pages
13
+ $pmpro_pages = array(
14
+ 'account' => get_option( 'pmpro_account_page_id' ),
15
+ 'billing' => get_option( 'pmpro_billing_page_id' ),
16
+ 'cancel' =>get_option( 'pmpro_cancel_page_id' ),
17
+ 'checkout' => get_option( 'pmpro_checkout_page_id' ),
18
+ 'confirmation' => get_option( 'pmpro_confirmation_page_id' ),
19
+ 'invoice' => get_option( 'pmpro_invoice_page_id' ),
20
+ 'levels' => get_option( 'pmpro_levels_page_id' ),
21
+ 'login' => get_option( 'pmpro_login_page_id' ),
22
+ 'member_profile_edit' => get_option( 'pmpro_member_profile_edit_page_id' )
23
+ );
 
 
 
 
 
 
 
 
 
24
 
25
+ foreach ( $pmpro_pages as $pmpro_page_id => $pmpro_page ) {
26
+ $shortcode_prefix = 'pmpro_';
27
+ $shortcode = '[' . $shortcode_prefix . $pmpro_page_id . ']';
28
+ $post = get_post( $pmpro_page );
29
+
30
+ // If shortcode is found at the beginning of the page content and it is the only content that exists, remove the page
31
+ if ( strpos( $post->post_content, $shortcode ) === 0 && strcmp( $post->post_content, $shortcode ) === 0 )
32
+ wp_delete_post( $post->ID, true ); // Force delete (no trash)
33
+ }
34
+
35
+ // otherwise remove db tables
36
+ global $wpdb;
 
 
 
 
 
 
 
 
 
37
 
38
+ $tables = array(
39
+ 'pmpro_discount_codes',
40
+ 'pmpro_discount_codes_levels',
41
+ 'pmpro_discount_codes_uses',
42
+ 'pmpro_memberships_categories',
43
+ 'pmpro_memberships_pages',
44
+ 'pmpro_memberships_users',
45
+ 'pmpro_membership_levels',
46
+ 'pmpro_membership_orders'
47
+ );
48
 
49
+ foreach($tables as $table){
50
+ $delete_table = $wpdb->prefix . $table;
51
+ // setup sql query
52
+ $sql = "DROP TABLE `$delete_table`";
53
+ // run the query
54
+ $wpdb->query($sql);
55
+ }
56
+
57
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
58
+ dbDelta($sql);
59
+
60
+ //delete options
61
+ global $wpdb;
62
+ $sqlQuery = "DELETE FROM $wpdb->options WHERE option_name LIKE 'pmpro_%'";
63
+ $wpdb->query($sqlQuery);
64
+ }