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,
			)
		);

		$this->displayed = $query->get_notifications();

		// Push to JS.
		LLMS_Frontend_Assets::enqueue_inline_script(
			'llms-queued-notifications',
			'window.llms = window.llms || {};window.llms.queued_notifications = ' . wp_json_encode( $this->displayed ) . ';'
		);

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.38.0 Use wp_json_decode() in favor of json_decode().
3.36.1 Don't automatically mark notifications as read.
3.22.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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