-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathno-wpmu.php
89 lines (73 loc) · 2.06 KB
/
no-wpmu.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* We don't want to allow for this plugin to be used in WP-MS or network wide.
*
* @author Sean Fisher
*/
class Disable_WPMS_Plugin_LD
{
/**
* Object Constructor
*
* @return void
*/
function __construct()
{
register_activation_hook(LD_FILE_NAME, array( &$this, 'on_activate') );
}
/**
* Called when activating the plugin
*
* @access private
*/
function on_activate()
{
// Disable buggy sitewide activation in WPMU and WP 3.0
if ((is_multisite() && isset($_GET['sitewide'])) || ($this->is_network_mode() && isset($_GET['networkwide'])))
$this->network_activate_error();
// Default options
update_option('ld_http_auth', 'none');
update_option('ld_hide_wp_admin', 'no');
}
/**
* De-activate a plugin
*
* @access private
*/
public function network_activate_error()
{
// De-activate the plugin
$active_plugins = (array) get_option('active_plugins');
$active_plugins_network = (array) get_site_option('active_sitewide_plugins');
// workaround for WPMU deactivation bug
remove_action('deactivate_' . LD_FILE_NAME, 'deactivate_sitewide_plugin');
do_action('deactivate_plugin', LD_FILE_NAME);
$key = array_search(LD_FILE_NAME, $active_plugins);
if ($key !== false) {
array_splice($active_plugins, $key, 1);
}
unset($active_plugins_network[LD_FILE_NAME]);
do_action('deactivate_' . LD_FILE_NAME);
do_action('deactivated_plugin', LD_FILE_NAME);
update_option('active_plugins', $active_plugins);
update_site_option('active_sitewide_plugins', $active_plugins_network);
wp_die('The plugin cannot be activate network-wide.');
}
/**
* Returns true if it's WP with enabled Network mode
*
* @return boolean
* @author W3 Total Cache
*/
function is_network_mode()
{
static $network_mode = null;
if ($network_mode === null) {
$network_mode = (defined('MULTISITE') && MULTISITE);
}
return $network_mode;
}
}
// The object.
new Disable_WPMS_Plugin_LD;
/* End of file: no-wpmu.php */