Skip to content

Commit 2621cdc

Browse files
Multiple style fixes.
1 parent 33940e4 commit 2621cdc

8 files changed

Lines changed: 35 additions & 35 deletions

File tree

src/class-tiny-compress-fopen.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function validate() {
5555

5656
if ( 429 == $status_code || 400 == $status_code ) {
5757
return true;
58-
} else if ( is_array( $details ) && isset( $details['error'] ) ) {
58+
} elseif ( is_array( $details ) && isset( $details['error'] ) ) {
5959
throw new Tiny_Exception(
6060
$details['message'],
6161
'Tinify\Exception',
@@ -81,13 +81,13 @@ protected function compress( $input, $resize_opts, $preserve_opts ) {
8181
'Tinify\Exception',
8282
$status_code
8383
);
84-
} else if ( $status_code >= 400 ) {
84+
} elseif ( $status_code >= 400 ) {
8585
throw new Tiny_Exception(
8686
'Unexpected error during compression',
8787
'Tinify\Exception',
8888
$status_code
8989
);
90-
} else if ( null === $output_url ) {
90+
} elseif ( null === $output_url ) {
9191
throw new Tiny_Exception(
9292
'Could not find output location',
9393
'Tinify\Exception'
@@ -103,7 +103,7 @@ protected function compress( $input, $resize_opts, $preserve_opts ) {
103103
'Tinify\Exception',
104104
$status_code
105105
);
106-
} else if ( $status_code >= 400 ) {
106+
} elseif ( $status_code >= 400 ) {
107107
throw new Tiny_Exception(
108108
'Unexpected error during output retrieval',
109109
'Tinify\Exception',

src/class-tiny-notices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function show( $name, $message, $klass = 'error', $dismissible = true ) {
119119
$css = array( $klass, 'notice', 'tiny-notice' );
120120
if ( ! $dismissible ) {
121121
$add = '</p>';
122-
} else if ( self::check_wp_version( 4.2 ) ) {
122+
} elseif ( self::check_wp_version( 4.2 ) ) {
123123
$add = '</p>';
124124
$css[] = 'is-dismissible';
125125
} else {

src/class-tiny-settings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function admin_init() {
5656
'Please register or provide an API key to start compressing images',
5757
'tiny-compress-images'
5858
);
59-
} else if ( $this->get_api_key_pending() ) {
59+
} elseif ( $this->get_api_key_pending() ) {
6060
$notice_class = 'notice-warning';
6161
$notice = esc_html__(
6262
'Please activate your account to start compressing images',
@@ -380,7 +380,7 @@ private function render_size_checkbox( $size, $option ) {
380380
if ( Tiny_Image::is_original( $size ) ) {
381381
$label = esc_html__( 'Original image', 'tiny-compress-images' ) . ' (' .
382382
esc_html__( 'overwritten by compressed image', 'tiny-compress-images' ) . ')';
383-
} else if ( Tiny_Image::is_retina( $size ) ) {
383+
} elseif ( Tiny_Image::is_retina( $size ) ) {
384384
$label = esc_html__( 'WP Retina 2x sizes', 'tiny-compress-images' );
385385
} else {
386386
$width = $option['width'];
@@ -464,7 +464,7 @@ public function render_resize() {
464464

465465
echo '<p class="tiny-resize-available">';
466466
echo '<input type="checkbox" id="' . $id . '" name="' . $name .
467-
'" value="on" '. $checked . '/>';
467+
'" value="on" ' . $checked . '/>';
468468
echo '<label for="' . $id . '">' . $label . '</label>';
469469
echo '<br>';
470470
echo '</p>';

src/views/bulk-optimization.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
printf( esc_html__( '%s, you are doing good.', 'tiny-compress-images' ), $this->friendly_user_name() );
6060
}
6161
echo ' ';
62-
printf( esc_html__( '%d%% of your image library is optimized.', 'tiny-compress-images' ), $percentage_of_files );
62+
printf( esc_html__( '%1$d%2$% of your image library is optimized.', 'tiny-compress-images' ), $percentage_of_files );
6363
echo ' ';
6464
printf( esc_html__( 'Start the bulk optimization to optimize the remainder of your library.', 'tiny-compress-images' ) );
6565
} else {
@@ -95,7 +95,7 @@
9595
<?php if ( $stats['uploaded-images'] > 0 && sizeof( $active_tinify_sizes ) > 0 && $stats['available-unoptimised-sizes'] > 0 ) { ?>
9696
<p>
9797
<?php
98-
printf( esc_html__( 'With your current settings you can still optimize %d images sizes from your %d uploaded JPEG and PNG images.',
98+
printf( esc_html__( 'With your current settings you can still optimize %1$d images sizes from your %1$d uploaded JPEG and PNG images.',
9999
'tiny-compress-images'), $stats['available-unoptimised-sizes'], $stats['uploaded-images'] );
100100
?>
101101
</p>
@@ -128,7 +128,7 @@
128128
</strong>
129129
<?php sizeof( $active_tinify_sizes ) > 1 ? esc_html_e( 'are compressed.', 'tiny-compress-images' ) : esc_html_e( 'is compressed.', 'tiny-compress-images' ) ?>
130130
<?php } ?>
131-
<?php printf( wp_kses( __( 'You can change these settings %s', 'tiny-compress-images' ), array( 'a' => array( 'href' => array() ) ) ), '<a href='. admin_url( 'options-media.php#tiny-compress-images' ). '>'. __( 'here', 'tiny-compress-images' ). '</a>' )?>
131+
<?php printf( wp_kses( __( 'You can change these settings %s', 'tiny-compress-images' ), array( 'a' => array( 'href' => array() ) ) ), '<a href=' . admin_url( 'options-media.php#tiny-compress-images' ) . '>' . __( 'here', 'tiny-compress-images' ) . '</a>' )?>
132132
</p>
133133
</div>
134134
</div>

src/views/compress-details.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
<?php if ( $error ) {
2222
// dashicons-warning available for WP 4.3+ ?>
2323
<span class="icon dashicons dashicons-no error"></span>
24-
<?php } else if ( $total['missing'] > 0 || $total['modified'] > 0 ) { ?>
24+
<?php } elseif ( $total['missing'] > 0 || $total['modified'] > 0 ) { ?>
2525
<span class="icon dashicons dashicons-yes alert"></span>
26-
<?php } else if ( $total['compressed'] > 0 && $available_unoptimized_sizes > 0 ) { ?>
26+
<?php } elseif ( $total['compressed'] > 0 && $available_unoptimized_sizes > 0 ) { ?>
2727
<span class="icon dashicons dashicons-yes alert"></span>
28-
<?php } else if ( $total['compressed'] > 0 ) { ?>
28+
<?php } elseif ( $total['compressed'] > 0 ) { ?>
2929
<span class="icon dashicons dashicons-yes success"></span>
3030
<?php } ?>
3131
<span class="icon spinner hidden"></span>
@@ -43,13 +43,13 @@
4343
<?php } ?>
4444
<?php if ( $size_before - $size_after ) { ?>
4545
<span class="message">
46-
<?php printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), (1 - $size_after / floatval( $size_before )) * 100 ) ?>
46+
<?php printf( esc_html__( 'Total savings %1$.0f%2$%', 'tiny-compress-images' ), (1 - $size_after / floatval( $size_before )) * 100 ) ?>
4747
</span>
4848
<br />
4949
<?php } ?>
5050
<?php if ( $error ) { ?>
5151
<span class="message error_message">
52-
<?php echo esc_html__( 'Latest error', 'tiny-compress-images' ) . ': '. esc_html__( $error, 'tiny-compress-images' ) ?>
52+
<?php echo esc_html__( 'Latest error', 'tiny-compress-images' ) . ': ' . esc_html__( $error, 'tiny-compress-images' ) ?>
5353
</span>
5454
<br/>
5555
<?php } ?>
@@ -91,34 +91,34 @@
9191
echo ' ';
9292
if ( ! array_key_exists( $size_name, $active_sizes ) && ! Tiny_Image::is_retina( $size_name ) ) {
9393
echo '<em>' . esc_html__( '(not in use)', 'tiny-compress-images' ) . '</em>';
94-
} else if ( $size->missing() && ( Tiny_Settings::wr2x_active() || ! Tiny_Image::is_retina( $size_name ) ) ) {
94+
} elseif ( $size->missing() && ( Tiny_Settings::wr2x_active() || ! Tiny_Image::is_retina( $size_name ) ) ) {
9595
echo '<em>' . esc_html__( '(file removed)', 'tiny-compress-images' ) . '</em>';
96-
} else if ( $size->modified() ) {
96+
} elseif ( $size->modified() ) {
9797
echo '<em>' . esc_html__( '(modified after compression)', 'tiny-compress-images' ) . '</em>';
98-
} else if ( Tiny_Image::is_retina( $size_name ) ) {
98+
} elseif ( Tiny_Image::is_retina( $size_name ) ) {
9999
echo '<em>' . esc_html__( '(WP Retina 2x)', 'tiny-compress-images' ) . '</em>';
100-
} else if ( $size->resized() ) {
101-
printf( '<em>' . esc_html__( '(resized to %dx%d)', 'tiny-compress-images' ) . '</em>', $size->meta['output']['width'], $size->meta['output']['height'] );
100+
} elseif ( $size->resized() ) {
101+
printf( '<em>' . esc_html__( '(resized to %1$dx%1$d)', 'tiny-compress-images' ) . '</em>', $size->meta['output']['width'], $size->meta['output']['height'] );
102102
}
103103
echo '</td>';
104104

105105
if ( $size->is_duplicate() ) {
106106
echo '<td>-</td>';
107107
printf( '<td colspan=2><em>' . esc_html__( 'Same file as "%s"', 'tiny-compress-images' ) . '</em></td>', esc_html__( ucfirst( $size->duplicate_of_size() ) ) );
108-
} else if ( $size->has_been_compressed() ) {
108+
} elseif ( $size->has_been_compressed() ) {
109109
echo '<td>' . size_format( $size->meta['input']['size'], 1 ) . '</td>';
110110
echo '<td>' . size_format( $size->meta['output']['size'], 1 ) . '</td>';
111111
echo '<td>' . sprintf( esc_html__( '%s ago' ), human_time_diff( $size->end_time( $size_name ) ) ) . '</td>';
112-
} else if ( ! $size->exists() ) {
112+
} elseif ( ! $size->exists() ) {
113113
echo '<td>-</td>';
114114
echo '<td colspan=2><em>' . esc_html__( 'Not present', 'tiny-compress-images' ) . '</em></td>';
115-
} else if ( isset( $size_active[ $size_name ] ) || Tiny_Image::is_retina( $size_name ) ) {
115+
} elseif ( isset( $size_active[ $size_name ] ) || Tiny_Image::is_retina( $size_name ) ) {
116116
echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
117117
echo '<td colspan=2><em>' . esc_html__( 'Not compressed', 'tiny-compress-images' ) . '</em></td>';
118-
} else if ( isset( $size_exists[ $size_name ] ) ) {
118+
} elseif ( isset( $size_exists[ $size_name ] ) ) {
119119
echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
120120
echo '<td colspan=2><em>' . esc_html__( 'Not configured to be compressed', 'tiny-compress-images' ) . '</em></td>';
121-
} else if ( ! array_key_exists( $size_name, $active_sizes ) ) {
121+
} elseif ( ! array_key_exists( $size_name, $active_sizes ) ) {
122122
echo '<td>' . size_format( $size->filesize(), 1 ) . '</td>';
123123
echo '<td colspan=2><em>' . esc_html__( 'Size is not in use', 'tiny-compress-images' ) . '</em></td>';
124124
} else {
@@ -145,12 +145,12 @@
145145
<strong>
146146
<?php
147147
if ( $size_before - $size_after ) {
148-
printf( esc_html__( 'Total savings %.0f%% (%s)', 'tiny-compress-images' ),
148+
printf( esc_html__( 'Total savings %1$.0f%2$% (%3$s)', 'tiny-compress-images' ),
149149
( 1 - $size_after / floatval( $size_before ) ) * 100,
150150
size_format( $size_before - $size_after, 1 )
151151
);
152152
} else {
153-
printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), 0 );
153+
printf( esc_html__( 'Total savings %1$.0f%2$%', 'tiny-compress-images' ), 0 );
154154
}
155155
?>
156156
</strong>

test/fixtures/Client.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ private static function caBundle() {
1616
return __DIR__ . '/../data/cacert.pem';
1717
}
1818

19-
function __construct($key, $appIdentifier = null) {
20-
$userAgent = join( ' ', array_filter( array( self::userAgent(), $appIdentifier) ) );
19+
function __construct( $key, $appIdentifier = null ) {
20+
$userAgent = join( ' ', array_filter( array( self::userAgent(), $appIdentifier ) ) );
2121
$this->options = array(
2222
CURLOPT_BINARYTRANSFER => true,
2323
CURLOPT_RETURNTRANSFER => true,
@@ -27,7 +27,7 @@ function __construct($key, $appIdentifier = null) {
2727
);
2828
}
2929

30-
function request($method, $url, $body = null, $header = array() ) {
30+
function request( $method, $url, $body = null, $header = array() ) {
3131
if ( is_array( $body ) ) {
3232
if ( ! empty( $body ) ) {
3333
$body = json_encode( $body );
@@ -98,7 +98,7 @@ function request($method, $url, $body = null, $header = array() ) {
9898
}
9999
}
100100

101-
protected static function parseHeaders($headers) {
101+
protected static function parseHeaders( $headers ) {
102102
if ( ! is_array( $headers ) ) {
103103
$headers = explode( "\r\n", $headers );
104104
}
@@ -111,7 +111,7 @@ protected static function parseHeaders($headers) {
111111

112112
$split = explode( ':', $header, 2 );
113113
if ( count( $split ) === 2 ) {
114-
$result[strtolower( $split[0] )] = trim( $split[1] );
114+
$result[ strtolower( $split[0] ) ] = trim( $split[1] );
115115
}
116116
}
117117
return $result;

test/helpers/setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function setup_wordpress_site( $driver ) {
118118

119119
/* Confirm use of weak password if necessary. */
120120
$confirm = $driver->findElement( WebDriverBy::name( 'pw_weak' ) );
121-
if ( $confirm && ! $confirm->isSelected() ) $confirm->click();
121+
if ( $confirm && ! $confirm->isSelected() ) { $confirm->click(); }
122122
} else {
123123
$driver->findElement( WebDriverBy::name( 'admin_password' ) )->sendKeys( 'admin' );
124124
$driver->findElement( WebDriverBy::name( 'admin_password2' ) )->sendKeys( 'admin' );

test/integration/BulkOptimizationIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ public function test_start_bulk_optimization_should_optimize_remaining_images()
7979
}
8080

8181
public function test_should_display_tooltips() {
82-
$this->assertGreaterThanOrEqual( '1', sizeof($this->find_all( 'div.tip' )));
82+
$this->assertGreaterThanOrEqual( '1', sizeof( $this->find_all( 'div.tip' ) ) );
8383
}
8484
}

0 commit comments

Comments
 (0)