tribe_get_least_version_ever_installed( string|object $class )

Gets the lowest version number ever 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 v1. 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_least_version_ever_installed( $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
				$history = array_filter( $history );
				$history = array_unique( $history );

				if ( ! empty( $history ) ) {
					// Sort the array so smallest version number is first (likely how the array is stored anyway)
					usort( $history, 'version_compare' );

					return array_shift( $history );
				}
			}

			// 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.