LLMS_Notifications::enqueue_basic()

Enqueue basic notifications for onscreen display


Description Description


Return Return

(void)


Top ↑

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' );
			}
		}

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.22.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.