Skip to content

WordPressUtilities/wpunotifications

Repository files navigation

WPU Notifications

Handle user notifications

PHP workflow JS workflow

Roadmap

  • Basic CSS
  • Handle notification view.
  • Mark a notification as viewed.
  • Handle notification expiration.
  • JS Hooks.

How to

Display notifications

do_action('wpunotifications_display_notifications');

Display notifications pill

do_action('wpunotifications_display_notifications_unread_pill');

Create a notification

add_filter('wpunotifications__notifications', function ($notifications) {
    $notifications[] = array(
        'message' => 'Hello world',
        'user_id' => 3,
        'notif_type' => 'success'
    );
    return $notifications;
});

Action when a notification is created

add_action('wpunotifications__notification_created', function ($args) {
   error_log(json_encode($args));
});