Code Duplication    Length = 67-68 lines in 2 locations

includes/emails/class-woothemes-sensei-email-teacher-completed-lesson.php 1 location

@@ 5-72 (lines=68) @@
2
3
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5
if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Completed_Lesson' ) ) :
6
7
/**
8
 * Teacher Completed Lesson
9
 *
10
 * An email sent to the teacher when one of their students completes a Lesson.
11
 *
12
 * @package Users
13
 * @author Automattic
14
 *
15
 * @since		1.6.0
16
 */
17
class WooThemes_Sensei_Email_Teacher_Completed_Lesson {
18
19
	var $template;
20
	var $subject;
21
	var $heading;
22
	var $recipient;
23
	var $learner;
24
	var $teacher;
25
26
	/**
27
	 * Constructor
28
	 */
29
	function __construct() {
30
		$this->template = 'teacher-completed-lesson';
31
		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has completed a lesson', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
32
		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has completed a lesson', 'woothemes-sensei' ), $this->template );
33
	}
34
35
	/**
36
	 * trigger function.
37
	 *
38
     * @param int $learner_id
39
     * @param int $lesson_id
40
     *
41
	 * @return void
42
	 */
43
	function trigger( $learner_id = 0, $lesson_id = 0 ) {
44
45
		global $sensei_email_data;
46
47
		// Get learner user object
48
		$this->learner = new WP_User( $learner_id );
49
50
		// Get teacher ID and user object
51
		$teacher_id = get_post_field( 'post_author', $lesson_id, 'raw' );
52
		$this->teacher = new WP_User( $teacher_id );
53
54
        // Construct data array
55
		$sensei_email_data = apply_filters( 'sensei_email_data', array(
56
			'template'			=> $this->template,
57
			'heading'			=> $this->heading,
58
			'teacher_id'		=> $teacher_id,
59
			'learner_id'		=> $learner_id,
60
			'learner_name'		=> $this->learner->display_name,
61
			'lesson_id'			=> $lesson_id,
62
		), $this->template );
63
64
		// Set recipient (teacher)
65
		$this->recipient = stripslashes( $this->teacher->user_email );
66
67
		// Send mail
68
        Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
69
	}
70
}
71
72
endif;
73
74
return new WooThemes_Sensei_Email_Teacher_Completed_Lesson();

includes/emails/class-woothemes-sensei-email-teacher-started-course.php 1 location

@@ 5-71 (lines=67) @@
2
3
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5
if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Started_Course' ) ) :
6
7
/**
8
 * Teacher Started Course
9
 *
10
 * An email sent to the teacher when one of their students starts a course.
11
 *
12
 * @package Users
13
 * @author Automattic
14
 *
15
 * @since		1.6.0
16
 */
17
class WooThemes_Sensei_Email_Teacher_Started_Course {
18
19
	var $template;
20
	var $subject;
21
	var $heading;
22
	var $recipient;
23
	var $learner;
24
	var $teacher;
25
26
	/**
27
	 * Constructor
28
	 */
29
	function __construct() {
30
		$this->template = 'teacher-started-course';
31
		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has started a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
32
		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has started a course', 'woothemes-sensei' ), $this->template );
33
	}
34
35
	/**
36
	 * trigger function.
37
	 *
38
     * @param int $learner_id
39
     * @param int $course_id
40
     *
41
	 * @return void
42
	 */
43
	function trigger( $learner_id = 0, $course_id = 0 ) {
44
		global  $sensei_email_data;
45
46
		// Get learner user object
47
		$this->learner = new WP_User( $learner_id );
48
49
		// Get teacher ID and user object
50
		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
51
		$this->teacher = new WP_User( $teacher_id );
52
53
		// Construct data array
54
		$sensei_email_data = apply_filters( 'sensei_email_data', array(
55
			'template'			=> $this->template,
56
			'heading'			=> $this->heading,
57
			'teacher_id'		=> $teacher_id,
58
			'learner_id'		=> $learner_id,
59
			'learner_name'		=> $this->learner->display_name,
60
			'course_id'			=> $course_id,
61
		), $this->template );
62
63
		// Set recipient (learner)
64
		$this->recipient = stripslashes( $this->teacher->user_email );
65
66
		// Send mail
67
		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
68
	}
69
}
70
71
endif;
72
73
return new WooThemes_Sensei_Email_Teacher_Started_Course();