Skip to content

Commit 8aca1cf

Browse files
committed
WP_Debug_Data: Extract wp-constants data into separate method.
This is the part two in a larger modularization of the data in `WP_Debug_Data`. Previously this was a single massive method drawing in debug data from various groups of related data, where the groups were independent from each other. This patch separates the second of twelve groups, the `wp-constants` info, into a separate method focused on that data. This work precedes changes to make the `WP_Debug_Data` class more extensible for better use by plugin and theme code. Developed in #7106 Discussed in https://core.trac.wordpress.org/ticket/61648 Props: apermo, costdev, dmsnell. See #61648. git-svn-id: https://develop.svn.wordpress.org/trunk@58855 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8e7035f commit 8aca1cf

File tree

1 file changed

+152
-141
lines changed

1 file changed

+152
-141
lines changed

src/wp-admin/includes/class-wp-debug-data.php

Lines changed: 152 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -201,147 +201,6 @@ public static function debug_data() {
201201
'fields' => array(),
202202
);
203203

204-
// Check if WP_DEBUG_LOG is set.
205-
$wp_debug_log_value = __( 'Disabled' );
206-
207-
if ( is_string( WP_DEBUG_LOG ) ) {
208-
$wp_debug_log_value = WP_DEBUG_LOG;
209-
} elseif ( WP_DEBUG_LOG ) {
210-
$wp_debug_log_value = __( 'Enabled' );
211-
}
212-
213-
// Check CONCATENATE_SCRIPTS.
214-
if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
215-
$concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
216-
$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
217-
} else {
218-
$concatenate_scripts = __( 'Undefined' );
219-
$concatenate_scripts_debug = 'undefined';
220-
}
221-
222-
// Check COMPRESS_SCRIPTS.
223-
if ( defined( 'COMPRESS_SCRIPTS' ) ) {
224-
$compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
225-
$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
226-
} else {
227-
$compress_scripts = __( 'Undefined' );
228-
$compress_scripts_debug = 'undefined';
229-
}
230-
231-
// Check COMPRESS_CSS.
232-
if ( defined( 'COMPRESS_CSS' ) ) {
233-
$compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
234-
$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
235-
} else {
236-
$compress_css = __( 'Undefined' );
237-
$compress_css_debug = 'undefined';
238-
}
239-
240-
// Check WP_ENVIRONMENT_TYPE.
241-
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
242-
$wp_environment_type = WP_ENVIRONMENT_TYPE;
243-
} else {
244-
$wp_environment_type = __( 'Undefined' );
245-
}
246-
247-
$info['wp-constants'] = array(
248-
'label' => __( 'WordPress Constants' ),
249-
'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
250-
'fields' => array(
251-
'ABSPATH' => array(
252-
'label' => 'ABSPATH',
253-
'value' => ABSPATH,
254-
'private' => true,
255-
),
256-
'WP_HOME' => array(
257-
'label' => 'WP_HOME',
258-
'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
259-
'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
260-
),
261-
'WP_SITEURL' => array(
262-
'label' => 'WP_SITEURL',
263-
'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
264-
'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
265-
),
266-
'WP_CONTENT_DIR' => array(
267-
'label' => 'WP_CONTENT_DIR',
268-
'value' => WP_CONTENT_DIR,
269-
),
270-
'WP_PLUGIN_DIR' => array(
271-
'label' => 'WP_PLUGIN_DIR',
272-
'value' => WP_PLUGIN_DIR,
273-
),
274-
'WP_MEMORY_LIMIT' => array(
275-
'label' => 'WP_MEMORY_LIMIT',
276-
'value' => WP_MEMORY_LIMIT,
277-
),
278-
'WP_MAX_MEMORY_LIMIT' => array(
279-
'label' => 'WP_MAX_MEMORY_LIMIT',
280-
'value' => WP_MAX_MEMORY_LIMIT,
281-
),
282-
'WP_DEBUG' => array(
283-
'label' => 'WP_DEBUG',
284-
'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
285-
'debug' => WP_DEBUG,
286-
),
287-
'WP_DEBUG_DISPLAY' => array(
288-
'label' => 'WP_DEBUG_DISPLAY',
289-
'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
290-
'debug' => WP_DEBUG_DISPLAY,
291-
),
292-
'WP_DEBUG_LOG' => array(
293-
'label' => 'WP_DEBUG_LOG',
294-
'value' => $wp_debug_log_value,
295-
'debug' => WP_DEBUG_LOG,
296-
),
297-
'SCRIPT_DEBUG' => array(
298-
'label' => 'SCRIPT_DEBUG',
299-
'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
300-
'debug' => SCRIPT_DEBUG,
301-
),
302-
'WP_CACHE' => array(
303-
'label' => 'WP_CACHE',
304-
'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
305-
'debug' => WP_CACHE,
306-
),
307-
'CONCATENATE_SCRIPTS' => array(
308-
'label' => 'CONCATENATE_SCRIPTS',
309-
'value' => $concatenate_scripts,
310-
'debug' => $concatenate_scripts_debug,
311-
),
312-
'COMPRESS_SCRIPTS' => array(
313-
'label' => 'COMPRESS_SCRIPTS',
314-
'value' => $compress_scripts,
315-
'debug' => $compress_scripts_debug,
316-
),
317-
'COMPRESS_CSS' => array(
318-
'label' => 'COMPRESS_CSS',
319-
'value' => $compress_css,
320-
'debug' => $compress_css_debug,
321-
),
322-
'WP_ENVIRONMENT_TYPE' => array(
323-
'label' => 'WP_ENVIRONMENT_TYPE',
324-
'value' => $wp_environment_type,
325-
'debug' => $wp_environment_type,
326-
),
327-
'WP_DEVELOPMENT_MODE' => array(
328-
'label' => 'WP_DEVELOPMENT_MODE',
329-
'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
330-
'debug' => WP_DEVELOPMENT_MODE,
331-
),
332-
'DB_CHARSET' => array(
333-
'label' => 'DB_CHARSET',
334-
'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
335-
'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
336-
),
337-
'DB_COLLATE' => array(
338-
'label' => 'DB_COLLATE',
339-
'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
340-
'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
341-
),
342-
),
343-
);
344-
345204
// Conditionally add debug information for multisite setups.
346205
if ( is_multisite() ) {
347206
$site_id = get_current_blog_id();
@@ -1369,6 +1228,7 @@ public static function debug_data() {
13691228
);
13701229
}
13711230

