PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Media / Upload / Upload.php

Upload.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at classes/Media/Upload/Upload.php

56 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace Imagify\Media\Upload;
5
6 /**
7 * Upload Media Class.
8 */
9 class Upload {
10 /**
11 * Adds a dropdown that allows filtering on the attachments Imagify status.
12 *
13 * @return void
14 */
15 public function add_imagify_filter_to_attachments_dropdown() {
16 $data = [];
17
18 /**
19 * Tell if imagify stats query should run.
20 *
21 * @param bool $boolean True if the query should be run. False otherwise.
22 */
23 if ( wpm_apply_filters_typed( 'boolean', 'imagify_display_library_stats', false ) ) {
24 $data['optimized'] = imagify_count_optimized_attachments();
25 $data['unoptimized'] = imagify_count_unoptimized_attachments();
26 $data['errors'] = imagify_count_error_attachments();
27
28 }
29
30 $status = isset( $_GET['imagify-status'] ) ? sanitize_text_field( wp_unslash( $_GET['imagify-status'] ) ) : 0;
31 $options = [
32 'optimized' => _x( 'Optimized', 'Media Files', 'imagify' ),
33 'unoptimized' => _x( 'Unoptimized', 'Media Files', 'imagify' ),
34 'errors' => _x( 'Errors', 'Media Files', 'imagify' ),
35 ];
36
37 /**
38 * Nothing can be missing a next-gen version when no next-gen format is being generated,
39 * so the filter would only ever return an empty list. Offer it when it can do something.
40 */
41 if ( ! empty( imagify_nextgen_images_formats() ) ) {
42 $options['missing-nextgen'] = _x( 'Missing Next-Gen', 'Media Files', 'imagify' );
43 }
44
45 echo '<label class="screen-reader-text" for="filter-by-optimization-status">' . esc_html__( 'Filter by status', 'imagify' ) . '</label>';
46 echo '<select id="filter-by-optimization-status" name="imagify-status">';
47 echo '<option value="0" selected="selected">' . esc_html__( 'All Media Files', 'imagify' ) . '</option>';
48
49 foreach ( $options as $value => $label ) {
50 $filter_value = isset( $data[ $value ] ) ? ' (' . $data[ $value ] . ')' : '';
51 echo '<option value="' . esc_attr( $value ) . '" ' . selected( $status, $value, false ) . '>' . esc_html( $label ) . esc_html( $filter_value ) . '</option>';
52 }
53 echo '</select>&nbsp;';
54 }
55 }
56