Gocodebox_Banner_Notifier::is_notification_applicable( object $notification )

Check rules for a notification.


Parameters Parameters

$notification

(object) (Required) The notification object.


Top ↑

Source Source

File: libraries/banner-notifications/src/notifications.php

	function is_notification_applicable( $notification ) {
		// If one is specified by URL parameter, it's allowed.
		if ( ! empty( $_REQUEST[ "{$this->prefix}_notification" ] ) && $notification->id == intval( $_REQUEST[ "{$this->prefix}_notification" ] ) ) {
			return true;
		}

		// Hide if today's date is before notification start date.
		// TODO: Potentially switch as current_time( 'timestamp' ) is deprecated.
		if ( date( 'Y-m-d', current_time( 'timestamp' ) ) < $notification->starts ) {
			return false;
		}

		// Hide if today's date is after end date.
		// TODO: Potentially as current_time( 'timestamp' ) is deprecated.
		if ( date( 'Y-m-d', current_time( 'timestamp' ) ) > $notification->ends ) {
			return false;
		}

		// Check priority, e.g. if only security notifications should be shown.
		if ( $notification->priority > $this->get_max_notification_priority() ) {
			return false;
		}

		if ( ! $this->should_show_notification( $notification ) ) {
			return false;
		}

		if ( $this->should_hide_notification( $notification ) ) {
			return false;
		}

		// If we get here, show it.
		return true;
	}


Top ↑

User Contributed Notes User Contributed Notes

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