MS_Addon_Wpbe

WP Better Emails integration.

Defined (1)

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

/app/addon/wpbe/class-ms-addon-wpbe.php  
  1. class MS_Addon_Wpbe extends MS_Addon { 
  2.  
  3. /** 
  4. * The Add-on ID 
  5. * @since 1.0.0 
  6. */ 
  7. const ID = 'addon_wpbe'; 
  8.  
  9. protected $text_message = ''; 
  10.  
  11. /** 
  12. * Checks if the current Add-on is enabled 
  13. * @since 1.0.0 
  14. * @return bool 
  15. */ 
  16. static public function is_active() { 
  17. return MS_Model_Addon::is_enabled( self::ID ); 
  18.  
  19. /** 
  20. * Returns the Add-on ID (self::ID). 
  21. * @since 1.0.1.0 
  22. * @return string 
  23. */ 
  24. public function get_id() { 
  25. return self::ID; 
  26.  
  27. /** 
  28. * Initializes the Add-on. Always executed. 
  29. * @since 1.0.0 
  30. */ 
  31. public function init() { 
  32. if ( self::is_active() ) { 
  33. global $wp_better_emails; 
  34.  
  35. if ( $wp_better_emails ) { 
  36. $this->add_filter( 
  37. 'ms_model_communication_send_message_html_message',  
  38. 'html_message' 
  39. ); 
  40.  
  41. /** 
  42. * Registers the Add-On 
  43. * @since 1.0.0 
  44. * @param array $list The Add-Ons list. 
  45. * @return array The updated Add-Ons list. 
  46. */ 
  47. public function register( $list ) { 
  48. /** 
  49. // Don't register: Not completed yet... 
  50.   
  51. $list[ self::ID ] = (object) array( 
  52. 'name' => __( 'WP Better Emails', 'membership2' ),  
  53. 'description' => __( 'WP Better Emails integration.', 'membership2' ),  
  54. ); 
  55. */ 
  56. return $list; 
  57.  
  58. /** 
  59. * WP Better email wrapper. 
  60. * @since 1.0.0 
  61. * @access public 
  62. * @param string $html_message The html message body. 
  63. * @return string The modified html message. 
  64. */ 
  65. public function html_message( $html_message ) { 
  66. global $wp_better_emails; 
  67.  
  68. if ( $wp_better_emails ) { 
  69. $html_message = apply_filters( 
  70. 'ms_wpbe_html_body',  
  71. $wp_better_emails->template_vars_replacement( 
  72. $wp_better_emails->set_email_template( $html_message, 'template' ) 
  73. ); 
  74.  
  75. $this->text_message = apply_filters( 
  76. 'wpbe_plaintext_body',  
  77. $wp_better_emails->template_vars_replacement( 
  78. $wp_better_emails->set_email_template( $text_message, 'plaintext_template' ) 
  79. ); 
  80.  
  81. $this->add_filter( 'wpbe_plaintext_body', 'text_message' ); 
  82. add_filter( 'wpbe_plaintext_body', 'stripslashes', 11 ); 
  83.  
  84. return $html_message; 
  85.  
  86. public function text_message() { 
  87. $this->remove_filter( 'wpbe_plaintext_body', 'text_message' ); 
  88. remove_filter( 'wpbe_plaintext_body', 'stripslashes', 11 ); 
  89.  
  90. return sprintf( 'return "%s";', addslashes( $this->text_message ) );