Changeset 22497 for trunk/wp-includes/ms-functions.php
- Timestamp:
- 11/09/2012 10:35:42 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-functions.php
r22461 r22497 1930 1930 update_site_option( 'user_count', $count ); 1931 1931 } 1932 1933 /** 1934 * Returns the space used by the current blog. 1935 * 1936 * @since 3.5.0 1937 * 1938 * @return int Used space in megabytes 1939 */ 1940 function get_space_used() { 1941 // Allow for an alternative way of tracking storage space used 1942 $space_used = apply_filters( 'pre_get_space_used', false ); 1943 if ( false === $space_used ) { 1944 $upload_dir = wp_upload_dir(); 1945 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024; 1946 } 1947 1948 return $space_used; 1949 } 1950 1951 /** 1952 * Returns the upload quota for the current blog. 1953 * 1954 * @since MU 1955 * 1956 * @return int Quota in megabytes 1957 */ 1958 function get_space_allowed() { 1959 $space_allowed = get_option( 'blog_upload_space' ); 1960 1961 if ( ! is_numeric( $space_allowed ) ) 1962 $space_allowed = get_site_option( 'blog_upload_space' ); 1963 1964 if ( empty( $space_allowed ) || ! is_numeric( $space_allowed ) ) 1965 $space_allowed = 50; 1966 1967 return $space_allowed; 1968 } 1969 1970 /** 1971 * Determines if there is any upload space left in the current blog's quota. 1972 * 1973 * @since 3.0.0 1974 * 1975 * @return int of upload space available in bytes 1976 */ 1977 function get_upload_space_available() { 1978 $space_allowed = get_space_allowed() * 1024 * 1024; 1979 if ( get_site_option( 'upload_space_check_disabled' ) ) 1980 return $space_allowed; 1981 1982 $space_used = get_space_used() * 1024 * 1024; 1983 1984 if ( ( $space_allowed - $space_used ) <= 0 ) 1985 return 0; 1986 1987 return $space_allowed - $space_used; 1988 } 1989 1990 /** 1991 * @since 3.0.0 1992 * 1993 * @return int of upload size limit in bytes 1994 */ 1995 function upload_size_limit_filter( $size ) { 1996 $fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 ); 1997 if ( get_site_option( 'upload_space_check_disabled' ) ) 1998 return min( $size, $fileupload_maxk ); 1999 2000 return min( $size, $fileupload_maxk, get_upload_space_available() ); 2001 }
Note: See TracChangeset
for help on using the changeset viewer.