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?
- Can I use wp_widget_rss_output to show my site’s feed in the dashboard?
- Script in sidebar blocks other widget’s load
- Make a widget to my footer
- Create a setting at backend,to print only selected categries at front-end
- How to change text of a widget depend on condition?
- Widget Admin page and Javascript enqueuing
- Does current page contain widget or sidebar
- widgets_init actions not fired from functions.php’s child theme
- Adding a trinket.io widget to a post
- Nonce and widget
- Widgets Opening In New Window – Unwanted
- How to call theme default widget in custom template?
- How to make featured area?
- Checking if widget has title not working
- three sidebars showing without call
- Active Sidebar Conditional Question?
- wp_list_categories + widget
- How to place a widget beside a div/text so that they display as a continuous line
- Widget stuck at particular point when dragging to bottom
- Always show the widget title in a wordpress widget
- How to add/save/retrieve additional fields to all available widgets?
- How can I add widgets to the category page?
- Randomizing the RSS Widget
- WordPress version quick check?
- How to get data from one wordpress site to another
- Editor Widget Role
- I cannot customize custom widgets anymore after moving WordPress website
- How can I build a widget area widget using the built in WordPress functionalities?
- Shared Custom post type between WP network sites
- Change Widget that display posts from categories to tags
- How to create another widgets.php page
- Why isn’t this widget displaying one of the icons?
- Target logic based on Widget / Sidebar Name
- Widget Logic code for different PMP membership levels
- Help with custom widget
- Allow end users to change settings of a widget
- Custom php Widget keeps disappearing from the front end
- Get widget locations in WordPress plugin
- How to Activate WordPress Widgets
- How to Make widget area on place of comment
- Display Posts by Views (Popular Posts Widget)
- Registered widget is showing up collapsed in the dashboard
- Can I get variable into dynamic sidebar?
- WordPress wiget admin panel
- How can I only show a widget prior to a specific date?
- Filter “widget_comments_args” won’t work
- Default WordPress widgets always appear
- Remove default WordPress widgets
- How to change the publishing date of each posts?
- Why is the phone number a hyperlink on desktop sites, in my widget?
- Paginate recent posts widget
- Add space to the end on a widget
- How to show a widget for logged-in users only?
- Add sidebar in inner pages
- Can’t output the number 0 in widget
- Dynamic Width of Widgets
- How to filter the widgets like calendar and archives based on category in WordPress
- Using AJAX in WordPress Widget
- $before/after_widget/title not displaying anything
- widget exclude post by custom field
- can’t edit widgets after moving from subfolder to root
- Create a widget to display image and Title?
- widget that will do shortcodes that user inputs
- How to give a File Upload option in wordpress Widget backend?
- How to optimize performance without transient?
- Display widget outside sidebar?
- Pass widget variable to external function
- Widget checkbox array empty on update function
- Insert to wp_footer if widget is found in the sidebar