/app/model/communication/class-ms-model-communication-renewed.php

  1. <?php 
  2. /** 
  3. * Communication model - subscription was renewed. 
  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_Renewed extends MS_Model_Communication { 
  12.  
  13. /** 
  14. * Add action to credit card expire event. 
  15. * 
  16. * Related Action Hooks: 
  17. * - ms_model_event_paid 
  18. * 
  19. * @since 1.0.0 
  20. * @var string The communication type. 
  21. */ 
  22. protected $type = self::COMM_TYPE_RENEWED; 
  23.  
  24. /** 
  25. * Get communication description. 
  26. * 
  27. * @since 1.0.0 
  28. * @return string The description. 
  29. */ 
  30. public function get_description() { 
  31. return __( 
  32. 'Sent to the member when a previously expired or cancelled membership is renewed - triggered for both free and paid memberships.', 'membership2' 
  33. ); 
  34.  
  35. /** 
  36. * Communication default communication. 
  37. * 
  38. * @since 1.0.0 
  39. */ 
  40. public function reset_to_default() { 
  41. parent::reset_to_default(); 
  42.  
  43. $this->subject = sprintf( 
  44. __( 'Subscription renewed for %s', 'membership2' ),  
  45. self::COMM_VAR_BLOG_NAME 
  46. ); 
  47. $this->message = self::get_default_message(); 
  48. $this->enabled = false; 
  49.  
  50. do_action( 
  51. 'ms_model_communication_reset_to_default_after',  
  52. $this->type,  
  53. $this 
  54. ); 
  55.  
  56. /** 
  57. * Get default email message. 
  58. * 
  59. * @since 1.0.0 
  60. * @return string The email message. 
  61. */ 
  62. public static function get_default_message() { 
  63. $subject = sprintf( 
  64. __( 'Hi %1$s, ', 'membership2' ),  
  65. self::COMM_VAR_USERNAME 
  66. ); 
  67. $body_notice = sprintf( 
  68. __( 'Thanks for renewing your <strong>%1$s</strong> subscription over at %2$s!', 'membership2' ),  
  69. self::COMM_VAR_MS_NAME,  
  70. self::COMM_VAR_BLOG_NAME 
  71. ); 
  72. $body_account = sprintf( 
  73. __( 'You can review and edit your membership details here: %1$s', 'membership2' ),  
  74. self::COMM_VAR_MS_ACCOUNT_PAGE_URL 
  75. ); 
  76.  
  77. $html = sprintf( 
  78. '<h2>%1$s</h2><br /><br />%2$s<br /><br />%3$s<br />',  
  79. $subject,  
  80. $body_notice,  
  81. $body_account 
  82. ); 
  83.  
  84. return apply_filters( 
  85. 'ms_model_communication_renewed_get_default_message',  
  86. $html 
  87. ); 
  88.  
  89. /** 
  90. * Process communication registration. 
  91. * 
  92. * @since 1.0.0 
  93. */ 
  94. public function process_communication( $event, $subscription ) { 
  95. do_action( 
  96. 'ms_model_communication_renewed_process_before',  
  97. $subscription,  
  98. $event,  
  99. $this 
  100. ); 
  101.  
  102. $this->send_message( $subscription ); 
  103.  
  104. do_action( 
  105. 'ms_model_communication_renewed_process_after',  
  106. $subscription,  
  107. $event,  
  108. $this 
  109. ); 
.