wppaste
WordPress

apply_filters( 'pre_recurse_dirsize', int|false $space_used, string $directory, string|string[]|null $exclude, int $max_execution_time, array $directory_cache )

Since
5.6.0
Filters the amount of storage space used by one directory and all its children, in megabytes.

Description

Return the actual used space to short-circuit the recursive PHP file size calculation and use something else, like a CDN API or native operating system tools for better performance.

Compatibility

WordPress
since 5.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$space_usedint|false
The amount of used space, in bytes. Default false.
$directorystring
Full path of a directory.
$excludestring|string[]|null
Full path of a subdirectory to exclude from the total, or array of paths.
$max_execution_timeint
Maximum time to run before giving up. In seconds.
$directory_cachearray
Array of cached directory paths.

Where this hook fires · 1

  • wp-includes/functions.php:8734recurse_dirsize()

Source code

	 * @param string               $directory          Full path of a directory.	 * @param string|string[]|null $exclude            Full path of a subdirectory to exclude from the total,	 *                                                 or array of paths.	 * @param int                  $max_execution_time Maximum time to run before giving up. In seconds.	 * @param array                $directory_cache    Array of cached directory paths.	 */	$size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache ); 	if ( false === $size ) {		$size = 0; 		$handle = opendir( $directory );		if ( $handle ) {

Changelog

Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.