PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.75
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.75
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / utils / class-versions.php

class-versions.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.75, at public/utils/class-versions.php

63 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadin\utils;
4
5 /**
6 * Static class containing all the utility functions related to versioning.
7 */
8 class Versions {
9 /**
10 * Return the given version until the patch version
11 * eg: 6.4.2.1-beta => 6.4.2
12 *
13 * @param String $version version.
14 */
15 private static function parse_version( $version ) {
16 preg_match( '/^\d+(\.\d+){0,2}/', $version, $match );
17 if ( empty( $match ) ) {
18 return '';
19 }
20 return $match[0];
21 }
22
23 /**
24 * Return the current WordPress version.
25 */
26 public static function get_wp_version() {
27 global $wp_version;
28 return self::parse_version( $wp_version );
29 }
30
31 /**
32 * Return the current PHP version.
33 */
34 public static function get_php_version() {
35 return self::parse_version( phpversion() );
36 }
37
38 /**
39 * Return true if the current PHP version is not supported.
40 */
41 public static function is_php_version_not_supported() {
42 return version_compare( phpversion(), LEADIN_REQUIRED_PHP_VERSION, '<' );
43 }
44
45 /**
46 * Return true if the current WordPress version is not supported.
47 */
48 public static function is_wp_version_not_supported() {
49 global $wp_version;
50 return version_compare( $wp_version, LEADIN_REQUIRED_WP_VERSION, '<' );
51 }
52
53 /**
54 * Return true if a given version is less than the supported version
55 *
56 * @param String $version Given version to check.
57 * @param String $version_to_compare The version number to test the given version against.
58 */
59 public static function is_version_less_than( $version, $version_to_compare ) {
60 return version_compare( $version, $version_to_compare, '<' );
61 }
62 }
63