26 * @since 5.3.0 Added database charset, database collation, |
27 * @since 5.3.0 Added database charset, database collation, |
27 * and timezone information. |
28 * and timezone information. |
28 * @since 5.5.0 Added pretty permalinks support information. |
29 * @since 5.5.0 Added pretty permalinks support information. |
29 * |
30 * |
30 * @throws ImagickException |
31 * @throws ImagickException |
31 * @global wpdb $wpdb WordPress database abstraction object. |
32 * @global wpdb $wpdb WordPress database abstraction object. |
|
33 * @global array $_wp_theme_features |
32 * |
34 * |
33 * @return array The debug data for the site. |
35 * @return array The debug data for the site. |
34 */ |
36 */ |
35 public static function debug_data() { |
37 public static function debug_data() { |
36 global $wpdb; |
38 global $wpdb, $_wp_theme_features; |
37 |
39 |
38 // Save few function calls. |
40 // Save few function calls. |
39 $upload_dir = wp_upload_dir(); |
41 $upload_dir = wp_upload_dir(); |
40 $permalink_structure = get_option( 'permalink_structure' ); |
42 $permalink_structure = get_option( 'permalink_structure' ); |
41 $is_ssl = is_ssl(); |
43 $is_ssl = is_ssl(); |
233 $compress_css = __( 'Undefined' ); |
236 $compress_css = __( 'Undefined' ); |
234 $compress_css_debug = 'undefined'; |
237 $compress_css_debug = 'undefined'; |
235 } |
238 } |
236 |
239 |
237 // Check WP_ENVIRONMENT_TYPE. |
240 // Check WP_ENVIRONMENT_TYPE. |
238 if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) { |
241 if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) { |
239 $wp_environment_type = WP_ENVIRONMENT_TYPE; |
242 $wp_environment_type = WP_ENVIRONMENT_TYPE; |
240 } else { |
243 } else { |
241 $wp_environment_type = __( 'Undefined' ); |
244 $wp_environment_type = __( 'Undefined' ); |
242 } |
245 } |
243 |
246 |
319 'WP_ENVIRONMENT_TYPE' => array( |
322 'WP_ENVIRONMENT_TYPE' => array( |
320 'label' => 'WP_ENVIRONMENT_TYPE', |
323 'label' => 'WP_ENVIRONMENT_TYPE', |
321 'value' => $wp_environment_type, |
324 'value' => $wp_environment_type, |
322 'debug' => $wp_environment_type, |
325 'debug' => $wp_environment_type, |
323 ), |
326 ), |
|
327 'WP_DEVELOPMENT_MODE' => array( |
|
328 'label' => 'WP_DEVELOPMENT_MODE', |
|
329 'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ), |
|
330 'debug' => WP_DEVELOPMENT_MODE, |
|
331 ), |
324 'DB_CHARSET' => array( |
332 'DB_CHARSET' => array( |
325 'label' => 'DB_CHARSET', |
333 'label' => 'DB_CHARSET', |
326 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ), |
334 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ), |
327 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ), |
335 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ), |
328 ), |
336 ), |
337 $is_writable_abspath = wp_is_writable( ABSPATH ); |
345 $is_writable_abspath = wp_is_writable( ABSPATH ); |
338 $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR ); |
346 $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR ); |
339 $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] ); |
347 $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] ); |
340 $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR ); |
348 $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR ); |
341 $is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) ); |
349 $is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) ); |
|
350 $is_writable_fonts_dir = wp_is_writable( wp_get_font_dir()['basedir'] ); |
342 |
351 |
343 $info['wp-filesystem'] = array( |
352 $info['wp-filesystem'] = array( |
344 'label' => __( 'Filesystem Permissions' ), |
353 'label' => __( 'Filesystem Permissions' ), |
345 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ), |
354 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ), |
346 'fields' => array( |
355 'fields' => array( |
367 'themes' => array( |
376 'themes' => array( |
368 'label' => __( 'The themes directory' ), |
377 'label' => __( 'The themes directory' ), |
369 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ), |
378 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ), |
370 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ), |
379 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ), |
371 ), |
380 ), |
|
381 'fonts' => array( |
|
382 'label' => __( 'The fonts directory' ), |
|
383 'value' => ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) ), |
|
384 'debug' => ( $is_writable_fonts_dir ? 'writable' : 'not writable' ), |
|
385 ), |
372 ), |
386 ), |
373 ); |
387 ); |
374 |
388 |
375 // Conditionally add debug information for multisite setups. |
389 // Conditionally add debug information for multisite setups. |
376 if ( is_multisite() ) { |
390 if ( is_multisite() ) { |
|
391 $site_id = get_current_blog_id(); |
|
392 |
|
393 $info['wp-core']['fields']['site_id'] = array( |
|
394 'label' => __( 'Site ID' ), |
|
395 'value' => $site_id, |
|
396 'debug' => $site_id, |
|
397 ); |
|
398 |
377 $network_query = new WP_Network_Query(); |
399 $network_query = new WP_Network_Query(); |
378 $network_ids = $network_query->query( |
400 $network_ids = $network_query->query( |
379 array( |
401 array( |
380 'fields' => 'ids', |
402 'fields' => 'ids', |
381 'number' => 100, |
403 'number' => 100, |
465 'plugins_size' => array( |
487 'plugins_size' => array( |
466 'label' => __( 'Plugins directory size' ), |
488 'label' => __( 'Plugins directory size' ), |
467 'value' => $loading, |
489 'value' => $loading, |
468 'debug' => 'loading...', |
490 'debug' => 'loading...', |
469 ), |
491 ), |
|
492 'fonts_path' => array( |
|
493 'label' => __( 'Fonts directory location' ), |
|
494 'value' => wp_get_font_dir()['basedir'], |
|
495 ), |
|
496 'fonts_size' => array( |
|
497 'label' => __( 'Fonts directory size' ), |
|
498 'value' => $loading, |
|
499 'debug' => 'loading...', |
|
500 ), |
470 'database_size' => array( |
501 'database_size' => array( |
471 'label' => __( 'Database size' ), |
502 'label' => __( 'Database size' ), |
472 'value' => $loading, |
503 'value' => $loading, |
473 'debug' => 'loading...', |
504 'debug' => 'loading...', |
474 ), |
505 ), |
539 ), |
570 ), |
540 'debug' => 'ini_get() is disabled', |
571 'debug' => 'ini_get() is disabled', |
541 ); |
572 ); |
542 } else { |
573 } else { |
543 // Get the PHP ini directive values. |
574 // Get the PHP ini directive values. |
|
575 $file_uploads = ini_get( 'file_uploads' ); |
544 $post_max_size = ini_get( 'post_max_size' ); |
576 $post_max_size = ini_get( 'post_max_size' ); |
545 $upload_max_filesize = ini_get( 'upload_max_filesize' ); |
577 $upload_max_filesize = ini_get( 'upload_max_filesize' ); |
546 $max_file_uploads = ini_get( 'max_file_uploads' ); |
578 $max_file_uploads = ini_get( 'max_file_uploads' ); |
547 $effective = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) ); |
579 $effective = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) ); |
548 |
580 |
549 // Add info in Media section. |
581 // Add info in Media section. |
550 $info['wp-media']['fields']['file_uploads'] = array( |
582 $info['wp-media']['fields']['file_uploads'] = array( |
551 'label' => __( 'File uploads' ), |
583 'label' => __( 'File uploads' ), |
552 'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ), |
584 'value' => $file_uploads ? __( 'Enabled' ) : __( 'Disabled' ), |
553 'debug' => 'File uploads is turned off', |
585 'debug' => $file_uploads, |
554 ); |
586 ); |
555 $info['wp-media']['fields']['post_max_size'] = array( |
587 $info['wp-media']['fields']['post_max_size'] = array( |
556 'label' => __( 'Max size of post data allowed' ), |
588 'label' => __( 'Max size of post data allowed' ), |
557 'value' => $post_max_size, |
589 'value' => $post_max_size, |
558 ); |
590 ); |
577 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ), |
609 '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 ), |
610 '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 ), |
611 '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 ), |
612 '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 ), |
613 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ), |
|
614 'time' => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : $not_available ), |
582 ); |
615 ); |
583 |
616 |
584 $limits_debug = array( |
617 $limits_debug = array( |
585 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ), |
618 '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' ), |
619 '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' ), |
620 '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' ), |
621 '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' ), |
622 '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' ), |
623 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ), |
|
624 'imagick::RESOURCETYPE_TIME' => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : 'not available' ), |
591 ); |
625 ); |
592 |
626 |
593 $info['wp-media']['fields']['imagick_limits'] = array( |
627 $info['wp-media']['fields']['imagick_limits'] = array( |
594 'label' => __( 'Imagick Resource Limits' ), |
628 'label' => __( 'Imagick Resource Limits' ), |
595 'value' => $limits, |
629 'value' => $limits, |
675 $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ); |
709 $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ); |
676 } else { |
710 } else { |
677 $server_architecture = 'unknown'; |
711 $server_architecture = 'unknown'; |
678 } |
712 } |
679 |
713 |
680 if ( function_exists( 'phpversion' ) ) { |
714 $php_version_debug = PHP_VERSION; |
681 $php_version_debug = phpversion(); |
715 // Whether PHP supports 64-bit. |
682 // Whether PHP supports 64-bit. |
716 $php64bit = ( PHP_INT_SIZE * 8 === 64 ); |
683 $php64bit = ( PHP_INT_SIZE * 8 === 64 ); |
717 |
684 |
718 $php_version = sprintf( |
685 $php_version = sprintf( |
719 '%s %s', |
686 '%s %s', |
720 $php_version_debug, |
687 $php_version_debug, |
721 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) ) |
688 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) ) |
722 ); |
689 ); |
723 |
690 |
724 if ( $php64bit ) { |
691 if ( $php64bit ) { |
725 $php_version_debug .= ' 64bit'; |
692 $php_version_debug .= ' 64bit'; |
|
693 } |
|
694 } else { |
|
695 $php_version = __( 'Unable to determine PHP version' ); |
|
696 $php_version_debug = 'unknown'; |
|
697 } |
|
698 |
|
699 if ( function_exists( 'php_sapi_name' ) ) { |
|
700 $php_sapi = php_sapi_name(); |
|
701 } else { |
|
702 $php_sapi = 'unknown'; |
|
703 } |
726 } |
704 |
727 |
705 $info['wp-server']['fields']['server_architecture'] = array( |
728 $info['wp-server']['fields']['server_architecture'] = array( |
706 'label' => __( 'Server architecture' ), |
729 'label' => __( 'Server architecture' ), |
707 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ), |
730 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ), |
717 'value' => $php_version, |
740 'value' => $php_version, |
718 'debug' => $php_version_debug, |
741 'debug' => $php_version_debug, |
719 ); |
742 ); |
720 $info['wp-server']['fields']['php_sapi'] = array( |
743 $info['wp-server']['fields']['php_sapi'] = array( |
721 'label' => __( 'PHP SAPI' ), |
744 'label' => __( 'PHP SAPI' ), |
722 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI' ) ), |
745 'value' => PHP_SAPI, |
723 'debug' => $php_sapi, |
746 'debug' => PHP_SAPI, |
724 ); |
747 ); |
725 |
748 |
726 // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values. |
749 // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values. |
727 if ( ! function_exists( 'ini_get' ) ) { |
750 if ( ! function_exists( 'ini_get' ) ) { |
728 $info['wp-server']['fields']['ini_get'] = array( |
751 $info['wp-server']['fields']['ini_get'] = array( |
838 'value' => $htaccess_rules_string, |
861 'value' => $htaccess_rules_string, |
839 'debug' => $filtered_htaccess_content, |
862 'debug' => $filtered_htaccess_content, |
840 ); |
863 ); |
841 } |
864 } |
842 |
865 |
|
866 // Server time. |
|
867 $date = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); |
|
868 |
|
869 $info['wp-server']['fields']['current'] = array( |
|
870 'label' => __( 'Current time' ), |
|
871 'value' => $date->format( DateTime::ATOM ), |
|
872 ); |
|
873 $info['wp-server']['fields']['utc-time'] = array( |
|
874 'label' => __( 'Current UTC time' ), |
|
875 'value' => $date->format( DateTime::RFC850 ), |
|
876 ); |
|
877 $info['wp-server']['fields']['server-time'] = array( |
|
878 'label' => __( 'Current Server time' ), |
|
879 'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ), |
|
880 ); |
|
881 |
843 // Populate the database debug fields. |
882 // Populate the database debug fields. |
844 if ( is_resource( $wpdb->dbh ) ) { |
883 if ( is_object( $wpdb->dbh ) ) { |
845 // Old mysql extension. |
|
846 $extension = 'mysql'; |
|
847 } elseif ( is_object( $wpdb->dbh ) ) { |
|
848 // mysqli or PDO. |
884 // mysqli or PDO. |
849 $extension = get_class( $wpdb->dbh ); |
885 $extension = get_class( $wpdb->dbh ); |
850 } else { |
886 } else { |
851 // Unknown sql extension. |
887 // Unknown sql extension. |
852 $extension = null; |
888 $extension = null; |
853 } |
889 } |
854 |
890 |
855 $server = $wpdb->get_var( 'SELECT VERSION()' ); |
891 $server = $wpdb->get_var( 'SELECT VERSION()' ); |
856 |
892 |
857 if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) { |
893 $client_version = $wpdb->dbh->client_info; |
858 $client_version = $wpdb->dbh->client_info; |
|
859 } else { |
|
860 // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved |
|
861 if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) { |
|
862 $client_version = $matches[0]; |
|
863 } else { |
|
864 $client_version = null; |
|
865 } |
|
866 } |
|
867 |
894 |
868 $info['wp-database']['fields']['extension'] = array( |
895 $info['wp-database']['fields']['extension'] = array( |
869 'label' => __( 'Extension' ), |
896 'label' => __( 'Extension' ), |
870 'value' => $extension, |
897 'value' => $extension, |
871 ); |
898 ); |
1066 'debug' => $plugin_version_string_debug, |
1093 'debug' => $plugin_version_string_debug, |
1067 ); |
1094 ); |
1068 } |
1095 } |
1069 |
1096 |
1070 // Populate the section for the currently active theme. |
1097 // Populate the section for the currently active theme. |
1071 global $_wp_theme_features; |
|
1072 $theme_features = array(); |
1098 $theme_features = array(); |
1073 |
1099 |
1074 if ( ! empty( $_wp_theme_features ) ) { |
1100 if ( ! empty( $_wp_theme_features ) ) { |
1075 foreach ( $_wp_theme_features as $feature => $options ) { |
1101 foreach ( $_wp_theme_features as $feature => $options ) { |
1076 $theme_features[] = $feature; |
1102 $theme_features[] = $feature; |
1397 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), |
1423 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ), |
1398 ); |
1424 ); |
1399 } |
1425 } |
1400 |
1426 |
1401 /** |
1427 /** |
1402 * Add to or modify the debug information shown on the Tools -> Site Health -> Info screen. |
1428 * Filters the debug information shown on the Tools -> Site Health -> Info screen. |
1403 * |
1429 * |
1404 * Plugin or themes may wish to introduce their own debug information without creating |
1430 * Plugin or themes may wish to introduce their own debug information without creating |
1405 * additional admin pages. They can utilize this filter to introduce their own sections |
1431 * additional admin pages. They can utilize this filter to introduce their own sections |
1406 * or add more data to existing sections. |
1432 * or add more data to existing sections. |
1407 * |
1433 * |
1597 */ |
1625 */ |
1598 if ( function_exists( 'ini_get' ) ) { |
1626 if ( function_exists( 'ini_get' ) ) { |
1599 $max_execution_time = ini_get( 'max_execution_time' ); |
1627 $max_execution_time = ini_get( 'max_execution_time' ); |
1600 } |
1628 } |
1601 |
1629 |
1602 // The max_execution_time defaults to 0 when PHP runs from cli. |
1630 /* |
1603 // We still want to limit it below. |
1631 * The max_execution_time defaults to 0 when PHP runs from cli. |
|
1632 * We still want to limit it below. |
|
1633 */ |
1604 if ( empty( $max_execution_time ) ) { |
1634 if ( empty( $max_execution_time ) ) { |
1605 $max_execution_time = 30; |
1635 $max_execution_time = 30; // 30 seconds. |
1606 } |
1636 } |
1607 |
1637 |
1608 if ( $max_execution_time > 20 ) { |
1638 if ( $max_execution_time > 20 ) { |
1609 // If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent |
1639 /* |
1610 // edge-case timeouts that may happen after the size loop has finished running. |
1640 * If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent |
|
1641 * edge-case timeouts that may happen after the size loop has finished running. |
|
1642 */ |
1611 $max_execution_time -= 2; |
1643 $max_execution_time -= 2; |
1612 } |
1644 } |
1613 |
1645 |
1614 // Go through the various installation directories and calculate their sizes. |
1646 /* |
1615 // No trailing slashes. |
1647 * Go through the various installation directories and calculate their sizes. |
|
1648 * No trailing slashes. |
|
1649 */ |
1616 $paths = array( |
1650 $paths = array( |
1617 'wordpress_size' => untrailingslashit( ABSPATH ), |
1651 'wordpress_size' => untrailingslashit( ABSPATH ), |
1618 'themes_size' => get_theme_root(), |
1652 'themes_size' => get_theme_root(), |
1619 'plugins_size' => WP_PLUGIN_DIR, |
1653 'plugins_size' => WP_PLUGIN_DIR, |
1620 'uploads_size' => $upload_dir['basedir'], |
1654 'uploads_size' => $upload_dir['basedir'], |
|
1655 'fonts_size' => wp_get_font_dir()['basedir'], |
1621 ); |
1656 ); |
1622 |
1657 |
1623 $exclude = $paths; |
1658 $exclude = $paths; |
1624 unset( $exclude['wordpress_size'] ); |
1659 unset( $exclude['wordpress_size'] ); |
1625 $exclude = array_values( $exclude ); |
1660 $exclude = array_values( $exclude ); |
1633 $results = array( |
1668 $results = array( |
1634 'path' => $path, |
1669 'path' => $path, |
1635 'raw' => 0, |
1670 'raw' => 0, |
1636 ); |
1671 ); |
1637 |
1672 |
|
1673 // If the directory does not exist, skip checking it, as it will skew the other results. |
|
1674 if ( ! is_dir( $path ) ) { |
|
1675 $all_sizes[ $name ] = array( |
|
1676 'path' => $path, |
|
1677 'raw' => 0, |
|
1678 'size' => __( 'The directory does not exist.' ), |
|
1679 'debug' => 'directory not found', |
|
1680 ); |
|
1681 |
|
1682 continue; |
|
1683 } |
|
1684 |
1638 if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) { |
1685 if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) { |
1639 if ( 'wordpress_size' === $name ) { |
1686 if ( 'wordpress_size' === $name ) { |
1640 $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time ); |
1687 $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time ); |
1641 } else { |
1688 } else { |
1642 $dir_size = recurse_dirsize( $path, null, $max_execution_time ); |
1689 $dir_size = recurse_dirsize( $path, null, $max_execution_time ); |