1231+
$info['wp-constants'] = self::get_wp_constants();
13721232
$info['wp-filesystem'] = self::get_wp_filesystem();
13731233

13741234
/**
@@ -1436,6 +1296,157 @@ public static function debug_data() {
14361296
return $info;
14371297
}
14381298

1299+
/**
1300+
* Gets the WordPress constants section of the debug data.
1301+
*
1302+
* @since 6.7.0
1303+
*
1304+
* @return array
1305+
*/
1306+
public static function get_wp_constants(): array {
1307+
// Check if WP_DEBUG_LOG is set.
1308+
$wp_debug_log_value = __( 'Disabled' );
1309+
if ( is_string( WP_DEBUG_LOG ) ) {
1310+
$wp_debug_log_value = WP_DEBUG_LOG;
1311+
} elseif ( WP_DEBUG_LOG ) {
1312+
$wp_debug_log_value = __( 'Enabled' );
1313+
}
1314+
1315+
// Check CONCATENATE_SCRIPTS.
1316+
if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
1317+
$concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
1318+
$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
1319+
} else {
1320+
$concatenate_scripts = __( 'Undefined' );
1321+
$concatenate_scripts_debug = 'undefined';
1322+
}
1323+
1324+
// Check COMPRESS_SCRIPTS.
1325+
if ( defined( 'COMPRESS_SCRIPTS' ) ) {
1326+
$compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
1327+
$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
1328+
} else {
1329+
$compress_scripts = __( 'Undefined' );
1330+
$compress_scripts_debug = 'undefined';
1331+
}
1332+
1333+
// Check COMPRESS_CSS.
1334+
if ( defined( 'COMPRESS_CSS' ) ) {
1335+
$compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
1336+
$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
1337+
} else {
1338+
$compress_css = __( 'Undefined' );
1339+
$compress_css_debug = 'undefined';
1340+
}
1341+
1342+
// Check WP_ENVIRONMENT_TYPE.
1343+
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
1344+
$wp_environment_type = WP_ENVIRONMENT_TYPE;
1345+
} else {
1346+
$wp_environment_type = __( 'Undefined' );
1347+
}
1348+
1349+
$fields = array(
1350+
'ABSPATH' => array(
1351+
'label' => 'ABSPATH',
1352+
'value' => ABSPATH,
1353+
'private' => true,
1354+
),
1355+
'WP_HOME' => array(
1356+
'label' => 'WP_HOME',
1357+
'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
1358+
'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
1359+
),
1360+
'WP_SITEURL' => array(
1361+
'label' => 'WP_SITEURL',
1362+
'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
1363+
'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
1364+
),
1365+
'WP_CONTENT_DIR' => array(
1366+
'label' => 'WP_CONTENT_DIR',
1367+
'value' => WP_CONTENT_DIR,
1368+
),
1369+
'WP_PLUGIN_DIR' => array(
1370+
'label' => 'WP_PLUGIN_DIR',
1371+
'value' => WP_PLUGIN_DIR,
1372+
),
1373+
'WP_MEMORY_LIMIT' => array(
1374+
'label' => 'WP_MEMORY_LIMIT',
1375+
'value' => WP_MEMORY_LIMIT,
1376+
),
1377+
'WP_MAX_MEMORY_LIMIT' => array(
1378+
'label' => 'WP_MAX_MEMORY_LIMIT',
1379+
'value' => WP_MAX_MEMORY_LIMIT,
1380+
),
1381+
'WP_DEBUG' => array(
1382+
'label' => 'WP_DEBUG',
1383+
'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
1384+
'debug' => WP_DEBUG,
1385+
),
1386+
'WP_DEBUG_DISPLAY' => array(
1387+
'label' => 'WP_DEBUG_DISPLAY',
1388+
'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
1389+
'debug' => WP_DEBUG_DISPLAY,
1390+
),
1391+
'WP_DEBUG_LOG' => array(
1392+
'label' => 'WP_DEBUG_LOG',
1393+
'value' => $wp_debug_log_value,
1394+
'debug' => WP_DEBUG_LOG,
1395+
),
1396+
'SCRIPT_DEBUG' => array(
1397+
'label' => 'SCRIPT_DEBUG',
1398+
'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
1399+
'debug' => SCRIPT_DEBUG,
1400+
),
1401+
'WP_CACHE' => array(
1402+
'label' => 'WP_CACHE',
1403+
'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
1404+
'debug' => WP_CACHE,
1405+
),
1406+
'CONCATENATE_SCRIPTS' => array(
1407+
'label' => 'CONCATENATE_SCRIPTS',
1408+
'value' => $concatenate_scripts,
1409+
'debug' => $concatenate_scripts_debug,
1410+
),
1411+
'COMPRESS_SCRIPTS' => array(
1412+
'label' => 'COMPRESS_SCRIPTS',
1413+
'value' => $compress_scripts,
1414+
'debug' => $compress_scripts_debug,
1415+
),
1416+
'COMPRESS_CSS' => array(
1417+
'label' => 'COMPRESS_CSS',
1418+
'value' => $compress_css,
1419+
'debug' => $compress_css_debug,
1420+
),
1421+
'WP_ENVIRONMENT_TYPE' => array(
1422+
'label' => 'WP_ENVIRONMENT_TYPE',
1423+
'value' => $wp_environment_type,
1424+
'debug' => $wp_environment_type,
1425+
),
1426+
'WP_DEVELOPMENT_MODE' => array(
1427+
'label' => 'WP_DEVELOPMENT_MODE',
1428+
'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
1429+
'debug' => WP_DEVELOPMENT_MODE,
1430+
),
1431+
'DB_CHARSET' => array(
1432+
'label' => 'DB_CHARSET',
1433+
'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
1434+
'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
1435+
),
1436+
'DB_COLLATE' => array(
1437+
'label' => 'DB_COLLATE',
1438+
'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
1439+
'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
1440+
),
1441+
);
1442+
1443+
return array(
1444+
'label' => __( 'WordPress Constants' ),
1445+
'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
1446+
'fields' => $fields,
1447+
);
1448+
}
1449+
14391450
/**
14401451
* Gets the file system section of the debug data.
14411452
*

0 commit comments

Comments
 (0)