Automattic\WooCommerce\Internal\Admin

ShippingLabelBannerDisplayRules::banner_not_dismissed()privateWC 1.0

Checks if the banner was not dismissed by the user.

Method of the class: ShippingLabelBannerDisplayRules{}

No Hooks.

Return

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->banner_not_dismissed();

ShippingLabelBannerDisplayRules::banner_not_dismissed() code WC 7.1.0

private function banner_not_dismissed() {
	$dismissed_timestamp_ms = get_option( 'woocommerce_shipping_dismissed_timestamp' );

	if ( ! is_numeric( $dismissed_timestamp_ms ) ) {
		return true;
	}
	$dismissed_timestamp_ms = intval( $dismissed_timestamp_ms );
	$dismissed_timestamp    = intval( round( $dismissed_timestamp_ms / 1000 ) );
	$expired_timestamp      = $dismissed_timestamp + 24 * 60 * 60; // 24 hours from click time

	$dismissed_for_good = -1 === $dismissed_timestamp_ms;
	$dismissed_24h      = time() < $expired_timestamp;

	return ! $dismissed_for_good && ! $dismissed_24h;
}