Ticket #46726: 46726.1.diff
File 46726.1.diff, 52.3 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/class-wp-debug-data.php
30 30 * @param string $locale Optional. An ISO formatted language code to provide debug translations in. Default null. 31 31 * @return array The debug data for the site. 32 32 */ 33 static function debug_data( $locale = null) {33 static function debug_data() { 34 34 global $wpdb; 35 if ( ! empty( $locale ) ) {36 // Change the language used for translations37 $original_locale = get_user_locale();38 $switched_locale = switch_to_locale( $locale );39 }40 35 41 $upload_dir = wp_get_upload_dir(); 42 $core_current_version = get_bloginfo( 'version' ); 43 $core_updates = get_core_updates(); 44 $core_update_needed = ''; 36 // Save few function calls. 37 $locale = get_user_locale(); 38 $upload_dir = wp_get_upload_dir(); 39 $permalink_structure = get_option( 'permalink_structure' ); 40 $is_ssl = is_ssl(); 41 $users_can_register = get_option( 'users_can_register' ); 42 $is_multisite = is_multisite(); 45 43 44 $core_version = get_bloginfo( 'version' ); 45 $core_updates = get_core_updates(); 46 $core_update_needed = ''; 47 46 48 foreach ( $core_updates as $core => $update ) { 47 49 if ( 'upgrade' === $update->response ) { 48 50 // translators: %s: Latest WordPress version number. … … 53 55 } 54 56 55 57 // Set up the array that holds all debug information. 56 $info = array( 57 'wp-core' => array( 58 'label' => __( 'WordPress' ), 59 'fields' => array( 60 'version' => array( 61 'label' => __( 'Version' ), 62 'value' => $core_current_version . $core_update_needed, 63 ), 64 'language' => array( 65 'label' => __( 'Language' ), 66 'value' => ( ! empty( $locale ) ? $original_locale : get_user_locale() ), 67 ), 68 'home_url' => array( 69 'label' => __( 'Home URL' ), 70 'value' => get_bloginfo( 'url' ), 71 'private' => true, 72 ), 73 'site_url' => array( 74 'label' => __( 'Site URL' ), 75 'value' => get_bloginfo( 'wpurl' ), 76 'private' => true, 77 ), 78 'permalink' => array( 79 'label' => __( 'Permalink structure' ), 80 'value' => get_option( 'permalink_structure' ) ?: __( 'No permalink structure set' ), 81 ), 82 'https_status' => array( 83 'label' => __( 'Is this site using HTTPS?' ), 84 'value' => ( is_ssl() ? __( 'Yes' ) : __( 'No' ) ), 85 ), 86 'user_registration' => array( 87 'label' => __( 'Can anyone register on this site?' ), 88 'value' => ( get_option( 'users_can_register' ) ? __( 'Yes' ) : __( 'No' ) ), 89 ), 90 'default_comment_status' => array( 91 'label' => __( 'Default comment status' ), 92 'value' => get_option( 'default_comment_status' ), 93 ), 94 'multisite' => array( 95 'label' => __( 'Is this a multisite?' ), 96 'value' => ( is_multisite() ? __( 'Yes' ) : __( 'No' ) ), 97 ), 58 $info = array(); 59 60 $info[ 'wp-core' ] = array( 61 'label' => __( 'WordPress' ), 62 'fields' => array( 63 'version' => array( 64 'label' => __( 'Version' ), 65 'value' => $core_version . $core_update_needed, 66 'debug' => $core_version, 98 67 ), 68 'language' => array( 69 'label' => __( 'Language' ), 70 'value' => $locale, 71 ), 72 'home_url' => array( 73 'label' => __( 'Home URL' ), 74 'value' => get_bloginfo( 'url' ), 75 'private' => true, 76 ), 77 'site_url' => array( 78 'label' => __( 'Site URL' ), 79 'value' => get_bloginfo( 'wpurl' ), 80 'private' => true, 81 ), 82 'permalink' => array( 83 'label' => __( 'Permalink structure' ), 84 'value' => $permalink_structure ?: __( 'No permalink structure set' ), 85 'debug' => $permalink_structure, 86 ), 87 'https_status' => array( 88 'label' => __( 'Is this site using HTTPS?' ), 89 'value' => ( $is_ssl ? __( 'Yes' ) : __( 'No' ) ), 90 'debug' => $is_ssl, 91 ), 92 'user_registration' => array( 93 'label' => __( 'Can anyone register on this site?' ), 94 'value' => ( $users_can_register ? __( 'Yes' ) : __( 'No' ) ), 95 'debug' => $users_can_register, 96 ), 97 'default_comment_status' => array( 98 'label' => __( 'Default comment status' ), 99 'value' => get_option( 'default_comment_status' ), 100 ), 101 'multisite' => array( 102 'label' => __( 'Is this a multisite?' ), 103 'value' => ( $is_multisite ? __( 'Yes' ) : __( 'No' ) ), 104 'debug' => $is_multisite, 105 ), 99 106 ), 100 'wp-paths-sizes' => array(101 'label' => __( 'Directories and Sizes' ), 102 'fields' => array(),103 ),104 ' wp-dropins' => array(105 'label' => __( 'Drop-ins' ),106 'show_count' => true, 107 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),108 'fields' => array(),109 ),110 ' wp-active-theme' => array(111 'label' => __( 'Active Theme'),112 'fields' => array(),113 ), 114 'wp-themes' =>array(115 'label' => __( 'Other Themes' ),116 'show_count' => true,117 'fields' => array(),118 ), 119 'wp-mu-plugins' =>array(120 'label' => __( 'Must Use Plugins' ),121 122 123 ),124 'wp-plugins-active' => array( 125 'label' => __( 'Active Plugins' ),126 'show_count' => true,127 'fields' => array(),128 ),129 'wp-plugins-inactive' => array(130 'label' => __( 'Inactive Plugins' ), 131 'show_count' => true,132 'fields' => array(),133 ),134 ' wp-media' => array(135 'label' => __( 'Media Handling' ),136 'fields' => array(), 137 ),138 ' wp-server' => array(139 'label' => __( 'Server' ),140 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.'),141 'fields' => array(),142 ), 143 'wp-database' =>array(144 'label' => __( 'Database' ),145 146 ),147 'wp-constants' => array( 148 'label' => __( 'WordPress Constants' ),149 'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),150 'fields' => array(151 'ABSPATH' => array(152 'label' => 'ABSPATH',153 'value' => ABSPATH, 154 'private' => true,155 156 'WP_HOME' => array(157 'label' => 'WP_HOME',158 'value' => ( ! defined( 'WP_HOME' ) ? __( 'Undefined' ) : WP_HOME ), 159 ),160 'WP_SITEURL' => array(161 'label' => 'WP_SITEURL', 162 'value' => ( ! defined( 'WP_SITEURL' ) ? __( 'Undefined' ) : WP_SITEURL ),163 ),164 'WP_CONTENT_DIR' => array(165 'label' => 'WP_CONTENT_DIR',166 'value' => WP_CONTENT_DIR,167 ), 168 'WP_PLUGIN_DIR' => array(169 'label' => 'WP_PLUGIN_DIR',170 'value' => WP_PLUGIN_DIR,171 ),172 'WP_DEBUG' => array(173 'label' => 'WP_DEBUG',174 'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),175 ),176 'WP_MAX_MEMORY_LIMIT' => array( 177 'label' => 'WP_MAX_MEMORY_LIMIT',178 'value' => WP_MAX_MEMORY_LIMIT,179 ),180 'WP_DEBUG_DISPLAY' => array(181 'label' => 'WP_DEBUG_DISPLAY',182 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),183 ),184 'WP_DEBUG_LOG' => array(185 'label' => 'WP_DEBUG_LOG', 186 'value' => ( is_string( WP_DEBUG_LOG ) ? WP_DEBUG_LOG : ( WP_DEBUG_LOG ? __( 'Enabled' ) : __( 'Disabled' ) ) ),187 ),188 'SCRIPT_DEBUG' => array(189 'label' => 'SCRIPT_DEBUG',190 'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),191 ),192 'WP_CACHE' => array(193 'label' => 'WP_CACHE',194 'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ), 195 ),196 'CONCATENATE_SCRIPTS' => array(197 'label' => 'CONCATENATE_SCRIPTS',198 'value' => ( ! defined( 'CONCATENATE_SCRIPTS' ) ? __( 'Undefined' ) : ( CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ) ) ),199 ),200 'COMPRESS_SCRIPTS' => array(201 'label' => 'COMPRESS_SCRIPTS',202 'value' => ( ! defined( 'COMPRESS_SCRIPTS' ) ? __( 'Undefined' ) : ( COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ) ) ),203 ), 204 'COMPRESS_CSS' =>array(205 'label' => 'COMPRESS_CSS',206 'value' => ( ! defined( 'COMPRESS_CSS' ) ? __( 'Undefined' ) : ( COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' ) )),207 ),208 'WP_LOCAL_DEV'=> array(209 'label' => 'WP_LOCAL_DEV',210 'value' => ( ! defined( 'WP_LOCAL_DEV' ) ? __( 'Undefined' ) : ( WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' ) ) ),211 ),107 ); 108 109 $info[ 'wp-paths-sizes' ] = array( 110 'label' => __( 'Directories and Sizes' ), 111 'fields' => array(), 112 ); 113 114 $info[ 'wp-dropins' ] = array( 115 'label' => __( 'Drop-ins' ), 116 'show_count' => true, 117 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ), 118 'fields' => array(), 119 ); 120 121 $info[ 'wp-active-theme' ] = array( 122 'label' => __( 'Active Theme' ), 123 'fields' => array(), 124 ); 125 126 $info[ 'wp-themes' ] = array( 127 'label' => __( 'Other Themes' ), 128 'show_count' => true, 129 'fields' => array(), 130 ); 131 132 $info[ 'wp-mu-plugins' ] = array( 133 'label' => __( 'Must Use Plugins' ), 134 'show_count' => true, 135 'fields' => array(), 136 ); 137 138 $info[ 'wp-plugins-active' ] = array( 139 'label' => __( 'Active Plugins' ), 140 'show_count' => true, 141 'fields' => array(), 142 ); 143 144 $info[ 'wp-plugins-inactive' ] = array( 145 'label' => __( 'Inactive Plugins' ), 146 'show_count' => true, 147 'fields' => array(), 148 ); 149 150 $info[ 'wp-media' ] = array( 151 'label' => __( 'Media Handling' ), 152 'fields' => array(), 153 ); 154 155 $info[ 'wp-server' ] = array( 156 'label' => __( 'Server' ), 157 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ), 158 'fields' => array(), 159 ); 160 161 $info[ 'wp-database' ] = array( 162 'label' => __( 'Database' ), 163 'fields' => array(), 164 ); 165 166 // Check if WP_DEBUG_LOG is set. 167 $wp_debug_log_value = __( 'Disabled' ); 168 169 if ( is_string( WP_DEBUG_LOG ) ) { 170 $wp_debug_log_value = WP_DEBUG_LOG; 171 } elseif ( WP_DEBUG_LOG ) { 172 $wp_debug_log_value = __( 'Enabled' ); 173 } 174 175 // Check CONCATENATE_SCRIPTS. 176 if ( defined( 'CONCATENATE_SCRIPTS' ) ) { 177 $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ); 178 $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false'; 179 } else { 180 $concatenate_scripts = __( 'Undefined' ); 181 $concatenate_scripts_debug = 'undefined'; 182 } 183 184 // Check COMPRESS_SCRIPTS. 185 if ( defined( 'COMPRESS_SCRIPTS' ) ) { 186 $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ); 187 $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false'; 188 } else { 189 $compress_scripts = __( 'Undefined' ); 190 $compress_scripts_debug = 'undefined'; 191 } 192 193 // Check COMPRESS_CSS. 194 if ( defined( 'COMPRESS_CSS' ) ) { 195 $compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' ); 196 $compress_css_debug = COMPRESS_CSS ? 'true' : 'false'; 197 } else { 198 $compress_css = __( 'Undefined' ); 199 $compress_css_debug = 'undefined'; 200 } 201 202 // Check WP_LOCAL_DEV. 203 if ( defined( 'WP_LOCAL_DEV' ) ) { 204 $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' ); 205 $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false'; 206 } else { 207 $wp_local_dev = __( 'Undefined' ); 208 $wp_local_dev_debug = 'undefined'; 209 } 210 211 $info[ 'wp-constants' ] = array( 212 'label' => __( 'WordPress Constants' ), 213 'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ), 214 'fields' => array( 215 'ABSPATH' => array( 216 'label' => 'ABSPATH', 217 'value' => ABSPATH, 218 'private' => true, 212 219 ), 220 'WP_HOME' => array( 221 'label' => 'WP_HOME', 222 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ), 223 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ), 224 ), 225 'WP_SITEURL' => array( 226 'label' => 'WP_SITEURL', 227 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ), 228 'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ), 229 ), 230 'WP_CONTENT_DIR' => array( 231 'label' => 'WP_CONTENT_DIR', 232 'value' => WP_CONTENT_DIR, 233 ), 234 'WP_PLUGIN_DIR' => array( 235 'label' => 'WP_PLUGIN_DIR', 236 'value' => WP_PLUGIN_DIR, 237 ), 238 'WP_DEBUG' => array( 239 'label' => 'WP_DEBUG', 240 'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ), 241 'debug' => WP_DEBUG, 242 ), 243 'WP_MAX_MEMORY_LIMIT' => array( 244 'label' => 'WP_MAX_MEMORY_LIMIT', 245 'value' => WP_MAX_MEMORY_LIMIT, 246 ), 247 'WP_DEBUG_DISPLAY' => array( 248 'label' => 'WP_DEBUG_DISPLAY', 249 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ), 250 'debug' => WP_DEBUG_DISPLAY, 251 ), 252 'WP_DEBUG_LOG' => array( 253 'label' => 'WP_DEBUG_LOG', 254 'value' => $wp_debug_log_value, 255 'debug' => WP_DEBUG_LOG, 256 ), 257 'SCRIPT_DEBUG' => array( 258 'label' => 'SCRIPT_DEBUG', 259 'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ), 260 'debug' => SCRIPT_DEBUG, 261 ), 262 'WP_CACHE' => array( 263 'label' => 'WP_CACHE', 264 'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ), 265 'debug' => WP_CACHE, 266 ), 267 'CONCATENATE_SCRIPTS' => array( 268 'label' => 'CONCATENATE_SCRIPTS', 269 'value' => $concatenate_scripts, 270 'debug' => $concatenate_scripts_debug, 271 ), 272 'COMPRESS_SCRIPTS' => array( 273 'label' => 'COMPRESS_SCRIPTS', 274 'value' => $compress_scripts, 275 'debug' => $compress_scripts_debug, 276 ), 277 'COMPRESS_CSS' => array( 278 'label' => 'COMPRESS_CSS', 279 'value' => $compress_css, 280 'debug' => $compress_css_debug, 281 ), 282 'WP_LOCAL_DEV' => array( 283 'label' => 'WP_LOCAL_DEV', 284 'value' => $wp_local_dev, 285 'debug' => $wp_local_dev_debug, 286 ), 213 287 ), 214 'wp-filesystem' => array( 215 'label' => __( 'Filesystem Permissions' ), 216 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ), 217 'fields' => array( 218 'all' => array( 219 'label' => __( 'The main WordPress directory' ), 220 'value' => ( wp_is_writable( ABSPATH ) ? __( 'Writable' ) : __( 'Not writable' ) ), 221 ), 222 'wp-content' => array( 223 'label' => __( 'The wp-content directory' ), 224 'value' => ( wp_is_writable( WP_CONTENT_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ), 225 ), 226 'uploads' => array( 227 'label' => __( 'The uploads directory' ), 228 'value' => ( wp_is_writable( $upload_dir['basedir'] ) ? __( 'Writable' ) : __( 'Not writable' ) ), 229 ), 230 'plugins' => array( 231 'label' => __( 'The plugins directory' ), 232 'value' => ( wp_is_writable( WP_PLUGIN_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ), 233 ), 234 'themes' => array( 235 'label' => __( 'The themes directory' ), 236 'value' => ( wp_is_writable( get_template_directory() . '/..' ) ? __( 'Writable' ) : __( 'Not writable' ) ), 237 ), 288 ); 289 290 $is_writable_abspath = wp_is_writable( ABSPATH ); 291 $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR ); 292 $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] ); 293 $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR ); 294 $is_writable_template_directory = wp_is_writable( get_template_directory() . '/..' ); 295 296 $info[ 'wp-filesystem' ] = array( 297 'label' => __( 'Filesystem Permissions' ), 298 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ), 299 'fields' => array( 300 'wordpress' => array( 301 'label' => __( 'The main WordPress directory' ), 302 'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ), 303 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ), 238 304 ), 305 'wp-content' => array( 306 'label' => __( 'The wp-content directory' ), 307 'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 308 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ), 309 ), 310 'uploads' => array( 311 'label' => __( 'The uploads directory' ), 312 'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 313 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ), 314 ), 315 'plugins' => array( 316 'label' => __( 'The plugins directory' ), 317 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 318 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ), 319 ), 320 'themes' => array( 321 'label' => __( 'The themes directory' ), 322 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ), 323 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ), 324 ), 239 325 ), 240 326 ); 241 327 … … 255 341 $site_count += get_blog_count( $network_id ); 256 342 } 257 343 258 $info['wp-core']['fields']['user_count'] 344 $info['wp-core']['fields']['user_count'] = array( 259 345 'label' => __( 'User count' ), 260 346 'value' => get_user_count(), 261 347 ); 262 $info['wp-core']['fields']['site_count'] = array( 348 349 $info['wp-core']['fields']['site_count'] = array( 263 350 'label' => __( 'Site count' ), 264 351 'value' => $site_count, 265 352 ); 353 266 354 $info['wp-core']['fields']['network_count'] = array( 267 355 'label' => __( 'Network count' ), 268 356 'value' => $network_query->found_networks, … … 277 365 } 278 366 279 367 // WordPress features requiring processing. 280 $wp_dotorg = wp_remote_get( 281 'https://wordpress.org', 282 array( 283 'timeout' => 10, 284 ) 285 ); 368 $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) ); 369 286 370 if ( ! is_wp_error( $wp_dotorg ) ) { 287 371 $info['wp-core']['fields']['dotorg_communication'] = array( 288 372 'label' => __( 'Communication with WordPress.org' ), 289 'value' => sprintf( 290 __( 'WordPress.org is reachable' ) 291 ), 373 'value' => __( 'WordPress.org is reachable' ), 374 'debug' => 'true', 292 375 ); 293 376 } else { 294 377 $info['wp-core']['fields']['dotorg_communication'] = array( … … 299 382 gethostbyname( 'wordpress.org' ), 300 383 $wp_dotorg->get_error_message() 301 384 ), 385 'debug' => $wp_dotorg->get_error_message(), 302 386 ); 303 387 } 304 388 … … 350 434 ), 351 435 ); 352 436 353 $timeout = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' ); 354 $inaccessible = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' ); 355 $size_total = 0; 437 $size_total = 0; 356 438 357 439 // Loop over all the directories we want to gather the sizes for. 358 440 foreach ( $size_directories as $size => $attributes ) { … … 364 446 365 447 if ( $dir_size === false ) { 366 448 // Error reading. 367 $dir_size = $inaccessible; 449 $size_directories[ $size ]['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' ); 450 $size_directories[ $size ]['debug'] = 'not accessible'; 451 368 452 // Stop total size calculation. 369 453 $size_total = null; 370 454 } elseif ( $dir_size === null ) { 371 455 // Timeout. 372 $dir_size = $timeout; 456 $size_directories[ $size ]['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' ); 457 $size_directories[ $size ]['debug'] = 'timeout while calculating size'; 458 373 459 // Stop total size calculation. 374 460 $size_total = null; 375 461 } else { … … 380 466 $size_total += $dir_size; 381 467 } 382 468 383 $dir_size = size_format( $dir_size, 2 ); 469 $size_directories[ $size ]['size'] = size_format( $dir_size, 2 ); 470 $size_directories[ $size ]['debug'] = $size_directories[ $size ]['size']; 384 471 } 385 386 $size_directories[ $size ]['size'] = $dir_size;387 472 } 388 473 389 474 if ( $size_total !== null && $size_db > 0 ) { 390 475 $size_total = size_format( $size_total + $size_db, 2 ); 391 476 } else { 392 $size_total = __( 'Total size is not available. Some errors were encountered when determining the size of your installation.' );477 $size_total = 0; 393 478 } 394 479 395 480 $info['wp-paths-sizes']['fields'] = array( 396 array(481 'uploads_path' => array( 397 482 'label' => __( 'Uploads Directory Location' ), 398 483 'value' => $size_directories['uploads']['path'], 399 484 ), 400 array(485 'uploads_size' => array( 401 486 'label' => __( 'Uploads Directory Size' ), 402 487 'value' => $size_directories['uploads']['size'], 488 'debug' => $size_directories['uploads']['debug'], 403 489 ), 404 array(490 'themes_path' => array( 405 491 'label' => __( 'Themes Directory Location' ), 406 492 'value' => $size_directories['themes']['path'], 407 493 ), 408 array(494 'current_theme_path' => array( 409 495 'label' => __( 'Current Theme Directory' ), 410 496 'value' => get_template_directory(), 411 497 ), 412 array(498 'themes_size' => array( 413 499 'label' => __( 'Themes Directory Size' ), 414 500 'value' => $size_directories['themes']['size'], 501 'debug' => $size_directories['themes']['debug'], 415 502 ), 416 array(503 'plugins_path' => array( 417 504 'label' => __( 'Plugins Directory Location' ), 418 505 'value' => $size_directories['plugins']['path'], 419 506 ), 420 array(507 'plugins_size' => array( 421 508 'label' => __( 'Plugins Directory Size' ), 422 509 'value' => $size_directories['plugins']['size'], 510 'debug' => $size_directories['plugins']['debug'], 423 511 ), 424 array(512 'wordpress_path' => array( 425 513 'label' => __( 'WordPress Directory Location' ), 426 514 'value' => $size_directories['wordpress']['path'], 427 515 ), 428 array(516 'wordpress_size' => array( 429 517 'label' => __( 'WordPress Directory Size' ), 430 518 'value' => $size_directories['wordpress']['size'], 519 'debug' => $size_directories['wordpress']['debug'], 431 520 ), 432 array(521 'database_size' => array( 433 522 'label' => __( 'Database size' ), 434 523 'value' => size_format( $size_db, 2 ), 435 524 ), 436 array(525 'total_size' => array( 437 526 'label' => __( 'Total installation size' ), 438 'value' => $size_total, 527 'value' => $size_total > 0 ? $size_total : __( 'Total size is not available. Some errors were encountered when determining the size of your installation.' ), 528 'debug' => $size_total > 0 ? $size_total : 'not available', 439 529 ), 440 530 ); 441 531 442 532 // Get a list of all drop-in replacements. 443 $dropins = get_dropins(); 444 $dropin_description = _get_dropins(); 533 $dropins = get_dropins(); 534 535 // Get dropins descriptions. 536 $dropin_descriptions = _get_dropins(); 537 538 // Spare few function calls. 539 $not_available = __( 'Not available' ); 540 445 541 foreach ( $dropins as $dropin_key => $dropin ) { 446 $info['wp-dropins']['fields'][ sanitize_ key( $dropin_key ) ] = array(542 $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array( 447 543 'label' => $dropin_key, 448 'value' => $dropin_description[ $dropin_key ][0], 544 'value' => $dropin_descriptions[ $dropin_key ][0], 545 'debug' => 'true', 449 546 ); 450 547 } 451 548 … … 458 555 // Get ImageMagic information, if available. 459 556 if ( class_exists( 'Imagick' ) ) { 460 557 // Save the Imagick instance for later use. 461 $imagick 558 $imagick = new Imagick(); 462 559 $imagick_version = $imagick->getVersion(); 463 560 } else { 464 561 $imagick_version = __( 'Not available' ); 465 562 } 563 466 564 $info['wp-media']['fields']['imagick_module_version'] = array( 467 565 'label' => __( 'ImageMagick version number' ), 468 566 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ), 469 567 ); 470 $info['wp-media']['fields']['imagemagick_version'] = array( 568 569 $info['wp-media']['fields']['imagemagick_version'] = array( 471 570 'label' => __( 'ImageMagick version string' ), 472 571 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ), 473 572 ); … … 475 574 // If Imagick is used as our editor, provide some more information about its limitations. 476 575 if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) { 477 576 $limits = array( 478 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : __( 'Not available' )),479 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : __( 'Not available' )),480 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : __( 'Not available' )),481 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : __( 'Not available' )),482 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : __( 'Not available' )),483 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : __( 'Not available' )),577 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ), 578 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ), 579 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ), 580 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ), 581 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ), 582 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ), 484 583 ); 485 584 585 $limits_debug = array( 586 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ), 587 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ), 588 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ), 589 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ), 590 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ), 591 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ), 592 ); 593 486 594 $info['wp-media']['fields']['imagick_limits'] = array( 487 595 'label' => __( 'Imagick Resource Limits' ), 488 596 'value' => $limits, 597 'debug' => $limits_debug, 489 598 ); 490 599 } 491 600 … … 495 604 } else { 496 605 $gd = false; 497 606 } 607 498 608 $info['wp-media']['fields']['gd_version'] = array( 499 609 'label' => __( 'GD version' ), 500 'value' => ( is_array( $gd ) ? $gd['GD Version'] : __( 'Not available' ) ), 610 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ), 611 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ), 501 612 ); 502 613 503 614 // Get Ghostscript information, if available. 504 615 if ( function_exists( 'exec' ) ) { 505 616 $gs = exec( 'gs --version' ); 506 $gs = ( ! empty( $gs ) ? $gs : __( 'Not available' ) ); 617 618 if ( empty( $gs ) ) { 619 $gs = $not_available; 620 $gs_debug = 'not available'; 621 } else { 622 $gs_debug = $gs; 623 } 507 624 } else { 508 625 $gs = __( 'Unable to determine if Ghostscript is installed' ); 626 $gs_debug = 'unknown'; 509 627 } 628 510 629 $info['wp-media']['fields']['ghostscript_version'] = array( 511 630 'label' => __( 'Ghostscript version' ), 512 631 'value' => $gs, 632 'debug' => $gs_debug, 513 633 ); 514 634 515 635 // Populate the server debug fields. 636 if ( function_exists( 'php_uname' ) ) { 637 $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ); 638 } else { 639 $server_architecture = 'unknown'; 640 } 641 642 if ( function_exists( 'phpversion' ) ) { 643 $php_version_debug = phpversion(); 644 // Whether PHP supports 64bit 645 $php64bit = ( PHP_INT_SIZE * 8 === 64 ); 646 647 $php_version = sprintf( 648 '%s %s', 649 $php_version_debug, 650 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) ) 651 ); 652 653 if ( $php64bit ) { 654 $php_version_debug .= ' 64bit'; 655 } 656 } else { 657 $php_version = __( 'Unable to determine PHP version' ); 658 $php_version_debug = 'unknown'; 659 } 660 661 if ( function_exists( 'php_sapi_name' ) ) { 662 $php_sapi = php_sapi_name(); 663 } else { 664 $php_sapi = 'unknown'; 665 } 666 516 667 $info['wp-server']['fields']['server_architecture'] = array( 517 668 'label' => __( 'Server architecture' ), 518 'value' => ( ! function_exists( 'php_uname' ) ? __( 'Unable to determine server architecture' ) : sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ) ), 669 'value' => ( $server_architecture !== 'unknown' ? $server_architecture : __( 'Unable to determine server architecture' ) ), 670 'debug' => $server_architecture, 519 671 ); 520 672 $info['wp-server']['fields']['httpd_software'] = array( 521 673 'label' => __( 'Web server' ), 522 674 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ), 675 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ), 523 676 ); 524 677 $info['wp-server']['fields']['php_version'] = array( 525 678 'label' => __( 'PHP version' ), 526 'value' => ( ! function_exists( 'phpversion' ) ? __( 'Unable to determine PHP version' ) : sprintf( 527 '%s %s', 528 phpversion(), 529 ( 64 === PHP_INT_SIZE * 8 ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) ) 530 ) 531 ), 679 'value' => $php_version, 680 'debug' => $php_version_debug, 532 681 ); 533 682 $info['wp-server']['fields']['php_sapi'] = array( 534 683 'label' => __( 'PHP SAPI' ), 535 'value' => ( ! function_exists( 'php_sapi_name' ) ? __( 'Unable to determine PHP SAPI' ) : php_sapi_name() ), 684 'value' => ( $php_sapi !== 'unknown' ? $php_sapi : __( 'Unable to determine PHP SAPI' ) ), 685 'debug' => $php_sapi, 536 686 ); 537 687 538 688 // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values. … … 540 690 $info['wp-server']['fields']['ini_get'] = array( 541 691 'label' => __( 'Server settings' ), 542 692 'value' => __( 'Unable to determine some settings, as the ini_get() function has been disabled.' ), 693 'debug' => 'ini_get() is disabled', 543 694 ); 544 695 } else { 545 696 $info['wp-server']['fields']['max_input_variables'] = array( … … 578 729 } else { 579 730 $info['wp-server']['fields']['curl_version'] = array( 580 731 'label' => __( 'cURL version' ), 581 'value' => __( 'Not available' ), 732 'value' => $not_available, 733 'debug' => 'not available', 582 734 ); 583 735 } 584 736 737 // SUHOSIN 738 $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ); 739 585 740 $info['wp-server']['fields']['suhosin'] = array( 586 741 'label' => __( 'Is SUHOSIN installed?' ), 587 'value' => ( ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? __( 'Yes' ) : __( 'No' ) ), 742 'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ), 743 'debug' => $suhosin_loaded, 588 744 ); 589 745 746 // Imagick 747 $imagick_loaded = extension_loaded( 'imagick' ); 748 590 749 $info['wp-server']['fields']['imagick_availability'] = array( 591 750 'label' => __( 'Is the Imagick library available?' ), 592 'value' => ( extension_loaded( 'imagick' ) ? __( 'Yes' ) : __( 'No' ) ), 751 'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ), 752 'debug' => $imagick_loaded, 593 753 ); 594 754 595 755 // Check if a .htaccess file exists. … … 599 759 600 760 // Filter away the core WordPress rules. 601 761 $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) ); 762 $filtered_htaccess_content = ! empty( $filtered_htaccess_content ); 602 763 603 764 $info['wp-server']['fields']['htaccess_extra_rules'] = array( 604 765 'label' => __( 'htaccess rules' ), 605 'value' => ( ! empty( $filtered_htaccess_content ) ? __( 'Custom rules have been added to your htaccess file.' ) : __( 'Your htaccess file contains only core WordPress features.' ) ), 766 'value' => ( $filtered_htaccess_content ? __( 'Custom rules have been added to your htaccess file.' ) : __( 'Your htaccess file contains only core WordPress features.' ) ), 767 'debug' => $filtered_htaccess_content, 606 768 ); 607 769 } 608 770 … … 646 808 } 647 809 } 648 810 649 $info['wp-database']['fields']['extension'] 811 $info['wp-database']['fields']['extension'] = array( 650 812 'label' => __( 'Extension' ), 651 813 'value' => $extension, 652 814 ); 653 $info['wp-database']['fields']['server_version'] 815 $info['wp-database']['fields']['server_version'] = array( 654 816 'label' => __( 'Server version' ), 655 817 'value' => $server, 656 818 ); 657 $info['wp-database']['fields']['client_version'] 819 $info['wp-database']['fields']['client_version'] = array( 658 820 'label' => __( 'Client version' ), 659 821 'value' => $client_version, 660 822 ); 661 $info['wp-database']['fields']['database_user'] 823 $info['wp-database']['fields']['database_user'] = array( 662 824 'label' => __( 'Database user' ), 663 825 'value' => $wpdb->dbuser, 664 826 'private' => true, 665 827 ); 666 $info['wp-database']['fields']['database_host'] 828 $info['wp-database']['fields']['database_host'] = array( 667 829 'label' => __( 'Database host' ), 668 830 'value' => $wpdb->dbhost, 669 831 'private' => true, 670 832 ); 671 $info['wp-database']['fields']['database_name'] 833 $info['wp-database']['fields']['database_name'] = array( 672 834 'label' => __( 'Database name' ), 673 835 'value' => $wpdb->dbname, 674 836 'private' => true, … … 687 849 $plugin_author = $plugin['Author']; 688 850 689 851 $plugin_version_string = __( 'No version or author information is available.' ); 852 $plugin_version_string_debug = 'author: (undefined), version: (undefined)'; 690 853 691 854 if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) { 692 855 // translators: 1: Plugin version number. 2: Plugin author name. 693 856 $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author ); 857 $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author ); 858 } else { 859 if ( ! empty( $plugin_author ) ) { 860 // translators: %s: Plugin author name. 861 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author ); 862 $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author ); 863 } 864 865 if ( ! empty( $plugin_version ) ) { 866 // translators: %s: Plugin version number. 867 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version ); 868 $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version ); 869 } 694 870 } 695 if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) {696 // translators: %s: Plugin author name.697 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );698 }699 if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) {700 // translators: %s: Plugin version number.701 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );702 }703 871 704 $info['wp-mu-plugins']['fields'][ sanitize_ key( $plugin['Name'] ) ] = array(872 $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array( 705 873 'label' => $plugin['Name'], 706 874 'value' => $plugin_version_string, 875 'debug' => $plugin_version_string_debug, 707 876 ); 708 877 } 709 878 710 879 // List all available plugins. 711 $plugins 880 $plugins = get_plugins(); 712 881 $plugin_updates = get_plugin_updates(); 713 882 714 883 foreach ( $plugins as $plugin_path => $plugin ) { … … 718 887 $plugin_author = $plugin['Author']; 719 888 720 889 $plugin_version_string = __( 'No version or author information is available.' ); 890 $plugin_version_string_debug = 'author: (undefined), version: (undefined)'; 721 891 722 892 if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) { 723 893 // translators: 1: Plugin version number. 2: Plugin author name. 724 894 $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author ); 895 $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author ); 896 } else { 897 if ( ! empty( $plugin_author ) ) { 898 // translators: %s: Plugin author name. 899 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author ); 900 $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author ); 901 } 902 903 if ( ! empty( $plugin_version ) ) { 904 // translators: %s: Plugin version number. 905 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version ); 906 $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version ); 907 } 725 908 } 726 if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) {727 // translators: %s: Plugin author name.728 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );729 }730 if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) {731 // translators: %s: Plugin version number.732 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );733 }734 909 735 910 if ( array_key_exists( $plugin_path, $plugin_updates ) ) { 736 911 // translators: %s: Latest plugin version number. 737 $plugin_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version ); 738 } else { 739 $plugin_update_needed = ''; 912 $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version ); 913 $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version ); 740 914 } 741 915 742 $info[ $plugin_part ]['fields'][ sanitize_ key( $plugin['Name'] ) ] = array(916 $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array( 743 917 'label' => $plugin['Name'], 744 'value' => $plugin_version_string . $plugin_update_needed, 918 'value' => $plugin_version_string, 919 'debug' => $plugin_version_string_debug, 745 920 ); 746 921 } 747 922 … … 748 923 // Populate the section for the currently active theme. 749 924 global $_wp_theme_features; 750 925 $theme_features = array(); 926 751 927 if ( ! empty( $_wp_theme_features ) ) { 752 928 foreach ( $_wp_theme_features as $feature => $options ) { 753 929 $theme_features[] = $feature; … … 757 933 $active_theme = wp_get_theme(); 758 934 $theme_updates = get_theme_updates(); 759 935 936 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 937 $active_theme_version = $active_theme->Version; 938 $active_theme_version_debug = $active_theme_version; 939 760 940 if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) { 941 $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version']; 942 761 943 // translators: %s: Latest theme version number. 762 $ theme_update_needed_active = ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $active_theme->stylesheet ]->update['new_version']);763 } else { 764 $ theme_update_needed_active = '';944 $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version ); 945 946 $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version ); 765 947 } 766 948 949 $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' ); 950 767 951 $info['wp-active-theme']['fields'] = array( 768 'name' 952 'name' => array( 769 953 'label' => __( 'Name' ), 770 954 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 771 955 'value' => $active_theme->Name, 772 956 ), 773 'version' 957 'version' => array( 774 958 'label' => __( 'Version' ), 775 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase776 ' value' => $active_theme->Version . $theme_update_needed_active,959 'value' => $active_theme_version, 960 'debug' => $active_theme_version_debug, 777 961 ), 778 'author' 962 'author' => array( 779 963 'label' => __( 'Author' ), 780 964 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 781 965 'value' => wp_kses( $active_theme->Author, array() ), … … 782 966 ), 783 967 'author_website' => array( 784 968 'label' => __( 'Author website' ), 785 'value' => ( $active_theme->offsetGet( 'Author URI' ) ? $active_theme->offsetGet( 'Author URI' ) : __( 'Undefined' ) ), 969 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ), 970 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ), 786 971 ), 787 'parent_theme' 972 'parent_theme' => array( 788 973 'label' => __( 'Parent theme' ), 789 974 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme : __( 'None' ) ), 975 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme : 'none' ), 790 976 ), 791 977 'theme_features' => array( 792 978 'label' => __( 'Theme features' ), … … 807 993 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 808 994 $theme_author = $theme->Author; 809 995 996 // Sanitize 997 $theme_author = wp_kses( $theme_author, array() ); 998 810 999 $theme_version_string = __( 'No version or author information is available.' ); 1000 $theme_version_string_debug = 'undefined'; 811 1001 812 1002 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) { 813 1003 // translators: 1: Theme version number. 2: Theme author name. 814 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, wp_kses( $theme_author, array() ) ); 1004 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author ); 1005 $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author ); 1006 } else { 1007 if ( ! empty( $theme_author ) ) { 1008 // translators: %s: Theme author name. 1009 $theme_version_string = sprintf( __( 'By %s' ), $theme_author ); 1010 $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author ); 1011 } 1012 1013 if ( ! empty( $theme_version ) ) { 1014 // translators: %s: Theme version number. 1015 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version ); 1016 $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version ); 1017 } 815 1018 } 816 if ( empty( $theme_version ) && ! empty( $theme_author ) ) {817 // translators: %s: Theme author name.818 $theme_version_string = sprintf( __( 'By %s' ), wp_kses( $theme_author, array() ) );819 }820 if ( ! empty( $theme_version ) && empty( $theme_author ) ) {821 // translators: %s: Theme version number.822 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version );823 }824 1019 825 1020 if ( array_key_exists( $theme_slug, $theme_updates ) ) { 826 1021 // translators: %s: Latest theme version number. 827 $theme_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 828 } else { 829 $theme_update_needed = ''; 1022 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 1023 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] ); 830 1024 } 831 1025 832 $info['wp-themes']['fields'][ sanitize_ key( $theme->Name ) ] = array(1026 $info['wp-themes']['fields'][ sanitize_text_field( $theme->Name ) ] = array( 833 1027 'label' => sprintf( 834 1028 // translators: 1: Theme name. 2: Theme slug. 835 1029 __( '%1$s (%2$s)' ), … … 837 1031 $theme->Name, 838 1032 $theme_slug 839 1033 ), 840 'value' => $theme_version_string . $theme_update_needed, 1034 'value' => $theme_version_string, 1035 'debug' => $theme_version_string_debug, 841 1036 ); 842 1037 } 843 1038 844 1039 // Add more filesystem checks 845 1040 if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) { 846 $info['wp-filesystem']['fields']['mu_plugin_directory'] = array( 1041 $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR ); 1042 1043 $info['wp-filesystem']['fields']['mu-plugins'] = array( 847 1044 'label' => __( 'The must use plugins directory' ), 848 'value' => ( wp_is_writable( WPMU_PLUGIN_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ), 1045 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 1046 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), 849 1047 ); 850 1048 } 851 1049 852 1050 /** 853 * Add or modify new debug sections.1051 * Add or modify the debug information. 854 1052 * 855 * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this856 * kind of information as it is rarely needed, they can then utilize this filter to introduce their ownsections.1053 * Plugin or themes may wish to introduce their own debug information without creating additional admin pages 1054 * they can utilize this filter to introduce their own sections or add more data to existing sections. 857 1055 * 858 * Array keys added by core are all prefixed with `wp-`, plugins and themes are encouraged to use their own slug as 859 * a prefix, both for consistency as well as avoiding key collisions. 1056 * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as 1057 * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels 1058 * for the copied data. 860 1059 * 861 1060 * @since 5.2.0 862 1061 * … … 863 1062 * @param array $args { 864 1063 * The debug information to be added to the core information page. 865 1064 * 1065 * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections. 1066 * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be 1067 * another associative array of name/value pairs when there is more structured data to display. 1068 * 866 1069 * @type string $label The title for this section of the debug output. 867 1070 * @type string $description Optional. A description for your information section which may contain basic HTML 868 1071 * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis. … … 869 1072 * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for 870 1073 * this section. 871 1074 * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded 872 * from the cop y-paste text area.1075 * from the copied data. 873 1076 * @type array $fields { 874 1077 * An associative array containing the data to be displayed. 875 1078 * 876 1079 * @type string $label The label for this piece of information. 877 * @type string $value The output that is of interest for this field. 878 * @type boolean $private Optional. If set to `true` the field will not be included in the copy-paste text area 879 * on top of the page, allowing you to show, for example, API keys here. 1080 * @type string $value The output that is displayed for this field. Text should be translated. Can be 1081 * an associative array that is displayed as name/value pairs. 1082 * @type string $debug Optional. The output that is used for this field when the user copies the data. 1083 * It should be more concise and not translated. If not set, the content of `$value` is used. 1084 * Note that the array keys are used as labels for the copied data. 1085 * @type boolean $private Optional. If set to `true` the field will not be included in the copied data 1086 * allowing you to show, for example, API keys here. 880 1087 * } 881 1088 * } 882 1089 */ 883 1090 $info = apply_filters( 'debug_information', $info ); 884 1091 885 if ( ! empty( $locale ) ) {886 // Change the language used for translations887 if ( $switched_locale ) {888 restore_previous_locale();889 }890 }891 892 1092 return $info; 893 1093 } 894 1094 … … 898 1098 * @since 5.2.0 899 1099 * 900 1100 * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function. 901 * @param string $type Optional. The data type to format the information as. Default 'text'.1101 * @param string $type The data type to return, either 'info' or 'debug'. 902 1102 * @return string The formatted data. 903 1103 */ 904 public static function format( $info_array, $type = 'text') {1104 public static function format( $info_array, $type ) { 905 1105 $return = "`\n"; 906 1106 907 1107 foreach ( $info_array as $section => $details ) { … … 909 1109 if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) { 910 1110 continue; 911 1111 } 1112 1113 $section_label = $type === 'debug' ? $section : $details['label']; 912 1114 913 1115 $return .= sprintf( 914 1116 "### %s%s ###\n\n", 915 $ details['label'],1117 $section_label, 916 1118 ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) 917 1119 ); 918 1120 919 foreach ( $details['fields'] as $field ) {1121 foreach ( $details['fields'] as $field_name => $field ) { 920 1122 if ( isset( $field['private'] ) && true === $field['private'] ) { 921 1123 continue; 922 1124 } 923 1125 924 $values = $field['value']; 925 if ( is_array( $field['value'] ) ) { 926 $values = ''; 1126 if ( $type === 'debug' && isset( $field['debug'] ) ) { 1127 $debug_data = $field['debug']; 1128 } else { 1129 $debug_data = $field['value']; 1130 } 927 1131 1132 // Can be array, one level deep only. 1133 if ( is_array( $debug_data ) ) { 1134 $value = ''; 1135 928 1136 foreach ( $field['value'] as $name => $value ) { 929 $values .= sprintf( 930 "\n\t%s: %s", 931 $name, 932 $value 933 ); 1137 $value .= sprintf( "\n\t%s: %s", $name, $value ); 934 1138 } 1139 } elseif ( is_bool( $debug_data ) ) { 1140 $value = $debug_data ? 'true' : 'false'; 1141 } elseif ( empty( $debug_data ) && '0' !== $debug_data ) { 1142 $value = 'undefined'; 1143 } else { 1144 $value = $debug_data; 935 1145 } 936 1146 937 $return .= sprintf( 938 "%s: %s\n", 939 $field['label'], 940 $values 941 ); 1147 if ( $type === 'debug' ) { 1148 $label = $field_name; 1149 } else { 1150 $label = $field['label']; 1151 } 1152 1153 $return .= sprintf( "%s: %s\n", $label, $value ); 942 1154 } 1155 943 1156 $return .= "\n"; 944 1157 } 945 1158 -
src/wp-admin/site-health-info.php
66 66 <?php 67 67 WP_Debug_Data::check_for_updates(); 68 68 69 $info = WP_Debug_Data::debug_data(); 70 $english_info = ''; 71 if ( 0 !== strpos( get_user_locale(), 'en' ) ) { 72 $english_info = WP_Debug_Data::debug_data( 'en_US' ); 73 } 69 $info = WP_Debug_Data::debug_data(); 70 74 71 ?> 75 72 76 73 <h2> … … 86 83 87 84 <div class="site-health-copy-buttons"> 88 85 <div class="copy-button-wrapper"> 89 <button type="button" class="button button-primary copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'text' ) ); ?>"><?php _e( 'Copy site info to clipboard' ); ?></button> 86 <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>"> 87 <?php _e( 'Copy site debug data to clipboard' ); ?> 88 </button> 90 89 <span class="success" aria-hidden="true">Copied!</span> 91 90 </div> 92 <?php if ( $english_info ) : ?>93 <div class="copy-button-wrapper">94 <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $english_info, 'text' ) ); ?>"><?php _e( 'Copy site info to clipboard (English)' ); ?></button>95 <span class="success" aria-hidden="true">Copied!</span>96 </div>97 <?php endif; ?>98 91 </div> 99 92 100 93 <div id="health-check-debug" class="health-check-accordion">