WC_User_Birthday_Email

The WooCommerce Birthday Reminder WC User Birthday Email class.

Defined (1)

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

/class-wc-user-birthday-email.php  
  1. class WC_User_Birthday_Email extends WC_Email { 
  2.  
  3. public $enabled_day; 
  4. public $subject_day; 
  5. public $heading_day; 
  6. public $message_day; 
  7. public $email_type_day; 
  8.  
  9. public $enabled_month; 
  10. public $subject_month; 
  11. public $heading_month; 
  12. public $message_month; 
  13. public $email_type_month; 
  14.  
  15. public function __construct() { 
  16. $this->id = 'wc_user_birthday_email'; 
  17. $this->title = __( 'Aniversrio' , 'woocommerce-birthday-coupon' ); 
  18. $this->description = __( 'E-mails de aniversrio sero mandados no ms e/ou dia do aniversrio do usurio' , 'woocommerce-birthday-coupon' ); 
  19.  
  20. $this->enabled_day = $this->get_option('enabled_day'); 
  21. $this->subject_day = $this->get_option('subject_day'); 
  22. $this->heading_day = $this->get_option('heading_day'); 
  23. $this->message_day = $this->get_option('message_day'); 
  24. $this->email_type_day = $this->get_option('email_type_day'); 
  25.  
  26. $this->enabled_month = $this->get_option('enabled_month'); 
  27. $this->subject_month = $this->get_option('subject_month'); 
  28. $this->heading_month = $this->get_option('heading_month'); 
  29. $this->message_month = $this->get_option('message_month'); 
  30. $this->email_type_month = $this->get_option('email_type_month'); 
  31.  
  32. $this->template_html = 'day-birthday-reminder.php'; 
  33. $this->template_plain = 'plain-day-birthday-reminder.php'; 
  34. $this->template_base = WooCommerce_Birthday_Reminder::plugin_path() . 'emails/'; 
  35.  
  36. add_action( 'birthdays_users_of_the_day' , array( $this , 'trigger_day' ) ); 
  37. add_action( 'birthdays_users_of_the_month' , array( $this , 'trigger_month' ) ); 
  38.  
  39. parent::__construct(); 
  40.  
  41. public function trigger_month( $users ) { 
  42. $this->enabled = $this->enabled_month; 
  43. $this->subject = $this->subject_month; 
  44. $this->heading = $this->heading_month; 
  45. $this->message = $this->message_month; 
  46. $this->email_type = $this->email_type_month; 
  47. $this->template_html = 'month-birthday-reminder.php'; 
  48. $this->template_plain = 'plain-month-birthday-reminder.php'; 
  49.  
  50. $this->trigger( $users ); 
  51.  
  52. public function trigger_day( $users ) { 
  53. $this->enabled = $this->enabled_day; 
  54. $this->subject = $this->subject_day; 
  55. $this->heading = $this->heading_day; 
  56. $this->message = $this->message_day; 
  57. $this->email_type = $this->email_type_day; 
  58. $this->template_html = 'day-birthday-reminder.php'; 
  59. $this->template_plain = 'plain-day-birthday-reminder.php'; 
  60.  
  61. $this->trigger( $users ); 
  62.  
  63. public function trigger( $users ) { 
  64. if ( ! $users || ! $this->is_enabled() ) { 
  65. return; 
  66. $position = count( $this->find ); 
  67.  
  68. $this->find[ $position ] = '{user}'; 
  69.  
  70. foreach ( $users as $user ) { 
  71. $this->object = $user; 
  72.  
  73. $this->replace[ $position ] = $this->object->user_nicename; 
  74.  
  75. $this->send( $this->object->user_email , $this->get_subject() . ' - ' . $this->get_blogname() , $this->get_content() , $this->get_headers() , $this->get_attachments() ); 
  76.  
  77. public function get_content_html() { 
  78. return $this->my_get_content( $this->template_html ); 
  79.  
  80. public function get_content_plain() { 
  81. return $this->my_get_content( $this->template_plain ); 
  82.  
  83. private function my_get_content( $from ) { 
  84. ob_start(); 
  85. wc_get_template( $from , array( 
  86. 'email_heading' => $this->get_heading(),  
  87. 'message' => $this->format_string( $this->message ) 
  88. ), $this->template_base , $this->template_base ); 
  89. return ob_get_clean(); 
  90.  
  91. public function init_form_fields() { 
  92. $this->form_fields = array( 
  93. 'first_section' => array( 
  94. 'title' => __( 'Dia do aniversrio' , 'woocommerce-birthday-coupon' ),  
  95. 'type' => 'title',  
  96. 'description' => __( 'Configuraes para o e-mail enviado para os aniversariantes do dia' , 'woocommerce-birthday-coupon' ) 
  97. ),  
  98. 'enabled_day' => array( 
  99. 'title' => __( 'Habilitar/Desabilitar' , 'woocommerce-birthday-coupon' ),  
  100. 'type' => 'checkbox',  
  101. 'label' => __( 'Habilita o envio do e-mail no dia do aniversrio do usurio' , 'woocommerce-birthday-coupon' ),  
  102. 'default' => 'yes' 
  103. ),  
  104. 'subject_day' => array( 
  105. 'title' => __( 'Assunto' , 'woocommerce-birthday-coupon' ),  
  106. 'type' => 'text',  
  107. 'description' => __( 'Assunto do e-mail' , 'woocommerce-birthday-coupon' ),  
  108. 'placeholder' => __( 'Assunto' , 'woocommerce-birthday-coupon' ),  
  109. 'default' => __( 'Dia do aniversrio' , 'woocommerce-birthday-coupon' ) 
  110. ),  
  111. 'heading_day' => array( 
  112. 'title' => __( 'Ttulo' , 'woocommerce-birthday-coupon' ),  
  113. 'type' => 'text',  
  114. 'description' => __( 'Ttulo do e-mail' , 'woocommerce-birthday-coupon' ),  
  115. 'placeholder' => __( 'Ttulo' , 'woocommerce-birthday-coupon' ),  
  116. 'default' => __( 'Parabns!' , 'woocommerce-birthday-coupon' ) 
  117. ),  
  118. 'message_day' => array( 
  119. 'title' => __( 'Mensagem' , 'woocommerce-birthday-coupon' ),  
  120. 'type' => 'textarea',  
  121. 'description' => __( 'Contedo do e-mail. Use: <code>{user}</code> para o nome do aniversariante' , 'woocommerce-birthday-coupon' ),  
  122. 'placeholder' => __( 'Contedo' , 'woocommerce-birthday-coupon' ),  
  123. 'default' => __( 'Hoje o seu aniversrio!' , 'woocommerce-birthday-coupon' ) 
  124. ),  
  125. 'email_type_day' => array( 
  126. 'title' => __( 'Tipo de e-mail' , 'woocommerce-birthday-coupon' ),  
  127. 'type' => 'select',  
  128. 'description' => __( 'Escolha o formato em que o e-mail ser enviado' , 'woocommerce-birthday-coupon' ),  
  129. 'default' => 'html',  
  130. 'class' => 'email_type',  
  131. 'options' => array( 
  132. 'plain' => 'Plain text',  
  133. 'html' => 'HTML' 
  134. ),  
  135. 'second_section' => array( 
  136. 'title' => __( 'Ms do aniversrio' , 'woocommerce-birthday-coupon' ),  
  137. 'type' => 'title',  
  138. 'description' => __( 'Configuraes para o e-mail enviado para os aniversariantes do ms' , 'woocommerce-birthday-coupon' ) 
  139. ),  
  140. 'enabled_month' => array( 
  141. 'title' => __( 'Habilitar/Desabilitar' , 'woocommerce-birthday-coupon' ),  
  142. 'type' => 'checkbox',  
  143. 'label' => __( 'Habilita o envio do e-mail no ms do aniversrio do usurio' , 'woocommerce-birthday-coupon' ),  
  144. 'default' => 'yes' 
  145. ),  
  146. 'subject_month' => array( 
  147. 'title' => __( 'Assunto' , 'woocommerce-birthday-coupon' ),  
  148. 'type' => 'text',  
  149. 'description' => __( 'Assunto do e-mail' , 'woocommerce-birthday-coupon' ),  
  150. 'placeholder' => __( 'Assunto' , 'woocommerce-birthday-coupon' ),  
  151. 'default' => __( 'Ms do aniversrio' , 'woocommerce-birthday-coupon' ) 
  152. ),  
  153. 'heading_month' => array( 
  154. 'title' => __( 'Ttulo' , 'woocommerce-birthday-coupon' ),  
  155. 'type' => 'text',  
  156. 'description' => __( 'Ttulo do e-mail' , 'woocommerce-birthday-coupon' ),  
  157. 'placeholder' => __( 'Ttulo' , 'woocommerce-birthday-coupon' ),  
  158. 'default' => __( 'Parabns antecipado!' , 'woocommerce-birthday-coupon' ) 
  159. ),  
  160. 'message_month' => array( 
  161. 'title' => __( 'Mensagem' , 'woocommerce-birthday-coupon' ),  
  162. 'type' => 'textarea',  
  163. 'description' => __( 'Contedo do e-mail. Use: <code>{user}</code> para o nome do aniversariante' , 'woocommerce-birthday-coupon' ),  
  164. 'placeholder' => __( 'Contedo' , 'woocommerce-birthday-coupon' ),  
  165. 'default' => __( 'Preparamos uma oferta especial para o ms do seu aniversrio :)' , 'woocommerce-birthday-coupon' ) 
  166. ),  
  167. 'email_type_month' => array( 
  168. 'title' => __( 'Tipo de e-mail' , 'woocommerce-birthday-coupon' ),  
  169. 'type' => 'select',  
  170. 'description' => __( 'Escolha o formato em que o e-mail ser enviado' , 'woocommerce-birthday-coupon' ),  
  171. 'default' => 'html',  
  172. 'class' => 'email_type',  
  173. 'options' => array( 
  174. 'plain' => 'Plain text',  
  175. 'html' => 'HTML' 
  176. );