From 4680f5c69666368ec68e8fd7dfdc992ff7ce9768 Mon Sep 17 00:00:00 2001 From: Sertii <36940685+Sreini@users.noreply.github.com> Date: Mon, 16 Feb 2026 07:34:38 +0100 Subject: [PATCH 1/8] release: 3.6.10 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 565e7c67..aa6e9ea1 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://tinypng.com/ Tags: compress images, compression, image size, page speed, performance Requires at least: 4.0 Tested up to: 6.9 -Stable tag: 3.6.9 +Stable tag: 3.6.10 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From 0c8216567d6d60e908cddabeabd5bc82bbb6ce8a Mon Sep 17 00:00:00 2001 From: tijmen Date: Thu, 26 Mar 2026 16:28:38 +0100 Subject: [PATCH 2/8] allow delivery to be undefined, defaults to picture --- test/integration/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/utils.ts b/test/integration/utils.ts index 01640e24..e6f7a59f 100644 --- a/test/integration/utils.ts +++ b/test/integration/utils.ts @@ -214,7 +214,7 @@ export async function deactivatePlugin(page: Page, pluginSlug: string) { await plugin.getByLabel('Deactivate').click(); } -export async function setConversionSettings(page: Page, settings: { convert: boolean; output?: 'smallest' | 'webp' | 'avif'; delivery: 'picture' | 'htaccess' }) { +export async function setConversionSettings(page: Page, settings: { convert: boolean; output?: 'smallest' | 'webp' | 'avif'; delivery?: 'picture' | 'htaccess' }) { await page.goto('/wp-admin/options-general.php?page=tinify'); if (settings.convert) { From c677d0f979f30723324ffead43256cd6c7946d2d Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 08:56:49 +0200 Subject: [PATCH 3/8] add feedback notice --- src/class-tiny-notices.php | 16 ++++++++++++++++ src/views/notice-feedback.php | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 src/views/notice-feedback.php diff --git a/src/class-tiny-notices.php b/src/class-tiny-notices.php index fce29796..28d1ff73 100644 --- a/src/class-tiny-notices.php +++ b/src/class-tiny-notices.php @@ -102,6 +102,7 @@ private function show_stored() { public function show_notices() { $this->incompatible_plugins_notice(); $this->outdated_platform_notice(); + $this->feedback_notice(); } public function add( $name, $message ) { @@ -303,4 +304,19 @@ function () use ( $notice ) { } ); } + + /** + * Checks if the feedback notice should be displayed and hooks it to admin_notices. + * + * @return void + */ + function feedback_notice() { + if ( ! isset( $this->dismissals[ 'feedback' ] ) ) { + add_action('admin_notices', array( $this, 'feedback_notice_show' ) ); + } + } + + function feedback_notice_show() { + include __DIR__ . '/views/notice-feedback.php'; + } } diff --git a/src/views/notice-feedback.php b/src/views/notice-feedback.php new file mode 100644 index 00000000..099d5630 --- /dev/null +++ b/src/views/notice-feedback.php @@ -0,0 +1,5 @@ +
+

+ +

