/app/model/communication/class-ms-model-communication-credit-card-expire.php

  1. <?php 
  2. /** 
  3. * Communication model - credit card expire. 
  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_Credit_Card_Expire 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_CREDIT_CARD_EXPIRE; 
  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'] = __( 'Notify Period', 'membership2' ); 
  30. $field['desc'] = __( 'We want to notify the user some days in advance, so there is time to react.<br>Enter here, how many days in advance this message should be sent.', '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 __( 'A notice to indicate that the member\'s credit card is about to expire.', 'membership2' ); 
  42.  
  43. /** 
  44. * Communication default communication. 
  45. * 
  46. * @since 1.0.0 
  47. */ 
  48. public function reset_to_default() { 
  49. parent::reset_to_default(); 
  50.  
  51. $this->subject = __( 'Your credit card is about to expire', 'membership2' ); 
  52. $this->message = self::get_default_message(); 
  53. $this->enabled = false; 
  54. $this->period_enabled = true; 
  55.  
  56. do_action( 'ms_model_communication_reset_to_default_after', $this->type, $this ); 
  57.  
  58. /** 
  59. * Get default email message. 
  60. * 
  61. * @since 1.0.0 
  62. * @return string The email message. 
  63. */ 
  64. public static function get_default_message() { 
  65. $subject = sprintf( 
  66. __( 'Hi %1$s, ', 'membership2' ),  
  67. self::COMM_VAR_USERNAME 
  68. ); 
  69. $body_notice = __( 'This is a reminder that your credit card is about to expire.', 'membership2' ); 
  70. $body_continue = sprintf( 
  71. __( 'To continue your %1$s membership at %2$s, please update your card details before your next payment is due here: %3$s', 'membership2' ),  
  72. self::COMM_VAR_MS_NAME,  
  73. self::COMM_VAR_BLOG_NAME,  
  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',  
  79. $subject,  
  80. $body_notice,  
  81. $body_continue 
  82. ); 
  83.  
  84. return apply_filters( 
  85. 'ms_model_communication_credit_card_expire_get_default_message',  
  86. $html 
  87. ); 
.