| 1 |
<?php |
| 2 |
|
| 3 |
class Boxzilla_PHP_Fallback |
| 4 |
{ |
| 5 |
|
| 6 |
/** |
| 7 |
* @var string |
| 8 |
*/ |
| 9 |
private $plugin_name = ''; |
| 10 |
|
| 11 |
/** |
| 12 |
* @var string |
| 13 |
*/ |
| 14 |
private $plugin_file = ''; |
| 15 |
|
| 16 |
/** |
| 17 |
* @param $plugin_name |
| 18 |
* @param $plugin_file |
| 19 |
*/ |
| 20 |
public function __construct($plugin_name, $plugin_file) |
| 21 |
{ |
| 22 |
$this->plugin_name = $plugin_name; |
| 23 |
$this->plugin_file = $plugin_file; |
| 24 |
|
| 25 |
// deactivate plugin straight away |
| 26 |
add_action('admin_init', array( $this, 'deactivate_self' )); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* @return bool |
| 31 |
*/ |
| 32 |
public function deactivate_self() |
| 33 |
{ |
| 34 |
if (! current_user_can('activate_plugins')) { |
| 35 |
return false; |
| 36 |
} |
| 37 |
|
| 38 |
// deactivate self |
| 39 |
deactivate_plugins($this->plugin_file); |
| 40 |
|
| 41 |
// get rid of "Plugin activated" notice |
| 42 |
if (isset($_GET['activate'])) { |
| 43 |
unset($_GET['activate']); |
| 44 |
} |
| 45 |
|
| 46 |
// show notice to user |
| 47 |
add_action('admin_notices', array( $this, 'show_notice' )); |
| 48 |
|
| 49 |
return true; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
public function show_notice() |
| 56 |
{ |
| 57 |
?> |
| 58 |
<div class="updated"> |
| 59 |
<p><?php printf('<strong>%s</strong> did not activate because it requires <strong>PHP v5.3</strong> or higher, while your server is running <strong>PHP v%s</strong>.', $this->plugin_name, PHP_VERSION); ?> |
| 60 |
<p><?php printf('<a href="%s">Updating your PHP version</a> makes your site faster, more secure and should be easy for your host.', 'http://www.wpupdatephp.com/update/#utm_source=wp-plugin&utm_medium=boxzillas&utm_campaign=activation-notice'); ?></p> |
| 61 |
</div> |
| 62 |
<?php |
| 63 |
} |
| 64 |
} |
| 65 |
|