PageRenderTime 42ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/learnpress/inc/emails/class-lp-email-rejected-course.php

https://gitlab.com/gregtyka/lfmawordpress
PHP | 83 lines | 58 code | 18 blank | 7 comment | 4 complexity | e2f05e83b4cc900007697a4fbcbf3eb6 MD5 | raw file
  1. <?php
  2. /**
  3. * Class LP_Email_Rejected_Course
  4. *
  5. * @author ThimPress
  6. * @package LearnPress/Classes
  7. * @version 1.0
  8. */
  9. defined( 'ABSPATH' ) || exit();
  10. class LP_Email_Rejected_Course extends LP_Email {
  11. function __construct() {
  12. $this->id = 'rejected_course';
  13. $this->title = __( 'Rejected course', 'learnpress' );
  14. $this->template_html = 'emails/rejected-course.php';
  15. $this->template_plain = 'emails/plain/rejected-course.php';
  16. $this->default_subject = __( '[{site_title}] Your course {course_name} has rejected', 'learnpress' );
  17. $this->default_heading = __( 'Rejected course', 'learnpress' );
  18. parent::__construct();
  19. }
  20. function admin_options( $obj ) {
  21. $view = learn_press_get_admin_view( 'settings/emails/rejected-course.php' );
  22. include_once $view;
  23. }
  24. function trigger( $course_id ) {
  25. if ( !$this->enable ) {
  26. return;
  27. }
  28. $course = learn_press_get_course( $course_id );
  29. $this->find['site_title'] = '{site_title}';
  30. $this->find['course_name'] = '{course_name}';
  31. $this->replace['site_title'] = $this->get_blogname();
  32. $this->replace['course_name'] = get_the_title( $course_id );
  33. $this->object = array(
  34. 'course' => $course
  35. );
  36. $user_course = learn_press_get_course_user( $course_id );
  37. $this->recipient = $user_course->user_email;
  38. if ( !$this->get_recipient() ) {
  39. return;
  40. }
  41. $return = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
  42. return $return;
  43. }
  44. function get_content_html() {
  45. ob_start();
  46. learn_press_get_template( $this->template_html, $this->get_template_data( 'html' ) );
  47. return ob_get_clean();
  48. }
  49. function get_content_plain() {
  50. ob_start();
  51. learn_press_get_template( $this->template_plain, $this->get_template_data( 'plain' ) );
  52. return ob_get_clean();
  53. }
  54. function get_template_data( $format = 'plain' ) {
  55. return array(
  56. 'email_heading' => $this->get_heading(),
  57. 'footer_text' => $this->get_footer_text(),
  58. 'site_title' => $this->get_blogname(),
  59. 'course' => $this->object['course'],
  60. 'login_url' => learn_press_get_login_url(),
  61. 'plain_text' => $format == 'plain'
  62. );
  63. }
  64. }
  65. return new LP_Email_Rejected_Course();