PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.1
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 / CLI / BulkOptimizeCommand.php

BulkOptimizeCommand.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.1, at classes/CLI/BulkOptimizeCommand.php

67 lines 1.3 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\CLI;
5
6 use Imagify\Bulk\Bulk;
7
8 /**
9 * Command class for the bulk optimization
10 */
11 class BulkOptimizeCommand extends AbstractCommand {
12 /**
13 * Executes the command.
14 *
15 * @param array $arguments Positional argument.
16 * @param array $options Optional arguments.
17 */
18 public function __invoke( $arguments, $options ) {
19 $level = 2;
20
21 if ( isset( $options['lossless'] ) ) {
22 $level = 0;
23 }
24
25 foreach ( $arguments as $context ) {
26 Bulk::get_instance()->run_optimize( $context, $level );
27 }
28
29 \WP_CLI::log( 'Imagify bulk optimization triggered.' );
30 }
31
32 /**
33 * {@inheritdoc}
34 */
35 protected function get_command_name(): string {
36 return 'bulk-optimize';
37 }
38
39 /**
40 * {@inheritdoc}
41 */
42 public function get_description(): string {
43 return 'Run the bulk optimization';
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function get_synopsis(): array {
50 return [
51 [
52 'type' => 'positional',
53 'name' => 'contexts',
54 'description' => 'The context(s) to run the bulk optimization for. Possible values are wp and custom-folders.',
55 'optional' => false,
56 'repeating' => true,
57 ],
58 [
59 'type' => 'flag',
60 'name' => 'lossless',
61 'description' => 'Use lossless compression.',
62 'optional' => true,
63 ],
64 ];
65 }
66 }
67