HEX
Server: Apache
System: Linux hp3-wp-1011494.hostingp3.local 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64
User: csh2729955 (2121743)
PHP: 7.4.33
Disabled: shell_exec,exec,system,popen,set_time_limit
Upload Files
File: /home/storage/162/3480162/user/htdocs/wp-content/plugins/leadin/public/utils/class-versions.php
<?php

namespace Leadin\utils;

/**
 * Static class containing all the utility functions related to versioning.
 */
class Versions {
	/**
	 * Return the given version until the patch version
	 * eg: 6.4.2.1-beta => 6.4.2
	 *
	 * @param String $version version.
	 */
	private static function parse_version( $version ) {
		preg_match( '/^\d+(\.\d+){0,2}/', $version, $match );
		if ( empty( $match ) ) {
			return '';
		}
		return $match[0];
	}

	/**
	 * Return the current WordPress version.
	 */
	public static function get_wp_version() {
		global $wp_version;
		return self::parse_version( $wp_version );
	}

	/**
	 * Return the current PHP version.
	 */
	public static function get_php_version() {
		return self::parse_version( phpversion() );
	}

	/**
	 * Return true if the current PHP version is not supported.
	 */
	public static function is_php_version_not_supported() {
		return version_compare( phpversion(), LEADIN_REQUIRED_PHP_VERSION, '<' );
	}

	/**
	 * Return true if the current WordPress version is not supported.
	 */
	public static function is_wp_version_not_supported() {
		global $wp_version;
		return version_compare( $wp_version, LEADIN_REQUIRED_WP_VERSION, '<' );
	}

	/**
	 * Return true if a given version is less than the supported version
	 *
	 * @param String $version Given version to check.
	 * @param String $version_to_compare The version number to test the given version against.
	 */
	public static function is_version_less_than( $version, $version_to_compare ) {
		return version_compare( $version, $version_to_compare, '<' );
	}
}