Add the following code to your widget code:
function fileSizeInfo($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB');
if ($filesize < 1024)
$filesize = 1;
for ($i = 0; $filesize > 1024; $i++)
$filesize /= 1024;
$dbSizeInfo['size'] = round($filesize, 3);
$dbSizeInfo['type'] = $bytes[$i];
return $dbSizeInfo;
}
function databaseSize() {
global $wpdb;
$dbsize = 0;
$rows = $wpdb->get_results("SHOW table STATUS");
foreach($rows as $row)
$dbsize += $row->Data_length + $row->Index_length;
return fileSizeInfo($dbsize);
}
$dbSize = databaseSize();
echo "<b>Database size</b> = {$dbSize['size']} {$dbSize['type']}";
Related Posts:
- How do I save data from submitted form from widget
- Give Editor Access To Sidebar
- Enabling jquery when dragging available widget to sidebar area
- Prevent widgets removal
- How to listen to color changes on the color picker?
- Role that can edit only widgets, not other theme options
- How can I delete all inactive widgets?
- Reorder dashboard widgets
- Ban certain widgets from certain sidebars
- Using tabs in admin widgets [closed]
- Widget queries even when there are no sidebars?
- Multiple users editting widgets
- dynamic_sidebar() returns false in admin section
- Widgets not expanding on wordpress 3.3 widget dashbord
- How to get “Widget Logic” plugin’s input value in a custom widget code (to display on the Widget admin page)
- Grabbing how Many Posts by Month for a Dashboard Widget
- How to change color of registered widget areas in admin?
- Proper approach to moving complete site from one domain to another AND preserve widgets
- Adding a single text input field to a custom Dashboard widget
- How to change widget’s form color in admin?
- accessing wordpress serialized data outside wp
- Editing Help Section
- Allow users to give a dashboard widget a custom name using ACF
- How to customize WordPress dashboard for different users?
- Reposition the widget sidebar in Appearance->Widgets
- How to update the options table for a widget
- Handling dozens of sidebars
- Widget Areas Still Appearing in WP ADMIN When They Shouldn’t
- Creating an custom admin page for editing widgets
- Unable to add options on dashboard widget ?
- How to add the “page” post type to Recent Activity widget displayed in admin?
- How can I use the built in WordPress “browse link” functionality?
- Modifying the default search widget
- How to build widget with arrays inside arrays?
- Add New Footer Widget Area with Limited Options?
- Add div class to only one widget
- How to use control_callback when creating a widget via functions.php or plugin?
- Disable default WordPress widgets in sidebar
- Adding classes to dynamic sidebar
- Add Admin User via SQL
- Widget area inside a widget
- Defer Code in Widgets – Page Speed
- Where are widget configurations stored?
- How to limit wp_get_archives to show months for the X years only
- Bolding specific word(s)/parts of widget title
- How to add a class to a link in text editor
- WordPress widget new instance creates content duplicates
- Remove the widgets tab from theme customizer
- Remove/Add widgets from/to the Available Widgets pool
- Remove/Unregister or hide a widget added by a plugin
- Check if widget is active
- Radio buttons in widget not saving
- How can I apply css styling to the current day in the calendar widget
- How to check if a widget has no title
- Is there an official email form widget or block?
- Widget html code error
- Excluding specific widgets from default sidebar class
- How to truncate titles in Recent Posts widget?
- Can WordPress Read Its Own RSS Feed?
- Can’t see widget areas in my customizer
- Display custom widget, added as a shortcode in the correct place
- Debug errors on sidebar
- Can’t work out why widget contents disappear from admin
- Show posts from one category with thumbnail and description on latest
- Widget textarea input gets formatted
- Show widget differently depending on if it’s in the sidebar or footer
- Get posts after today (upcoming events)
- Enqueue script/style if certain widget has certain value
- How to display/register widget only on post pages in custom plugin
- Widget page is missing from menu and default widgets are not showing
- Fire on widgets_init only on dashboard
- Access Customizer widget instance form
- Allow shortcode for custom widget
- is_tax() not working in Widget Logic [closed]
- One register_sidebar function works, the other doesn’t?
- Modify WordPress widgets Screen
- What does apply_filters() do exactly? [duplicate]
- Filter Text from sidebar widget?
- How to filter widget(s) based on a specific category landing page
- Change the background color of my theme widgets
- Change Woocommerce Product Categories Widget ‘Title’ based on Product Category
- Output column number according to active sidebars
- Why isn’t my custom widget outputting any content?
- Why would apply_filters return a non-empty string, when the value returned is empty?
- How to customize wordpress sidebar widget
- Jquery checkbox -show posts with checked tags
- How to translate widget titles in 2021 theme?
- Widget editing returns JSON response error
- why the code html apear in this widget in footer
- A checkbox Option for description in Widget
- My widgets do not save
- Inkness theme sidebar
- Automatically hide Widgets that would lengthen page
- Add New Footer Widget Area with Limited Options?
- I add some js files from a plugin to a specific location
- Include widget within newsletter template?
- My understrap-child theme doesent have a head.php, footer.php
- Text Widget Not Working
- Sample widget code which get data(1-5 record) from Wp_Admin panel and display to Homepage(WordPress Custom Theme)
- Widget block editor: Unable to collect checkbox values inside widget update() method