diff --git a/includes/class-sensei.php b/includes/class-sensei.php
index a6064e38ba..1dfa373c20 100644
--- a/includes/class-sensei.php
+++ b/includes/class-sensei.php
@@ -530,6 +530,7 @@ public function initialize_global_objects() {
new Sensei_Exit_Survey();
Sensei_No_Users_Table_Relationship::instance()->init();
+ SenseiLMS_Plugin_Updater::init();
} else {
diff --git a/tests/unit-tests/admin/test-class-sensei-admin-notices.php b/tests/unit-tests/admin/test-class-sensei-admin-notices.php
index 85dc666ea7..1b8ed0564a 100644
--- a/tests/unit-tests/admin/test-class-sensei-admin-notices.php
+++ b/tests/unit-tests/admin/test-class-sensei-admin-notices.php
@@ -220,6 +220,227 @@ public function testCheckNoScreensCondition() {
$this->assertArrayHasKey( 'on-sensei-pages', $notices_on_edit_course );
}
+ public function testGetNoticesToDisplay_WithDateRangeCondtionMet_ShowNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '-1 minute' ) )->format( 'c' ),
+ 'end_date' => ( new DateTime( '+1 minute' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithDateRangeEndingMinuteAgo_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '-2 minutes' ) )->format( 'c' ),
+ 'end_date' => ( new DateTime( '-1 minute' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithDateRangeStartingInOneMinute_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '+1 minute' ) )->format( 'c' ),
+ 'end_date' => ( new DateTime( '+1 year' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithInvalidStartDateFormat_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '-1 year' ) )->format( 'c' ) . ' MoonTime',
+ 'end_date' => ( new DateTime( '+1 year' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithInvalidEndDateFormat_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '-1 year' ) )->format( 'c' ),
+ 'end_date' => ( new DateTime( '+1 year' ) )->format( 'c' ) . ' MoonTime',
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithPartialStartDateInFuture_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '+1 hour' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithPartialStartDateInPast_ShowNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'start_date' => ( new DateTime( '-1 hour' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithPartialEndDateInPast_HideNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'end_date' => ( new DateTime( '-1 hour' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayNotHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
+ public function testGetNoticesToDisplay_WithPartialEndDateInFuture_ShowNotice() {
+ // Arrange.
+ $this->login_as_admin();
+ $notices = [
+ 'notice-with-date-range' => [
+ 'message' => 'Important message to show on sites during a specific date range.',
+ 'conditions' => [
+ [
+ 'type' => 'date_range',
+ 'end_date' => ( new DateTime( '+1 hour' ) )->format( 'c' ),
+ ],
+ ],
+ ],
+ ];
+
+ $instance = $this->getMockInstance( [ 'notices' => $notices ] );
+
+ // Act.
+ $notices_to_display = $instance->get_notices_to_display();
+
+ // Assert.
+ $this->assertArrayHasKey( 'notice-with-date-range', $notices_to_display );
+ }
+
/**
* Tests basic has/doesn't have plugins test.
*/
diff --git a/webpack.config.js b/webpack.config.js
index 6dd4d3eb75..0f42cfff66 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -118,6 +118,7 @@ const files = [
'css/sensei-theme-blocks.scss',
'css/sensei-course-theme/sidebar-mobile-menu.scss',
'css/showcase-upsell.scss',
+ 'css/senseilms-licensing.scss',
'course-theme/learning-mode.js',
'course-theme/course-theme.editor.js',
'course-theme/blocks/index.js',