diff --git a/README.md b/README.md index 624067d..d60ffd7 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ A module for managing Newfold in-site notifications. "newfold-notifications", filter prefixes, etc.) If necessary, we can leverage the container to get the ID of a plugin (e.g. `bluehost`, `hostgator`, `web`, etc.) - [x] Update notifications to have a container and always load scripts in admin so event listeners can be attached to contaienr (for CTB updates) -- [ ] Take the React [notifications component](https://github.com/bluehost/bluehost-wordpress-plugin/blob/575c9dfc7ad9e2cc7a3932ebc9e5a07505108d7c/src/app/components/organisms/bwa-notification/index.js) +- [x] Take the React [notifications component](https://github.com/bluehost/bluehost-wordpress-plugin/blob/575c9dfc7ad9e2cc7a3932ebc9e5a07505108d7c/src/app/components/organisms/bwa-notification/index.js) [reducers](https://github.com/bluehost/bluehost-wordpress-plugin/blob/c842ce4925f567eab754154d0a2d52483dd79534/src/app/store/reducer.js#L47-L55) and [actions](https://github.com/bluehost/bluehost-wordpress-plugin/blob/c842ce4925f567eab754154d0a2d52483dd79534/src/app/store/actions.js) from the Bluehost plugin and make them more generic and add it to this module. We'll just include the component from @@ -44,8 +44,8 @@ A module for managing Newfold in-site notifications. - [ ] Ensure that notifications are working properly in the following contexts: - [x] Admin notices on standard WP admin pages - [ ] Realtime notices on the plugins page - - [ ] Notices within our plugin-specific React app -- [ ] Clean up terminology to make it consistent - notification vs notice. + - [x] Notices within our plugin-specific React app +- [ ] Clean up terminology to make it consistent - notification vs notice Note: The `NotificationsApi.php` file around line #45 has some commented out test code which will let you mock a notification for testing. diff --git a/includes/NotificationsApi.php b/includes/NotificationsApi.php index c38cbcc..1953cba 100644 --- a/includes/NotificationsApi.php +++ b/includes/NotificationsApi.php @@ -45,18 +45,83 @@ function ( Notification $notification ) { ->values(); // TODO: Remove test code - $results[] = [ - 'id' => 'test', - 'locations' => [ - [ - 'context' => container()->plugin()->id . '-plugin', - // 'context' => 'wp-admin-notice', - 'pages' => 'all', - ] - ], - 'expiration' => '2026-01-19T15:46:34.475088Z', - 'content' => 'HELLOW THERE!', - ]; + // $results[] = [ + // 'id' => 'test-plugin', + // 'locations' => [ + // [ + // 'context' => container()->plugin()->id . '-plugin', + // 'pages' => '#/home', + // ] + // ], + // 'expiration' => 1648863456503, + // 'content' => '

Expired notice should not display in app app notice

', + // ]; + // $results[] = [ + // 'id' => 'test-admin', + // 'locations' => [ + // [ + // 'context' => container()->plugin()->id . '-plugin', + // 'pages' => '#/home', + // ], + // [ + // 'context' => container()->plugin()->id . '-plugin', + // 'pages' => '#/help', + // ] + // ], + // 'expiration' => 1649860279240, + // 'content' => '

Here is a plugin notice it should display on home and help screen only! x

', + // ]; + // $results[] = [ + // 'id' => 'test-admin-prime', + // 'locations' => [ + // [ + // 'context' => 'wp-admin-prime', + // 'pages' => 'all', + // ] + // ], + // 'expiration' => 1649860279240, + // 'content' => '

HELLOW THERE `wp-admin-prime` notice!

', + // ]; + // $results[] = [ + // 'id' => 'test-search-realtime', + // 'locations' => [ + // [ + // 'context' => 'wp-plugin-search', + // 'pages' => 'all', + // ] + // ], + // 'expiration' => 1649860279240, + // 'content' => '

HELLOW THERE plugin search notice!

', + // ]; + // $results[] = [ + // 'id' => "36832018-3d86-4fc1-80d2-fc36973f6b2f", + // 'locations' => [ + // [ + // 'pages' => "all", + // 'context' => 'wp-admin-notice' + // ] + // ], + // 'expiration' => 1649860279240, + // 'content' => "
Jetpack Backup provides redundant backups and an activity log of all your changes, which means you can choose the right backup and restore that specific version of your site. Learn More
Close
" + // ]; + // $results[] = [ + // 'id' => 'b33d6d88-a8c0-4d75-b9ff-f75d339babb3', + // 'locations' => [ + // [ + // 'pages' => ["#/marketplace/themes","#/marketplace/plugins","#/marketplace/services"], + // 'context' => "web-plugin" + // ], + // [ + // 'pages' => 'index.php', + // 'context' => "wp-admin-notice" + // ], + // ], + // 'expiration' => 1649860279240, + // 'content' => "
For over 30 years, .org has given a voice to millions. Start your mission with a .org domain name, now only $9.99/first year. Learn More
Close
" + // ]; + + // $notifications->setTransient( $results ); + //END test code return rest_ensure_response( $results ); },