Gets the WordPress server section of the debug data.
Source
private static function get_wp_server(): array {
// Populate the server debug fields.
if ( function_exists( 'php_uname' ) ) {
$server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
} else {
$server_architecture = 'unknown';
}
$php_version_debug = PHP_VERSION;
// Whether PHP supports 64-bit.
$php64bit = ( PHP_INT_SIZE * 8 === 64 );
$php_version = sprintf(
'%s %s',
$php_version_debug,
( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
);
if ( $php64bit ) {
$php_version_debug .= ' 64bit';
}
$fields = array();
$fields['server_architecture'] = array(
'label' => __( 'Server architecture' ),
'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
'debug' => $server_architecture,
);
$fields['httpd_software'] = array(
'label' => __( 'Web server' ),
'value' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : __( 'Unable to determine what web server software is used' ),
'debug' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : 'unknown',
);
$fields['php_version'] = array(
'label' => __( 'PHP version' ),
'value' => $php_version,
'debug' => $php_version_debug,
);
$fields['php_sapi'] = array(
'label' => __( 'PHP SAPI' ),
'value' => PHP_SAPI,
'debug' => PHP_SAPI,
);
// Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
if ( ! function_exists( 'ini_get' ) ) {
$fields['ini_get'] = array(
'label' => __( 'Server settings' ),
'value' => sprintf(
/* translators: %s: ini_get() */
__( 'Unable to determine some settings, as the %s function has been disabled.' ),
'ini_get()'
),
'debug' => 'ini_get() is disabled',
);
} else {
$fields['max_input_variables'] = array(
'label' => __( 'PHP max input variables' ),
'value' => ini_get( 'max_input_vars' ),
);
$fields['time_limit'] = array(
'label' => __( 'PHP time limit' ),
'value' => ini_get( 'max_execution_time' ),
);
if ( WP_Site_Health::get_instance()->php_memory_limit !== ini_get( 'memory_limit' ) ) {
$fields['memory_limit'] = array(
'label' => __( 'PHP memory limit' ),
'value' => WP_Site_Health::get_instance()->php_memory_limit,
);
$fields['admin_memory_limit'] = array(
'label' => __( 'PHP memory limit (only for admin screens)' ),
'value' => ini_get( 'memory_limit' ),
);
} else {
$fields['memory_limit'] = array(
'label' => __( 'PHP memory limit' ),
'value' => ini_get( 'memory_limit' ),
);
}
$fields['max_input_time'] = array(
'label' => __( 'Max input time' ),
'value' => ini_get( 'max_input_time' ),
);
$fields['upload_max_filesize'] = array(
'label' => __( 'Upload max filesize' ),
'value' => ini_get( 'upload_max_filesize' ),
);
$fields['php_post_max_size'] = array(
'label' => __( 'PHP post max size' ),
'value' => ini_get( 'post_max_size' ),
);
}
if ( function_exists( 'curl_version' ) ) {
$curl = curl_version();
$fields['curl_version'] = array(
'label' => __( 'cURL version' ),
'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
);
} else {
$fields['curl_version'] = array(
'label' => __( 'cURL version' ),
'value' => __( 'Not available' ),
'debug' => 'not available',
);
}
// SUHOSIN.
$suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
$fields['suhosin'] = array(
'label' => __( 'Is SUHOSIN installed?' ),
'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),
'debug' => $suhosin_loaded,
);
// Imagick.
$imagick_loaded = extension_loaded( 'imagick' );
$fields['imagick_availability'] = array(
'label' => __( 'Is the Imagick library available?' ),
'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),
'debug' => $imagick_loaded,
);
// Opcode Cache.
if ( function_exists( 'opcache_get_status' ) ) {
$opcache_status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Warning emitted in failure case.
if ( false === $opcache_status ) {
$fields['opcode_cache'] = array(
'label' => __( 'Opcode cache' ),
'value' => __( 'Disabled by configuration' ),
'debug' => 'not available',
);
} else {
$fields['opcode_cache'] = array(
'label' => __( 'Opcode cache' ),
'value' => $opcache_status['opcache_enabled'] ? __( 'Enabled' ) : __( 'Disabled' ),
'debug' => $opcache_status['opcache_enabled'],
);
if ( true === $opcache_status['opcache_enabled'] ) {
$fields['opcode_cache_memory_usage'] = array(
'label' => __( 'Opcode cache memory usage' ),
'value' => sprintf(
/* translators: 1: Used memory, 2: Total memory */
__( '%1$s of %2$s' ),
size_format( $opcache_status['memory_usage']['used_memory'] ),
size_format( $opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory'] )
),
'debug' => sprintf(
'%s of %s',
$opcache_status['memory_usage']['used_memory'],
$opcache_status['memory_usage']['free_memory'] + $opcache_status['memory_usage']['used_memory']
),
);
if ( 0 !== $opcache_status['interned_strings_usage']['buffer_size'] ) {
$fields['opcode_cache_interned_strings_usage'] = array(
'label' => __( 'Opcode cache interned strings usage' ),
'value' => sprintf(
/* translators: 1: Percentage used, 2: Total memory, 3: Free memory */
__( '%1$s%% of %2$s (%3$s free)' ),
number_format_i18n( ( $opcache_status['interned_strings_usage']['used_memory'] / $opcache_status['interned_strings_usage']['buffer_size'] ) * 100, 2 ),
size_format( $opcache_status['interned_strings_usage']['buffer_size'] ),
size_format( $opcache_status['interned_strings_usage']['free_memory'] )
),
'debug' => sprintf(
'%s%% of %s (%s free)',
round( ( $opcache_status['interned_strings_usage']['used_memory'] / $opcache_status['interned_strings_usage']['buffer_size'] ) * 100, 2 ),
$opcache_status['interned_strings_usage']['buffer_size'],
$opcache_status['interned_strings_usage']['free_memory']
),
);
}
$fields['opcode_cache_hit_rate'] = array(
'label' => __( 'Opcode cache hit rate' ),
'value' => sprintf(
/* translators: %s: Hit rate percentage */
__( '%s%%' ),
number_format_i18n( $opcache_status['opcache_statistics']['opcache_hit_rate'], 2 )
),
'debug' => round( $opcache_status['opcache_statistics']['opcache_hit_rate'], 2 ),
);
$fields['opcode_cache_full'] = array(
'label' => __( 'Is the Opcode cache full?' ),
'value' => $opcache_status['cache_full'] ? __( 'Yes' ) : __( 'No' ),
'debug' => $opcache_status['cache_full'],
);
}
}
} else {
$fields['opcode_cache'] = array(
'label' => __( 'Opcode cache' ),
'value' => __( 'Disabled' ),
'debug' => 'not available',
);
}
// Pretty permalinks.
$pretty_permalinks_supported = got_url_rewrite();
$fields['pretty_permalinks'] = array(
'label' => __( 'Are pretty permalinks supported?' ),
'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),
'debug' => $pretty_permalinks_supported,
);
// Check if a .htaccess file exists.
if ( is_file( ABSPATH . '.htaccess' ) ) {
// If the file exists, grab the content of it.
$htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
// Filter away the core WordPress rules.
$filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
$filtered_htaccess_content = ! empty( $filtered_htaccess_content );
if ( $filtered_htaccess_content ) {
/* translators: %s: .htaccess */
$htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );
} else {
/* translators: %s: .htaccess */
$htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );
}
$fields['htaccess_extra_rules'] = array(
'label' => __( '.htaccess rules' ),
'value' => $htaccess_rules_string,
'debug' => $filtered_htaccess_content,
);
}
// Check if a robots.txt file exists.
if ( is_file( get_home_path() . 'robots.txt' ) ) {
// If the file exists, turn debug info to true.
$robotstxt_debug = true;
/* translators: %s: robots.txt */
$robotstxt_string = sprintf( __( 'Your site is using a static %s file. WordPress cannot dynamically serve one.' ), 'robots.txt' );
} elseif ( got_url_rewrite() ) {
// No robots.txt file available and rewrite rules in place, turn debug info to false.
$robotstxt_debug = false;
/* translators: %s: robots.txt */
$robotstxt_string = sprintf( __( 'Your site is using the dynamic %s file which is generated by WordPress.' ), 'robots.txt' );
} else {
// No robots.txt file, but without rewrite rules WP can't serve one.
$robotstxt_debug = true;
/* translators: %s: robots.txt */
$robotstxt_string = sprintf( __( 'WordPress cannot dynamically serve a %s file due to a lack of rewrite rule support.' ), 'robots.txt' );
}
$fields['static_robotstxt_file'] = array(
'label' => __( 'robots.txt' ),
'value' => $robotstxt_string,
'debug' => $robotstxt_debug,
);
// Server time.
$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
$fields['current'] = array(
'label' => __( 'Current time' ),
'value' => $date->format( DateTime::ATOM ),
);
$fields['utc-time'] = array(
'label' => __( 'Current UTC time' ),
'value' => $date->format( DateTime::RFC850 ),
);
$fields['server-time'] = array(
'label' => __( 'Current Server time' ),
'value' => isset( $_SERVER['REQUEST_TIME'] ) ? wp_date( 'c', (int) $_SERVER['REQUEST_TIME'] ) : __( 'Unable to determine server time' ),
);
return array(
'label' => __( 'Server' ),
'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ),
'fields' => $fields,
);
}
Changelog
| Version | Description |
|---|---|
| 6.7.0 | Introduced. |

User Contributed Notes
You must log in before being able to contribute a note or feedback.