tribe_get_greatest_version_ever_installed( string|object $class )

Gets the highest 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, updated to v3, then downgraded to v2, this will return v3. 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.

See also #


Top ↑

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_greatest_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_pop( $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.