LLMS_Notifications::enqueue_basic()
Enqueue basic notifications for onscreen display
Description Description
Return Return
(void)
Source Source
File: includes/notifications/class.llms.notifications.php
public function enqueue_basic() { $user_id = get_current_user_id(); if ( ! $user_id ) { return; } // get 5 most recent new notifications for the current user $query = new LLMS_Notifications_Query( array( 'per_page' => 5, 'statuses' => 'new', 'types' => 'basic', 'subscriber' => $user_id, ) ); $notifications = $query->get_notifications(); // push to JS LLMS_Frontend_Assets::enqueue_inline_script( 'llms-queued-notifications', 'window.llms = window.llms || {};window.llms.queued_notifications = ' . json_encode( $notifications ) . ';' ); // record as read if ( $query->has_results() ) { foreach ( $notifications as $notification ) { $notification->set( 'status', 'read' ); } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.22.0 | Introduced. |