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