@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | add_action( 'sensei_course_status_updated', array( $this, 'learner_completed_course' ), 10, 4 ); |
| 46 | 46 | add_action( 'sensei_course_status_updated', array( $this, 'teacher_completed_course' ), 10, 4 ); |
| 47 | 47 | add_action( 'sensei_user_course_start', array( $this, 'teacher_started_course' ), 10, 2 ); |
| 48 | - add_action( 'sensei_user_lesson_end', array( $this, 'teacher_completed_lesson' ), 10, 2 ); |
|
| 48 | + add_action( 'sensei_user_lesson_end', array( $this, 'teacher_completed_lesson' ), 10, 2 ); |
|
| 49 | 49 | add_action( 'sensei_user_quiz_submitted', array( $this, 'teacher_quiz_submitted' ), 10, 5 ); |
| 50 | 50 | add_action( 'sensei_new_private_message', array( $this, 'teacher_new_message' ), 10, 1 ); |
| 51 | 51 | add_action( 'sensei_private_message_reply', array( $this, 'new_message_reply' ), 10, 2 ); |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $this->emails['learner-graded-quiz'] = include( 'emails/class-woothemes-sensei-email-learner-graded-quiz.php' ); |
| 63 | 63 | $this->emails['learner-completed-course'] = include( 'emails/class-woothemes-sensei-email-learner-completed-course.php' ); |
| 64 | 64 | $this->emails['teacher-completed-course'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-course.php' ); |
| 65 | - $this->emails['teacher-started-course'] = include( 'emails/class-woothemes-sensei-email-teacher-started-course.php' ); |
|
| 66 | - $this->emails['teacher-completed-lesson'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-lesson.php' ); |
|
| 67 | - $this->emails['teacher-quiz-submitted'] = include( 'emails/class-woothemes-sensei-email-teacher-quiz-submitted.php' ); |
|
| 65 | + $this->emails['teacher-started-course'] = include( 'emails/class-woothemes-sensei-email-teacher-started-course.php' ); |
|
| 66 | + $this->emails['teacher-completed-lesson'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-lesson.php' ); |
|
| 67 | + $this->emails['teacher-quiz-submitted'] = include( 'emails/class-woothemes-sensei-email-teacher-quiz-submitted.php' ); |
|
| 68 | 68 | $this->emails['teacher-new-message'] = include( 'emails/class-woothemes-sensei-email-teacher-new-message.php' ); |
| 69 | 69 | $this->emails['new-message-reply'] = include( 'emails/class-woothemes-sensei-email-new-message-reply.php' ); |
| 70 | 70 | $this->emails = apply_filters( 'sensei_email_classes', $this->emails ); |
@@ -171,20 +171,20 @@ discard block |
||
| 171 | 171 | add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
| 172 | 172 | add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
| 173 | 173 | |
| 174 | - // Send |
|
| 175 | - $send_email = true; |
|
| 174 | + // Send |
|
| 175 | + $send_email = true; |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Filter Sensei's ability to send out emails. |
|
| 179 | - * |
|
| 180 | - * @since 1.8.0 |
|
| 181 | - * @param bool $send_email default true |
|
| 182 | - */ |
|
| 183 | - if( apply_filters('sensei_send_emails', $send_email,$to, $subject, $message ) ){ |
|
| 177 | + /** |
|
| 178 | + * Filter Sensei's ability to send out emails. |
|
| 179 | + * |
|
| 180 | + * @since 1.8.0 |
|
| 181 | + * @param bool $send_email default true |
|
| 182 | + */ |
|
| 183 | + if( apply_filters('sensei_send_emails', $send_email,$to, $subject, $message ) ){ |
|
| 184 | 184 | |
| 185 | - wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
| 185 | + wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
| 186 | 186 | |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | // Unhook filters |
| 190 | 190 | remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
@@ -326,44 +326,44 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * teacher_completed_lesson() |
|
| 331 | - * |
|
| 332 | - * Send email to teacher on student completing lesson |
|
| 333 | - * |
|
| 334 | - * @access public |
|
| 335 | - * @return void |
|
| 336 | - * @since 1.9.0 |
|
| 337 | - */ |
|
| 338 | - function teacher_completed_lesson( $learner_id = 0, $lesson_id = 0 ) { |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - $send = false; |
|
| 342 | - |
|
| 343 | - if( isset( Sensei()->settings->settings[ 'email_teachers' ] ) ) { |
|
| 344 | - if( in_array( 'teacher-completed-lesson', (array) Sensei()->settings->settings[ 'email_teachers' ]) ) { |
|
| 345 | - $send = true; |
|
| 346 | - } |
|
| 347 | - } else { |
|
| 348 | - $send = true; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - if( $send ) { |
|
| 352 | - $email = $this->emails['teacher-completed-lesson']; |
|
| 353 | - $email->trigger( $learner_id, $lesson_id ); |
|
| 354 | - } |
|
| 355 | - } |
|
| 329 | + /** |
|
| 330 | + * teacher_completed_lesson() |
|
| 331 | + * |
|
| 332 | + * Send email to teacher on student completing lesson |
|
| 333 | + * |
|
| 334 | + * @access public |
|
| 335 | + * @return void |
|
| 336 | + * @since 1.9.0 |
|
| 337 | + */ |
|
| 338 | + function teacher_completed_lesson( $learner_id = 0, $lesson_id = 0 ) { |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + $send = false; |
|
| 342 | + |
|
| 343 | + if( isset( Sensei()->settings->settings[ 'email_teachers' ] ) ) { |
|
| 344 | + if( in_array( 'teacher-completed-lesson', (array) Sensei()->settings->settings[ 'email_teachers' ]) ) { |
|
| 345 | + $send = true; |
|
| 346 | + } |
|
| 347 | + } else { |
|
| 348 | + $send = true; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + if( $send ) { |
|
| 352 | + $email = $this->emails['teacher-completed-lesson']; |
|
| 353 | + $email->trigger( $learner_id, $lesson_id ); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | 358 | * Send email to teacher on quiz submission |
| 359 | 359 | * |
| 360 | 360 | * |
| 361 | - * @param int $learner_id |
|
| 362 | - * @param int $quiz_id |
|
| 363 | - * @param int $grade |
|
| 364 | - * @param int $passmark |
|
| 365 | - * @param string $quiz_grade_type |
|
| 366 | - */ |
|
| 361 | + * @param int $learner_id |
|
| 362 | + * @param int $quiz_id |
|
| 363 | + * @param int $grade |
|
| 364 | + * @param int $passmark |
|
| 365 | + * @param string $quiz_grade_type |
|
| 366 | + */ |
|
| 367 | 367 | function teacher_quiz_submitted( $learner_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0, $quiz_grade_type = 'manual' ) { |
| 368 | 368 | |
| 369 | 369 | $send = false; |
@@ -16,38 +16,38 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class WooThemes_Sensei_Email_New_Message_Reply { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - var $template; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + var $template; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | 27 | var $subject; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - var $heading; |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + var $heading; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | 37 | var $recipient; |
| 38 | 38 | |
| 39 | 39 | var $original_sender; |
| 40 | 40 | var $original_receiver; |
| 41 | 41 | var $commenter; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var WP_Post |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var WP_Post |
|
| 45 | + */ |
|
| 46 | 46 | var $message; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var WP_Comment |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var WP_Comment |
|
| 50 | + */ |
|
| 51 | 51 | var $comment; |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * trigger function. |
| 66 | 66 | * |
| 67 | - * @param WP_Comment $comment |
|
| 68 | - * @param string $message |
|
| 69 | - * |
|
| 67 | + * @param WP_Comment $comment |
|
| 68 | + * @param string $message |
|
| 69 | + * |
|
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | 72 | function trigger ( $comment, $message ) { |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $comment_link = get_comment_link( $comment ); |
| 92 | 92 | |
| 93 | - // setup the post type parameter |
|
| 94 | - $content_type = get_post_type( $content_id ); |
|
| 95 | - if( !$content_type ){ |
|
| 96 | - $content_type =''; |
|
| 97 | - } |
|
| 93 | + // setup the post type parameter |
|
| 94 | + $content_type = get_post_type( $content_id ); |
|
| 95 | + if( !$content_type ){ |
|
| 96 | + $content_type =''; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // Construct data array |
|
| 100 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
| 101 | - 'template' => $this->template, |
|
| 102 | - $content_type.'_id' => $content_id, |
|
| 99 | + // Construct data array |
|
| 100 | + $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
| 101 | + 'template' => $this->template, |
|
| 102 | + $content_type.'_id' => $content_id, |
|
| 103 | 103 | 'heading' => $this->heading, |
| 104 | 104 | 'commenter_name' => $this->commenter->display_name, |
| 105 | 105 | 'message' => $this->comment->comment_content, |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * trigger function. |
| 38 | 38 | * |
| 39 | 39 | * @access public |
| 40 | - * @param integer $message_id |
|
| 40 | + * @param integer $message_id |
|
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | function trigger( $message_id = 0 ) { |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | $content_id = get_post_meta( $message_id, '_post', true ); |
| 56 | 56 | $content_title = get_the_title( $content_id ); |
| 57 | 57 | |
| 58 | - // setup the post type parameter |
|
| 59 | - $content_type = get_post_type( $content_id ); |
|
| 60 | - if( !$content_type ){ |
|
| 61 | - $content_type =''; |
|
| 62 | - } |
|
| 58 | + // setup the post type parameter |
|
| 59 | + $content_type = get_post_type( $content_id ); |
|
| 60 | + if( !$content_type ){ |
|
| 61 | + $content_type =''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | // Construct data array |
| 65 | 65 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
| 66 | 66 | 'template' => $this->template, |
| 67 | - $content_type.'_id' => $content_id, |
|
| 67 | + $content_type.'_id' => $content_id, |
|
| 68 | 68 | 'heading' => $this->heading, |
| 69 | 69 | 'teacher_id' => $this->teacher->ID, |
| 70 | 70 | 'learner_id' => $this->learner->ID, |
@@ -36,11 +36,11 @@ |
||
| 36 | 36 | /** |
| 37 | 37 | * trigger function. |
| 38 | 38 | * |
| 39 | - * @param int $user_id |
|
| 40 | - * @param int $quiz_id |
|
| 41 | - * @param int $grade |
|
| 42 | - * @param int $passmark |
|
| 43 | - * |
|
| 39 | + * @param int $user_id |
|
| 40 | + * @param int $quiz_id |
|
| 41 | + * @param int $grade |
|
| 42 | + * @param int $passmark |
|
| 43 | + * |
|
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | 46 | function trigger ( $user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0 ) { |
@@ -38,10 +38,10 @@ |
||
| 38 | 38 | * trigger function. |
| 39 | 39 | * |
| 40 | 40 | * @access public |
| 41 | - * |
|
| 42 | - * @param int $user_id |
|
| 43 | - * @param int $course_id |
|
| 44 | - * |
|
| 41 | + * |
|
| 42 | + * @param int $user_id |
|
| 43 | + * @param int $course_id |
|
| 44 | + * |
|
| 45 | 45 | * @return void |
| 46 | 46 | */ |
| 47 | 47 | function trigger( $user_id = 0, $course_id = 0 ) { |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 7 | 7 | |
| 8 | 8 | if ( class_exists( 'Teacher_New_Course_Assignment' ) ){ |
| 9 | - return; |
|
| 9 | + return; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -40,40 +40,40 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function __construct() { |
| 42 | 42 | |
| 43 | - $this->template = 'teacher-new-course-assignment'; |
|
| 43 | + $this->template = 'teacher-new-course-assignment'; |
|
| 44 | 44 | $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have been assigned to a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
| 45 | 45 | $this->heading = apply_filters( 'sensei_email_heading', __( 'Course assigned to you', 'woothemes-sensei' ), $this->template ); |
| 46 | - return; |
|
| 46 | + return; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * trigger function. |
| 51 | 51 | * |
| 52 | 52 | * @access public |
| 53 | - * @param $teacher_id |
|
| 54 | - * @param $course_id |
|
| 53 | + * @param $teacher_id |
|
| 54 | + * @param $course_id |
|
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | 57 | function trigger( $teacher_id = 0, $course_id = 0 ) { |
| 58 | 58 | global $sensei_email_data; |
| 59 | 59 | |
| 60 | 60 | $this->teacher = new WP_User( $teacher_id ); |
| 61 | - $this->recipient = stripslashes( $this->teacher->user_email ); |
|
| 62 | - $this->subject = __( 'New course assigned to you', 'woothemes-sensei' ); |
|
| 61 | + $this->recipient = stripslashes( $this->teacher->user_email ); |
|
| 62 | + $this->subject = __( 'New course assigned to you', 'woothemes-sensei' ); |
|
| 63 | 63 | |
| 64 | - //course edit link |
|
| 65 | - $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
|
| 64 | + //course edit link |
|
| 65 | + $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
|
| 66 | 66 | |
| 67 | - // Course name |
|
| 68 | - $course = get_post( $course_id); |
|
| 67 | + // Course name |
|
| 68 | + $course = get_post( $course_id); |
|
| 69 | 69 | // Construct data array |
| 70 | 70 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
| 71 | 71 | 'template' => $this->template, |
| 72 | 72 | 'heading' => $this->heading, |
| 73 | 73 | 'teacher_id' => $teacher_id, |
| 74 | 74 | 'course_id' => $course_id, |
| 75 | - 'course_name' => $course->post_title, |
|
| 76 | - 'course_edit_link' => $course_edit_link, |
|
| 75 | + 'course_name' => $course->post_title, |
|
| 76 | + 'course_edit_link' => $course_edit_link, |
|
| 77 | 77 | ), $this->template ); |
| 78 | 78 | |
| 79 | 79 | // Send mail |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * trigger function. |
| 37 | - * |
|
| 38 | - * @param integer $learner_id |
|
| 39 | - * @param integer $quiz_id |
|
| 40 | - * |
|
| 37 | + * |
|
| 38 | + * @param integer $learner_id |
|
| 39 | + * @param integer $quiz_id |
|
| 40 | + * |
|
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | function trigger( $learner_id = 0, $quiz_id = 0 ) { |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | $this->learner = new WP_User( $learner_id ); |
| 48 | 48 | |
| 49 | 49 | // Get teacher ID and user object |
| 50 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 51 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 50 | + $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 51 | + $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 52 | 52 | $teacher_id = get_post_field( 'post_author', $course_id, 'raw' ); |
| 53 | 53 | $this->teacher = new WP_User( $teacher_id ); |
| 54 | 54 | |
@@ -37,9 +37,9 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * trigger function. |
| 39 | 39 | * |
| 40 | - * @param int $learner_id |
|
| 41 | - * @param int $course_id |
|
| 42 | - * |
|
| 40 | + * @param int $learner_id |
|
| 41 | + * @param int $course_id |
|
| 42 | + * |
|
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | 45 | function trigger( $learner_id = 0, $course_id = 0 ) { |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * trigger function. |
| 37 | 37 | * |
| 38 | - * @param int $learner_id |
|
| 39 | - * @param int $lesson_id |
|
| 40 | - * |
|
| 38 | + * @param int $learner_id |
|
| 39 | + * @param int $lesson_id |
|
| 40 | + * |
|
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | function trigger( $learner_id = 0, $lesson_id = 0 ) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $teacher_id = get_post_field( 'post_author', $lesson_id, 'raw' ); |
| 52 | 52 | $this->teacher = new WP_User( $teacher_id ); |
| 53 | 53 | |
| 54 | - // Construct data array |
|
| 54 | + // Construct data array |
|
| 55 | 55 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
| 56 | 56 | 'template' => $this->template, |
| 57 | 57 | 'heading' => $this->heading, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->recipient = stripslashes( $this->teacher->user_email ); |
| 66 | 66 | |
| 67 | 67 | // Send mail |
| 68 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
| 68 | + Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |