Skip to content

newfold-labs/wp-module-notifications

WordPress Notifications Module

Version Number License

A module for managing Newfold in-site notifications.

Module Responsibilities

  • Renders admin notices contextually on specific admin screens or globally unless they have expired or been dismissed.
  • Provides an API for fetching notifications, dispatching events that update available notifications, and dismissing notifications.
  • Responds in real-time to plugin searches with notifications if triggered.

Critical Paths

  • Notifications with a specific context should only show on the appropriate pages.
  • Notifications that have expired should not show at all.
  • Notifications that have been dismissed should not show again.
  • A plugin search for a specific matching keyword should render a notification in real-time.

Installation

1. Add the Newfold Satis to your composer.json.

composer config repositories.newfold composer https://newfold-labs.github.io/satis

2. Require the newfold-labs/wp-module-notifications package.

composer require newfold-labs/wp-module-notifications

More on Newfold WordPress Modules

TODO:

  • Clean up/standardize REST API endpoints so they can be versioned at the module level (e.g. wp-json/newfold-notifications/v1/* and wp-json/newfold-data/v1/*).
  • Clean up remaining references to bluehost and bh_ (text domains, notification display context - use "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.)
  • 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 reducers and actions from the Bluehost plugin and make them more generic and add it to this module. We'll just include the component from the vendor directory for now. We'll probably need to update the component to accept the data store as a prop and maybe some other things as well.
  • Ensure that notifications are working properly in the following contexts:
    • 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
  • Set up webpack alias in plugin so we don't need to reference such a long path for importing component
  • Set up hiive brand relationship so bluehost notifications don't display in other brands plugins etc.

Note: The NotificationsApi.php file around line #45 has some commented out test code which will let you mock a notification for testing.