Skip to content

Commit 622895c

Browse files
Remove $settings
1 parent 0643bf2 commit 622895c

2 files changed

Lines changed: 11 additions & 24 deletions

File tree

src/class-tiny-cli.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,9 @@
2020

2121
class Tiny_Cli
2222
{
23-
/**
24-
* Tiny_Plugin $settings
25-
*
26-
* @var Tiny_Settings
27-
*/
28-
private $tiny_settings;
2923

30-
public function __construct($settings)
24+
public function __construct()
3125
{
32-
$this->tiny_settings = $settings;
3326

3427
// Only add CLI hooks when WP-CLI is available
3528
if (defined('WP_CLI') && WP_CLI) {
@@ -38,23 +31,13 @@ public function __construct($settings)
3831
}
3932

4033
public function register_command() {
41-
$command_instance = new Tiny_Command( $this->tiny_settings );
34+
$command_instance = new Tiny_Command();
4235
WP_CLI::add_command('tiny', $command_instance);
4336
}
4437
}
4538

4639
class Tiny_Command
4740
{
48-
/**
49-
* Tiny_Plugin $settings
50-
*
51-
* @var Tiny_Settings
52-
*/
53-
private $tiny_settings;
54-
55-
public function __construct( $settings ) {
56-
$tiny_settings = $settings;
57-
}
5841

5942
/**
6043
* Optimize will process images
@@ -79,11 +62,6 @@ public function __construct( $settings ) {
7962
*/
8063
public function optimize($args, $assoc_args)
8164
{
82-
if (! $this->tiny_settings) {
83-
WP_CLI::error('TinyPNG settings not available.');
84-
return;
85-
}
86-
8765
$attachments = isset($assoc_args['attachments']) ? array_map('trim', explode(',', $assoc_args['attachments'])) : array();
8866

8967
if (empty($attachments)) {

test/unit/TinyCliTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ public function test_will_not_hook_if_cli_is_unavailable() {
4646

4747
$this->assertFalse($cli_init_found, 'No cli_init hooks should be registered when WP_CLI is not available');
4848
}
49+
50+
public function test_will_compress_attachments_given_in_params() {
51+
$command = new Tiny_Command();
52+
$command->optimize(array(), array(
53+
"attachments" => array(4030),
54+
));
55+
56+
57+
}
4958
}

0 commit comments

Comments
 (0)