diff --git a/admin/inc/basic.php b/admin/inc/basic.php index 3670f71..34d5bc1 100644 --- a/admin/inc/basic.php +++ b/admin/inc/basic.php @@ -1084,20 +1084,23 @@ function get_site_version($echo = true) { /** * Convert to Bytes + * Convert M/G/K byte string to bytes * * @since 3.0 + * @since 3.5.0 Fix notice * - * @param $str string - * @return string + * @param mixed $str + * @return mixed */ function toBytes($str) { - $val = trim($str); - $last = strtolower($str[strlen($str)-1]); - switch($last) { - case 'g': $val *= 1024; - case 'm': $val *= 1024; - case 'k': $val *= 1024; - } + if (is_numeric($str)) return (int)$str; + $val = (int)trim($str, 'gmkGMK'); + $last = strtolower($str[strlen($str) - 1]); + switch ($last) { + case 'g': $val *= 1024; + case 'm': $val *= 1024; + case 'k': $val *= 1024; + } return $val; }