public function get_site_size()
{
if ($this->size) {
return $this->size;
}
$size = 0;
// Include database size except for file only schedule.
if ('file' !== $this->type) {
$size = (int) get_transient('hmbkp_database_size');
if (!$size) {
global $wpdb;
$tables = $wpdb->get_results('SHOW TABLE STATUS FROM `' . DB_NAME . '`', ARRAY_A);
foreach ($tables as $table) {
$size += (double) $table['Data_length'];
}
set_transient('hmbkp_database_size', $size, WEEK_IN_SECONDS);
}
}
// Include total size of dirs/files except for database only schedule.
if ('database' !== $this->type) {
$root = new \SplFileInfo(Path::get_root());
$size += $this->filesize($root);
}
$this->size = $size;
return $size;
}