diff --git a/includes/course-theme/class-sensei-course-theme-lesson.php b/includes/course-theme/class-sensei-course-theme-lesson.php index 84267796ce..45465c6738 100644 --- a/includes/course-theme/class-sensei-course-theme-lesson.php +++ b/includes/course-theme/class-sensei-course-theme-lesson.php @@ -250,8 +250,9 @@ private function maybe_add_lesson_prerequisite_notice() { * @return void */ private function maybe_add_not_enrolled_notice() { - $lesson_id = \Sensei_Utils::get_current_lesson(); - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); + $lesson_id = \Sensei_Utils::get_current_lesson(); + $course_id = Sensei()->lesson->get_course_id( $lesson_id ); + $is_preview = $lesson_id && Sensei_Utils::is_preview_lesson( $lesson_id ); if ( Sensei_Course::is_user_enrolled( $course_id ) ) { return; @@ -262,11 +263,16 @@ private function maybe_add_not_enrolled_notice() { $notice_title = __( 'You don\'t have access to this lesson', 'sensei-lms' ); $notice_icon = 'lock'; + if ( $is_preview ) { + $notice_title = __( 'This is a preview lesson', 'sensei-lms' ); + $notice_icon = 'eye'; + } + // Check if self-enrollment is allowed. if ( Sensei_Course::is_self_enrollment_not_allowed( $course_id ) ) { $notices->add_notice( $notice_key, - __( 'Please contact the course administrator to access the course content.', 'sensei-lms' ), + __( 'Please contact the course administrator to take this lesson.', 'sensei-lms' ), $notice_title, [], $notice_icon @@ -311,10 +317,8 @@ private function maybe_add_not_enrolled_notice() { $notice_text = __( 'Please register or sign in to access the course content.', 'sensei-lms' ); - if ( $lesson_id && Sensei_Utils::is_preview_lesson( $lesson_id ) ) { - $notice_text = __( 'Register or sign in to take this lesson.', 'sensei-lms' ); - $notice_title = __( 'This is a preview lesson', 'sensei-lms' ); - $notice_icon = 'eye'; + if ( $is_preview ) { + $notice_text = __( 'Register or sign in to take this lesson.', 'sensei-lms' ); } $notices->add_notice( @@ -340,10 +344,8 @@ private function maybe_add_not_enrolled_notice() { $notice_text = __( 'Please register for this course to access the content.', 'sensei-lms' ); - if ( $lesson_id && Sensei_Utils::is_preview_lesson( $lesson_id ) ) { - $notice_text = __( 'Register for this course to take this lesson.', 'sensei-lms' ); - $notice_title = __( 'This is a preview lesson', 'sensei-lms' ); - $notice_icon = 'eye'; + if ( $is_preview ) { + $notice_text = __( 'Register for this course to take this lesson.', 'sensei-lms' ); } $notices->add_notice( diff --git a/tests/unit-tests/course-theme/test-class-sensei-course-theme-lesson.php b/tests/unit-tests/course-theme/test-class-sensei-course-theme-lesson.php index 95d43427fa..ace6187fd6 100644 --- a/tests/unit-tests/course-theme/test-class-sensei-course-theme-lesson.php +++ b/tests/unit-tests/course-theme/test-class-sensei-course-theme-lesson.php @@ -245,7 +245,7 @@ public function testCourseNotAllowedSelfEnrollmentNotice() { $html = \Sensei_Context_Notices::instance( 'course_theme_locked_lesson' )->get_notices_html( 'course-theme/locked-lesson-notice.php' ); /* Assert. */ - $this->assertStringContainsString( 'Please contact the course administrator to access the course content.', $html, 'Should return not allowed self-enrollment notice' ); + $this->assertStringContainsString( 'Please contact the course administrator to take this lesson.', $html, 'Should return not allowed self-enrollment notice' ); } /**