Disk Usage Widget

The Disk Usage Widget module adds a dashboard widget that shows detailed WordPress disk usage statistics, including core, database, plugins, themes, and uploads. With built-in alerts and customizable thresholds, it helps administrators monitor storage and prevent performance issues.

How to use

To enable the Disk Usage Widget Module:

  1. Click on the “Utilities” category
  2. Search or scroll to locate the Disk Usage Widget Module
  3. Click on the switch to enable

What’s next?

The widget will appear on your WordPress dashboard, showing detailed disk usage information.

1. Understanding the Widget

The Disk Usage Widget provides three main sections:

Current Installation

  • WordPress Size: Size of your WordPress core files
  • Database Size: Size of your WordPress database
  • Full Website Size: Combined size of WordPress and database

WP Content Sizes

Detailed breakdown of your wp-content directory:

  • Plugins
  • Themes
  • Uploads
  • Languages
  • Upgrade
  • Backup
  • Cache

Server Space

  • Used Disk Space: Total disk space used
  • Free Disk Space: Available disk space
  • Total Disk Space: Total disk capacity

2. Threshold Alerts

The widget includes built-in thresholds that trigger warnings or errors:

  • Warning: When usage approaches a threshold (default: 80% of limit)
  • Error: When usage exceeds a threshold

3. Default Thresholds

  • WordPress Core: Warning at 200MB, Error at 250MB
  • Database: Warning at 800MB, Error at 1GB
  • Uploads: Warning at 40GB, Error at 50GB
  • Disk Space: Warning at 90% usage

4. Customizing Thresholds

You can customize thresholds using filters:

add_filter('wpextended/disk_usage/thresholds', function($thresholds) {
// Change WordPress core warning threshold to 150MB
$thresholds['wordpress_size']['size'] = '150MB';

// Change database warning percentage to 70%
$thresholds['database_size']['percentage'] = 70;

// Change uploads warning threshold to 20GB
$thresholds['wp_content_directories']['uploads']['size'] = '20GB';

return $thresholds;
});

5. Best Practices

  1. Monitor Regularly: Check the widget periodically to stay informed about your disk usage
  2. Clean Up: Remove unused plugins, themes, and media files
  3. Backup: Always back up your site before making significant changes
  4. Optimize Database: Use database optimization plugins to keep your database lean

6. Troubleshooting

If the widget isn’t displaying correctly:

  1. Ensure your web server has permissions to read disk usage
  2. Check for any PHP errors in your debug log
  3. Verify that your server’s PHP configuration allows the necessary functions:
    • disk_free_space()
    • disk_total_space()
    • Directory iteration functions

7. Security Notes

  • The widget only shows information to administrators
  • No sensitive file paths or database information is exposed
  • All data is sanitized before display

8. Performance Considerations

  • The widget performs disk scans when loaded
  • On large sites, loading might be slower
  • The widget caches results to minimize performance impact

9. Custom Development

For developers, you can extend the widget’s functionality:

// Add custom directory to WP Content Sizes
add_filter('wpextended/disk_usage/wp_content_directories', function($directories) {
$custom_dir = WP_CONTENT_DIR . '/custom-files';
if (is_dir($custom_dir)) {
$directories['custom-files'] = [
'size' => '2GB', // Warning threshold
'percentage' => 0 // Not using percentage
];
}
return $directories;
});

// Add custom section to the widget
add_action('wpextended/disk_usage/after_widget', function() {
$custom_data = get_custom_disk_usage_data(); // Your custom function
if ($custom_data) {
echo '<h3>Custom Storage</h3>';
echo '<pre>' . esc_html(print_r($custom_data, true)) . '</pre>';
}
});

This module is ideal for:

  • Website administrators
  • Developers managing multiple sites
  • Agencies managing client websites
  • Anyone who needs to monitor their WordPress site’s disk usage

Need help?

Still need help? Create a support ticket and our team will get back to you shortly.