Automattic\WooCommerce\Admin

WCAdminHelper::is_site_fresh()public staticWC 1.0

Test if the site is fresh. A fresh site must meet the following requirements.

  • The current user was registered less than 1 month ago.
  • fresh_site option must be 1

Method of the class: WCAdminHelper{}

No Hooks.

Return

true|false.

Usage

$result = WCAdminHelper::is_site_fresh();

WCAdminHelper::is_site_fresh() code WC 9.8.2

public static function is_site_fresh() {
	$fresh_site = get_option( 'fresh_site' );
	if ( '1' !== $fresh_site ) {
		return false;
	}

	$current_userdata = get_userdata( get_current_user_id() );
	// Return false if we can't get user meta data for some reason.
	if ( ! $current_userdata ) {
		return false;
	}

	$date      = new \DateTime( $current_userdata->user_registered );
	$month_ago = new \DateTime( '-1 month' );

	return $date > $month_ago;
}