pre_recurse_dirsize хук-фильтрWP 5.6.0

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

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.

Использование

add_filter( 'pre_recurse_dirsize', 'wp_kama_pre_recurse_dirsize_filter', 10, 5 );

/**
 * Function for `pre_recurse_dirsize` filter-hook.
 * 
 * @param int|false            $space_used         The amount of used space, in bytes.
 * @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.
 *
 * @return int|false
 */
function wp_kama_pre_recurse_dirsize_filter( $space_used, $directory, $exclude, $max_execution_time, $directory_cache ){

	// filter...
	return $space_used;
}
$space_used(int|false)
The amount of used space, in bytes.
По умолчанию: false
$directory(строка)
Full path of a directory.
$exclude(строка|string[]|null)
Full path of a subdirectory to exclude from the total, or array of paths.
$max_execution_time(int)
Maximum time to run before giving up. In seconds.
$directory_cache(массив)
Array of cached directory paths.

Список изменений

С версии 5.6.0 Введена.

Где вызывается хук

recurse_dirsize()
pre_recurse_dirsize
wp-includes/functions.php 8734
$size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache );

Где используется хук в WordPress

Использование не найдено.