src/Modules/Notification.php
public static function show_notification() {

		$current_notification = self::get_last_notification();

		$notification_details = [];
		// Check if the saved notification is still present among the possible ones.
		if ( ! empty( $current_notification ) ) {
			$notification_details = self::get_notification_details( $current_notification );
			if ( empty( $notification_details ) ) {
				$current_notification = [];
			}
		}
		// Check if the notificatin is expired.
		if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) {
			update_option( $current_notification['id'], 'no' );
			self::set_last_active_notification_timestamp();
			$current_notification = [];
		}
		// If we don't have any saved notification, get a new one.
		if ( empty( $current_notification ) ) {
			$notification_details = self::get_random_notification();
			if ( empty( $notification_details ) ) {
				return;
			}
			self::set_active_notification(
				[
					'id'         => $notification_details['id'],
					'display_at' => time(),
				]
			);
		}
		if ( empty( $notification_details ) ) {
			return;
		}
		$notification_html = self::get_notification_html( $notification_details );
		do_action( $notification_details['id'] . '_before_render' );

		echo $notification_html;

		do_action( $notification_details['id'] . '_after_render' );
		self::render_snippets();
	}
public static function show_notification() {

		$current_notification = self::get_last_notification();

		$notification_details = [];
		// Check if the saved notification is still present among the possible ones.
		if ( ! empty( $current_notification ) ) {
			$notification_details = self::get_notification_details( $current_notification );
			if ( empty( $notification_details ) ) {
				$current_notification = [];
			}
		}
		// Check if the notificatin is expired.
		if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) {
			update_option( $current_notification['id'], 'no' );
			self::set_last_active_notification_timestamp();
			$current_notification = [];
		}
		// If we don't have any saved notification, get a new one.
		if ( empty( $current_notification ) ) {
			$notification_details = self::get_random_notification();
			if ( empty( $notification_details ) ) {
				return;
			}
			self::set_active_notification(
				[
					'id'         => $notification_details['id'],
					'display_at' => time(),
				]
			);
		}
		if ( empty( $notification_details ) ) {
			return;
		}
		$notification_html = self::get_notification_html( $notification_details );
		do_action( $notification_details['id'] . '_before_render' );

		echo $notification_html;

		do_action( $notification_details['id'] . '_after_render' );
		self::render_snippets();
	}
public static function show_notification ( ) { $ current_notification = self :: get_last_notification ( ) ; $ notification_details = [ ] ; // Check if the saved notification is still present among the possible ones. if ( ! empty ( $ current_notification ) ) { $ notification_details = self :: get_notification_details ( $ current_notification ) ; if ( empty ( $ notification_details ) ) { $ current_notification = [ ] ; } } // Check if the notificatin is expired. if ( ! empty ( $ current_notification ) && self :: is_notification_expired ( $ current_notification ) ) { update_option ( $ current_notification [ 'id' ] , 'no' ) ; self :: set_last_active_notification_timestamp ( ) ; $ current_notification = [ ] ; } // If we don't have any saved notification, get a new one. if ( empty ( $ current_notification ) ) { $ notification_details = self :: get_random_notification ( ) ; if ( empty ( $ notification_details ) ) { return ; } self :: set_active_notification ( [ 'id' => $ notification_details [ 'id' ] , 'display_at' => time ( ) , ] ) ; } if ( empty ( $ notification_details ) ) { return ; } $ notification_html = self :: get_notification_html ( $ notification_details ) ; do_action ( $ notification_details [ 'id' ] . '_before_render' ) ; echo $ notification_html ; do_action ( $ notification_details [ 'id' ] . '_after_render' ) ; self :: render_snippets ( ) ; }
Show notification data.
Show notification data .