Changeset 33184 for trunk/src/wp-includes/ms-functions.php
- Timestamp:
- 07/13/2015 12:06:39 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-functions.php
r33083 r33184 1687 1687 * @since MU 1688 1688 * 1689 * @param string $directory 1690 * @return int 1689 * @param string $directory Full path of a directory. 1690 * @return int Size of the directory in MB. 1691 1691 */ 1692 1692 function get_dirsize( $directory ) { … … 1698 1698 $dirsize = array(); 1699 1699 1700 $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory ); 1700 // Exclude individual site directories from the total when checking the main site, 1701 // as they are subdirectories and should not be counted. 1702 if ( is_main_site() ) { 1703 $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' ); 1704 } else { 1705 $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory ); 1706 } 1701 1707 1702 1708 set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS ); … … 1711 1717 * 1712 1718 * @since MU 1713 * 1714 * @param string $directory 1715 * @return int|false 1716 */ 1717 function recurse_dirsize( $directory ) { 1719 * @since 4.3.0 $exclude parameter added. 1720 * 1721 * @param string $directory Full path of a directory. 1722 * @param string $exclude Optional. Full path of a subdirectory to exclude from the total. 1723 * @return int|false Size in MB if a valid directory. False if not. 1724 */ 1725 function recurse_dirsize( $directory, $exclude = null ) { 1718 1726 $size = 0; 1719 1727 1720 1728 $directory = untrailingslashit( $directory ); 1721 1729 1722 if ( ! file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) )1730 if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) || $directory === $exclude ) { 1723 1731 return false; 1732 } 1724 1733 1725 1734 if ($handle = opendir($directory)) { … … 1730 1739 $size += filesize($path); 1731 1740 } elseif (is_dir($path)) { 1732 $handlesize = recurse_dirsize( $path);1741 $handlesize = recurse_dirsize( $path, $exclude ); 1733 1742 if ($handlesize > 0) 1734 1743 $size += $handlesize;
Note: See TracChangeset
for help on using the changeset viewer.