account-status-connected.php
9 years ago
account-status-create-advanced.php
9 years ago
account-status-create-simple.php
9 years ago
account-status-loading.php
9 years ago
bulk-optimization-chart.php
9 years ago
bulk-optimization-form.php
9 years ago
bulk-optimization.php
9 years ago
compress-details-processing.php
9 years ago
compress-details.php
9 years ago
dashboard-widget.php
9 years ago
compress-details.php
162 lines
| 1 | <?php |
| 2 | |
| 3 | $available_sizes = array_keys( $this->settings->get_sizes() ); |
| 4 | $active_sizes = $this->settings->get_sizes(); |
| 5 | $active_tinify_sizes = $this->settings->get_active_tinify_sizes(); |
| 6 | $error = $tiny_image->get_latest_error(); |
| 7 | $total = $tiny_image->get_count( array( 'modified', 'missing', 'has_been_compressed', 'compressed' ) ); |
| 8 | $active = $tiny_image->get_count( array( 'uncompressed', 'never_compressed' ), $active_tinify_sizes ); |
| 9 | $image_statistics = $tiny_image->get_statistics(); |
| 10 | $available_unoptimized_sizes = $image_statistics['available_unoptimized_sizes']; |
| 11 | $size_before = $image_statistics['initial_total_size']; |
| 12 | $size_after = $image_statistics['optimized_total_size']; |
| 13 | |
| 14 | $size_active = array_fill_keys( $active_tinify_sizes, true ); |
| 15 | $size_exists = array_fill_keys( $available_sizes, true ); |
| 16 | ksort( $size_exists ); |
| 17 | |
| 18 | ?> |
| 19 | <div class="details-container"> |
| 20 | <div class="details" > |
| 21 | <?php if ( $error ) { |
| 22 | // dashicons-warning available for WP 4.3+ ?> |
| 23 | <span class="icon dashicons dashicons-no error"></span> |
| 24 | <?php } elseif ( $total['missing'] > 0 || $total['modified'] > 0 ) { ?> |
| 25 | <span class="icon dashicons dashicons-yes alert"></span> |
| 26 | <?php } elseif ( $total['compressed'] > 0 && $available_unoptimized_sizes > 0 ) { ?> |
| 27 | <span class="icon dashicons dashicons-yes alert"></span> |
| 28 | <?php } elseif ( $total['compressed'] > 0 ) { ?> |
| 29 | <span class="icon dashicons dashicons-yes success"></span> |
| 30 | <?php } ?> |
| 31 | <span class="icon spinner hidden"></span> |
| 32 | <?php if ( $total['has_been_compressed'] > 0 || (0 == $total['has_been_compressed'] && 0 == $available_unoptimized_sizes) ) { ?> |
| 33 | <span class="message"> |
| 34 | <?php printf( wp_kses( _n( '<strong>%d</strong> size compressed', '<strong>%d</strong> sizes compressed', $total['has_been_compressed'], 'tiny-compress-images' ), array( |
| 35 | 'strong' => array(), |
| 36 | ) ), $total['has_been_compressed'] ) ?> |
| 37 | </span> |
| 38 | <br/> |
| 39 | <?php } ?> |
| 40 | <?php if ( $available_unoptimized_sizes > 0 ) { ?> |
| 41 | <span class="message"> |
| 42 | <?php printf( esc_html( _n( '%d size to be compressed', '%d sizes to be compressed', $available_unoptimized_sizes, 'tiny-compress-images' ) ), $available_unoptimized_sizes ) ?> |
| 43 | </span> |
| 44 | <br /> |
| 45 | <?php } ?> |
| 46 | <?php if ( $size_before - $size_after ) { ?> |
| 47 | <span class="message"> |
| 48 | <?php printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), (1 - $size_after / floatval( $size_before )) * 100 ) ?> |
| 49 | </span> |
| 50 | <br /> |
| 51 | <?php } ?> |
| 52 | <?php if ( $error ) { ?> |
| 53 | <span class="message error_message"> |
| 54 | <?php echo esc_html__( 'Latest error', 'tiny-compress-images' ) . ': ' . esc_html( $error, 'tiny-compress-images' ) ?> |
| 55 | </span> |
| 56 | <br/> |
| 57 | <?php } ?> |
| 58 | <a class="thickbox message" href="#TB_inline?width=700&height=500&inlineId=modal_<?php echo $tiny_image->get_id() ?>"> |
| 59 | <?php esc_html_e( 'Details', 'tiny-compress-images' ) ?> |
| 60 | </a> |
| 61 | </div> |
| 62 | <?php if ( $active['uncompressed'] > 0 ) { ?> |
| 63 | <button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo $tiny_image->get_id() ?>"> |
| 64 | <?php esc_html_e( 'Compress', 'tiny-compress-images' ) ?> |
| 65 | </button> |
| 66 | <?php } ?> |
| 67 | </div> |
| 68 | |
| 69 | <div class="modal" id="modal_<?php echo $tiny_image->get_id() ?>"> |
| 70 | <div class="tiny-compression-details"> |
| 71 | <h3> |
| 72 | <?php printf( esc_html__( 'Compression details for %s', 'tiny-compress-images' ), $tiny_image->get_name() ) ?> |
| 73 | </h3> |
| 74 | <table> |
| 75 | <tr> |
| 76 | <th><?php esc_html_e( 'Size' ) ?></th> |
| 77 | <th><?php esc_html_e( 'Initial Size', 'tiny-compress-images' ) ?></th> |
| 78 | <th><?php esc_html_e( 'Compressed', 'tiny-compress-images' ) ?></th> |
| 79 | <th><?php esc_html_e( 'Date' ) ?></th> |
| 80 | </tr> |
| 81 | <?php |
| 82 | $i = 0; |
| 83 | $sizes = $tiny_image->get_image_sizes() + $size_exists; |
| 84 | foreach ( $sizes as $size_name => $size ) { |
| 85 | if ( ! is_object( $size ) ) { |
| 86 | $size = new Tiny_Image_Size(); |
| 87 | } |
| 88 | ?> |
| 89 | <tr class="<?php echo ( 0 == $i % 2 ) ? 'even' : 'odd' ?>"> |
| 90 | <?php |
| 91 | echo '<td>'; |
| 92 | echo ( Tiny_Image::is_original( $size_name ) ? esc_html__( 'Original', 'tiny-compress-images' ) : esc_html( ucfirst( rtrim( $size_name, '_wr2x' ) ) ) ); |
| 93 | echo ' '; |
| 94 | if ( ! array_key_exists( $size_name, $active_sizes ) && ! Tiny_Image::is_retina( $size_name ) ) { |
| 95 | echo '<em>' . esc_html__( '(not in use)', 'tiny-compress-images' ) . '</em>'; |
| 96 | } elseif ( $size->missing() && ( Tiny_Settings::wr2x_active() || ! Tiny_Image::is_retina( $size_name ) ) ) { |
| 97 | echo '<em>' . esc_html__( '(file removed)', 'tiny-compress-images' ) . '</em>'; |
| 98 | } elseif ( $size->modified() ) { |
| 99 | echo '<em>' . esc_html__( '(modified after compression)', 'tiny-compress-images' ) . '</em>'; |
| 100 | } elseif ( Tiny_Image::is_retina( $size_name ) ) { |
| 101 | echo '<em>' . esc_html__( '(WP Retina 2x)', 'tiny-compress-images' ) . '</em>'; |
| 102 | } elseif ( $size->resized() ) { |
| 103 | printf( '<em>' . esc_html__( '(resized to %1$dx%2$d)', 'tiny-compress-images' ) . '</em>', $size->meta['output']['width'], $size->meta['output']['height'] ); |
| 104 | } |
| 105 | echo '</td>'; |
| 106 | |
| 107 | if ( $size->is_duplicate() ) { |
| 108 | echo '<td>-</td>'; |
| 109 | printf( '<td colspan=2><em>' . esc_html__( 'Same file as "%s"', 'tiny-compress-images' ) . '</em></td>', esc_html( ucfirst( $size->duplicate_of_size() ) ) ); |
| 110 | } elseif ( $size->has_been_compressed() ) { |
| 111 | echo '<td>' . size_format( $size->meta['input']['size'], 1 ) . '</td>'; |
| 112 | echo '<td>' . size_format( $size->meta['output']['size'], 1 ) . '</td>'; |
| 113 | echo '<td>' . sprintf( esc_html__( '%s ago' ), human_time_diff( $size->end_time( $size_name ) ) ) . '</td>'; |
| 114 | } elseif ( ! $size->exists() ) { |
| 115 | echo '<td>-</td>'; |
| 116 | echo '<td colspan=2><em>' . esc_html__( 'Not present', 'tiny-compress-images' ) . '</em></td>'; |
| 117 | } elseif ( isset( $size_active[ $size_name ] ) || Tiny_Image::is_retina( $size_name ) ) { |
| 118 | echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>'; |
| 119 | echo '<td colspan=2><em>' . esc_html__( 'Not compressed', 'tiny-compress-images' ) . '</em></td>'; |
| 120 | } elseif ( isset( $size_exists[ $size_name ] ) ) { |
| 121 | echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>'; |
| 122 | echo '<td colspan=2><em>' . esc_html__( 'Not configured to be compressed', 'tiny-compress-images' ) . '</em></td>'; |
| 123 | } elseif ( ! array_key_exists( $size_name, $active_sizes ) ) { |
| 124 | echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>'; |
| 125 | echo '<td colspan=2><em>' . esc_html__( 'Size is not in use', 'tiny-compress-images' ) . '</em></td>'; |
| 126 | } else { |
| 127 | echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>'; |
| 128 | echo '<td>-</td>'; |
| 129 | } |
| 130 | ?> |
| 131 | </tr><?php |
| 132 | $i++; |
| 133 | }// End foreach(). |
| 134 | if ( $image_statistics['image_sizes_optimized'] > 0 ) { ?> |
| 135 | <tfoot> |
| 136 | <tr> |
| 137 | <td><?php esc_html_e( 'Combined', 'tiny-compress-images' ) ?></td> |
| 138 | <td><?php echo size_format( $size_before, 1 ) ?></td> |
| 139 | <td><?php echo size_format( $size_after, 1 ) ?></td> |
| 140 | <td></td> |
| 141 | </tr> |
| 142 | </tfoot><?php |
| 143 | } |
| 144 | ?> |
| 145 | </table> |
| 146 | <p> |
| 147 | <strong> |
| 148 | <?php |
| 149 | if ( $size_before - $size_after ) { |
| 150 | printf( esc_html__( 'Total savings %1$.0f%% (%2$s)', 'tiny-compress-images' ), |
| 151 | ( 1 - $size_after / floatval( $size_before ) ) * 100, |
| 152 | size_format( $size_before - $size_after, 1 ) |
| 153 | ); |
| 154 | } else { |
| 155 | printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), 0 ); |
| 156 | } |
| 157 | ?> |
| 158 | </strong> |
| 159 | </p> |
| 160 | </div> |
| 161 | </div> |
| 162 |