Make WordPress Core


Ignore:
Timestamp:
08/02/2010 05:56:05 PM (14 years ago)
Author:
ryan
Message:

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

File:
1 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).
Note: See TracChangeset for help on using the changeset viewer.