PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.9.8
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.9.8
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 / Bulk / AbstractBulk.php

AbstractBulk.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.9.8, at classes/Bulk/AbstractBulk.php

89 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\Bulk;
3
4 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
5
6 /**
7 * Abstract class to use for bulk.
8 *
9 * @since 1.9
10 * @author Grégory Viguier
11 */
12 abstract class AbstractBulk implements BulkInterface {
13
14 /**
15 * Filesystem object.
16 *
17 * @var \Imagify_Filesystem
18 * @since 1.9
19 * @access protected
20 * @author Grégory Viguier
21 */
22 protected $filesystem;
23
24 /**
25 * The constructor.
26 *
27 * @since 1.9
28 * @access public
29 * @author Grégory Viguier
30 */
31 public function __construct() {
32 $this->filesystem = \Imagify_Filesystem::get_instance();
33 }
34
35 /**
36 * Format context data (stats).
37 *
38 * @since 1.9
39 * @access protected
40 * @author Grégory Viguier
41 *
42 * @param array $data {
43 * The data to format.
44 *
45 * @type int $count-optimized Number of media optimized.
46 * @type int $count-errors Number of media having an optimization error.
47 * @type int $optimized-size Optimized filesize.
48 * @type int $original-size Original filesize.
49 * @type string $errors_url URL to the page listing the optimization errors.
50 * }
51 * @return array {
52 * The formated data.
53 *
54 * @type string $count-optimized Number of media optimized.
55 * @type string $count-errors Number of media having an optimization error, with a link to the page listing the optimization errors.
56 * @type string $optimized-size Optimized filesize.
57 * @type string $original-size Original filesize.
58 * }
59 */
60 protected function format_context_data( $data ) {
61 /* translators: %s is a formatted number, dont use %d. */
62 $data['count-optimized'] = sprintf( _n( '%s Media File Optimized', '%s Media Files Optimized', $data['count-optimized'], 'imagify' ), '<span>' . number_format_i18n( $data['count-optimized'] ) . '</span>' );
63
64 if ( $data['count-errors'] ) {
65 /* translators: %s is a formatted number, dont use %d. */
66 $data['count-errors'] = sprintf( _n( '%s Error', '%s Errors', $data['count-errors'], 'imagify' ), '<span>' . number_format_i18n( $data['count-errors'] ) . '</span>' );
67 $data['count-errors'] .= ' <a href="' . esc_url( $data['errors_url'] ) . '">' . __( 'View Errors', 'imagify' ) . '</a>';
68 } else {
69 $data['count-errors'] = '';
70 }
71
72 if ( $data['optimized-size'] ) {
73 $data['optimized-size'] = '<span class="imagify-cell-label">' . __( 'Optimized Filesize', 'imagify' ) . '</span> ' . imagify_size_format( $data['optimized-size'], 2 );
74 } else {
75 $data['optimized'] = '';
76 }
77
78 if ( $data['original-size'] ) {
79 $data['original-size'] = '<span class="imagify-cell-label">' . __( 'Original Filesize', 'imagify' ) . '</span> ' . imagify_size_format( $data['original-size'], 2 );
80 } else {
81 $data['original-size'] = '';
82 }
83
84 unset( $data['errors_url'] );
85
86 return $data;
87 }
88 }
89