/app/template/template-tags.php

  1. <?php 
  2. /** 
  3. * Template functions that can be used to create new templates 
  4. * for several M2 pages 
  5. * 
  6. * @since 1.0.3 
  7. * 
  8. * @package Membership2 
  9. */ 
  10.  
  11. if ( ! function_exists( 'is_ms_admin_user' ) ) { 
  12. function is_ms_admin_user() { 
  13. return MS_Model_Member::is_admin_user(); 
  14.  
  15. /***************************** Single Membership Box *****************************/ 
  16.  
  17. if ( ! function_exists( 'get_ms_single_box_membership_obj' ) ) { 
  18. function get_ms_single_box_membership_obj() { 
  19. return MS_Helper_Template::$ms_single_box['m2_obj']; 
  20.  
  21. if ( ! function_exists( 'get_ms_single_box_membership_id' ) ) { 
  22. function get_ms_single_box_membership_id() { 
  23. return MS_Helper_Template::$ms_single_box['membership_id']; 
  24.  
  25. if ( ! function_exists( 'get_ms_single_box_wrapper_classes' ) ) { 
  26. function get_ms_single_box_wrapper_classes() { 
  27. return MS_Helper_Template::$ms_single_box['membership_wrapper_classes']; 
  28.  
  29. if ( ! function_exists( 'get_ms_single_box_membership_name' ) ) { 
  30. function get_ms_single_box_membership_name() { 
  31. return MS_Helper_Template::$ms_single_box['membership_name']; 
  32.  
  33. if ( ! function_exists( 'get_ms_single_box_membership_description' ) ) { 
  34. function get_ms_single_box_membership_description() { 
  35. return MS_Helper_Template::$ms_single_box['membership_description']; 
  36.  
  37. if ( ! function_exists( 'get_ms_single_box_membership_price' ) ) { 
  38. function get_ms_single_box_membership_price() { 
  39. return MS_Helper_Template::$ms_single_box['membership_price']; 
  40.  
  41. if ( ! function_exists( 'is_ms_single_box_msg' ) ) { 
  42. function is_ms_single_box_msg() { 
  43. return isset( MS_Helper_Template::$ms_single_box['msg'] ); 
  44.  
  45. if ( ! function_exists( 'get_ms_single_box_msg' ) ) { 
  46. function get_ms_single_box_msg() { 
  47. return '' . MS_Helper_Template::$ms_single_box['msg']; 
  48.  
  49. if ( ! function_exists( 'is_ms_single_box_action_pay' ) ) { 
  50. function is_ms_single_box_action_pay() { 
  51. return MS_Helper_Membership::MEMBERSHIP_ACTION_PAY === MS_Helper_Template::$ms_single_box['action']; 
  52.  
  53. if ( ! function_exists( 'get_ms_single_box_payment_btn' ) ) { 
  54. function get_ms_single_box_payment_btn() { 
  55. $html = ''; 
  56. ob_start(); 
  57. MS_Helper_Html::html_link( MS_Helper_Template::$ms_single_box['link'] ); 
  58. $html = ob_get_contents(); 
  59. ob_end_clean(); 
  60.  
  61. return $html; 
  62.  
  63. if ( ! function_exists( 'get_ms_single_box_hidden_fields' ) ) { 
  64. function get_ms_single_box_hidden_fields() { 
  65. $html = ''; 
  66. ob_start(); 
  67. foreach ( MS_Helper_Template::$ms_single_box['fields'] as $field ) { 
  68. $html .= MS_Helper_Html::html_element( $field ); 
  69. $html = ob_get_contents(); 
  70. ob_end_clean(); 
  71.  
  72. return $html; 
  73.  
  74. if ( ! function_exists( 'get_ms_single_box_btn' ) ) { 
  75. function get_ms_single_box_btn() { 
  76.  
  77. $html = ''; 
  78. ob_start(); 
  79. MS_Helper_Html::html_element( MS_Helper_Template::$ms_single_box['button'] ); 
  80. $html = ob_get_contents(); 
  81. ob_end_clean(); 
  82.  
  83. return $html; 
  84.  
  85.  
  86. /***************************** M2 Registration Form *****************************/ 
  87.  
  88. if ( ! function_exists( 'ms_registration_form_obj' ) ) { 
  89. function ms_registration_form_obj() { 
  90. return MS_Helper_Template::$ms_registration_form['m2_obj']; 
  91.  
  92. if ( ! function_exists( 'is_ms_registration_form_title_exists' ) ) { 
  93. function is_ms_registration_form_title_exists() { 
  94. return isset( MS_Helper_Template::$ms_registration_form['title'] ); 
  95.  
  96. if ( ! function_exists( 'get_ms_registration_form_title' ) ) { 
  97. function get_ms_registration_form_title() { 
  98. return MS_Helper_Template::$ms_registration_form['title']; 
  99.  
  100. if ( ! function_exists( 'get_ms_registration_form_fields' ) ) { 
  101. function get_ms_registration_form_fields() { 
  102.  
  103. $html = ''; 
  104. ob_start(); 
  105. foreach ( MS_Helper_Template::$ms_registration_form['fields'] as $field ) { 
  106. if ( is_string( $field ) ) { 
  107. MS_Helper_Html::html_element( $field ); 
  108. } elseif ( MS_Helper_Html::INPUT_TYPE_HIDDEN == $field['type'] ) { 
  109. MS_Helper_Html::html_element( $field ); 
  110. } else { 
  111. ?> 
  112. <div class="ms-form-element ms-form-element-<?php echo esc_attr( $field['id'] ); ?>"> 
  113. <?php MS_Helper_Html::html_element( $field ); ?> 
  114. </div> 
  115. <?php 
  116. $html = ob_get_contents(); 
  117. ob_end_clean(); 
  118.  
  119. return $html; 
  120.  
  121. if ( ! function_exists( 'ms_registration_form_extra_fields' ) ) { 
  122. function ms_registration_form_extra_fields() { 
  123.  
  124. /** 
  125. * Trigger default WordPress action to allow other plugins 
  126. * to add custom fields to the registration form. 
  127. * 
  128. * signup_extra_fields Defined in wp-signup.php which is used 
  129. * for Multisite signup process. 
  130. * 
  131. * register_form Defined in wp-login.php which is only used for 
  132. * Single site registration process. 
  133. * 
  134. * @since 1.0.0 
  135. */ 
  136. if ( is_multisite() ) { 
  137. do_action( 'signup_extra_fields', MS_Helper_Template::$ms_registration_form['empty_error'] ); 
  138. } else { 
  139. do_action( 'register_form' ); 
  140.  
  141. if ( ! function_exists( 'get_ms_registration_form_register_button' ) ) { 
  142. function get_ms_registration_form_register_button() { 
  143. $html = ''; 
  144. ob_start(); 
  145. MS_Helper_Html::html_element( MS_Helper_Template::$ms_registration_form['register_button'] ); 
  146. $html = ob_get_contents(); 
  147. ob_end_clean(); 
  148.  
  149. return $html; 
  150.  
  151. if ( ! function_exists( 'ms_registration_form_error' ) ) { 
  152. function ms_registration_form_error() { 
  153. if ( is_wp_error( MS_Helper_Template::$ms_registration_form['m2_reg_error'] ) ) { 
  154. /** 
  155. * Display registration errors. 
  156. * 
  157. * @since 1.0.0 
  158. */ 
  159. do_action( 'registration_errors', MS_Helper_Template::$ms_registration_form['m2_reg_error'] ); 
  160.  
  161. if ( ! function_exists( 'is_ms_registration_form_login_link_exists' ) ) { 
  162. function is_ms_registration_form_login_link_exists() { 
  163. return lib3()->is_true( MS_Helper_Template::$ms_registration_form['login_link_exists'] ); 
  164.  
  165. if ( ! function_exists( 'get_ms_registration_form_login_link' ) ) { 
  166. function get_ms_registration_form_login_link() { 
  167. $html = ''; 
  168. ob_start(); 
  169. MS_Helper_Html::html_link( MS_Helper_Template::$ms_registration_form['login_link'] ); 
  170. $html = ob_get_contents(); 
  171. ob_end_clean(); 
  172.  
  173. return $html; 
  174.  
  175.  
  176. /************************** M2 Frontend Payment Table ***************************/ 
  177.  
  178. if ( ! function_exists( 'get_ms_payment_obj' ) ) { 
  179. function get_ms_payment_obj() { 
  180. return MS_Helper_Template::$ms_front_payment['m2_payment_obj']; 
  181.  
  182. if ( ! function_exists( 'get_ms_payment_obj_data' ) ) { 
  183. function get_ms_payment_obj_data() { 
  184. return MS_Helper_Template::$ms_front_payment['m2_payment_obj']->data; 
  185.  
  186. if ( ! function_exists( 'get_ms_payment_subscription' ) ) { 
  187. function get_ms_payment_subscription() { 
  188. return MS_Helper_Template::$ms_front_payment['subscription']; 
  189.  
  190. if ( ! function_exists( 'get_ms_payment_invoice' ) ) { 
  191. function get_ms_payment_invoice() { 
  192. return MS_Helper_Template::$ms_front_payment['invoice']; 
  193.  
  194. if ( ! function_exists( 'get_ms_pm_membership_wrapper_class' ) ) { 
  195. function get_ms_pm_membership_wrapper_class() { 
  196. return MS_Helper_Template::$ms_front_payment['membership_wrapper_class']; 
  197.  
  198. if ( ! function_exists( 'get_ms_pm_alert_box_class' ) ) { 
  199. function get_ms_pm_alert_box_class() { 
  200. return MS_Helper_Template::$ms_front_payment['alert_box_class']; 
  201.  
  202. if ( ! function_exists( 'get_ms_pm_message' ) ) { 
  203. function get_ms_pm_message() { 
  204. return MS_Helper_Template::$ms_front_payment['msg']; 
  205.  
  206. if ( ! function_exists( 'get_ms_pm_membership_name' ) ) { 
  207. function get_ms_pm_membership_name() { 
  208. return MS_Helper_Template::$ms_front_payment['membership_name']; 
  209.  
  210. if ( ! function_exists( 'is_ms_pm_membership_description' ) ) { 
  211. function is_ms_pm_membership_description() { 
  212. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['is_membership_description'] ); 
  213.  
  214. if ( ! function_exists( 'get_ms_pm_membership_description' ) ) { 
  215. function get_ms_pm_membership_description() { 
  216. return MS_Helper_Template::$ms_front_payment['membership_description']; 
  217.  
  218. if ( ! function_exists( 'is_ms_pm_membership_free' ) ) { 
  219. function is_ms_pm_membership_free() { 
  220. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['is_membership_free'] ); 
  221.  
  222. if ( ! function_exists( 'is_ms_pm_invoice_discount' ) ) { 
  223. function is_ms_pm_invoice_discount() { 
  224. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['invoice_discount'] ); 
  225.  
  226. if ( ! function_exists( 'is_ms_pm_invoice_pro_rate' ) ) { 
  227. function is_ms_pm_invoice_pro_rate() { 
  228. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['invoice_pro_rate'] ); 
  229.  
  230. if ( ! function_exists( 'is_ms_pm_invoice_tax_rate' ) ) { 
  231. function is_ms_pm_invoice_tax_rate() { 
  232. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['invoice_tax_rate'] ); 
  233.  
  234. if ( ! function_exists( 'get_ms_pm_membership_price' ) ) { 
  235. function get_ms_pm_membership_price() { 
  236. return MS_Helper_Template::$ms_front_payment['membership_price']; 
  237.  
  238. if ( ! function_exists( 'get_ms_pm_membership_formatted_price' ) ) { 
  239. function get_ms_pm_membership_formatted_price() { 
  240. return MS_Helper_Template::$ms_front_payment['membership_formatted_price']; 
  241.  
  242. if ( ! function_exists( 'get_ms_pm_invoice_formatted_discount' ) ) { 
  243. function get_ms_pm_invoice_formatted_discount() { 
  244. return MS_Helper_Template::$ms_front_payment['invoice_formatted_discount']; 
  245.  
  246. if ( ! function_exists( 'get_ms_pm_invoice_formatted_pro_rate' ) ) { 
  247. function get_ms_pm_invoice_formatted_pro_rate() { 
  248. return MS_Helper_Template::$ms_front_payment['invoice_formatted_pro_rate']; 
  249.  
  250. if ( ! function_exists( 'is_ms_pm_show_tax' ) ) { 
  251. function is_ms_pm_show_tax() { 
  252. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['show_tax'] ); 
  253.  
  254. if ( ! function_exists( 'get_ms_pm_invoice_tax_name' ) ) { 
  255. function get_ms_pm_invoice_tax_name() { 
  256. return MS_Helper_Template::$ms_front_payment['invoice_tax_name']; 
  257.  
  258. if ( ! function_exists( 'get_ms_pm_invoice_formatted_tax' ) ) { 
  259. function get_ms_pm_invoice_formatted_tax() { 
  260. return MS_Helper_Template::$ms_front_payment['invoice_formatted_tax']; 
  261.  
  262. if ( ! function_exists( 'get_ms_pm_invoice_total' ) ) { 
  263. function get_ms_pm_invoice_total() { 
  264. return MS_Helper_Template::$ms_front_payment['invoice_total']; 
  265.  
  266. if ( ! function_exists( 'get_ms_pm_invoice_formatted_total_for_admin' ) ) { 
  267. function get_ms_pm_invoice_formatted_total_for_admin() { 
  268. return MS_Helper_Template::$ms_front_payment['invoice_formatted_total_for_admin']; 
  269.  
  270. if ( ! function_exists( 'get_ms_pm_invoice_formatted_total' ) ) { 
  271. function get_ms_pm_invoice_formatted_total() { 
  272. return MS_Helper_Template::$ms_front_payment['invoice_formatted_total']; 
  273.  
  274. if ( ! function_exists( 'is_ms_pm_trial' ) ) { 
  275. function is_ms_pm_trial() { 
  276. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['is_trial'] ); 
  277.  
  278. if ( ! function_exists( 'get_ms_pm_invoice_formatted_due_date' ) ) { 
  279. function get_ms_pm_invoice_formatted_due_date() { 
  280. return MS_Helper_Template::$ms_front_payment['invoice_formatted_due_date']; 
  281.  
  282. if ( ! function_exists( 'get_ms_pm_invoice_trial_price' ) ) { 
  283. function get_ms_pm_invoice_trial_price() { 
  284. return MS_Helper_Template::$ms_front_payment['invoice_trial_price']; 
  285.  
  286. if ( ! function_exists( 'get_ms_pm_invoice_formatted_trial_price' ) ) { 
  287. function get_ms_pm_invoice_formatted_trial_price() { 
  288. return MS_Helper_Template::$ms_front_payment['invoice_formatted_trial_price']; 
  289.  
  290. if ( ! function_exists( 'get_ms_pm_invoice_payment_description' ) ) { 
  291. function get_ms_pm_invoice_payment_description() { 
  292. return MS_Helper_Template::$ms_front_payment['invoice_payment_description']; 
  293.  
  294. if ( ! function_exists( 'is_ms_pm_cancel_warning' ) ) { 
  295. function is_ms_pm_cancel_warning() { 
  296. return lib3()->is_true( MS_Helper_Template::$ms_front_payment['cancel_warning'] ); 
  297.  
  298. if ( ! function_exists( 'get_ms_pm_cancel_warning' ) ) { 
  299. function get_ms_pm_cancel_warning() { 
  300. return MS_Helper_Template::$ms_front_payment['cancel_warning']; 
  301.  
  302.  
  303. /***************************** ACCOUNT PAGE *****************************/ 
  304.  
  305. if ( ! function_exists( 'get_ms_ac_data' ) ) { 
  306. function get_ms_ac_data() { 
  307. return MS_Helper_Template::$ms_account; 
  308.  
  309. if ( ! function_exists( 'ms_is_user_logged_in' ) ) { 
  310. function ms_is_user_logged_in() { 
  311. return MS_Helper_Template::$ms_account['is_user_logged_in']; 
  312.  
  313. if ( ! function_exists( 'get_ms_ac_title' ) ) { 
  314. function get_ms_ac_title() { 
  315. return MS_Helper_Template::$ms_account['membership_title']; 
  316.  
  317. if ( ! function_exists( 'ms_show_users_membership' ) ) { 
  318. function ms_show_users_membership() { 
  319. return lib3()->is_true( MS_Helper_Template::$ms_account['show_membership'] ); 
  320.  
  321. if ( ! function_exists( 'show_membership_change_link' ) ) { 
  322. function show_membership_change_link() { 
  323. return lib3()->is_true( MS_Helper_Template::$ms_account['show_membership_change'] ); 
  324.  
  325. if ( ! function_exists( 'get_ms_ac_signup_modified_url' ) ) { 
  326. function get_ms_ac_signup_modified_url() { 
  327. return MS_Helper_Template::$ms_account['signup_modified_url']; 
  328.  
  329. if ( ! function_exists( 'get_ms_ac_member_obj' ) ) { 
  330. function get_ms_ac_member_obj() { 
  331. return MS_Helper_Template::$ms_account['member']; 
  332.  
  333. if ( ! function_exists( 'get_ms_ac_account_obj' ) ) { 
  334. function get_ms_ac_account_obj() { 
  335. return MS_Helper_Template::$ms_account['m2_account_obj']; 
  336.  
  337. if ( ! function_exists( 'has_ms_ac_subscriptions' ) ) { 
  338. function has_ms_ac_subscriptions() { 
  339. return ! empty( MS_Helper_Template::$ms_account['m2_subscriptions'] ); 
  340.  
  341. if ( ! function_exists( 'get_ms_ac_subscriptions' ) ) { 
  342. function get_ms_ac_subscriptions() { 
  343. return MS_Helper_Template::$ms_account['m2_subscriptions']; 
  344.  
  345. if ( ! function_exists( 'ms_account_the_membership' ) ) { 
  346. function ms_account_the_membership( $subscription ) { 
  347. MS_Helper_Template::$ms_account['subscription'] = $subscription; 
  348. MS_Helper_Template::$ms_account['membership'] = $subscription->get_membership(); 
  349.  
  350. if ( ! function_exists( 'prepare_ms_account_classes' ) ) { 
  351. function prepare_ms_account_classes() { 
  352. $subscription = MS_Helper_Template::$ms_account['subscription']; 
  353. $membership = $subscription->get_membership(); 
  354. return array( 
  355. 'ms-subscription-' . $subscription->id,  
  356. 'ms-status-' . $subscription->status,  
  357. 'ms-type-' . $membership->type,  
  358. 'ms-payment-' . $membership->payment_type,  
  359. 'ms-gateway-' . $subscription->gateway_id,  
  360. 'ms-membership-' . $subscription->membership_id,  
  361. $subscription->has_trial() ? 'ms-with-trial' : 'ms-no-trial',  
  362. ); 
  363.  
  364. if ( ! function_exists( 'get_ms_account_classes' ) ) { 
  365. function get_ms_account_classes() { 
  366. return esc_attr( implode( ' ', prepare_ms_account_classes() ) ); 
  367.  
  368. if ( ! function_exists( 'get_ms_account_membership_name' ) ) { 
  369. function get_ms_account_membership_name() { 
  370. return esc_html( MS_Helper_Template::$ms_account['membership']->name ); 
  371.  
  372. if ( ! function_exists( 'get_ms_account_membership_status' ) ) { 
  373. function get_ms_account_membership_status() { 
  374. if ( MS_Model_Relationship::STATUS_PENDING == MS_Helper_Template::$ms_account['subscription']->status ) { 
  375. // Display a "Purchase" link when status is Pending 
  376. $code = sprintf( 
  377. '[%s id="%s" label="%s"]',  
  378. MS_Helper_Shortcode::SCODE_MS_BUY,  
  379. MS_Helper_Template::$ms_account['membership']->id,  
  380. __( 'Pending', 'membership2' ) 
  381. ); 
  382. return do_shortcode( $code ); 
  383. } else { 
  384. return esc_html( MS_Helper_Template::$ms_account['subscription']->status_text() ); 
  385.  
  386. if ( ! function_exists( 'get_ms_account_expire_date' ) ) { 
  387. function get_ms_account_expire_date() { 
  388.  
  389. // These subscriptions have no expire date 
  390. $no_expire_list = array( 
  391. MS_Model_Relationship::STATUS_PENDING,  
  392. MS_Model_Relationship::STATUS_WAITING,  
  393. MS_Model_Relationship::STATUS_DEACTIVATED,  
  394. ); 
  395.  
  396. // These subscriptions display the trial-expire date 
  397. $trial_expire_list = array( 
  398. MS_Model_Relationship::STATUS_TRIAL,  
  399. MS_Model_Relationship::STATUS_TRIAL_EXPIRED,  
  400. ); 
  401.  
  402. if ( in_array( MS_Helper_Template::$ms_account['subscription']->status, $no_expire_list ) ) { 
  403. return ' '; 
  404. } elseif ( in_array( MS_Helper_Template::$ms_account['subscription']->status, $trial_expire_list ) ) { 
  405. return esc_html( 
  406. MS_Helper_Period::format_date( MS_Helper_Template::$ms_account['subscription']->trial_expire_date ) 
  407. ); 
  408. } elseif ( MS_Helper_Template::$ms_account['subscription']->expire_date ) { 
  409. return esc_html( 
  410. MS_Helper_Period::format_date( MS_Helper_Template::$ms_account['subscription']->expire_date ) 
  411. ); 
  412. } else { 
  413. return __( 'Never', 'membership2' ); 
  414.  
  415. if ( ! function_exists( 'get_ms_no_account_membership_status' ) ) { 
  416. function get_ms_no_account_membership_status() { 
  417. $cols = 3; 
  418.  
  419. if ( MS_Model_Addon::is_enabled( MS_Model_Addon::ADDON_TRIAL ) ) { 
  420. $cols += 1; 
  421.  
  422. return sprintf( 
  423. '<tr><td colspan="%1$s">%2$s</td></tr>',  
  424. $cols,  
  425. __( '(No Membership)', 'membership2' ) 
  426. ); 
  427.  
  428. if ( ! function_exists( 'is_ms_ac_show_profile' ) ) { 
  429. function is_ms_ac_show_profile() { 
  430. return lib3()->is_true( MS_Helper_Template::$ms_account['show_profile'] ); 
  431.  
  432. if ( ! function_exists( 'get_ms_ac_profile_title' ) ) { 
  433. function get_ms_ac_profile_title() { 
  434. return MS_Helper_Template::$ms_account['profile_title']; 
  435.  
  436. if ( ! function_exists( 'is_ms_ac_show_profile_change' ) ) { 
  437. function is_ms_ac_show_profile_change() { 
  438. return lib3()->is_true( MS_Helper_Template::$ms_account['show_profile_change'] ); 
  439.  
  440. if ( ! function_exists( 'get_ms_ac_profile_change_link' ) ) { 
  441. function get_ms_ac_profile_change_link() { 
  442. return MS_Helper_Template::$ms_account['profile_change_formatted_label']; 
  443.  
  444. if ( ! function_exists( 'get_ms_ac_profile_fields' ) ) { 
  445. function get_ms_ac_profile_fields() { 
  446. return MS_Helper_Template::$ms_account['fields']['personal_info']; 
  447.  
  448. if ( ! function_exists( 'get_ms_ac_profile_info' ) ) { 
  449. function get_ms_ac_profile_info( $field ) { 
  450. return MS_Helper_Template::$ms_account['member']->$field; 
  451.  
  452. if ( ! function_exists( 'is_ms_ac_show_invoices' ) ) { 
  453. function is_ms_ac_show_invoices() { 
  454. return lib3()->is_true( MS_Helper_Template::$ms_account['show_invoices'] ); 
  455.  
  456. if ( ! function_exists( 'get_ms_ac_invoices_title' ) ) { 
  457. function get_ms_ac_invoices_title() { 
  458. return MS_Helper_Template::$ms_account['invoices_title']; 
  459.  
  460. if ( ! function_exists( 'is_ms_ac_show_all_invoices' ) ) { 
  461. function is_ms_ac_show_all_invoices() { 
  462. return lib3()->is_true( MS_Helper_Template::$ms_account['show_all_invoices'] ); 
  463.  
  464. if ( ! function_exists( 'get_ms_ac_invoices_detail_label' ) ) { 
  465. function get_ms_ac_invoices_detail_label() { 
  466. return MS_Helper_Template::$ms_account['invoices_details_formatted_label']; 
  467.  
  468. if ( ! function_exists( 'get_ms_ac_invoices' ) ) { 
  469. function get_ms_ac_invoices() { 
  470. return MS_Helper_Template::$ms_account['invoices']; 
  471.  
  472. if ( ! function_exists( 'ms_account_the_invoice' ) ) { 
  473. function ms_account_the_invoice( $invoice ) { 
  474. MS_Helper_Template::$ms_account['invoice'] = $invoice; 
  475. MS_Helper_Template::$ms_account['inv_membership'] = MS_Factory::load( 'MS_Model_Membership', $invoice->membership_id ); 
  476.  
  477. if ( ! function_exists( 'prepare_ms_invoice_classes' ) ) { 
  478. function prepare_ms_invoice_classes() { 
  479. return array( 
  480. 'ms-invoice-' . MS_Helper_Template::$ms_account['invoice']->id,  
  481. 'ms-subscription-' . MS_Helper_Template::$ms_account['invoice']->ms_relationship_id,  
  482. 'ms-invoice-' . MS_Helper_Template::$ms_account['invoice']->status,  
  483. 'ms-gateway-' . MS_Helper_Template::$ms_account['invoice']->gateway_id,  
  484. 'ms-membership-' . MS_Helper_Template::$ms_account['invoice']->membership_id,  
  485. 'ms-type-' . MS_Helper_Template::$ms_account['invoice']->type,  
  486. 'ms-payment-' . MS_Helper_Template::$ms_account['invoice']->payment_type,  
  487. ); 
  488.  
  489. if ( ! function_exists( 'get_ms_invoice_classes' ) ) { 
  490. function get_ms_invoice_classes() { 
  491. return esc_attr( implode( ' ', prepare_ms_invoice_classes() ) ); 
  492.  
  493. if ( ! function_exists( 'get_ms_invoice_number' ) ) { 
  494. function get_ms_invoice_number() { 
  495. return sprintf( 
  496. '<a href="%s">%s</a>',  
  497. get_permalink( MS_Helper_Template::$ms_account['invoice']->id ),  
  498. MS_Helper_Template::$ms_account['invoice']->get_invoice_number() 
  499. ); 
  500.  
  501. if ( ! function_exists( 'get_ms_invoice_next_status' ) ) { 
  502. function get_ms_invoice_next_status() { 
  503. return esc_html( MS_Helper_Template::$ms_account['invoice']->status_text() ); 
  504.  
  505. if ( ! function_exists( 'get_ms_invoice_total' ) ) { 
  506. function get_ms_invoice_total() { 
  507. return esc_html( MS_Helper_Billing::format_price( MS_Helper_Template::$ms_account['invoice']->total ) ); 
  508.  
  509. if ( ! function_exists( 'get_ms_invoice_name' ) ) { 
  510. function get_ms_invoice_name() { 
  511. return esc_html( MS_Helper_Template::$ms_account['inv_membership']->name ); 
  512.  
  513. if ( ! function_exists( 'get_ms_invoice_due_date' ) ) { 
  514. function get_ms_invoice_due_date() { 
  515. return esc_html( 
  516. MS_Helper_Period::format_date( 
  517. MS_Helper_Template::$ms_account['invoice']->due_date,  
  518. __( 'F j', 'membership2' ) 
  519. ); 
  520.  
  521. if ( ! function_exists( 'is_ms_ac_show_activity' ) ) { 
  522. function is_ms_ac_show_activity() { 
  523. return lib3()->is_true( MS_Helper_Template::$ms_account['show_activity'] ); 
  524.  
  525. if ( ! function_exists( 'get_ms_ac_activity_title' ) ) { 
  526. function get_ms_ac_activity_title() { 
  527. return MS_Helper_Template::$ms_account['activity_title']; 
  528.  
  529. if ( ! function_exists( 'is_ms_ac_show_all_activities' ) ) { 
  530. function is_ms_ac_show_all_activities() { 
  531. return lib3()->is_true( MS_Helper_Template::$ms_account['show_all_activities'] ); 
  532.  
  533. if ( ! function_exists( 'get_ms_ac_activity_details_label' ) ) { 
  534. function get_ms_ac_activity_details_label() { 
  535. return MS_Helper_Template::$ms_account['activity_details_formatted_label']; 
  536.  
  537. if ( ! function_exists( 'get_ms_ac_events' ) ) { 
  538. function get_ms_ac_events() { 
  539. return MS_Helper_Template::$ms_account['events']; 
  540.  
  541. if ( ! function_exists( 'ms_account_the_event' ) ) { 
  542. function ms_account_the_event( $event ) { 
  543. MS_Helper_Template::$ms_account['event'] = $event; 
  544.  
  545. if ( ! function_exists( 'prepare_ms_event_classes' ) ) { 
  546. function prepare_ms_event_classes() { 
  547. return array( 
  548. 'ms-activity-topic-' . MS_Helper_Template::$ms_account['event']->topic,  
  549. 'ms-activity-type-' . MS_Helper_Template::$ms_account['event']->type,  
  550. 'ms-membership-' . MS_Helper_Template::$ms_account['event']->membership_id,  
  551. ); 
  552.  
  553. if ( ! function_exists( 'get_ms_event_classes' ) ) { 
  554. function get_ms_event_classes() { 
  555. return esc_attr( implode( ' ', prepare_ms_event_classes() ) ); 
  556.  
  557. if ( ! function_exists( 'get_ms_event_date' ) ) { 
  558. function get_ms_event_date() { 
  559. return esc_html( 
  560. MS_Helper_Period::format_date( 
  561. MS_Helper_Template::$ms_account['event']->post_modified 
  562. ); 
  563.  
  564. if ( ! function_exists( 'get_ms_event_description' ) ) { 
  565. function get_ms_event_description() { 
  566. return esc_html( MS_Helper_Template::$ms_account['event']->description ); 
  567.  
  568. if ( ! function_exists( 'has_ms_ac_login_form' ) ) { 
  569. function has_ms_ac_login_form() { 
  570. return lib3()->is_true( MS_Helper_Template::$ms_account['has_login_form'] ); 
  571.  
  572. if ( ! function_exists( 'get_ms_ac_login_form' ) ) { 
  573. function get_ms_ac_login_form() { 
  574. return MS_Helper_Template::$ms_account['login_form_sc']; 
.