PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / 3.6.13
TinyPNG – JPEG, PNG & WebP image compression v3.6.13
3.7.0 3.6.14 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.7.0 1.7.1 1.7.2 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.0.0 3.0.1 3.1.0 3.2.0 3.2.1 3.3 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.10 3.6.11 3.6.12 3.6.13 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
tiny-compress-images / src / views / compress-details.php
tiny-compress-images / src / views Last commit date
account-status-connected.php 5 months ago account-status-create-advanced.php 5 months ago account-status-create-simple.php 5 months ago account-status-loading.php 3 years ago bulk-optimization-form.php 5 months ago bulk-optimization-upgrade-notice.php 5 months ago bulk-optimization.php 2 months ago compress-details-processing.php 5 months ago compress-details.php 5 months ago dashboard-widget.php 2 months ago notice-feedback.php 2 months ago optimization-chart.php 5 months ago request-review.php 2 months ago settings-conversion-delivery.php 2 months ago settings-conversion-enabled.php 2 months ago settings-conversion-output.php 2 months ago settings-conversion.php 2 months ago settings-diagnostics.php 5 months ago settings-original-image-original.php 2 months ago settings-original-image-preserve.php 2 months ago settings-original-image.php 2 months ago settings.php 2 months ago
compress-details.php
260 lines
1 <?php
2
3 $available_sizes = array_keys( $this->settings->get_sizes() );
4 $conversion_enabled = $this->settings->get_conversion_enabled();
5 $active_sizes = $this->settings->get_sizes();
6 $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
7 $error = $tiny_image->get_latest_error();
8 $total = $tiny_image->get_count( array( 'modified', 'missing', 'has_been_compressed', 'compressed', 'has_been_converted' ) );
9 $active = $tiny_image->get_count( array( 'uncompressed', 'never_compressed', 'unconverted' ), $active_tinify_sizes );
10 $image_statistics = $tiny_image->get_statistics( $active_sizes, $active_tinify_sizes );
11 $available_uncompressed_sizes = $image_statistics['available_uncompressed_sizes'];
12 $size_before = $image_statistics['initial_total_size'];
13 $size_after = $image_statistics['compressed_total_size'];
14
15 $size_active = array_fill_keys( $active_tinify_sizes, true );
16 $size_exists = array_fill_keys( $available_sizes, true );
17 ksort( $size_exists );
18
19 $images_to_compress = array();
20 if ( ! empty( $_REQUEST['ids'] ) ) {
21 $images_to_compress = array_map( 'intval', explode( '-', $_REQUEST['ids'] ) );
22 }
23 ?>
24 <div class="details-container">
25 <div class="details">
26 <?php
27 if ( $error ) {
28 // dashicons-warning available for WP 4.3+
29 ?>
30 <span class="icon dashicons dashicons-no error"></span>
31 <?php } elseif ( $total['missing'] > 0 || $total['modified'] > 0 ) { ?>
32 <span class="icon dashicons dashicons-yes alert"></span>
33 <?php } elseif ( $total['compressed'] > 0 && $available_uncompressed_sizes > 0 ) { ?>
34 <span class="icon dashicons dashicons-yes alert"></span>
35 <?php } elseif ( $total['compressed'] > 0 ) { ?>
36 <span class="icon dashicons dashicons-yes success"></span>
37 <?php } ?>
38 <span class="icon spinner hidden"></span>
39 <?php if ( $total['has_been_compressed'] > 0 || ( 0 == $total['has_been_compressed'] && 0 == $available_uncompressed_sizes ) ) { ?>
40 <span class="message">
41 <?php
42 printf(
43 wp_kses(
44 /* translators: %d: number of compressed sizes */
45 _n( '<strong>%d</strong> size compressed', '<strong>%d</strong> sizes compressed', $total['has_been_compressed'], 'tiny-compress-images' ),
46 array(
47 'strong' => array(),
48 )
49 ),
50 $total['has_been_compressed']
51 );
52 ?>
53 </span>
54 <br>
55 <?php } ?>
56 <?php if ( $active['uncompressed'] > 0 ) { ?>
57 <span class="message">
58 <?php
59 /* translators: %d: number of sizes to be compressed */
60 printf( esc_html( _n( '%d size to be compressed', '%d sizes to be compressed', $available_uncompressed_sizes, 'tiny-compress-images' ) ), $available_uncompressed_sizes );
61 ?>
62 </span>
63 <br>
64 <?php } ?>
65 <?php
66 if ( $conversion_enabled ) {
67 if ( $total['has_been_converted'] > 0 || 0 == $image_statistics['available_unconverted_sizes'] ) {
68 ?>
69 <span class="message">
70 <?php
71 printf(
72 wp_kses(
73 /* translators: %d: number of compressed sizes */
74 _n( '<strong>%d</strong> size converted', '<strong>%d</strong> sizes converted', $total['has_been_converted'], 'tiny-compress-images' ),
75 array(
76 'strong' => array(),
77 )
78 ),
79 $total['has_been_converted']
80 );
81 ?>
82 </span>
83 <br>
84 <?php } ?>
85 <?php if ( $active['unconverted'] > 0 ) { ?>
86 <span class="message">
87 <?php
88 /* translators: %d: number of sizes to be converted */
89 printf( esc_html( _n( '%d size to be converted', '%d sizes to be converted', $active['unconverted'], 'tiny-compress-images' ) ), $active['unconverted'] );
90 ?>
91 </span>
92 <br>
93 <?php
94 }
95 }
96 ?>
97 <?php if ( $size_before - $size_after ) { ?>
98 <span class="message">
99 <?php
100 /* translators: %.0f%: savings percentage */
101 printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), ( 1 - $size_after / floatval( $size_before ) ) * 100 );
102 ?>
103 </span>
104 <br>
105 <?php } ?>
106 <?php if ( $error ) { ?>
107 <span class="message error_message">
108 <?php echo esc_html__( 'Latest error', 'tiny-compress-images' ) . ': ' . esc_html( $error, 'tiny-compress-images' ); ?>
109 </span>
110 <br>
111 <?php } ?>
112 <a class="thickbox message" href="#TB_inline?width=700&amp;height=500&amp;inlineId=modal_<?php echo $tiny_image->get_id(); ?>">
113 <?php esc_html_e( 'Details', 'tiny-compress-images' ); ?>
114 </a>
115 </div>
116 <?php if ( $available_uncompressed_sizes > 0 ) { ?>
117 <?php if ( in_array( $tiny_image->get_id(), $images_to_compress, true ) ) { ?>
118 <span class="hidden auto-compress"></span>
119 <?php } ?>
120 <button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo $tiny_image->get_id(); ?>">
121 <?php esc_html_e( 'Compress', 'tiny-compress-images' ); ?>
122 </button>
123 <button type="button" class="tiny-mark-as-compressed button button-small button-secondary" data-id="<?php echo $tiny_image->get_id(); ?>">
124 <?php esc_html_e( 'Mark as Compressed', 'tiny-compress-images' ); ?>
125 </button>
126 <?php } elseif ( $active['unconverted'] > 0 && $tiny_image->can_be_converted() ) { ?>
127 <button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo $tiny_image->get_id(); ?>">
128 <?php esc_html_e( 'Convert', 'tiny-compress-images' ); ?>
129 </button>
130 <button type="button" class="tiny-mark-as-compressed button button-small button-secondary" data-id="<?php echo $tiny_image->get_id(); ?>">
131 <?php esc_html_e( 'Mark as Converted', 'tiny-compress-images' ); ?>
132 </button>
133 <?php } ?>
134 </div>
135
136 <div class="modal" id="modal_<?php echo $tiny_image->get_id(); ?>">
137 <div class="tiny-compression-details">
138 <h3>
139 <?php
140 /* translators: %s is the image filename */
141 printf( esc_html__( 'Compression details for %s', 'tiny-compress-images' ), $tiny_image->get_name() );
142 ?>
143 </h3>
144 <table>
145 <tr>
146 <th><?php esc_html_e( 'Size', 'tiny-compress-images' ); ?></th>
147 <th><?php esc_html_e( 'Initial Size', 'tiny-compress-images' ); ?></th>
148 <th><?php esc_html_e( 'Compressed', 'tiny-compress-images' ); ?></th>
149 <th><?php esc_html_e( 'Format', 'tiny-compress-images' ); ?></th>
150 <?php
151 if ( $conversion_enabled ) {
152 ?>
153 <th><?php esc_html_e( 'Converted', 'tiny-compress-images' ); ?></th> <?php } ?>
154 <th><?php esc_html_e( 'Date', 'tiny-compress-images' ); ?></th>
155 </tr>
156 <?php
157 $i = 0;
158 $sizes = $tiny_image->get_image_sizes() + $size_exists;
159 foreach ( $sizes as $size_name => $size ) {
160 if ( ! is_object( $size ) ) {
161 $size = new Tiny_Image_Size();
162 }
163 ?>
164 <tr class="<?php echo ( 0 == $i % 2 ) ? 'even' : 'odd'; ?>">
165 <?php
166 echo '<td>';
167 echo '<span title="' . esc_html( basename( (string) $size->filename ) ) . '">';
168 echo ( Tiny_Image::is_original( $size_name ) ? esc_html__( 'Original', 'tiny-compress-images' ) : esc_html( ucfirst( rtrim( $size_name, '_wr2x' ) ) ) );
169 echo '</span>' . ' ';
170 if ( ! array_key_exists( $size_name, $active_sizes ) && ! Tiny_Image::is_retina( $size_name ) ) {
171 echo '<em>' . esc_html__( '(not in use)', 'tiny-compress-images' ) . '</em>';
172 } elseif ( $size->missing() && ( Tiny_Settings::wr2x_active() || ! Tiny_Image::is_retina( $size_name ) ) ) {
173 echo '<em>' . esc_html__( '(file removed)', 'tiny-compress-images' ) . '</em>';
174 } elseif ( $size->modified() ) {
175 echo '<em>' . esc_html__( '(modified after compression)', 'tiny-compress-images' ) . '</em>';
176 } elseif ( Tiny_Image::is_retina( $size_name ) ) {
177 echo '<em>' . esc_html__( '(WP Retina 2x)', 'tiny-compress-images' ) . '</em>';
178 } elseif ( $size->resized() ) {
179 /* translators: %1$dx%2$d: resized image width x height */
180 printf( '<em>' . esc_html__( '(resized to %1$dx%2$d)', 'tiny-compress-images' ) . '</em>', $size->meta['output']['width'], $size->meta['output']['height'] );
181 }
182 echo '</td>';
183
184 if ( $size->is_duplicate() ) {
185 echo '<td>-</td>';
186 /* translators: %s: name of similar thumbnail size */
187 printf( '<td colspan=4><em>' . esc_html__( 'Same file as "%s"', 'tiny-compress-images' ) . '</em></td>', esc_html( ucfirst( $size->duplicate_of_size() ) ) );
188 } elseif ( $size->has_been_compressed() ) {
189
190 echo '<td>' . size_format( $size->meta['input']['size'], 1 ) . '</td>';
191 echo '<td>' . size_format( $size->meta['output']['size'], 1 ) . '</td>';
192 echo '<td>' . esc_html( $size->meta['output']['type'] ) . '</td>';
193 if ( $conversion_enabled ) {
194 echo '<td>' . $size->conversion_text() . '</td>';
195 }
196 /* translators: %s human friendly time difference */
197 echo '<td>' . sprintf( esc_html__( '%s ago', 'tiny-compress-images' ), human_time_diff( $size->end_time( $size_name ) ) ) . '</td>';
198 } elseif ( ! $size->exists() ) {
199 echo '<td>-</td>';
200 echo '<td colspan=4><em>' . esc_html__( 'Not present', 'tiny-compress-images' ) . '</em></td>';
201 } elseif ( isset( $size_active[ $size_name ] ) || Tiny_Image::is_retina( $size_name ) ) {
202 echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
203 echo '<td colspan=5><em>' . esc_html__( 'Not compressed', 'tiny-compress-images' ) . '</em></td>';
204 } elseif ( isset( $size_exists[ $size_name ] ) ) {
205 echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
206 echo '<td colspan=4><em>' . esc_html__( 'Not configured to be compressed', 'tiny-compress-images' ) . '</em></td>';
207 } elseif ( ! array_key_exists( $size_name, $active_sizes ) ) {
208 echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
209 echo '<td colspan=4><em>' . esc_html__( 'Size is not in use', 'tiny-compress-images' ) . '</em></td>';
210 } else {
211 echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
212 echo '<td>-</td>';
213 echo '<td>-</td>';
214 echo '<td>-</td>';
215 echo '<td>-</td>';
216 }
217 ?>
218 </tr>
219 <?php
220 ++$i;
221 } // End foreach().
222 if ( $image_statistics['image_sizes_compressed'] > 0 ) {
223 ?>
224 <tfoot>
225 <tr>
226 <td><?php esc_html_e( 'Combined', 'tiny-compress-images' ); ?></td>
227 <td><?php echo size_format( $size_before, 1 ); ?></td>
228 <td><?php echo size_format( $size_after, 1 ); ?></td>
229 <td></td>
230 <?php
231 if ( $conversion_enabled ) {
232 ?>
233 <td></td> <?php } ?>
234 <td></td>
235 </tr>
236 </tfoot>
237 <?php
238 }
239 ?>
240 </table>
241 <p>
242 <strong>
243 <?php
244 if ( $size_before - $size_after ) {
245 printf(
246 /* translators: %1$.0f%%: savings percentage, %2$s: total file size savings */
247 esc_html__( 'Total savings %1$.0f%% (%2$s)', 'tiny-compress-images' ),
248 ( 1 - $size_after / floatval( $size_before ) ) * 100,
249 size_format( $size_before - $size_after, 1 )
250 );
251 } else {
252 /* translators: %.0f%%: savings percentage */
253 printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), 0 );
254 }
255 ?>
256 </strong>
257 </p>
258 </div>
259 </div>
260