+
\ No newline at end of file From 709257b05962db09e7246676d27a9e56506a7409 Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 09:24:01 +0200 Subject: [PATCH 4/8] show feedback notice on more than 5 compressions --- src/class-tiny-notices.php | 30 ++++++++++++++++++++++++++++-- src/class-tiny-settings.php | 2 +- src/views/notice-feedback.php | 17 ++++++++++++++--- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/class-tiny-notices.php b/src/class-tiny-notices.php index 28d1ff73..b8714170 100644 --- a/src/class-tiny-notices.php +++ b/src/class-tiny-notices.php @@ -22,6 +22,30 @@ class Tiny_Notices extends Tiny_WP_Base { private $notices; private $dismissals; + /** + * Tiny_Settings instance. + * + * @var Tiny_Settings + */ + private $settings; + + /** + * The number of compressions required before showing the feedback notice. + * + * @var int + */ + private $compressions_for_feedback = 5; + + /** + * Tiny_Notices constructor. + * + * @param Tiny_Settings $settings The settings instance. + */ + public function __construct( $settings ) { + parent::__construct(); + $this->settings = $settings; + } + protected static $incompatible_plugins = array( 'CheetahO Image Optimizer' => 'cheetaho-image-optimizer/cheetaho.php', 'EWWW Image Optimizer' => 'ewww-image-optimizer/ewww-image-optimizer.php', @@ -311,8 +335,10 @@ function () use ( $notice ) { * @return void */ function feedback_notice() { - if ( ! isset( $this->dismissals[ 'feedback' ] ) ) { - add_action('admin_notices', array( $this, 'feedback_notice_show' ) ); + if ( ! isset( $this->dismissals['feedback'] ) && + $this->settings->get_compression_count() > $this->compressions_for_feedback + ) { + add_action( 'admin_notices', array( $this, 'feedback_notice_show' ) ); } } diff --git a/src/class-tiny-settings.php b/src/class-tiny-settings.php index 290b8b0d..d19e8765 100644 --- a/src/class-tiny-settings.php +++ b/src/class-tiny-settings.php @@ -29,7 +29,7 @@ class Tiny_Settings extends Tiny_WP_Base { public function __construct() { parent::__construct(); - $this->notices = new Tiny_Notices(); + $this->notices = new Tiny_Notices( $this ); new Tiny_Diagnostics( $this ); } diff --git a/src/views/notice-feedback.php b/src/views/notice-feedback.php index 099d5630..813a909e 100644 --- a/src/views/notice-feedback.php +++ b/src/views/notice-feedback.php @@ -1,5 +1,16 @@ +%s', + esc_url( $review_url ), + esc_html__( 'Leave a review', 'tiny-compress-images' ) +); +?> +
-

- -

+

+ + + +

\ No newline at end of file From d2b97fec6f2dc7a29ff309199254e3094dc4062b Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 09:25:57 +0200 Subject: [PATCH 5/8] set visisiblity --- src/class-tiny-notices.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/class-tiny-notices.php b/src/class-tiny-notices.php index b8714170..f62391a3 100644 --- a/src/class-tiny-notices.php +++ b/src/class-tiny-notices.php @@ -34,7 +34,7 @@ class Tiny_Notices extends Tiny_WP_Base { * * @var int */ - private $compressions_for_feedback = 5; + private $compressions_for_feedback = 10; /** * Tiny_Notices constructor. @@ -334,7 +334,7 @@ function () use ( $notice ) { * * @return void */ - function feedback_notice() { + private function feedback_notice() { if ( ! isset( $this->dismissals['feedback'] ) && $this->settings->get_compression_count() > $this->compressions_for_feedback ) { @@ -342,7 +342,7 @@ function feedback_notice() { } } - function feedback_notice_show() { + private function feedback_notice_show() { include __DIR__ . '/views/notice-feedback.php'; } } From 6b1149a209c66afc8f32c11596d56256d3f57bf4 Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 09:31:12 +0200 Subject: [PATCH 6/8] add constructor in test --- test/unit/TinySettingsAjaxTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/unit/TinySettingsAjaxTest.php b/test/unit/TinySettingsAjaxTest.php index 40fb44b4..1e05c810 100644 --- a/test/unit/TinySettingsAjaxTest.php +++ b/test/unit/TinySettingsAjaxTest.php @@ -4,6 +4,7 @@ class Tiny_Settings_Ajax_Test extends Tiny_TestCase { protected $notices; + private $settings; public function set_up() { parent::set_up(); @@ -12,7 +13,8 @@ public function set_up() { public function test_settings_ajax_init() { $tiny_settings = new Tiny_Settings(); - $tiny_settings->ajax_init(); + $this->settings = $tiny_settings; + $this->settings->ajax_init(); WordPressStubs::assertHook('wp_ajax_tiny_image_sizes_notice', array( $tiny_settings, 'image_sizes_notice' )); WordPressStubs::assertHook('wp_ajax_tiny_account_status', array( $tiny_settings, 'account_status' )); @@ -21,7 +23,7 @@ public function test_settings_ajax_init() { } public function test_notices_ajax_init() { - $tiny_notices = new Tiny_Notices(); + $tiny_notices = new Tiny_Notices( $this->settings ); $tiny_notices->ajax_init(); WordPressStubs::assertHook('wp_ajax_tiny_dismiss_notice', array( $tiny_notices, 'dismiss' )); From 3126445c70963859e6718fde13de70af2683e8c5 Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 10:01:08 +0200 Subject: [PATCH 7/8] add assert to check if hook is not called --- test/helpers/wordpress.php | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/test/helpers/wordpress.php b/test/helpers/wordpress.php index ff1b2c0c..45e2406d 100644 --- a/test/helpers/wordpress.php +++ b/test/helpers/wordpress.php @@ -337,6 +337,34 @@ public function getTestMetadata($path = '14/01', $name = 'test') * @param mixed $expected_args arguments to the hook */ public static function assertHook($hookname, $expected_args = null) + { + $found = self::findHook($hookname, $expected_args); + + $message = is_null($expected_args) + ? sprintf('Expected hook "%s" to be called.', $hookname) + : sprintf('Expected hook "%s" to be called with the given arguments.', $hookname); + + Assert::assertTrue($found, $message); + } + + /** + * Testhelper to assert a hook has NOT been registered. + * + * @param string $hookname name of the filter or action + * @param mixed $expected_args arguments to the hook + */ + public static function assertNotHook($hookname, $expected_args = null) + { + $found = self::findHook($hookname, $expected_args); + + $message = is_null($expected_args) + ? sprintf('Expected hook "%s" NOT to be called.', $hookname) + : sprintf('Expected hook "%s" NOT to be called with the given arguments.', $hookname); + + Assert::assertFalse($found, $message); + } + + private static function findHook($hookname, $expected_args = null) { $hooks = array('add_action', 'add_filter'); $found = false; @@ -363,11 +391,7 @@ public static function assertHook($hookname, $expected_args = null) } } - $message = is_null($expected_args) - ? sprintf('Expected hook "%s" to be called.', $hookname) - : sprintf('Expected hook "%s" to be called with the given arguments.', $hookname); - - Assert::assertTrue($found, $message); + return $found; } } From 8659390da904bceea76579eac7206316ced6c7a0 Mon Sep 17 00:00:00 2001 From: tijmen Date: Mon, 30 Mar 2026 10:01:19 +0200 Subject: [PATCH 8/8] assert when dismissed, do not show notice --- test/unit/Tiny_Notices_Test.php | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 test/unit/Tiny_Notices_Test.php diff --git a/test/unit/Tiny_Notices_Test.php b/test/unit/Tiny_Notices_Test.php new file mode 100644 index 00000000..bccbc99f --- /dev/null +++ b/test/unit/Tiny_Notices_Test.php @@ -0,0 +1,86 @@ +wp->addMethod( 'get_user_meta' ); + $this->wp->addMethod( 'update_user_meta' ); + $this->wp->addMethod( 'get_current_user_id' ); + + $this->settings = $this->createMock( Tiny_Settings::class ); + $this->settings->method( 'get_compression_count' )->willReturn( 0 ); + + $this->wp->stub( 'current_user_can', function () { + return true; + } ); + + $this->subject = new Tiny_Notices( $this->settings ); + } + + /** + * Verifies that when the current user has the manage_options capability, + * calling admin_init() registers at least one admin_notices action. + */ + public function test_registers_notices_when_user_can_manage_options() { + $this->subject->add( 'test', 'Test notice message' ); + + $this->subject->admin_init(); + + WordPressStubs::assertHook( 'admin_notices' ); + } + + /** + * Verifies that feedback_notice_show is hooked to admin_notices when the + * feedback notice has not been dismissed + */ + public function test_registers_feedback_notice_when_not_dismissed() { + $this->settings = $this->createMock( Tiny_Settings::class ); + $this->settings->method( 'get_compression_count' )->willReturn( 20 ); + $this->subject = new Tiny_Notices( $this->settings ); + + $this->subject->show_notices(); + + WordPressStubs::assertHook( 'admin_notices', array( $this->subject, 'feedback_notice_show' ) ); + } + + /** + * Verifies that feedback_notice_show is hooked to admin_notices when the + * compression count is just above compressions_for_feedback + */ + public function test_registers_feedback_notice_when_compressioncount_reached() { + $this->settings = $this->createMock( Tiny_Settings::class ); + $this->settings->method( 'get_compression_count' )->willReturn( 11 ); + $this->subject = new Tiny_Notices( $this->settings ); + + $this->subject->show_notices(); + + WordPressStubs::assertHook( 'admin_notices', array( $this->subject, 'feedback_notice_show' ) ); + } + + + /** + * Verifies that feedback_notice_show is NOT hooked to admin_notices when + * the feedback notice has been dismissed by the user. + */ + public function test_will_not_show_feedback_notice_when_dismissed() { + $this->settings = $this->createMock( Tiny_Settings::class ); + $this->subject = new Tiny_Notices( $this->settings ); + + $this->wp->stub( 'get_user_meta', function () { + return array( 'feedback' => true ); + } ); + + $this->subject->admin_init(); + + WordPressStubs::assertNotHook( 'admin_notices', array( $this->subject, 'feedback_notice_show' ) ); + } + +}