From 827c9c028634785d4ada87b37a3552ea0c4377c8 Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 15:07:37 +0200
Subject: [PATCH 01/12] Increase strictness of phpcs
---
phpcs.xml | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/phpcs.xml b/phpcs.xml
index 9d0d00d2..b56e261b 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,8 +2,24 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From c1d32aba4f093fcd969d0931c01dc1e1ba70703f Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 15:08:07 +0200
Subject: [PATCH 02/12] autofixes
---
src/class-tiny-apache-rewrite.php | 6 ++---
src/class-tiny-cli.php | 1 -
src/class-tiny-compress-client.php | 9 ++++----
src/class-tiny-compress.php | 6 ++---
src/class-tiny-helpers.php | 24 ++++++++++----------
src/class-tiny-image.php | 6 +++--
src/class-tiny-logger.php | 1 -
src/class-tiny-php.php | 6 ++---
src/class-tiny-picture.php | 6 ++---
src/class-tiny-plugin.php | 10 +++++---
src/class-tiny-settings.php | 7 +++---
src/compatibility/as3cf/class-tiny-as3cf.php | 4 ++--
src/views/account-status-connected.php | 16 ++++++-------
13 files changed, 52 insertions(+), 50 deletions(-)
diff --git a/src/class-tiny-apache-rewrite.php b/src/class-tiny-apache-rewrite.php
index e91f4c56..e6944d70 100644
--- a/src/class-tiny-apache-rewrite.php
+++ b/src/class-tiny-apache-rewrite.php
@@ -31,6 +31,7 @@ class Tiny_Apache_Rewrite extends Tiny_WP_Base {
/**
* seperator when rules are inserted
+ *
* @var string
*/
const MARKER = 'tiny-compress-images';
@@ -40,9 +41,8 @@ class Tiny_Apache_Rewrite extends Tiny_WP_Base {
* hooked into `update_option_tinypng_convert_format`
* https://developer.wordpress.org/reference/hooks/update_option_option/
*
- *
- * @param mixed $old_value
- * @param mixed $value
+ * @param mixed $old_value
+ * @param mixed $value
* @param string $option
* @return void
*/
diff --git a/src/class-tiny-cli.php b/src/class-tiny-cli.php
index ba02f3af..d4f8a182 100644
--- a/src/class-tiny-cli.php
+++ b/src/class-tiny-cli.php
@@ -52,7 +52,6 @@ public static function register_command( $settings ) {
* optimize all unprocessed images
* wp tiny optimize
*
- *
* @param array $args
* @param array $assoc_args
* @return void
diff --git a/src/class-tiny-compress-client.php b/src/class-tiny-compress-client.php
index 3acd24b8..2f3531d6 100644
--- a/src/class-tiny-compress-client.php
+++ b/src/class-tiny-compress-client.php
@@ -98,7 +98,7 @@ protected function validate() {
}
throw new Tiny_Exception(
- $err->getMessage(),
+ esc_html( $err->getMessage() ),
get_class( $err ),
$err->status
);
@@ -165,7 +165,7 @@ protected function compress( $input, $resize_opts, $preserve_opts, $convert_to )
);
throw new Tiny_Exception(
- $err->getMessage(),
+ esc_html( $err->getMessage() ),
get_class( $err ),
$err->status
);
@@ -184,7 +184,7 @@ public function create_key( $email, $options ) {
$this->last_error_code = $err->status;
throw new Tiny_Exception(
- $err->getMessage(),
+ esc_html( $err->getMessage() ),
get_class( $err ),
$err->status
);
@@ -192,7 +192,8 @@ public function create_key( $email, $options ) {
}
private function set_request_options( $client ) {
- /* The client does not let us override cURL properties yet, so we have
+ /*
+ The client does not let us override cURL properties yet, so we have
to use a reflection property. */
$property = new ReflectionProperty( $client, 'options' );
$property->setAccessible( true );
diff --git a/src/class-tiny-compress.php b/src/class-tiny-compress.php
index d17f55c9..75ced00c 100644
--- a/src/class-tiny-compress.php
+++ b/src/class-tiny-compress.php
@@ -96,9 +96,9 @@ public function get_status() {
/**
* Compresses a single file
*
- * @param [type] $file
- * @param array $resize_opts
- * @param array $preserve_opts
+ * @param [type] $file
+ * @param array $resize_opts
+ * @param array $preserve_opts
* @param array{ string } conversion options
* @return void
*/
diff --git a/src/class-tiny-helpers.php b/src/class-tiny-helpers.php
index f2140d3c..51c678c3 100644
--- a/src/class-tiny-helpers.php
+++ b/src/class-tiny-helpers.php
@@ -29,7 +29,7 @@ class Tiny_Helpers {
* We can use mb_strlen & mb_substr as WordPress provides a compat function for
* it if mbstring php module is not installed.
*
- * @param string $text the text
+ * @param string $text the text
* @param integer $length the maximum length of the string
* @return string the truncated string
*/
@@ -173,17 +173,17 @@ public static function get_wp_filesystem() {
}
/**
- * Polyfill for `str_starts_with()` function added in PHP 8.0.
- *
- * Performs a case-sensitive check indicating if
- * the haystack begins with needle.
- *
- * @since 5.9.0
- *
- * @param string $haystack The string to search in.
- * @param string $needle The substring to search for in the `$haystack`.
- * @return bool True if `$haystack` starts with `$needle`, otherwise false.
- */
+ * Polyfill for `str_starts_with()` function added in PHP 8.0.
+ *
+ * Performs a case-sensitive check indicating if
+ * the haystack begins with needle.
+ *
+ * @since 5.9.0
+ *
+ * @param string $haystack The string to search in.
+ * @param string $needle The substring to search for in the `$haystack`.
+ * @return bool True if `$haystack` starts with `$needle`, otherwise false.
+ */
public static function str_starts_with( $haystack, $needle ) {
if ( function_exists( 'str_starts_with' ) ) {
return str_starts_with( $haystack, $needle );
diff --git a/src/class-tiny-image.php b/src/class-tiny-image.php
index a586f430..1a6576f5 100644
--- a/src/class-tiny-image.php
+++ b/src/class-tiny-image.php
@@ -51,7 +51,8 @@ private function parse_wp_metadata() {
}
if ( ! is_array( $this->wp_metadata ) || ! isset( $this->wp_metadata['file'] ) ) {
- /* No file metadata found, this might be another plugin messing with
+ /*
+ No file metadata found, this might be another plugin messing with
metadata. Simply ignore this! */
return;
}
@@ -63,7 +64,8 @@ private function parse_wp_metadata() {
$path_prefix .= $path_info['dirname'] . '/';
}
- /* Do not use pathinfo for getting the filename.
+ /*
+ Do not use pathinfo for getting the filename.
It doesn't work when the filename starts with a special character. */
$path_parts = explode( '/', $this->wp_metadata['file'] );
$this->name = end( $path_parts );
diff --git a/src/class-tiny-logger.php b/src/class-tiny-logger.php
index 311eec79..6fc8f061 100644
--- a/src/class-tiny-logger.php
+++ b/src/class-tiny-logger.php
@@ -22,7 +22,6 @@
/**
* Handles logging of plugin events to file.
*
- *
* @since 3.7.0
*/
class Tiny_Logger {
diff --git a/src/class-tiny-php.php b/src/class-tiny-php.php
index 91071da0..bbeb5818 100644
--- a/src/class-tiny-php.php
+++ b/src/class-tiny-php.php
@@ -37,8 +37,8 @@ public static function curl_exec_disabled() {
}
public static function client_supported() {
- return Tiny_PHP::has_fully_supported_php() &&
- Tiny_PHP::curl_available() &&
- ! Tiny_PHP::curl_exec_disabled();
+ return self::has_fully_supported_php() &&
+ self::curl_available() &&
+ ! self::curl_exec_disabled();
}
}
diff --git a/src/class-tiny-picture.php b/src/class-tiny-picture.php
index ab318131..ae3f5e41 100644
--- a/src/class-tiny-picture.php
+++ b/src/class-tiny-picture.php
@@ -109,7 +109,7 @@ private function replace_picture_sources( $content ) {
private function replace_img_sources( $content ) {
$image_sources = $this->filter_images( $content );
foreach ( $image_sources as $image_source ) {
- $content = Tiny_Picture::replace_image( $content, $image_source );
+ $content = self::replace_image( $content, $image_source );
}
return $content;
}
@@ -145,7 +145,7 @@ private function filter_pictures( $content ) {
/**
* Will add additional sourcesets to picture elements.
*
- * @param string $content the full page content
+ * @param string $content the full page content
* @param Tiny_Source_Picture $source the picture element
*
* @return string the updated content including augmented picture elements
@@ -159,7 +159,7 @@ private function replace_picture( $content, $source ) {
/**
* Will replace img elements with picture elements that (possibly) have additional formats.
*
- * @param string $content the full page content
+ * @param string $content the full page content
* @param Tiny_Source_Image $source the picture element
*
* @return string the updated content including augmented picture elements
diff --git a/src/class-tiny-plugin.php b/src/class-tiny-plugin.php
index 820da686..91420d19 100644
--- a/src/class-tiny-plugin.php
+++ b/src/class-tiny-plugin.php
@@ -32,7 +32,8 @@ public static function jpeg_quality() {
}
public static function version() {
- /* Avoid using get_plugin_data() because it is not loaded early enough
+ /*
+ Avoid using get_plugin_data() because it is not loaded early enough
in xmlrpc.php. */
return self::VERSION;
}
@@ -111,7 +112,8 @@ public function ajax_init() {
$this->get_method( 'mark_image_as_compressed' )
);
- /* When touching any functionality linked to image compressions when
+ /*
+ When touching any functionality linked to image compressions when
uploading images make sure it also works with XML-RPC. See README. */
add_filter(
'wp_ajax_nopriv_tiny_rpc',
@@ -788,7 +790,8 @@ public function add_dashboard_widget() {
true
);
- /* This might be deduplicated with the admin script localization, but
+ /*
+ This might be deduplicated with the admin script localization, but
the order of including scripts is sometimes different. So in that
case we need to make sure that the order of inclusion is correc.t */
wp_localize_script(
@@ -850,6 +853,7 @@ public function friendly_user_name() {
* Will clean up converted files (if any) when the original is deleted
*
* Hooked to the `delete_attachment` action.
+ *
* @see https://developer.wordpress.org/reference/hooks/deleted_post/
*
* @param [int] $post_id
diff --git a/src/class-tiny-settings.php b/src/class-tiny-settings.php
index d19e8765..294b26e9 100644
--- a/src/class-tiny-settings.php
+++ b/src/class-tiny-settings.php
@@ -221,7 +221,8 @@ protected function clear_api_key_pending() {
}
protected static function get_intermediate_size( $size ) {
- /* Inspired by
+ /*
+ Inspired by
http://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes */
global $_wp_additional_image_sizes;
@@ -789,14 +790,12 @@ public function render_account_status() {
if ( $this->get_api_key_pending() ) {
$this->clear_api_key_pending();
}
- } else {
- if ( $this->get_api_key_pending() ) {
+ } elseif ( $this->get_api_key_pending() ) {
$status->ok = true;
$status->pending = true;
$status->message = (
'An email has been sent to activate your account'
);
- }
}
include __DIR__ . '/views/account-status-connected.php';
}
diff --git a/src/compatibility/as3cf/class-tiny-as3cf.php b/src/compatibility/as3cf/class-tiny-as3cf.php
index 314f65e3..79d5e141 100644
--- a/src/compatibility/as3cf/class-tiny-as3cf.php
+++ b/src/compatibility/as3cf/class-tiny-as3cf.php
@@ -44,11 +44,11 @@ public function __construct( $settings ) {
* Will verify if either the Lite or Pro version of AS3CF is active.
*/
public static function is_active() {
- return Tiny_AS3CF::pro_is_active() || Tiny_AS3CF::lite_is_active();
+ return self::pro_is_active() || self::lite_is_active();
}
public static function remove_local_files_setting_enabled() {
- if ( ! Tiny_AS3CF::is_active() ) {
+ if ( ! self::is_active() ) {
return false;
}
$settings = get_option( 'tantan_wordpress_s3' );
diff --git a/src/views/account-status-connected.php b/src/views/account-status-connected.php
index 4f8b1bff..ac2910db 100644
--- a/src/views/account-status-connected.php
+++ b/src/views/account-status-connected.php
@@ -51,23 +51,21 @@
$compressions
);
}
- } else {
- if ( isset( $status->message ) ) {
+ } elseif ( isset( $status->message ) ) {
echo esc_html__( 'Error', 'tiny-compress-images' ) . ': ';
echo esc_html( $status->message, 'tiny-compress-images' );
- } else {
- esc_html_e(
- 'API status could not be checked, enable cURL for more information',
- 'tiny-compress-images'
- );
- }
+ } else {
+ esc_html_e(
+ 'API status could not be checked, enable cURL for more information',
+ 'tiny-compress-images'
+ );
} // End if().
?>
Date: Fri, 15 May 2026 15:08:14 +0200
Subject: [PATCH 03/12] remove unused
---
src/compatibility/as3cf/class-tiny-as3cf.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/compatibility/as3cf/class-tiny-as3cf.php b/src/compatibility/as3cf/class-tiny-as3cf.php
index 79d5e141..ca5af84a 100644
--- a/src/compatibility/as3cf/class-tiny-as3cf.php
+++ b/src/compatibility/as3cf/class-tiny-as3cf.php
@@ -62,7 +62,7 @@ public static function remove_local_files_setting_enabled() {
* Registers hooks required for the AS3CF integration.
*/
public function add_hooks() {
- add_action( 'as3cf_pre_upload_object', array( $this, 'as3cf_before_offload' ), 10, 2 );
+ add_action( 'as3cf_pre_upload_object', array( $this, 'as3cf_before_offload' ), 10, 1 );
}
/**
@@ -72,10 +72,9 @@ public function add_hooks() {
*
* Will handle file before file is possibly offloaded
*
- * @param Item $as3cf_item
- * @param array $args
+ * @param mixed $as3cf_item
*/
- public function as3cf_before_offload( $as3cf_item, $args ) {
+ public function as3cf_before_offload( $as3cf_item ) {
if ( ! $this->tiny_settings->auto_compress_enabled() ) {
return;
}
From 3cfdfc60af0c0a200cc0300d88a18e95a59795bb Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 15:16:17 +0200
Subject: [PATCH 04/12] remove unused
---
src/class-tiny-logger.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/class-tiny-logger.php b/src/class-tiny-logger.php
index 6fc8f061..4345c526 100644
--- a/src/class-tiny-logger.php
+++ b/src/class-tiny-logger.php
@@ -72,7 +72,7 @@ public static function init() {
'pre_update_option_tinypng_logging_enabled',
'Tiny_Logger::on_save_log_enabled',
10,
- 3
+ 2
);
}
@@ -113,7 +113,7 @@ public function get_log_file_path() {
*
* @return bool true if enabled
*/
- public static function on_save_log_enabled( $log_enabled, $old, $option ) {
+ public static function on_save_log_enabled( $log_enabled, $old ) {
$instance = self::get_instance();
$was_enabled = 'on' === $old;
$is_now_enabled = 'on' === $log_enabled;
From b603f27c72fd62ba238a452ff62d36f5e4e2811f Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 15:17:51 +0200
Subject: [PATCH 05/12] non-translatable string
---
src/views/compress-details.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/compress-details.php b/src/views/compress-details.php
index b0e30f43..1c1c1a7d 100644
--- a/src/views/compress-details.php
+++ b/src/views/compress-details.php
@@ -105,7 +105,7 @@
-
+
From d165ad5d78328ca8bf88852e0c0f9d0fe93ee3c4 Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 15:19:39 +0200
Subject: [PATCH 06/12] non translatable strings
---
src/views/account-status-connected.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/views/account-status-connected.php b/src/views/account-status-connected.php
index ac2910db..085b1dca 100644
--- a/src/views/account-status-connected.php
+++ b/src/views/account-status-connected.php
@@ -4,7 +4,7 @@
ok ) {
if ( isset( $status->message ) ) {
- echo esc_html( $status->message, 'tiny-compress-images' );
+ echo esc_html( $status->message );
} else {
esc_html_e( 'Your account is connected', 'tiny-compress-images' );
}
@@ -53,7 +53,7 @@
}
} elseif ( isset( $status->message ) ) {
echo esc_html__( 'Error', 'tiny-compress-images' ) . ': ';
- echo esc_html( $status->message, 'tiny-compress-images' );
+ echo esc_html( $status->message );
} else {
esc_html_e(
'API status could not be checked, enable cURL for more information',
From 35720e52f21d0eb27d084db0f7a65de030071227 Mon Sep 17 00:00:00 2001
From: tijmen
Date: Fri, 15 May 2026 21:56:12 +0200
Subject: [PATCH 07/12] use count instead of sizeof
---
src/views/bulk-optimization.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/views/bulk-optimization.php b/src/views/bulk-optimization.php
index 109afe38..a4ddd8e5 100644
--- a/src/views/bulk-optimization.php
+++ b/src/views/bulk-optimization.php
@@ -50,7 +50,7 @@
esc_html_e( 'This page is designed to bulk optimize all your images.', 'tiny-compress-images' );
echo ' ';
esc_html_e( 'You do not seem to have uploaded any JPEG, PNG or WebP images yet.', 'tiny-compress-images' );
- } elseif ( 0 == sizeof( $active_tinify_sizes ) ) {
+ } elseif ( 0 == count( $active_tinify_sizes ) ) {
esc_html_e( 'Based on your current settings, nothing will be optimized. There are no active sizes selected for optimization.', 'tiny-compress-images' );
} elseif ( 0 == $stats['available-unoptimized-sizes'] ) {
/* translators: %s: friendly user name */
@@ -115,7 +115,7 @@