1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This email will be sent to a teacher when a course is assigned to them. |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
7
|
|
|
|
8
|
|
|
if ( class_exists('Sensei_Email_Teacher_New_Course_Assignment') ){ |
9
|
|
|
return; |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Teacher Started Course |
14
|
|
|
* |
15
|
|
|
* An email sent to the teacher when one of their students starts a course. |
16
|
|
|
* |
17
|
|
|
* @package Users |
18
|
|
|
* @author Automattic |
19
|
|
|
* |
20
|
|
|
* @since 1.6.0 |
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
|
|
|
* Constructor |
33
|
|
|
* @since 1.8.0 |
34
|
|
|
* @access public |
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
|
|
|
* trigger function. |
46
|
|
|
* |
47
|
|
|
* @access public |
48
|
|
|
* @param $teacher_id |
49
|
|
|
* @param $course_id |
50
|
|
|
* @return void |
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
|
|
|
//course edit link |
60
|
|
|
$course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
61
|
|
|
|
62
|
|
|
// Course name |
63
|
|
|
$course = get_post( $course_id); |
64
|
|
|
// Construct data array |
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
|
|
|
// Send mail |
75
|
|
|
Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Return a new instance of this files class |
81
|
|
|
*/ |
82
|
|
|
return new Sensei_Email_Teacher_New_Course_Assignment(); |
83
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.