Making WordPress.org

Ticket #2866: add-zip-filesize.2866.diff

File add-zip-filesize.2866.diff, 1.5 KB (added by tellyworth, 8 years ago)

Quick first pass. wfm in simple cases on a sandbox. I'm not sure if files will be available locally in production, in which case something more complex is needed.

  • admin/metabox/class-review-tools.php

     
    1212
    1313                $zip_files = array();
    1414                foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
    15                         $zip_files[ $zip_file->post_date ] = wp_get_attachment_url( $zip_file->ID );
     15                        $zip_files[ $zip_file->post_date ] = array(     wp_get_attachment_url( $zip_file->ID ), $zip_file );
    1616                }
    1717                uksort( $zip_files, function( $a, $b ) {
    1818                        return strtotime( $a ) < strtotime( $b );
     
    2020
    2121                if ( $zip_url = get_post_meta( $post->ID, '_submitted_zip', true ) ) {
    2222                        // Back-compat only.
    23                         $zip_files[ 'User provided URL' ] = $zip_url;
     23                        $zip_files[ 'User provided URL' ] = array( $zip_url, null );
    2424                }
    2525
    26                 foreach ( $zip_files as $zip_date => $zip_url ) {
     26                foreach ( $zip_files as $zip_date => $zip ) {
     27                        list( $zip_url, $zip_file ) = $zip;
     28                        $zip_size = ( is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ) ) : __( 'unknown size', 'wporg-plugins' ) );
    2729                        printf( '<p>' . __( '<strong>Zip file:</strong> %s', 'wporg-plugins' ) . '</p>',
    28                                 sprintf( '%s <a href="%s">%s</a>', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ) )
     30                                sprintf( '%s <a href="%s">%s</a> (%s)', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) )
    2931                        );
    3032                }
    3133