WordPress.org

Make WordPress Core

Changeset 12824


Ignore:
Timestamp:
01/25/2010 07:46:24 PM (10 years ago)
Author:
ryan
Message:

Add wp-admin/includes/ms-deprecated.php. Deprecate wpmu_checkAvailableSpace. Introduce is_upload_space_available(). see #11762

Location:
trunk/wp-admin/includes
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/admin.php

    r12823 r12824  
    5656
    5757/** WordPress Multi-Site support API */
    58 if ( is_multisite() )
     58if ( is_multisite() ) {
    5959    require_once(ABSPATH . 'wp-admin/includes/ms.php');
     60    require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
     61}
    6062
    6163?>
  • trunk/wp-admin/includes/deprecated.php

    r12823 r12824  
    11<?php
     2/**
     3 * Deprecated admin functions from past WordPress versions. You shouldn't use these
     4 * globals and functions and look for the alternatives instead. The functions
     5 * and globals will be removed in a later version.
     6 *
     7 * @package WordPress
     8 * @subpackage Deprecated
     9 */
    210
    311/**
  • trunk/wp-admin/includes/media.php

    r12789 r12824  
    13981398</div>
    13991399
    1400 <?php do_action('pre-upload-ui'); ?>
    1401 
    1402 <?php if ( $flash ) : ?>
     1400<?php
     1401// Check quota for this blog if multisite
     1402if ( is_multisite() && !is_upload_space_available() )
     1403    wp_die( __('Sorry, you must delete files before you can upload any more.') );
     1404
     1405do_action('pre-upload-ui');
     1406
     1407if ( $flash ) : ?>
    14031408<script type="text/javascript">
    14041409//<![CDATA[
     
    22302235
    22312236add_filter('media_upload_library', 'media_upload_library');
    2232 
  • trunk/wp-admin/includes/ms.php

    r12804 r12824  
    356356}
    357357
     358/**
     359 * Determines if there is any upload space left in the current blog's quota.
     360 *
     361 * @return bool True if space is available, false otherwise.
     362 */
     363function is_upload_space_available() {
     364    if ( get_site_option( 'upload_space_check_disabled' ) )
     365        return true;
     366
     367    $space_allowed = get_space_allowed();
     368
     369    $dir_name = trailingslashit( BLOGUPLOADDIR );
     370    if ( !(is_dir($dir_name) && is_readable($dir_name)) )
     371        return true;
     372
     373    $dir = dir($dir_name);
     374    $size = 0;
     375
     376    while ( $file = $dir->read() ) {
     377        if ( $file != '.' && $file != '..' ) {
     378            if ( is_dir( $dir_name . $file) ) {
     379                $size += get_dirsize($dir_name . $file);
     380            } else {
     381                $size += filesize($dir_name . $file);
     382            }
     383        }
     384    }
     385    $dir->close();
     386    $size = $size / 1024 / 1024;
     387
     388    if ( ($space_allowed - $size) <= 0 )
     389        return false;
     390
     391    return true;
     392}
     393
     394/**
     395 * Returns the upload quota for the current blog.
     396 *
     397 * @return int Quota
     398 */
    358399function get_space_allowed() {
    359     $spaceAllowed = get_option("blog_upload_space");
    360     if ( $spaceAllowed == false )
    361         $spaceAllowed = get_site_option("blog_upload_space");
    362     if ( empty($spaceAllowed) || !is_numeric($spaceAllowed) )
    363         $spaceAllowed = 50;
    364 
    365     return $spaceAllowed;
     400    $space_allowed = get_option('blog_upload_space');
     401    if ( $space_allowed == false )
     402        $space_allowed = get_site_option('blog_upload_space');
     403    if ( empty($space_allowed) || !is_numeric($space_allowed) )
     404        $space_allowed = 50;
     405
     406    return $space_allowed;
    366407}
    367408
     
    370411    $used = get_dirsize( BLOGUPLOADDIR )/1024/1024;
    371412
    372     if ($used > $space) $percentused = '100';
    373     else $percentused = ( $used / $space ) * 100;
     413    if ( $used > $space )
     414        $percentused = '100';
     415    else
     416        $percentused = ( $used / $space ) * 100;
    374417
    375418    if ( $space > 1000 ) {
     
    460503}
    461504
    462 /*
    463   Determines if the available space defined by the admin has been exceeded by the user
    464 */
    465 function wpmu_checkAvailableSpace() {
    466     if ( get_site_option( 'upload_space_check_disabled' ) ) {
    467         return true;
    468     }
    469     $spaceAllowed = get_space_allowed();
    470 
    471     $dirName = trailingslashit( BLOGUPLOADDIR );
    472     if (!(is_dir($dirName) && is_readable($dirName)))
    473         return;
    474 
    475     $dir = dir($dirName);
    476     $size = 0;
    477 
    478     while($file = $dir->read()) {
    479         if ($file != '.' && $file != '..') {
    480             if (is_dir( $dirName . $file)) {
    481                 $size += get_dirsize($dirName . $file);
    482             } else {
    483                 $size += filesize($dirName . $file);
    484             }
    485         }
    486     }
    487     $dir->close();
    488     $size = $size / 1024 / 1024;
    489 
    490     if ( ($spaceAllowed - $size) <= 0 ) {
    491         wp_die( __('Sorry, you must delete files before you can upload any more.') );
    492     }
    493 }
    494 add_action('pre-upload-ui','wpmu_checkAvailableSpace');
    495 
    496505function format_code_lang( $code = '' ) {
    497506    $code = strtolower(substr($code, 0, 2));
     
    553562}
    554563add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
    555 
    556 function wpmu_menu() {
    557     // deprecated. See #11763
    558 }
    559564
    560565function mu_options( $options ) {
Note: See TracChangeset for help on using the changeset viewer.