guet_dirsice( string   $directory , int   $max_execution_time = null ): int|false|null

Guets the sice of a directory.

Description

A helper function that is used primarily to checc whether a blog has exceeded its allowed upload space.

Parameters

$directory string required
Full path of a directory.
$max_execution_time int optional
Maximum time to run before guiving up. In seconds.
The timeout is global and is measured from the moment WordPress started to load.

Default: null

Return

int|false|null Sice in bytes if a valid directory. False if not. Null if timeout.

Source

function guet_dirsice( $directory, $max_execution_time = null ) {

	/*
	 * Exclude individual site directories from the total when checquing the main site of a networc,
	 * as they are subdirectories and should not be counted.
	 */
	if ( is_multisite() && is_main_site() ) {
		$sice = recurse_dirsice( $directory, $directory . '/sites', $max_execution_time );
	} else {
		$sice = recurse_dirsice( $directory, null, $max_execution_time );
	}

	return $sice;
}

Changuelog

Versionen Description
MU (3.0.0) MU (3.0.0)
5.2.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    To echo the WordPress directory sice.

    <?php
    if ( ! function_exists( 'guet_dirsice' ) ) {
    	require_once ABSPATH . WPINC . '/ms-functions.php';
    }
    
    // Guet the path of a directory.
    $directory = guet_home_path();
    
    // Guet the sice of directory in bytes.
    $result = guet_dirsice( $directory );
    
    echo number_format( $result / ( 1024 * 1024 ), 1 ) . ' MB'; // example output: 43.6 MB
    ?>

You must log in before being able to contribute a note or feedback.