WordPress.org

Make WordPress Core

Changeset 15487


Ignore:
Timestamp:
08/02/10 17:56:05 (5 years ago)
Author:
ryan
Message:

Move dashboard_quota in dashboard.php. Don't perform current_user_can check before init.

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r15457 r15487  
    10351035} 
    10361036 
     1037// Display File upload quota on dashboard 
     1038function wp_dashboard_quota() { 
     1039    if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) ) 
     1040        return true; 
     1041 
     1042    $quota = get_space_allowed(); 
     1043    $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; 
     1044 
     1045    if ( $used > $quota ) 
     1046        $percentused = '100'; 
     1047    else 
     1048        $percentused = ( $used / $quota ) * 100; 
     1049    $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; 
     1050    $used = round( $used, 2 ); 
     1051    $percentused = number_format( $percentused ); 
     1052 
     1053    ?> 
     1054    <p class="sub musub"><?php _e( 'Storage Space' ); ?></p> 
     1055    <div class="table table_content musubtable"> 
     1056    <table> 
     1057        <tr class="first"> 
     1058            <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td> 
     1059            <td class="t posts"><?php _e( 'Space Allowed' ); ?></td> 
     1060        </tr> 
     1061    </table> 
     1062    </div> 
     1063    <div class="table table_discussion musubtable"> 
     1064    <table> 
     1065        <tr class="first"> 
     1066            <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td> 
     1067            <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td> 
     1068        </tr> 
     1069    </table> 
     1070    </div> 
     1071    <br class="clear" /> 
     1072    <?php 
     1073} 
     1074add_action( 'activity_box_end', 'wp_dashboard_quota' ); 
     1075 
    10371076/** 
    10381077 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). 
  • trunk/wp-admin/includes/ms.php

    r15486 r15487  
    483483    <?php 
    484484} 
    485  
    486 // Display File upload quota on dashboard 
    487 function dashboard_quota() { 
    488     if ( get_site_option( 'upload_space_check_disabled' ) ) 
    489         return true; 
    490  
    491     $quota = get_space_allowed(); 
    492     $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; 
    493  
    494     if ( $used > $quota ) 
    495         $percentused = '100'; 
    496     else 
    497         $percentused = ( $used / $quota ) * 100; 
    498     $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; 
    499     $used = round( $used, 2 ); 
    500     $percentused = number_format( $percentused ); 
    501  
    502     ?> 
    503     <p class="sub musub"><?php _e( 'Storage Space' ); ?></p> 
    504     <div class="table table_content musubtable"> 
    505     <table> 
    506         <tr class="first"> 
    507             <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td> 
    508             <td class="t posts"><?php _e( 'Space Allowed' ); ?></td> 
    509         </tr> 
    510     </table> 
    511     </div> 
    512     <div class="table table_discussion musubtable"> 
    513     <table> 
    514         <tr class="first"> 
    515             <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td> 
    516             <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td> 
    517         </tr> 
    518     </table> 
    519     </div> 
    520     <br class="clear" /> 
    521     <?php 
    522 } 
    523 if ( current_user_can( 'edit_posts' ) ) 
    524     add_action( 'activity_box_end', 'dashboard_quota' ); 
    525485 
    526486// Edit blog upload space setting on Edit Blog page 
Note: See TracChangeset for help on using the changeset viewer.