Skip to content

Instantly share code, notes, and snippets.

@greatislander
Created April 6, 2018 17:32
Show Gist options
  • Save greatislander/5c9f5aacb7176b90131f8ae97b25abf4 to your computer and use it in GitHub Desktop.
Save greatislander/5c9f5aacb7176b90131f8ae97b25abf4 to your computer and use it in GitHub Desktop.
Network Storage Checker
<?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