| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Legacy TaxoPress file: keep behavior unchanged while documenting existing PHPCS exceptions. |
| 4 |
|
| 5 |
class SimpleTags_Compatibility |
| 6 |
{ |
| 7 |
/** |
| 8 |
* admin_init hook callback |
| 9 |
* |
| 10 |
* @since 0.1 |
| 11 |
*/ |
| 12 |
public static function admin_init() |
| 13 |
{ |
| 14 |
// Not on ajax |
| 15 |
if (defined('DOING_AJAX') && DOING_AJAX) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
// Check activation |
| 20 |
if (! current_user_can('activate_plugins')) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
trigger_error(sprintf(esc_html__('TaxoPress requires PHP version %s or greater to be activated.'), esc_html(STAGS_MIN_PHP_VERSION))); |
| 25 |
|
| 26 |
// Deactive self |
| 27 |
deactivate_plugins(plugin_basename(STAGS_DIR . '/simple-tags.php')); |
| 28 |
|
| 29 |
unset($_GET['activate']); |
| 30 |
|
| 31 |
add_action('admin_notices', array( __CLASS__, 'admin_notices' )); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Notify the user about the incompatibility issue. |
| 36 |
*/ |
| 37 |
public static function admin_notices() |
| 38 |
{ |
| 39 |
echo '<div class="notice error is-dismissible taxopress-notice">'; |
| 40 |
$data = get_plugin_data(TAXOPRESS_FILE); |
| 41 |
|
| 42 |
echo '<p><strong>' . esc_html__('Warning:', 'simple-tags') . '</strong> ' |
| 43 |
. sprintf( |
| 44 |
esc_html__('The active plugin %s is not compatible with your PHP version.', 'simple-tags') . '</p><p>', |
| 45 |
'«' . esc_html($data['Name']) . ' ' . esc_html($data['Version']) . '»' |
| 46 |
) |
| 47 |
. sprintf(esc_html__('%s is the minimum version required for this plugin.', 'simple-tags'), 'PHP 7.2.5 ') |
| 48 |
. '</p>'; |
| 49 |
|
| 50 |
echo '</div>'; |
| 51 |
} |
| 52 |
} |
| 53 |
|