Created
April 6, 2018 17:32
-
-
Save greatislander/5c9f5aacb7176b90131f8ae97b25abf4 to your computer and use it in GitHub Desktop.
Network Storage Checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function format_bytes( $bytes, $precision = 2 ) { | |
$units = [ 'B', 'KB', 'MB', 'GB', 'TB' ]; | |
$bytes = max( $bytes, 0 ); | |
$pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) ); | |
$pow = min( $pow, count( $units ) - 1 ); | |
$bytes /= ( 1 << ( 10 * $pow ) ); | |
return round( $bytes, $precision ) . ' ' . $units[ $pow ]; | |
} | |
add_action( 'mu_rightnow_end', function() { | |
printf( '<p>%1$s: %2$s</p>', __( 'Network Storage' ), format_bytes( recurse_dirsize( wp_upload_dir()['basedir'] ) ) ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment