| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handle checking requirements. |
| 4 |
* |
| 5 |
* @package Depicter |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if ( ! function_exists( 'depicter_requirements_satisfied' ) ) { |
| 13 |
|
| 14 |
/** |
| 15 |
* Whether required php version is available or not. |
| 16 |
* |
| 17 |
* @param string $name Project name. |
| 18 |
* @param string $min Minimum PHP version. |
| 19 |
* |
| 20 |
* @return bool |
| 21 |
*/ |
| 22 |
function depicter_requirements_satisfied( $name, $min ) { |
| 23 |
|
| 24 |
if ( version_compare( PHP_VERSION, $min, '>=' ) ) { |
| 25 |
return true; |
| 26 |
} |
| 27 |
|
| 28 |
add_action( |
| 29 |
'admin_notices', |
| 30 |
function () use ( $name, $min ) { |
| 31 |
$message = __( '%1$s plugin requires PHP version %2$s but current version is %3$s. Please contact your host provider and ask them to upgrade PHP version.', 'depicter' ); |
| 32 |
?> |
| 33 |
<div class="notice notice-error"> |
| 34 |
<p><?php echo wp_kses( sprintf( |
| 35 |
$message, |
| 36 |
'<strong>' . $name . '</strong>', |
| 37 |
'<strong>' . $min . '</strong>', |
| 38 |
'<strong>' . PHP_VERSION . '</strong>' |
| 39 |
), ['strong' => [] ] ); ?></p> |
| 40 |
</div> |
| 41 |
<?php |
| 42 |
} |
| 43 |
); |
| 44 |
|
| 45 |
// An incompatible version is already loaded. |
| 46 |
return false; |
| 47 |
} |
| 48 |
} |
| 49 |
|