Automattic\WooCommerce\Internal\Admin

LegacyReportsMenu::is_new_store │ private │ WC 1.0

Whether the store was first installed on the version that hides the menu, or later.

Until admin_init records the initial version on a fresh install, the current version is used. A missing or malformed initial version (e.g. stores installed before 9.2.0) counts as an existing store.

Method of the class: LegacyReportsMenu{}

No Hooks.

Returns

bool.

Usage

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

LegacyReportsMenu::is_new_store() code WC 11.3.0

private function is_new_store(): bool {
	$initial_version = get_option( WC_Install::INITIAL_INSTALLED_VERSION );

	if ( false === $initial_version && 'yes' === get_option( WC_Install::NEWLY_INSTALLED_OPTION ) ) {
		$initial_version = WC()->version;
	}

	if ( ! is_string( $initial_version ) || ! preg_match( '/^\d+\.\d+\.\d+(-(dev|alpha|beta|rc)(\.?\d+)?)?$/i', $initial_version ) ) {
		return false;
	}

	return version_compare( $initial_version, self::NEW_STORE_VERSION, '>=' );
}