/app/model/communication/class-ms-model-communication-before-payment-due.php

  1. <?php 
  2. /** 
  3. * Communication model - before payment is due. 
  4. * 
  5. * Persisted by parent class MS_Model_CustomPostType. 
  6. * 
  7. * @since 1.0.0 
  8. * @package Membership2 
  9. * @subpackage Model 
  10. */ 
  11. class MS_Model_Communication_Before_Payment_Due extends MS_Model_Communication { 
  12.  
  13. /** 
  14. * Communication type. 
  15. * 
  16. * @since 1.0.0 
  17. * @var string The communication type. 
  18. */ 
  19. protected $type = self::COMM_TYPE_BEFORE_PAYMENT_DUE; 
  20.  
  21. /** 
  22. * Populates the field title/description of the Period before/after field 
  23. * in the admin settings. 
  24. * 
  25. * @since 1.0.0 
  26. * @param array $field A HTML definition, passed to lib3()->html->element() 
  27. */ 
  28. public function set_period_name( $field ) { 
  29. $field['title'] = __( 'Notice Period', 'membership2' ); 
  30. $field['desc'] = __( 'Define, how many days in advance the user should be notified.', 'membership2' ); 
  31.  
  32. return $field; 
  33.  
  34. /** 
  35. * Get communication description. 
  36. * 
  37. * @since 1.0.0 
  38. * @return string The description. 
  39. */ 
  40. public function get_description() { 
  41. return __( 
  42. 'Sent a predefined number of days before the payment is due. You must decide how many days beforehand a message is to be sent.', 'membership2' 
  43. ); 
  44.  
  45. /** 
  46. * Communication default communication. 
  47. * 
  48. * @since 1.0.0 
  49. */ 
  50. public function reset_to_default() { 
  51. parent::reset_to_default(); 
  52.  
  53. $this->subject = __( 'Membership payment due soon', 'membership2' ); 
  54. $this->message = self::get_default_message(); 
  55. $this->enabled = false; 
  56. $this->period_enabled = true; 
  57.  
  58. do_action( 
  59. 'ms_model_communication_reset_to_default_after',  
  60. $this->type,  
  61. $this 
  62. ); 
  63.  
  64. /** 
  65. * Get default email message. 
  66. * 
  67. * @since 1.0.0 
  68. * @return string The email message. 
  69. */ 
  70. public static function get_default_message() { 
  71. $subject = sprintf( 
  72. __( 'Hi %1$s, ', 'membership2' ),  
  73. self::COMM_VAR_USERNAME 
  74. ); 
  75. $body_notice = sprintf( 
  76. __( 'This is a reminder that the next payment for your %1$s membership at %2$s will be due on (%3$s).', 'membership2' ),  
  77. self::COMM_VAR_MS_NAME,  
  78. self::COMM_VAR_BLOG_NAME,  
  79. self::COMM_VAR_MS_EXPIRY_DATE 
  80. ); 
  81. $body_invoice = __( 'Here are your latest invoice details:', 'membership2' ); 
  82.  
  83. $html = sprintf( 
  84. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s<br /><br />%4$s',  
  85. $subject,  
  86. $body_notice,  
  87. $body_invoice,  
  88. self::COMM_VAR_MS_INVOICE 
  89. ); 
  90.  
  91. return apply_filters( 
  92. 'ms_model_communication_before_payment_due_get_default_message',  
  93. $html 
  94. ); 
.