/app/model/communication/class-ms-model-communication-after-finishes.php

  1. <?php 
  2. /** 
  3. * Communication model - after membership finishes. 
  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_After_Finishes 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_AFTER_FINISHES; 
  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'] = __( 'Message Delay', 'membership2' ); 
  30. $field['desc'] = __( 'Use "0" to send instantly, or another value to delay the message.', '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 after the membership finishes. You must decide how many days after 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 = sprintf( 
  54. __( 'Reminder: your %s membership has ended', 'membership2' ),  
  55. self::COMM_VAR_MS_NAME 
  56. ); 
  57. $this->message = self::get_default_message(); 
  58. $this->enabled = false; 
  59. $this->period_enabled = true; 
  60.  
  61. do_action( 
  62. 'ms_model_communication_reset_to_default_after',  
  63. $this->type,  
  64. $this 
  65. ); 
  66.  
  67. /** 
  68. * Get default email message. 
  69. * 
  70. * @since 1.0.0 
  71. * @return string The email message. 
  72. */ 
  73. public static function get_default_message() { 
  74. $subject = sprintf( 
  75. __( 'Hi %1$s, ', 'membership2' ),  
  76. self::COMM_VAR_USERNAME 
  77. ); 
  78. $body_notice = sprintf( 
  79. __( 'This is a reminder that your %1$s membership at %2$s has ended on %3$s.', 'membership2' ),  
  80. self::COMM_VAR_MS_NAME,  
  81. self::COMM_VAR_BLOG_NAME,  
  82. self::COMM_VAR_MS_EXPIRY_DATE 
  83. ); 
  84. $body_renew = sprintf( 
  85. __( 'You can renew your membership here: %1$s', 'membership2' ),  
  86. self::COMM_VAR_MS_ACCOUNT_PAGE_URL 
  87. ); 
  88.  
  89. $html = sprintf( 
  90. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s',  
  91. $subject,  
  92. $body_notice,  
  93. $body_renew 
  94. ); 
  95.  
  96. return apply_filters( 
  97. 'ms_model_communication_after_finished_get_default_message',  
  98. $html 
  99. ); 
.