Server and Site Info Widget
Adds a dashboard widget with the PHP, database and WordPress versions, memory limit, upload limit and active theme at a glance.
Opens WPIDE on
Code
add_action( 'wp_dashboard_setup', function () {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_server_info', 'Server Info', function () {
global $wpdb;
$theme = wp_get_theme();
$rows = array(
'WordPress' => get_bloginfo( 'version' ),
'PHP' => PHP_VERSION,
'Database' => $wpdb->db_server_info(),
'Web server' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : 'Unknown',
'PHP memory limit' => ini_get( 'memory_limit' ),
'WP memory limit' => WP_MEMORY_LIMIT,
'Max upload size' => size_format( wp_max_upload_size() ),
'Max execution time' => ini_get( 'max_execution_time' ) . 's',
'Environment' => wp_get_environment_type(),
'Active theme' => $theme->get( 'Name' ) . ' ' . $theme->get( 'Version' ),
'Object cache' => wp_using_ext_object_cache() ? 'Persistent' : 'None',
);
echo '<table class="widefat striped"><tbody>';
foreach ( $rows as $label => $value ) {
printf( '<tr><th scope="row" style="width:45%%">%s</th><td><code>%s</code></td></tr>', esc_html( $label ), esc_html( (string) $value ) );
}
echo '</tbody></table>';
} );
} );
Notes
Only administrators see the widget.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.