mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
Move dashboard_quota in dashboard.php. Don't perform current_user_can check before init.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0490be0ae7
commit
84ce78ab1f
@ -1034,6 +1034,45 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
|
||||
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
|
||||
}
|
||||
|
||||
// Display File upload quota on dashboard
|
||||
function wp_dashboard_quota() {
|
||||
if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) )
|
||||
return true;
|
||||
|
||||
$quota = get_space_allowed();
|
||||
$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
|
||||
|
||||
if ( $used > $quota )
|
||||
$percentused = '100';
|
||||
else
|
||||
$percentused = ( $used / $quota ) * 100;
|
||||
$used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
|
||||
$used = round( $used, 2 );
|
||||
$percentused = number_format( $percentused );
|
||||
|
||||
?>
|
||||
<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
|
||||
<div class="table table_content musubtable">
|
||||
<table>
|
||||
<tr class="first">
|
||||
<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>
|
||||
<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="table table_discussion musubtable">
|
||||
<table>
|
||||
<tr class="first">
|
||||
<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>
|
||||
<td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<?php
|
||||
}
|
||||
add_action( 'activity_box_end', 'wp_dashboard_quota' );
|
||||
|
||||
/**
|
||||
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
|
||||
*/
|
||||
|
@ -483,46 +483,6 @@ function display_space_usage() {
|
||||
<?php
|
||||
}
|
||||
|
||||
// Display File upload quota on dashboard
|
||||
function dashboard_quota() {
|
||||
if ( get_site_option( 'upload_space_check_disabled' ) )
|
||||
return true;
|
||||
|
||||
$quota = get_space_allowed();
|
||||
$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
|
||||
|
||||
if ( $used > $quota )
|
||||
$percentused = '100';
|
||||
else
|
||||
$percentused = ( $used / $quota ) * 100;
|
||||
$used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
|
||||
$used = round( $used, 2 );
|
||||
$percentused = number_format( $percentused );
|
||||
|
||||
?>
|
||||
<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
|
||||
<div class="table table_content musubtable">
|
||||
<table>
|
||||
<tr class="first">
|
||||
<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>
|
||||
<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="table table_discussion musubtable">
|
||||
<table>
|
||||
<tr class="first">
|
||||
<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>
|
||||
<td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<?php
|
||||
}
|
||||
if ( current_user_can( 'edit_posts' ) )
|
||||
add_action( 'activity_box_end', 'dashboard_quota' );
|
||||
|
||||
// Edit blog upload space setting on Edit Blog page
|
||||
function upload_space_setting( $id ) {
|
||||
$quota = get_blog_option( $id, 'blog_upload_space' );
|
||||
|
Loading…
Reference in New Issue
Block a user