-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathadmin-notices-ms.php
More file actions
112 lines (67 loc) · 2.16 KB
/
admin-notices-ms.php
File metadata and controls
112 lines (67 loc) · 2.16 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
// Subpackage namespace
namespace LittleBizzy\ForceHTTPS;
/**
* Admin Notices MultiSite class
*
* @package WordPress
* @subpackage Admin Notices MultiSite
*/
final class Admin_Notices_MS {
// Configuration
// ---------------------------------------------------------------------------------------------------
/**
* Custom message
* Mark %plugin% reflects the plugin name
*/
private $message = 'For performance reasons, <strong>%plugin%</strong> does not support Multisite. For best results, always place your WordPress website on a <a href="https://www.littlebizzy.com/hosting?utm_source=multisite" target="_blank">dedicated Nginx server</a>.';
// Internal properties (do not touch from here)
// ---------------------------------------------------------------------------------------------------
/**
* Caller plugin file
*/
private $plugin_file;
/**
* Single class instance
*/
private static $instance;
// Initialization
// ---------------------------------------------------------------------------------------------------
/**
* Create or retrieve instance
*/
public static function instance($plugin_file = null) {
// Avoid direct calls
if (!function_exists('add_action'))
die;
// Single install
if (!is_multisite())
return false;
// Check instance
if (!isset(self::$instance))
self::$instance = new self($plugin_file);
// Done
return self::$instance;
}
/**
* Constructor
*/
private function __construct($plugin_file = null) {
// Main plugin file
$this->plugin_file = isset($plugin_file)? $plugin_file : __FILE__;
// Admin notices both in admin and network admin
add_action('admin_notices', [&$this, 'adminNoticesMS']);
add_action('network_admin_notices', [&$this, 'adminNoticesMS']);
}
// WP Hooks
// ---------------------------------------------------------------------------------------------------
/**
* The admin notice message
*/
public function adminNoticesMS() {
$plugin_data = get_plugin_data($this->plugin_file);
?><div class="notice notice-error">
<p><?php echo str_replace('%plugin%', $plugin_data['Name'], $this->message); ?></p>
</div><?php
}
}