| 1 |
<?php |
| 2 |
|
| 3 |
class Boxzilla_PHP_Fallback { |
| 4 |
|
| 5 |
/** |
| 6 |
* @var string |
| 7 |
*/ |
| 8 |
private $plugin_name = ''; |
| 9 |
|
| 10 |
/** |
| 11 |
* @var string |
| 12 |
*/ |
| 13 |
private $plugin_file = ''; |
| 14 |
|
| 15 |
/** |
| 16 |
* @param $plugin_name |
| 17 |
* @param $plugin_file |
| 18 |
*/ |
| 19 |
public function __construct( $plugin_name, $plugin_file ) { |
| 20 |
|
| 21 |
$this->plugin_name = $plugin_name; |
| 22 |
$this->plugin_file = $plugin_file; |
| 23 |
|
| 24 |
// deactivate plugin straight away |
| 25 |
add_action( 'admin_init', array( $this, 'deactivate_self' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* @return bool |
| 30 |
*/ |
| 31 |
public function deactivate_self() { |
| 32 |
if( ! current_user_can( 'activate_plugins' ) ) { |
| 33 |
return false; |
| 34 |
} |
| 35 |
|
| 36 |
// deactivate self |
| 37 |
deactivate_plugins( $this->plugin_file ); |
| 38 |
|
| 39 |
// get rid of "Plugin activated" notice |
| 40 |
if( isset( $_GET['activate'] ) ) { |
| 41 |
unset( $_GET['activate'] ); |
| 42 |
} |
| 43 |
|
| 44 |
// show notice to user |
| 45 |
add_action( 'admin_notices', array( $this, 'show_notice' ) ); |
| 46 |
|
| 47 |
return true; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* @return void |
| 52 |
*/ |
| 53 |
public function show_notice() { |
| 54 |
?> |
| 55 |
<div class="updated"> |
| 56 |
<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 ); ?> |
| 57 |
<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> |
| 58 |
</div> |
| 59 |
<?php |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
|