-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdashboard-summary.php
210 lines (189 loc) · 5.11 KB
/
dashboard-summary.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/**
* Dashboard Summary
*
* Improves the At a Glance dashboard widget and offers a replacement
* widget with more detailed website and network information.
*
* Compatible with multisite installations and with ClassicPress.
*
* @package Dashboard_Summary
* @version 1.0.0
* @link https://github.com/ControlledChaos/dashboard-summary
*
* Plugin Name: Dashboard Summary
* Plugin URI: https://github.com/ControlledChaos/dashboard-summary
* Description: Improves the At a Glance dashboard widget and offers a replacement widget with more detailed website and network information. Compatible with multisite installations and with ClassicPress.
* Version: 1.0.0
* Author: Controlled Chaos Design
* Author URI: http://ccdzine.com/
* Text Domain: dashboard-summary
* Domain Path: /languages
* Requires PHP: 5.4
* Requires at least: 3.8
* Tested up to: 6.2.2
*/
namespace Dashboard_Summary;
// Restrict direct access.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
/**
* License & Warranty
*
* Dashboard Summary is free software.
* It can be redistributed and/or modified ad libidum.
*
* Dashboard Summary is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Constant: Plugin basename
*
* @since 1.0.0
* @var string The basename of this plugin file.
*/
define( 'DS_BASENAME', plugin_basename( __FILE__ ) );
/**
* Load text domain
*
* @since 1.0.0
* @return void
*/
function load_plugin_textdomain() {
// Load plugin text domain.
\load_plugin_textdomain(
'dashboard-summary',
false,
dirname( DS_BASENAME ) . '/languages'
);
// If this is in the must-use plugins directory.
\load_muplugin_textdomain(
'dashboard-summary',
dirname( DS_BASENAME ) . '/languages'
);
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\load_plugin_textdomain' );
/**
* Settings link
*
* Add settings link to plugin row on the Plugins pages
* in site and network admin.
*
* @param array $links Default plugin links on the Plugins admin page.
* @since 1.0.0
* @return string Returns the new set of plugin links.
*/
function settings_link( $links, $settings = [] ) {
// Stop if not in the admin.
if ( ! is_admin() ) {
return;
}
// Markup of the network admin link.
if ( is_multisite() && is_network_admin() ) {
$settings = [
sprintf(
'<a href="%s">%s</a>',
esc_url( network_admin_url( 'settings.php#network-summary-description' ) ),
esc_html__( 'Settings', 'dashboard-summary' )
)
];
// Markup of the site admin link.
} else {
$settings = [
sprintf(
'<a href="%s">%s</a>',
esc_url( admin_url( 'options-general.php#website-summary-description' ) ),
esc_html__( 'Settings', 'dashboard-summary' )
)
];
}
// Merge the new link with existing links.
return array_merge( $settings, $links );
}
add_action( 'plugins_loaded', function() {
add_filter( 'plugin_action_links_' . DS_BASENAME, __NAMESPACE__ . '\settings_link' );
add_filter( 'network_admin_plugin_action_links_' . DS_BASENAME, __NAMESPACE__ . '\settings_link' );
} );
// Get plugin configuration file.
require plugin_dir_path( __FILE__ ) . 'config.php';
/**
* Activation & deactivation
*
* The activation & deactivation methods run here before the check
* for PHP version which otherwise disables the functionality of
* the plugin.
*/
// Get the plugin activation class.
include_once DS_PATH . 'includes/activate/activate.php';
// Get the plugin deactivation class.
include_once DS_PATH . 'includes/activate/deactivate.php';
/**
* Register the activation & deactivation hooks
*
* The namespace of this file must remain escaped by use of the
* backslash (`\`) prepending the activation hooks and corresponding
* functions.
*
* @since 1.0.0
* @access public
* @return void
*/
\register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_plugin' );
\register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_plugin' );
/**
* Activation callback
*
* The function that runs during plugin activation.
*
* @since 1.0.0
* @access public
* @return void
*/
function activate_plugin() {
Activate\get_row_notice();
Activate\update_user_dashboard();
}
/**
* Deactivation callback
*
* The function that runs during plugin deactivation.
*
* @since 1.0.0
* @access public
* @return void
*/
function deactivate_plugin() {
Deactivate\update_user_dashboard();
}
/**
* Disable plugin for PHP version
*
* Stop here if the minimum PHP version in the config
* file is not met. Prevents breaking sites running
* older PHP versions.
*
* A notice is added to the plugin row on the Plugins
* screen as a more elegant and more informative way
* of disabling the plugin than putting the PHP minimum
* in the plugin header, which activates a die() message.
* However, the Requires PHP tag is included in the
* plugin header with a minimum of version 5.4
* because of the namespaces.
*
* @since 1.0.0
* @return void
*/
if ( ! min_php_version() ) {
return;
}
/**
* Plugin initialization
*
* Get the plugin initialization file if
* the PHP minimum is met.
*
* @since 1.0.0
*/
require_once DS_PATH . 'init.php';