Ticket #46726: 46726.diff
File 46726.diff, 47.6 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 // TODO: describe array structure... 59 $info = array(); 60 61 $info[ 'wp-core' ] = array( 62 'label' => __( 'WordPress' ), 63 'fields' => array( 64 'version' => array( 65 'label' => __( 'Version' ), 66 'value' => $core_version . $core_update_needed, 67 'debug' => $core_version, 98 68 ), 69 'language' => array( 70 'label' => __( 'Language' ), 71 'value' => $locale, 72 ), 73 'home_url' => array( 74 'label' => __( 'Home URL' ), 75 'value' => get_bloginfo( 'url' ), 76 'private' => true, 77 ), 78 'site_url' => array( 79 'label' => __( 'Site URL' ), 80 'value' => get_bloginfo( 'wpurl' ), 81 'private' => true, 82 ), 83 'permalink' => array( 84 'label' => __( 'Permalink structure' ), 85 'value' => $permalink_structure ?: __( 'No permalink structure set' ), 86 'debug' => $permalink_structure, 87 ), 88 'https_status' => array( 89 'label' => __( 'Is this site using HTTPS?' ), 90 'value' => ( $is_ssl ? __( 'Yes' ) : __( 'No' ) ), 91 'debug' => $is_ssl, 92 ), 93 'user_registration' => array( 94 'label' => __( 'Can anyone register on this site?' ), 95 'value' => ( $users_can_register ? __( 'Yes' ) : __( 'No' ) ), 96 'debug' => $users_can_register, 97 ), 98 'default_comment_status' => array( 99 'label' => __( 'Default comment status' ), 100 'value' => get_option( 'default_comment_status' ), 101 ), 102 'multisite' => array( 103 'label' => __( 'Is this a multisite?' ), 104 'value' => ( $is_multisite ? __( 'Yes' ) : __( 'No' ) ), 105 'debug' => $is_multisite, 106 ), 99 107 ), 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 ),108 ); 109 110 $info[ 'wp-paths-sizes' ] = array( 111 'label' => __( 'Directories and Sizes' ), 112 'fields' => array(), 113 ); 114 115 $info[ 'wp-dropins' ] = array( 116 'label' => __( 'Drop-ins' ), 117 'show_count' => true, 118 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ), 119 'fields' => array(), 120 ); 121 122 $info[ 'wp-active-theme' ] = array( 123 'label' => __( 'Active Theme' ), 124 'fields' => array(), 125 ); 126 127 $info[ 'wp-themes' ] = array( 128 'label' => __( 'Other Themes' ), 129 'show_count' => true, 130 'fields' => array(), 131 ); 132 133 $info[ 'wp-mu-plugins' ] = array( 134 'label' => __( 'Must Use Plugins' ), 135 'show_count' => true, 136 'fields' => array(), 137 ); 138 139 $info[ 'wp-plugins-active' ] = array( 140 'label' => __( 'Active Plugins' ), 141 'show_count' => true, 142 'fields' => array(), 143 ); 144 145 $info[ 'wp-plugins-inactive' ] = array( 146 'label' => __( 'Inactive Plugins' ), 147 'show_count' => true, 148 'fields' => array(), 149 ); 150 151 $info[ 'wp-media' ] = array( 152 'label' => __( 'Media Handling' ), 153 'fields' => array(), 154 ); 155 156 $info[ 'wp-server' ] = array( 157 'label' => __( 'Server' ), 158 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ), 159 'fields' => array(), 160 ); 161 162 $info[ 'wp-database' ] = array( 163 'label' => __( 'Database' ), 164 'fields' => array(), 165 ); 166 167 // Check if WP_DEBUG_LOG is set. 168 $wp_debug_log_value = __( 'Disabled' ); 169 170 if ( is_string( WP_DEBUG_LOG ) ) { 171 $wp_debug_log_value = WP_DEBUG_LOG; 172 } elseif ( WP_DEBUG_LOG ) { 173 $wp_debug_log_value = __( 'Enabled' ); 174 } 175 176 // Check CONCATENATE_SCRIPTS. 177 if ( defined( 'CONCATENATE_SCRIPTS' ) ) { 178 $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ); 179 $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false'; 180 } else { 181 $concatenate_scripts = __( 'Undefined' ); 182 $concatenate_scripts_debug = 'undefined'; 183 } 184 185 // Check COMPRESS_SCRIPTS. 186 if ( defined( 'COMPRESS_SCRIPTS' ) ) { 187 $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' ); 188 $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false'; 189 } else { 190 $compress_scripts = __( 'Undefined' ); 191 $compress_scripts_debug = 'undefined'; 192 } 193 194 // Check COMPRESS_CSS. 195 if ( defined( 'COMPRESS_CSS' ) ) { 196 $compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' ); 197 $compress_css_debug = COMPRESS_CSS ? 'true' : 'false'; 198 } else { 199 $compress_css = __( 'Undefined' ); 200 $compress_css_debug = 'undefined'; 201 } 202 203 // Check WP_LOCAL_DEV. 204 if ( defined( 'WP_LOCAL_DEV' ) ) { 205 $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' ); 206 $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false'; 207 } else { 208 $wp_local_dev = __( 'Undefined' ); 209 $wp_local_dev_debug = 'undefined'; 210 } 211 212 $info[ 'wp-constants' ] = array( 213 'label' => __( 'WordPress Constants' ), 214 'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ), 215 'fields' => array( 216 'ABSPATH' => array( 217 'label' => 'ABSPATH', 218 'value' => ABSPATH, 219 'private' => true, 212 220 ), 221 'WP_HOME' => array( 222 'label' => 'WP_HOME', 223 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ), 224 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ), 225 ), 226 'WP_SITEURL' => array( 227 'label' => 'WP_SITEURL', 228 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ), 229 'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ), 230 ), 231 'WP_CONTENT_DIR' => array( 232 'label' => 'WP_CONTENT_DIR', 233 'value' => WP_CONTENT_DIR, 234 ), 235 'WP_PLUGIN_DIR' => array( 236 'label' => 'WP_PLUGIN_DIR', 237 'value' => WP_PLUGIN_DIR, 238 ), 239 'WP_DEBUG' => array( 240 'label' => 'WP_DEBUG', 241 'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ), 242 'debug' => WP_DEBUG, 243 ), 244 'WP_MAX_MEMORY_LIMIT' => array( 245 'label' => 'WP_MAX_MEMORY_LIMIT', 246 'value' => WP_MAX_MEMORY_LIMIT, 247 ), 248 'WP_DEBUG_DISPLAY' => array( 249 'label' => 'WP_DEBUG_DISPLAY', 250 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ), 251 'debug' => WP_DEBUG_DISPLAY, 252 ), 253 'WP_DEBUG_LOG' => array( 254 'label' => 'WP_DEBUG_LOG', 255 'value' => $wp_debug_log_value, 256 'debug' => WP_DEBUG_LOG, 257 ), 258 'SCRIPT_DEBUG' => array( 259 'label' => 'SCRIPT_DEBUG', 260 'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ), 261 'debug' => SCRIPT_DEBUG, 262 ), 263 'WP_CACHE' => array( 264 'label' => 'WP_CACHE', 265 'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ), 266 'debug' => WP_CACHE, 267 ), 268 'CONCATENATE_SCRIPTS' => array( 269 'label' => 'CONCATENATE_SCRIPTS', 270 'value' => $concatenate_scripts, 271 'debug' => $concatenate_scripts_debug, 272 ), 273 'COMPRESS_SCRIPTS' => array( 274 'label' => 'COMPRESS_SCRIPTS', 275 'value' => $compress_scripts, 276 'debug' => $compress_scripts_debug, 277 ), 278 'COMPRESS_CSS' => array( 279 'label' => 'COMPRESS_CSS', 280 'value' => $compress_css, 281 'debug' => $compress_css_debug, 282 ), 283 'WP_LOCAL_DEV' => array( 284 'label' => 'WP_LOCAL_DEV', 285 'value' => $wp_local_dev, 286 'debug' => $wp_local_dev_debug, 287 ), 213 288 ), 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 ), 289 ); 290 291 $is_writable_abspath = wp_is_writable( ABSPATH ); 292 $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR ); 293 $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] ); 294 $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR ); 295 $is_writable_template_directory = wp_is_writable( get_template_directory() . '/..' ); 296 297 $info[ 'wp-filesystem' ] = array( 298 'label' => __( 'Filesystem Permissions' ), 299 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ), 300 'fields' => array( 301 'all' => array( 302 'label' => __( 'The main WordPress directory' ), 303 'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ), 304 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ), 238 305 ), 306 'wp-content' => array( 307 'label' => __( 'The wp-content directory' ), 308 'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 309 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ), 310 ), 311 'uploads' => array( 312 'label' => __( 'The uploads directory' ), 313 'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 314 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ), 315 ), 316 'plugins' => array( 317 'label' => __( 'The plugins directory' ), 318 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 319 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ), 320 ), 321 'themes' => array( 322 'label' => __( 'The themes directory' ), 323 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ), 324 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ), 325 ), 239 326 ), 240 327 ); 241 328 … … 255 342 $site_count += get_blog_count( $network_id ); 256 343 } 257 344 258 $info['wp-core']['fields']['user_count'] 345 $info['wp-core']['fields']['user_count'] = array( 259 346 'label' => __( 'User count' ), 260 347 'value' => get_user_count(), 261 348 ); 262 $info['wp-core']['fields']['site_count'] = array( 349 350 $info['wp-core']['fields']['site_count'] = array( 263 351 'label' => __( 'Site count' ), 264 352 'value' => $site_count, 265 353 ); 354 266 355 $info['wp-core']['fields']['network_count'] = array( 267 356 'label' => __( 'Network count' ), 268 357 'value' => $network_query->found_networks, … … 277 366 } 278 367 279 368 // WordPress features requiring processing. 280 $wp_dotorg = wp_remote_get( 281 'https://wordpress.org', 282 array( 283 'timeout' => 10, 284 ) 285 ); 369 $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) ); 370 286 371 if ( ! is_wp_error( $wp_dotorg ) ) { 287 372 $info['wp-core']['fields']['dotorg_communication'] = array( 288 373 'label' => __( 'Communication with WordPress.org' ), 289 'value' => sprintf( 290 __( 'WordPress.org is reachable' ) 291 ), 374 'value' => __( 'WordPress.org is reachable' ), 375 'debug' => 'true', 292 376 ); 293 377 } else { 294 378 $info['wp-core']['fields']['dotorg_communication'] = array( … … 299 383 gethostbyname( 'wordpress.org' ), 300 384 $wp_dotorg->get_error_message() 301 385 ), 386 'debug' => $wp_dotorg->get_error_message(), 302 387 ); 303 388 } 304 389 … … 350 435 ), 351 436 ); 352 437 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; 438 $size_total = 0; 356 439 357 440 // Loop over all the directories we want to gather the sizes for. 358 441 foreach ( $size_directories as $size => $attributes ) { … … 364 447 365 448 if ( $dir_size === false ) { 366 449 // Error reading. 367 $dir_size = $inaccessible; 450 $size_directories[ $size ]['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' ); 451 $size_directories[ $size ]['debug'] = 'not accessible'; 452 368 453 // Stop total size calculation. 369 454 $size_total = null; 370 455 } elseif ( $dir_size === null ) { 371 456 // Timeout. 372 $dir_size = $timeout; 457 $size_directories[ $size ]['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' ); 458 $size_directories[ $size ]['debug'] = 'timeout while calculating size'; 459 373 460 // Stop total size calculation. 374 461 $size_total = null; 375 462 } else { … … 380 467 $size_total += $dir_size; 381 468 } 382 469 383 $ dir_size= size_format( $dir_size, 2 );470 $size_directories[ $size ]['size'] = size_format( $dir_size, 2 ); 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() 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, … … 692 854 // translators: 1: Plugin version number. 2: Plugin author name. 693 855 $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author ); 694 856 } 857 695 858 if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) { 696 859 // translators: %s: Plugin author name. 697 860 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author ); 861 $plugin_version = '(unknown)'; 698 862 } 863 699 864 if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) { 700 865 // translators: %s: Plugin version number. 701 866 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version ); 867 $plugin_author = '(unknown)'; 702 868 } 703 869 704 $info['wp-mu-plugins']['fields'][ sanitize_ key( $plugin['Name'] ) ] = array(870 $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array( 705 871 'label' => $plugin['Name'], 706 872 'value' => $plugin_version_string, 873 'debug' => sprintf( '%s by %s', $plugin_version, $plugin_author ), 707 874 ); 708 875 } 709 876 710 877 // List all available plugins. 711 $plugins 878 $plugins = get_plugins(); 712 879 $plugin_updates = get_plugin_updates(); 713 880 714 881 foreach ( $plugins as $plugin_path => $plugin ) { … … 718 885 $plugin_author = $plugin['Author']; 719 886 720 887 $plugin_version_string = __( 'No version or author information is available.' ); 888 $plugin_version_string_debug = 'undefined'; 721 889 722 890 if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) { 723 891 // translators: 1: Plugin version number. 2: Plugin author name. 724 892 $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author ); 893 $plugin_version_string_debug = sprintf( 'version %s by %s', $plugin_version, $plugin_author ); 725 894 } 895 726 896 if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) { 727 897 // translators: %s: Plugin author name. 728 898 $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author ); 899 $plugin_version_string_debug = sprintf( 'author: %s', $plugin_author ); 729 900 } 901 730 902 if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) { 731 903 // translators: %s: Plugin version number. 732 904 $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version ); 905 $plugin_version_string_debug = sprintf( 'version: %s', $plugin_version ); 733 906 } 734 907 735 908 if ( array_key_exists( $plugin_path, $plugin_updates ) ) { 736 909 // 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 = ''; 910 $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version ); 911 $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version ); 740 912 } 741 913 742 $info[ $plugin_part ]['fields'][ sanitize_ key( $plugin['Name'] ) ] = array(914 $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array( 743 915 'label' => $plugin['Name'], 744 'value' => $plugin_version_string . $plugin_update_needed, 916 'value' => $plugin_version_string, 917 'debug' => $plugin_version_string_debug, 745 918 ); 746 919 } 747 920 … … 748 921 // Populate the section for the currently active theme. 749 922 global $_wp_theme_features; 750 923 $theme_features = array(); 924 751 925 if ( ! empty( $_wp_theme_features ) ) { 752 926 foreach ( $_wp_theme_features as $feature => $options ) { 753 927 $theme_features[] = $feature; … … 757 931 $active_theme = wp_get_theme(); 758 932 $theme_updates = get_theme_updates(); 759 933 934 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 935 $active_theme_version = $active_theme->Version; 936 $active_theme_version_debug = $active_theme_version; 937 760 938 if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) { 939 $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version']; 940 761 941 // 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 = '';942 $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version ); 943 944 $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version ); 765 945 } 766 946 947 $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' ); 948 767 949 $info['wp-active-theme']['fields'] = array( 768 'name' 950 'name' => array( 769 951 'label' => __( 'Name' ), 770 952 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 771 953 'value' => $active_theme->Name, 772 954 ), 773 'version' 955 'version' => array( 774 956 'label' => __( 'Version' ), 775 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase776 ' value' => $active_theme->Version . $theme_update_needed_active,957 'value' => $active_theme_version, 958 'debug' => $active_theme_version_debug, 777 959 ), 778 'author' 960 'author' => array( 779 961 'label' => __( 'Author' ), 780 962 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 781 963 'value' => wp_kses( $active_theme->Author, array() ), … … 782 964 ), 783 965 'author_website' => array( 784 966 'label' => __( 'Author website' ), 785 'value' => ( $active_theme->offsetGet( 'Author URI' ) ? $active_theme->offsetGet( 'Author URI' ) : __( 'Undefined' ) ), 967 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ), 968 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : 'undefined' ), 786 969 ), 787 'parent_theme' 970 'parent_theme' => array( 788 971 'label' => __( 'Parent theme' ), 789 972 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme : __( 'None' ) ), 973 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme : 'none' ), 790 974 ), 791 975 'theme_features' => array( 792 976 'label' => __( 'Theme features' ), … … 807 991 // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 808 992 $theme_author = $theme->Author; 809 993 994 // Sanitize 995 $theme_author = wp_kses( $theme_author, array() ); 996 810 997 $theme_version_string = __( 'No version or author information is available.' ); 998 $theme_version_string_debug = 'undefined'; 811 999 812 1000 if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) { 813 1001 // 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() ) ); 1002 $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author ); 1003 $theme_version_string_debug = sprintf( 'version %s by %s', $theme_version, $theme_author ); 815 1004 } 1005 816 1006 if ( empty( $theme_version ) && ! empty( $theme_author ) ) { 817 1007 // translators: %s: Theme author name. 818 $theme_version_string = sprintf( __( 'By %s' ), wp_kses( $theme_author, array() ) ); 1008 $theme_version_string = sprintf( __( 'By %s' ), $theme_author ); 1009 $theme_version_string_debug = sprintf( 'author: %s', $theme_author ); 819 1010 } 1011 820 1012 if ( ! empty( $theme_version ) && empty( $theme_author ) ) { 821 1013 // translators: %s: Theme version number. 822 1014 $theme_version_string = sprintf( __( 'Version %s' ), $theme_version ); 1015 $theme_version_string_debug = sprintf( 'version %s', $theme_version ); 823 1016 } 824 1017 825 1018 if ( array_key_exists( $theme_slug, $theme_updates ) ) { 826 1019 // 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 = ''; 1020 $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] ); 1021 $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] ); 830 1022 } 831 1023 832 $info['wp-themes']['fields'][ sanitize_ key( $theme->Name ) ] = array(1024 $info['wp-themes']['fields'][ sanitize_text_field( $theme->Name ) ] = array( 833 1025 'label' => sprintf( 834 1026 // translators: 1: Theme name. 2: Theme slug. 835 1027 __( '%1$s (%2$s)' ), … … 837 1029 $theme->Name, 838 1030 $theme_slug 839 1031 ), 840 'value' => $theme_version_string . $theme_update_needed, 1032 'value' => $theme_version_string, 1033 'debug' => $theme_version_string_debug, 841 1034 ); 842 1035 } 843 1036 844 1037 // Add more filesystem checks 845 1038 if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) { 1039 $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR ); 1040 846 1041 $info['wp-filesystem']['fields']['mu_plugin_directory'] = array( 847 1042 'label' => __( 'The must use plugins directory' ), 848 'value' => ( wp_is_writable( WPMU_PLUGIN_DIR ) ? __( 'Writable' ) : __( 'Not writable' ) ), 1043 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ), 1044 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), 849 1045 ); 850 1046 } 851 1047 … … 882 1078 */ 883 1079 $info = apply_filters( 'debug_information', $info ); 884 1080 885 if ( ! empty( $locale ) ) {886 // Change the language used for translations887 if ( $switched_locale ) {888 restore_previous_locale();889 }890 }891 892 1081 return $info; 893 1082 } 894 1083 … … 898 1087 * @since 5.2.0 899 1088 * 900 1089 * @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'.1090 * @param string $type The data type to return, either 'info' or 'debug'. 902 1091 * @return string The formatted data. 903 1092 */ 904 public static function format( $info_array, $type = 'text') {1093 public static function format( $info_array, $type ) { 905 1094 $return = "`\n"; 906 1095 907 1096 foreach ( $info_array as $section => $details ) { … … 909 1098 if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) { 910 1099 continue; 911 1100 } 1101 1102 $section_label = $type === 'debug' ? $section : $details['label']; 912 1103 913 1104 $return .= sprintf( 914 1105 "### %s%s ###\n\n", 915 $ details['label'],1106 $section_label, 916 1107 ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' ) 917 1108 ); 918 1109 919 foreach ( $details['fields'] as $field ) {1110 foreach ( $details['fields'] as $field_name => $field ) { 920 1111 if ( isset( $field['private'] ) && true === $field['private'] ) { 921 1112 continue; 922 1113 } 923 1114 924 $values = $field['value']; 925 if ( is_array( $field['value'] ) ) { 926 $values = ''; 1115 if ( $type === 'debug' && isset( $field['debug'] ) ) { 1116 $debug_data = $field['debug']; 1117 } else { 1118 $debug_data = $field['value']; 1119 } 927 1120 1121 // Can be array, one level deep only. 1122 if ( is_array( $debug_data ) ) { 1123 $value = ''; 1124 928 1125 foreach ( $field['value'] as $name => $value ) { 929 $values .= sprintf( 930 "\n\t%s: %s", 931 $name, 932 $value 933 ); 1126 $value .= sprintf( "\n\t%s: %s", $name, $value ); 934 1127 } 1128 } elseif ( is_bool( $debug_data ) ) { 1129 $value = $debug_data ? 'true' : 'false'; 1130 } elseif ( empty( $debug_data ) ) { 1131 $value = 'undefined'; 1132 } else { 1133 $value = $debug_data; 935 1134 } 936 1135 937 $return .= sprintf( 938 "%s: %s\n", 939 $field['label'], 940 $values 941 ); 1136 if ( $type === 'debug' ) { 1137 $label = $field_name; 1138 } else { 1139 $label = $field['label']; 1140 } 1141 1142 $return .= sprintf( "%s: %s\n", $label, $value ); 942 1143 } 1144 943 1145 $return .= "\n"; 944 1146 } 945 1147 -
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 button-primary copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'info' ) ); ?>"><?php _e( 'Copy site info to clipboard' ); ?></button> 90 87 <span class="success" aria-hidden="true">Copied!</span> 91 88 </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; ?> 89 <div class="copy-button-wrapper"> 90 <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>"> 91 <?php 92 if ( strpos( get_user_locale(), 'en' ) !== 0 ) { 93 _e( 'Copy site debug data to clipboard (in English)' ); 94 } else { 95 _e( 'Copy site debug data to clipboard' ); 96 } 97 ?> 98 </button> 99 <?php 100 101 ?> 102 <span class="success" aria-hidden="true">Copied!</span> 103 </div> 98 104 </div> 99 105 100 106 <div id="health-check-debug" class="health-check-accordion">