LLMS_Notifications::enqueue_basic()

Enqueue basic notifications for onscreen display


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,
				'no_found_rows' => true,
			)
		);

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

		// Push to JS.
		llms()->assets->enqueue_inline(
			'llms-queued-notifications',
			'window.llms.queued_notifications = ' . wp_json_encode( $this->displayed ) . ';',
			'footer'
		);


Top ↑

Changelog Changelog

Changelog
Version Description
4.4.0 Use LLMS_Assets::enqueue_inline() in favor of deprecated LLMS_Frontend_Assets::enqueue_inline_script().
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.