forked from ibericode/mailchimp-top-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp-backwards-compatibility.php
51 lines (40 loc) · 1.13 KB
/
php-backwards-compatibility.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// Prevent direct file access
if ( ! defined( 'ABSPATH' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
/**
* Deactivates the plugin
*
* @return bool
*/
function mailchimp_top_bar_deactivate_self() {
if( ! current_user_can( 'activate_plugins' ) ) {
return false;
}
// deactivate self
deactivate_plugins( plugin_basename( MAILCHIMP_TOP_BAR_FILE ) );
// get rid of "Plugin activated" notice
if( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
// show notice to user
add_action( 'admin_notices', 'mailchimp_top_bar_php_requirement_notice' );
return true;
}
/**
* Outputs a notice telling the user that the plugin deactivated itself
*/
function mailchimp_top_bar_php_requirement_notice() {
// load translations
load_plugin_textdomain( 'mailchimp-top-bar', false, 'mailchimp-top-bar/languages' );
?>
<div class="updated">
<p><?php _e( 'MailChimp Top Bar did not activate because it requires your server to run PHP 5.3 or higher.', 'mailchimp-top-bar' ); ?></p>
</div>
<?php
}
// Hook into `admin_init`
add_action( 'admin_init', 'mailchimp_top_bar_deactivate_self' );