SystemStatus.php
10.5 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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<?php
namespace AIOSEO\Plugin\Common\Tools;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class SystemStatus {
/**
* Get an aggregated list of all system info.
*
* @since 4.0.0
*
* @return array An array of system information.
*/
public static function getSystemStatusInfo() {
return [
'wordPress' => self::getWordPressInfo(),
'constants' => self::getConstants(),
'serverInfo' => self::getServerInfo(),
'muPlugins' => self::mustUsePlugins(),
'activeTheme' => self::activeTheme(),
'activePlugins' => self::activePlugins(),
'inactivePlugins' => self::inactivePlugins()
];
}
/**
* Get an array of system info from WordPress.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function getWordPressInfo() {
$uploadsDir = wp_upload_dir();
$version = get_bloginfo( 'version' );
$updates = get_site_transient( 'update_core' );
$updateVersion = ! empty( $updates->updates[0]->version ) ? $updates->updates[0]->version : null;
if ( version_compare( $version, $updateVersion, '<' ) ) {
$version .= ' (' . __( 'Latest version:', 'all-in-one-seo-pack' ) . ' ' . $updateVersion . ')';
}
return [
'label' => 'WordPress',
'results' => [
[
'header' => __( 'Version', 'all-in-one-seo-pack' ),
'value' => $version
],
[
'header' => __( 'Site Title', 'all-in-one-seo-pack' ),
'value' => get_bloginfo( 'name' )
],
[
'header' => __( 'Site Language', 'all-in-one-seo-pack' ),
'value' => defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US'
],
[
'header' => __( 'User Language', 'all-in-one-seo-pack' ),
'value' => get_user_locale( get_current_user_id() )
],
[
'header' => __( 'Timezone', 'all-in-one-seo-pack' ),
'value' => aioseo()->helpers->getTimeZoneOffset()
],
[
'header' => __( 'Home URL', 'all-in-one-seo-pack' ),
'value' => home_url()
],
[
'header' => __( 'Site URL', 'all-in-one-seo-pack' ),
'value' => site_url()
],
[
'header' => __( 'Permalink Structure', 'all-in-one-seo-pack' ),
'value' => get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : __( 'Default', 'all-in-one-seo-pack' )
],
[
'header' => __( 'Multisite', 'all-in-one-seo-pack' ),
'value' => is_multisite() ? __( 'Yes', 'all-in-one-seo-pack' ) : __( 'No', 'all-in-one-seo-pack' )
],
[
'header' => 'HTTPS',
'value' => is_ssl() ? __( 'Yes', 'all-in-one-seo-pack' ) : __( 'No', 'all-in-one-seo-pack' )
],
[
'header' => __( 'User Count', 'all-in-one-seo-pack' ),
'value' => count_users()['total_users']
],
[
'header' => __( 'Front Page Info', 'all-in-one-seo-pack' ),
'value' => 'page' === get_option( 'show_on_front' ) ? get_option( 'show_on_front' ) . ' [ID: ' . get_option( 'page_on_front' ) . ']' : get_option( 'show_on_front' )
],
[
'header' => __( 'Search Engine Visibility', 'all-in-one-seo-pack' ),
'value' => get_option( 'blog_public' ) ? __( 'Visible', 'all-in-one-seo-pack' ) : __( 'Hidden', 'all-in-one-seo-pack' )
],
[
'header' => __( 'Upload Directory Info', 'all-in-one-seo-pack' ),
'value' =>
__( 'Path:', 'all-in-one-seo-pack' ) . ' ' . $uploadsDir['path'] . ', ' .
__( 'Url:', 'all-in-one-seo-pack' ) . ' ' . $uploadsDir['url'] . ', ' .
__( 'Base Directory:', 'all-in-one-seo-pack' ) . ' ' . $uploadsDir['basedir'] . ', ' .
__( 'Base URL:', 'all-in-one-seo-pack' ) . ' ' . $uploadsDir['baseurl']
]
]
];
}
/**
* Get an array of system info from WordPress constants.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function getConstants() {
return [
'label' => __( 'Constants', 'all-in-one-seo-pack' ),
'results' => [
[
'header' => 'ABSPATH',
'value' => ABSPATH
],
[
'header' => 'WP_CONTENT_DIR',
'value' => defined( 'WP_CONTENT_DIR' ) ? ( WP_CONTENT_DIR ? WP_CONTENT_DIR : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'WP_CONTENT_URL',
'value' => defined( 'WP_CONTENT_URL' ) ? ( WP_CONTENT_URL ? WP_CONTENT_URL : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'UPLOADS',
'value' => defined( 'UPLOADS' ) ? ( UPLOADS ? UPLOADS : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'WP_DEBUG',
'value' => defined( 'WP_DEBUG' ) ? ( WP_DEBUG ? WP_DEBUG : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'WP_DEBUG_LOG',
'value' => defined( 'WP_DEBUG_LOG' ) ? ( WP_DEBUG_LOG ? WP_DEBUG_LOG : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'WP_DEBUG_DISPLAY',
'value' => defined( 'WP_DEBUG_DISPLAY' ) ? ( WP_DEBUG_DISPLAY ? WP_DEBUG_DISPLAY : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
],
[
'header' => 'WPS_DEBUG',
'value' => defined( 'WPS_DEBUG' ) ? ( WPS_DEBUG ? WPS_DEBUG : __( 'Disabled', 'all-in-one-seo-pack' ) ) : __( 'Not set', 'all-in-one-seo-pack' )
]
]
];
}
/**
* Get an array of system info from the server.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function getServerInfo() {
$sqlMode = null;
$mysqlInfo = aioseo()->db->db->get_results( "SHOW VARIABLES LIKE 'sql_mode'" );
if ( is_array( $mysqlInfo ) ) {
$sqlMode = $mysqlInfo[0]->Value;
}
return [
'label' => __( 'Server Info', 'all-in-one-seo-pack' ),
'results' => [
[
'header' => __( 'Operating System', 'all-in-one-seo-pack' ),
'value' => PHP_OS
],
[
'header' => __( 'Web Server', 'all-in-one-seo-pack' ),
'value' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : __( 'unknown', 'all-in-one-seo-pack' )
],
[
'header' => __( 'Memory Usage', 'all-in-one-seo-pack' ),
'value' => function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) . 'M' : __( 'N/A', 'all-in-one-seo-pack' )
],
[
'header' => __( 'MySQL Version', 'all-in-one-seo-pack' ),
'value' => aioseo()->db->db->db_version()
],
[
'header' => __( 'MySQL SQL Mode', 'all-in-one-seo-pack' ),
'value' => empty( $sqlMode ) ? __( 'Not Set', 'all-in-one-seo-pack' ) : $sqlMode
],
[
'header' => __( 'PHP Version', 'all-in-one-seo-pack' ),
'value' => PHP_VERSION
],
[
'header' => __( 'PHP Memory Limit', 'all-in-one-seo-pack' ),
'value' => ini_get( 'memory_limit' )
],
[
'header' => __( 'PHP Max Upload Size', 'all-in-one-seo-pack' ),
'value' => ini_get( 'upload_max_filesize' )
],
[
'header' => __( 'PHP Max Post Size', 'all-in-one-seo-pack' ),
'value' => ini_get( 'post_max_size' )
],
[
'header' => __( 'PHP Max Script Execution Time', 'all-in-one-seo-pack' ),
'value' => ini_get( 'max_execution_time' )
],
[
'header' => __( 'PHP Exif Support', 'all-in-one-seo-pack' ),
'value' => is_callable( 'exif_read_data' ) ? __( 'Yes', 'all-in-one-seo-pack' ) : __( 'No', 'all-in-one-seo-pack' )
],
[
'header' => __( 'PHP IPTC Support', 'all-in-one-seo-pack' ),
'value' => is_callable( 'iptcparse' ) ? __( 'Yes', 'all-in-one-seo-pack' ) : __( 'No', 'all-in-one-seo-pack' )
],
[
'header' => __( 'PHP XML Support', 'all-in-one-seo-pack' ),
'value' => is_callable( 'xml_parser_create' ) ? __( 'Yes', 'all-in-one-seo-pack' ) : __( 'No', 'all-in-one-seo-pack' )
]
]
];
}
/**
* Get an array of system info from the active theme.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function activeTheme() {
$themeData = wp_get_theme();
return [
'label' => __( 'Active Theme', 'all-in-one-seo-pack' ),
'results' => [
[
'header' => $themeData->name,
'value' => $themeData->Version
]
]
];
}
/**
* Get an array of system info from must-use plugins.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function mustUsePlugins() {
$plugins = [];
$muPlugins = get_mu_plugins();
if ( ! empty( $muPlugins ) ) {
foreach ( $muPlugins as $pluginData ) {
$plugins[] = [
'header' => $pluginData['Name'],
'value' => $pluginData['Version']
];
}
}
return [
'label' => __( 'Must-Use Plugins', 'all-in-one-seo-pack' ),
'results' => $plugins
];
}
/**
* Get an array of system info from active plugins.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function activePlugins() {
$plugins = [];
$allPlugins = get_plugins();
$activePlugins = get_option( 'active_plugins', [] );
$updates = get_plugin_updates();
if ( ! empty( $allPlugins ) ) {
foreach ( $allPlugins as $pluginPath => $pluginData ) {
if ( ! in_array( $pluginPath, $activePlugins, true ) ) {
continue;
}
$update = ( array_key_exists( $pluginPath, $updates ) ) ? ' (' . __( 'needs update', 'all-in-one-seo-pack' ) . ' - ' . $updates[ $pluginPath ]->update->new_version . ')' : '';
$plugins[] = [
'header' => $pluginData['Name'],
'value' => $pluginData['Version'] . $update
];
}
}
return [
'label' => __( 'Active Plugins', 'all-in-one-seo-pack' ),
'results' => $plugins
];
}
/**
* Get an array of system info from inactive plugins.
*
* @since 4.0.0
*
* @return array An array of system info.
*/
public static function inactivePlugins() {
$plugins = [];
$allPlugins = get_plugins();
$activePlugins = get_option( 'active_plugins', [] );
$updates = get_plugin_updates();
if ( ! empty( $allPlugins ) ) {
foreach ( $allPlugins as $pluginPath => $pluginData ) {
if ( in_array( $pluginPath, $activePlugins, true ) ) {
continue;
}
$update = ( array_key_exists( $pluginPath, $updates ) ) ? ' (' . __( 'needs update', 'all-in-one-seo-pack' ) . ' - ' . $updates[ $pluginPath ]->update->new_version . ')' : '';
$plugins[] = [
'header' => $pluginData['Name'],
'value' => $pluginData['Version'] . $update
];
}
}
return [
'label' => __( 'Inactive Plugins', 'all-in-one-seo-pack' ),
'results' => $plugins
];
}
}