/wp-content/plugins/membership/app/template/template-tags.php

https://gitlab.com/najomie/fit-hippie · PHP · 779 lines · 626 code · 121 blank · 32 comment · 112 complexity · 3a3546a7d5d6e24020a50fabac7ff775 MD5 · raw file

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