| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Utility functions for determining if a PHP version is supported or not |
| 5 |
* |
| 6 |
* @package Caldera_Forms Modified by QuantumCloud |
| 7 |
* @author Josh Pollock <Josh@CalderaWP.com> |
| 8 |
* @license GPL-2.0+ |
| 9 |
* @link |
| 10 |
* @copyright 2018 CalderaWP LLC |
| 11 |
*/ |
| 12 |
class Qcformbuilder_Forms_Admin_PHP{ |
| 13 |
|
| 14 |
/** |
| 15 |
* Minimum supported version of Qcformbuilder Forms |
| 16 |
* |
| 17 |
* When this changed, update Test_PHP_Version_Check::test_not_supported() |
| 18 |
* |
| 19 |
* @since 1.6.0 |
| 20 |
* |
| 21 |
* @var string |
| 22 |
*/ |
| 23 |
private static $min_supported_version = '5.2.4'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Minimum version of Qcformbuilder Forms that is tested |
| 27 |
* |
| 28 |
* When this changed, update Test_PHP_Version_Check::test_not_tested() |
| 29 |
* |
| 30 |
* @since 1.6.0 |
| 31 |
* |
| 32 |
* @var string |
| 33 |
*/ |
| 34 |
private static $min_tested_version = '5.6'; |
| 35 |
|
| 36 |
/** |
| 37 |
* Is a version of PHP supported by Qcformbuilder Forms? |
| 38 |
* |
| 39 |
* @since 1.6.0 |
| 40 |
* |
| 41 |
* @param string|null $version Optional. PHP version to test. Default is current version of PHP. |
| 42 |
* |
| 43 |
* @return bool |
| 44 |
*/ |
| 45 |
public static function is_version_supported( $version = null ){ |
| 46 |
return self::greater_than( self::$min_supported_version, $version ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Is a version of PHP tested with Qcformbuilder Forms? |
| 51 |
* |
| 52 |
* @since 1.6.0 |
| 53 |
* |
| 54 |
* @param string|null $version Optional. PHP version to test. Default is current version of PHP. |
| 55 |
* |
| 56 |
* @return bool |
| 57 |
*/ |
| 58 |
public static function is_version_tested( $version = null ){ |
| 59 |
return self::greater_than( self::$min_tested_version, $version ); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Is a version of PHP's supported deprecated by Qcformbuilder Forms? |
| 64 |
* |
| 65 |
* @since 1.6.0 |
| 66 |
* |
| 67 |
* @param string|null $version Optional. PHP version to test. Default is current version of PHP. |
| 68 |
* |
| 69 |
* @return bool |
| 70 |
*/ |
| 71 |
public static function is_version_deprecated( $version = null ){ |
| 72 |
//This may, in the future, need it's own comparison. |
| 73 |
return ! self::is_version_tested( $version ); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Check if a PHP version is greater than minimum version |
| 78 |
* |
| 79 |
* @since 1.6.0 |
| 80 |
* |
| 81 |
* @param string $min_version Minimum version to allow. |
| 82 |
* @param string|null $compare_version Optional. PHP version to test. Default is current version of PHP. |
| 83 |
* |
| 84 |
* @return bool |
| 85 |
*/ |
| 86 |
public static function greater_than( $min_version, $compare_version = null ){ |
| 87 |
$compare_version = !is_null($compare_version) ? $compare_version : PHP_VERSION; |
| 88 |
return version_compare($compare_version, $min_version ) >= 0; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Get the minimum supported version |
| 93 |
* |
| 94 |
* @since 1.6.0 |
| 95 |
* |
| 96 |
* @return string |
| 97 |
*/ |
| 98 |
public static function get_minimum_supported_version(){ |
| 99 |
return self::$min_supported_version; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Get the minimum tested version |
| 104 |
* |
| 105 |
* @since 1.6.0 |
| 106 |
* |
| 107 |
* @return string |
| 108 |
*/ |
| 109 |
public static function get_minimum_tested_version(){ |
| 110 |
return self::$min_tested_version; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Get the deprecation notice |
| 115 |
* |
| 116 |
* @since 1.6.0 |
| 117 |
* |
| 118 |
* @return string Output is escaped |
| 119 |
*/ |
| 120 |
public static function get_deprecated_notice(){ |
| 121 |
return sprintf('%s %s', |
| 122 |
esc_html__( sprintf('You are using a VERY out of date version of PHP: %s. Qcformbuilder Forms 1.7 will require PHP Version %s or later.', |
| 123 |
PHP_VERSION, self::get_minimum_tested_version() |
| 124 |
), 'qcformbuilder-forms'), |
| 125 |
sprintf('<a style="color:#fff;" href="https://quantumcloud.com/php?utm_source=wp-admin&utm_campaign=php_deprecated" target="__blank">%s</a>', |
| 126 |
esc_html__('Learn More', 'qcformbuilder-forms' ) |
| 127 |
) |
| 128 |
); |
| 129 |
|
| 130 |
} |
| 131 |
|
| 132 |
} |
| 133 |
|