Guest User

Untitled

a guest
Jan 22nd, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.04 KB | None | 0 0
  1. <?php
  2. if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');}
  3. MeprHooks::do_action('mepr_before_account_subscriptions', $mepr_current_user);
  4. $is_lifetime_premium = get_post_meta(get_current_user_id(),'is_lifetime_premium',TRUE);
  5. if($is_lifetime_premium){
  6. // _ex("", 'ui', 'memberpress');
  7. echo "Congratulation! You're lifetime premium user.";
  8. }else{
  9. if(!empty($subscriptions)) {
  10. $alt = false;
  11. ?>
  12. <div class="mp_wrapper">
  13. <table id="mepr-account-subscriptions-table" class="mepr-account-table">
  14. <thead>
  15. <tr>
  16. <th><?php _ex('Membership', 'ui', 'memberpress'); ?></th>
  17. <th><?php _ex('Subscription', 'ui', 'memberpress'); ?></th>
  18. <th><?php _ex('Active', 'ui', 'memberpress'); ?></th>
  19. <th><?php _ex('Created', 'ui', 'memberpress'); ?></th>
  20. <th><?php _ex('Expires', 'ui', 'memberpress'); ?></th>
  21. <th><?php _ex('Card Exp.', 'ui', 'memberpress'); ?></th>
  22. <th> </th>
  23. <?php MeprHooks::do_action('mepr-account-subscriptions-th', $mepr_current_user, $subscriptions); ?>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <?php
  28. foreach($subscriptions as $s):
  29. if(trim($s->sub_type) == 'transaction') {
  30. $is_sub = false;
  31. $txn = $sub = new MeprTransaction($s->id);
  32. $pm = $txn->payment_method();
  33. $prd = $txn->product();
  34. $group = $prd->group();
  35. $default = _x('Never', 'ui', 'memberpress');
  36. if($txn->txn_type == MeprTransaction::$fallback_str && $mepr_current_user->subscription_in_group($group)) {
  37. //Skip fallback transactions when user has an active sub in the fallback group
  38. continue;
  39. }
  40. }
  41. else {
  42. $is_sub = true;
  43. $sub = new MeprSubscription($s->id);
  44. $txn = $sub->latest_txn();
  45. $pm = $sub->payment_method();
  46. $prd = $sub->product();
  47. $group = $prd->group();
  48. if($txn == false || !($txn instanceof MeprTransaction) || $txn->id <= 0) {
  49. $default = _x('Unknown', 'ui', 'memberpress');
  50. }
  51. else if(trim($txn->expires_at) == MeprUtils::db_lifetime() or empty($txn->expires_at)) {
  52. $default = _x('Never', 'ui', 'memberpress');
  53. }
  54. else {
  55. $default = _x('Unknown', 'ui', 'memberpress');
  56. }
  57. }
  58. $mepr_options = MeprOptions::fetch();
  59. $alt = !$alt; // Facilitiates the alternating lines
  60. ?>
  61. <tr id="mepr-subscription-row-<?php echo $s->id; ?>" class="mepr-subscription-row <?php echo (isset($alt) && !$alt)?'mepr-alt-row':''; ?>">
  62. <td data-label="<?php _ex('Membership', 'ui', 'memberpress'); ?>">
  63. <!-- MEMBERSHIP ACCESS URL -->
  64. <?php if(isset($prd->access_url) && !empty($prd->access_url)): ?>
  65. <div class="mepr-account-product"><a href="<?php echo stripslashes($prd->access_url); ?>"><?php echo MeprHooks::apply_filters('mepr-account-subscr-product-name', $prd->post_title, $txn); ?></a></div>
  66. <?php else: ?>
  67. <div class="mepr-account-product"><?php echo MeprHooks::apply_filters('mepr-account-subscr-product-name', $prd->post_title, $txn); ?></div>
  68. <?php endif; ?>
  69.  
  70. <?php if($txn != false && $txn instanceof MeprTransaction && !$txn->is_sub_account()): ?>
  71. <div class="mepr-account-subscr-id"><?php echo $s->subscr_id; ?></div>
  72. <?php endif; ?>
  73. </td>
  74. <td data-label="<?php _ex('Terms', 'ui', 'memberpress'); ?>">
  75. <div class="mepr-account-auto-rebill">
  76. <?php
  77. if($txn != false && $txn instanceof MeprTransaction && $txn->is_sub_account()) {
  78. ?>
  79. <div class="mepr-account-sub-account-auto-rebill">
  80. <?php _ex('Sub Account', 'ui', 'memberpress'); ?>
  81. <?php MeprHooks::do_action('mepr_account_subscriptions_sub_account_auto_rebill', $txn); ?>
  82. </div>
  83. <?php
  84. }
  85. else {
  86. if($is_sub):
  87. echo ($s->status == MeprSubscription::$active_str)?_x('Enabled', 'ui', 'memberpress'):MeprAppHelper::human_readable_status($s->status, 'subscription');
  88. elseif(is_null($s->expires_at) or $s->expires_at == MeprUtils::db_lifetime()):
  89. _ex('Lifetime', 'ui', 'memberpress');
  90. else:
  91. _ex('None', 'ui', 'memberpress');
  92. endif;
  93. }
  94. ?>
  95. </div>
  96. <?php if($prd->register_price_action != 'hidden'): ?>
  97. <div class="mepr-account-terms">
  98. <?php
  99. if($txn != false && $txn instanceof MeprTransaction && $txn->is_sub_account()) {
  100. MeprHooks::do_action('mepr_account_subscriptions_sub_account_terms', $txn);
  101. }
  102. else {
  103. if($prd->register_price_action == 'custom' && !empty($prd->register_price)) {
  104. //Add coupon in if one was used eh
  105. $coupon_str = '';
  106. if($is_sub) {
  107. $subscr = new MeprSubscription($s->id);
  108. if($subscr->coupon_id && ($coupon = new MeprCoupon($subscr->coupon_id)) && isset($coupon->ID) && $coupon->ID) {
  109. $coupon_str = ' ' . _x('with coupon', 'ui', 'memberpress') . ' ' . $coupon->post_title;
  110. }
  111. }
  112. echo stripslashes($prd->register_price) . $coupon_str;
  113. }
  114. else if($txn != false && $txn instanceof MeprTransaction) {
  115. echo MeprTransactionsHelper::format_currency($txn);
  116. }
  117. }
  118. ?>
  119. </div>
  120. <?php endif; ?>
  121. <?php if($txn != false && $txn instanceof MeprTransaction && !$txn->is_sub_account && $is_sub && ($nba = $sub->next_billing_at)): ?>
  122. <div class="mepr-account-rebill"><?php printf(_x('Next Billing: %s', 'ui', 'memberpress'), MeprAppHelper::format_date($nba)); ?></div>
  123. <?php endif; ?>
  124. </td>
  125. <td data-label="<?php _ex('Active', 'ui', 'memberpress'); ?>"><div class="mepr-account-active"><?php echo $s->active; ?></div></td>
  126. <td data-label="<?php _ex('Created', 'ui', 'memberpress'); ?>">
  127. <?php if($txn != false && $txn instanceof MeprTransaction && $txn->is_sub_account()): ?>
  128. <div>--</div>
  129. <?php else: ?>
  130. <div class="mepr-account-created-at"><?php echo MeprAppHelper::format_date($s->created_at); ?></div>
  131. <?php endif; ?>
  132. </td>
  133. <td data-label="<?php _ex('Expires', 'ui', 'memberpress'); ?>">
  134. <?php if($txn != false && $txn instanceof MeprTransaction && $txn->is_sub_account()): ?>
  135. <div>--</div>
  136. <?php else: ?>
  137. <div class="mepr-account-expires-at">
  138. <?php if($txn != false && $txn instanceof MeprTransaction && $txn->txn_type == MeprTransaction::$payment_str || ($is_sub && !$sub->in_grace_period())) {
  139. echo MeprAppHelper::format_date($s->expires_at, $default);
  140. }
  141. elseif($txn != false && $txn instanceof MeprTransaction && $txn->txn_type == MeprTransaction::$fallback_str) {
  142. _ex('Never', 'ui', 'memberpress');
  143. }
  144. else {
  145. _ex('processing', 'ui', 'memberpress');
  146. }
  147. ?>
  148. </div>
  149. <?php endif; ?>
  150. </td>
  151. <td data-label="<?php _ex('Card Expires', 'ui', 'memberpress'); ?>">
  152. <?php if($txn != false && $txn instanceof MeprTransaction && $txn->is_sub_account()): ?>
  153. <div>--</div>
  154. <?php else: ?>
  155. <?php if( ($exp_mo = $sub->cc_exp_month) && ($exp_yr = $sub->cc_exp_year) ): ?>
  156. <?php $cc_class = (($sub->cc_expiring_before_next_payment())?' mepr-inactive':''); ?>
  157. <div class="mepr-account-cc-exp<?php echo $cc_class; ?>"><?php printf(_x('%1$02d-%2$d', 'ui', 'memberpress'), $exp_mo, $exp_yr); ?></div>
  158. <?php else: //Need a placeholder for responsive ?>
  159. <div>&zwnj;</div>
  160. <?php endif; ?>
  161. <?php endif; ?>
  162. </td>
  163. <td data-label="<?php _ex('Actions', 'ui', 'memberpress'); ?>">
  164. <div class="mepr-account-actions">
  165. <?php
  166. if($txn != false && $txn instanceof MeprTransaction && ($txn->is_sub_account() || $txn->txn_type == MeprTransaction::$fallback_str)) {
  167. echo '--';
  168. }
  169. else {
  170. if( $is_sub && $pm instanceof MeprBaseRealGateway &&
  171. ( $s->status == MeprSubscription::$active_str ||
  172. $s->status == MeprSubscription::$suspended_str ||
  173. strpos($s->active, 'mepr-active') !== false ) ) {
  174. $subscription = new MeprSubscription($s->id);
  175. if(!$subscription->in_grace_period()) { //Don't let people change shiz until a payment has come through yo
  176. $pm->print_user_account_subscription_row_actions($subscription);
  177. }
  178. }
  179. elseif(!$is_sub && !empty($prd->ID)) {
  180. if($prd->is_renewable() && $prd->is_renewal()) {
  181. ?>
  182. <a href="<?php echo $prd->url(); ?>" class="mepr-account-row-action mepr-account-renew"><?php _ex('Renew', 'ui', 'memberpress'); ?></a>
  183. <?php
  184. }
  185. if($txn != false && $txn instanceof MeprTransaction && $group !== false && strpos($s->active, 'mepr-inactive') === false) {
  186. MeprAccountHelper::group_link($txn);
  187. }
  188. elseif(/*$group !== false &&*/ strpos($s->active, 'mepr-inactive') !== false /*&& !$prd->is_renewable()*/) {
  189. if($prd->can_you_buy_me()) {
  190. MeprAccountHelper::purchase_link($prd);
  191. }
  192. }
  193. }
  194. else {
  195. if($prd->can_you_buy_me()) {
  196. if($group !== false) {
  197. MeprAccountHelper::purchase_link($prd);
  198. }
  199. else if($txn != false && $txn instanceof MeprTransaction) {
  200. $sub_in_group = $mepr_current_user->subscription_in_group($group);
  201. $life_in_group = $mepr_current_user->lifetime_subscription_in_group($group);
  202. if(!$sub_in_group && !$life_in_group) { //$prd is in group, but user has no other active subs in this group, so let's show the change plan option
  203. MeprAccountHelper::purchase_link($prd, _x('Re-Subscribe', 'ui', 'memberpress'));
  204. MeprAccountHelper::group_link($txn);
  205. }
  206. }
  207. }
  208. }
  209. MeprHooks::do_action('mepr-account-subscriptions-actions', $mepr_current_user, $s, $txn, $is_sub);
  210. }
  211. ?>
  212. &zwnj; <!-- Responsiveness when no actions present -->
  213. </div>
  214. </td>
  215. <?php MeprHooks::do_action('mepr-account-subscriptions-td', $mepr_current_user, $s, $txn, $is_sub); ?>
  216. </tr>
  217. <?php endforeach; ?>
  218. <?php MeprHooks::do_action('mepr-account-subscriptions-table', $mepr_current_user, $subscriptions); ?>
  219. </tbody>
  220. </table>
  221. <div id="mepr-subscriptions-paging">
  222. <?php if($prev_page): ?>
  223. <a href="<?php echo "{$account_url}{$delim}currpage={$prev_page}"; ?>"><< <?php _ex('Previous Page', 'ui', 'memberpress'); ?></a>
  224. <?php endif; ?>
  225. <?php if($next_page): ?>
  226. <a href="<?php echo "{$account_url}{$delim}currpage={$next_page}"; ?>" style="float:right;"><?php _ex('Next Page', 'ui', 'memberpress'); ?> >></a>
  227. <?php endif; ?>
  228. </div>
  229. <div style="clear:both"></div>
  230. </div>
  231. <?php
  232. }
  233. else {
  234. _ex('You have no active subscriptions to display.', 'ui', 'memberpress');
  235. }
  236. }
  237.  
  238. MeprHooks::do_action('mepr_account_subscriptions', $mepr_current_user);
Add Comment
Please, Sign In to add comment