tribe_get_first_ever_installed_version( string|object $class )

Gets the initially-recorded version number installed for the specified class of a plugin having a version_history_slug property or a VERSION constant (i.e. Main classes).

If user initially installed v2, downgraded to v1, then updated to v3, this will return v2. If no historical version records, fallback is the class’ current version. If no version info found, it will return false. Zero may have been logged as a past version but gets ignored.


Parameters

$class

(string|object) (Required) The plugin class' singleton name, class name, or instance.


Top ↑

Return

(string|boolean) The SemVer version string or false if no info found.


Top ↑

Source

File: src/functions/utils.php

	function tribe_get_first_ever_installed_version( $class ) {
		$instance = tribe_get_class_instance( $class );

		if ( $instance ) {
			// Try for the version history first.
			if ( ! empty( $instance->version_history_slug ) ) {
				$history = (array) Tribe__Settings_Manager::get_option( $instance->version_history_slug );

				// '0' may be logged as a version number, which isn't useful, so we remove it
				while (
					! empty( $history )
					&& empty( $history[0] )
				) {
					array_shift( $history );
				}

				// Found it so return it
				if ( ! empty( $history[0] ) ) {
					return $history[0];
				}
			}

			// Fall back to the current plugin version.
			if ( defined( get_class( $instance ) . '::VERSION' ) ) {
				return $instance::VERSION;
			}
		}

		// No version set.
		return false;
	}

Top ↑

Changelog

Changelog
Version Description
4.10.0 Introduced.