1: <?php
2: 3: 4:
5:
6: if ( ! defined( 'ABSPATH' ) ) exit;
7:
8: if ( class_exists('Sensei_Email_Teacher_New_Course_Assignment') ){
9: return;
10: }
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22: class Sensei_Email_Teacher_New_Course_Assignment {
23:
24: var $template;
25: var $subject;
26: var $heading;
27: var $recipient;
28: var $learner;
29: var $teacher;
30:
31: 32: 33: 34: 35:
36: function __construct() {
37:
38: $this->template = 'teacher-new-course-assignment';
39: $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have been assigned to a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
40: $this->heading = apply_filters( 'sensei_email_heading', __( 'Course assigned to you', 'woothemes-sensei' ), $this->template );
41: return;
42: }
43:
44: 45: 46: 47: 48: 49: 50: 51:
52: function trigger( $teacher_id = 0, $course_id = 0 ) {
53: global $sensei_email_data;
54:
55: $this->teacher = new WP_User( $teacher_id );
56: $this->recipient = stripslashes( $this->teacher->user_email );
57: $this->subject = __( 'New course assigned to you', 'woothemes-sensei' );
58:
59:
60: $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' );
61:
62:
63: $course = get_post( $course_id);
64:
65: $sensei_email_data = apply_filters( 'sensei_email_data', array(
66: 'template' => $this->template,
67: 'heading' => $this->heading,
68: 'teacher_id' => $teacher_id,
69: 'course_id' => $course_id,
70: 'course_name' => $course->post_title,
71: 'course_edit_link' => $course_edit_link,
72: ), $this->template );
73:
74:
75: Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
76: }
77: }
78:
79: 80: 81:
82: return new Sensei_Email_Teacher_New_Course_Assignment();
83: