MS_Model_Communication_Finished

Communication model - membership finished.

Defined (1)

The class is defined in the following location(s).

/app/model/communication/class-ms-model-communication-finished.php  
  1. class MS_Model_Communication_Finished extends MS_Model_Communication { 
  2.  
  3. /** 
  4. * Communication type. 
  5. * @since 1.0.0 
  6. * @var string The communication type. 
  7. */ 
  8. protected $type = self::COMM_TYPE_FINISHED; 
  9.  
  10. /** 
  11. * Add action to deactivated event. 
  12. * @since 1.0.0 
  13. * @var string The communication type. 
  14. */ 
  15. public function after_load() { 
  16. parent::after_load(); 
  17.  
  18. if ( $this->enabled ) { 
  19. $this->add_action( 
  20. 'ms_model_event_' . MS_Model_Event::TYPE_MS_DEACTIVATED,  
  21. 'enqueue_messages', 10, 2 
  22. ); 
  23.  
  24. /** 
  25. * Get communication description. 
  26. * @since 1.0.0 
  27. * @return string The description. 
  28. */ 
  29. public function get_description() { 
  30. return __( 
  31. 'Sent as soon as the membership is deactivated.', MS_TEXT_DOMAIN 
  32. ); 
  33.  
  34. /** 
  35. * Communication default communication. 
  36. * @since 1.0.0 
  37. */ 
  38. public function reset_to_default() { 
  39. parent::reset_to_default(); 
  40.  
  41. $this->subject = sprintf( 
  42. __( 'Your %s membership has ended', MS_TEXT_DOMAIN ),  
  43. self::COMM_VAR_MS_NAME 
  44. ); 
  45. $this->message = self::get_default_message(); 
  46. $this->enabled = false; 
  47. $this->save(); 
  48.  
  49. do_action( 
  50. 'ms_model_communication_reset_to_default_after',  
  51. $this->type,  
  52. $this 
  53. ); 
  54.  
  55. /** 
  56. * Get default email message. 
  57. * @since 1.0.0 
  58. * @return string The email message. 
  59. */ 
  60. public static function get_default_message() { 
  61. $subject = sprintf( 
  62. __( 'Hi %1$s, ', MS_TEXT_DOMAIN ),  
  63. self::COMM_VAR_USERNAME 
  64. ); 
  65. $body_notice = sprintf( 
  66. __( 'Your %1$s membership at %2$s has ended on %3$s.', MS_TEXT_DOMAIN ),  
  67. self::COMM_VAR_MS_NAME,  
  68. self::COMM_VAR_BLOG_NAME,  
  69. self::COMM_VAR_MS_EXPIRY_DATE 
  70. ); 
  71. $body_renew = sprintf( 
  72. __( 'You can renew your membership here: %1$s', MS_TEXT_DOMAIN ),  
  73. self::COMM_VAR_MS_ACCOUNT_PAGE_URL 
  74. ); 
  75.  
  76. $html = sprintf( 
  77. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s',  
  78. $subject,  
  79. $body_notice,  
  80. $body_renew 
  81. ); 
  82.  
  83. return apply_filters( 
  84. 'ms_model_communication_finished_get_default_message',  
  85. $html 
  86. );