Tribe__Admin__Notices::should_recurring_notice_show( string $slug, int|null $user_id = null )

Determines if a given notice needs to be re-displayed in case of recurring notice.


Parameters

$slug

(string) (Required) Slug of the notice to look for.

$user_id

(int|null) (Optional) Which user? If null will default to current user.

Default value: null


Top ↑

Return

(false|TribeUtilsDate_I18n)


Top ↑

Source

File: src/Tribe/Admin/Notices.php

	public function should_recurring_notice_show( $slug, $user_id = null ) {
		$notice = $this->get( $slug );
		if ( ! is_object( $notice ) ) {
			return false;
		}

		if ( ! $notice->recurring || ! $notice->recurring_interval ) {
			return false;
		}

		if ( is_null( $user_id ) ) {
			$user_id = get_current_user_id();
		}

		$interval       = Dates::interval( $notice->recurring_interval );
		$last_dismissal = $this->get_last_dismissal( $slug, $user_id );
		if ( ! $last_dismissal ) {
			return false;
		}

		$next_dismissal = $last_dismissal->add( $interval );
		$now            = Dates::build_date_object( 'now' );

		if ( $now >= $next_dismissal ) {
			delete_user_meta( $user_id, self::$meta_key, $slug );

			return true;
		}

		return false;
	}

Top ↑

Changelog

Changelog
Version Description
4.13.0 Introduced.