Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.7
Stable tag: 3.5.0
Stable tag: 3.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -127,6 +127,9 @@ A: Yes! After installing the plugin, go to *Media > Bulk Optimization*, and clic
A: You can upgrade to a paid account by adding your *Payment details* on your [account dashboard](https://tinypng.com/dashboard/api). Additional compressions above 500 will then be charged at the end of each month as a one-time fee.

== Changelog ==
= 3.5.1 =
* Will only check local file removal if AS3CF is active

= 3.5.0 =
* Support files uploaded through the WordPress REST API
* Removed notification on WooCommerce incompatibility
Expand Down
2 changes: 1 addition & 1 deletion src/class-tiny-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class Tiny_Plugin extends Tiny_WP_Base {
const VERSION = '3.5.0';
const VERSION = '3.5.1';
const MEDIA_COLUMN = self::NAME;
const DATETIME_FORMAT = 'Y-m-d G:i:s';

Expand Down
6 changes: 6 additions & 0 deletions src/compatibility/as3cf/class-tiny-as3cf.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ public static function is_active() {
}

public static function remove_local_files_setting_enabled() {
if ( ! Tiny_AS3CF::is_active() ) {
return false;
}
$settings = get_option( 'tantan_wordpress_s3' );
if ( ! is_array( $settings ) ) {
return false;
}
return array_key_exists( 'remove-local-file', $settings ) && $settings['remove-local-file'];
}

Expand Down
1 change: 1 addition & 0 deletions test/helpers/wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function __construct( $vfs ) {
$this->addMethod( 'current_user_can' );
$this->addMethod( 'wp_get_attachment_metadata' );
$this->addMethod( 'is_admin' );
$this->addMethod( 'is_plugin_active' );
$this->defaults();
$this->create_filesystem();
}
Expand Down
113 changes: 113 additions & 0 deletions test/unit/compatibility/TinyAC3SFTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

require_once dirname(__FILE__) . '/../TinyTestCase.php';
require_once dirname(__FILE__) . '/../../../src/compatibility/as3cf/class-tiny-as3cf.php';

class Tiny_AC3SF_Test extends Tiny_TestCase
{
public function set_up()
{
parent::set_up();
}

/**
* Stub is_plugin_active to return true for the pro plugin
* is_plugin_active will only work in admin area (after admin_init);
*/
public function test_is_active_when_pro_is_enabled()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return $plugin_name === 'amazon-s3-and-cloudfront-pro/amazon-s3-and-cloudfront-pro.php';
}
);

$tiny_settings = new Tiny_Settings();
$tiny_ac3sf = new Tiny_AS3CF($tiny_settings);

$this->assertTrue(Tiny_AS3CF::is_active());
}

public function test_is_active_when_lite_is_enabled()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return $plugin_name === 'amazon-s3-and-cloudfront/wordpress-s3.php';
}
);


$this->assertTrue(Tiny_AS3CF::is_active());
}

public function test_is_not_active()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return false;
}
);


$this->assertFalse(Tiny_AS3CF::is_active());
}

public function test_remove_local_enabled_is_false_when_plugin_inactive()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return false;
}
);

$this->assertFalse(Tiny_AS3CF::remove_local_files_setting_enabled());
}

public function test_remove_local_false_when_option_not_exists()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return true;
}
);

$this->assertFalse(Tiny_AS3CF::remove_local_files_setting_enabled());
}

public function test_remove_local_false_when_option_is_false()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return true;
}
);

$this->wp->addOption('tantan_wordpress_s3', array(
'remove-local-file' => false,
));

$this->assertFalse(Tiny_AS3CF::remove_local_files_setting_enabled());
}

public function test_remove_local_true_when_option_is_true()
{
$this->wp->stub(
'is_plugin_active',
function ($plugin_name) {
return true;
}
);

$this->wp->addOption('tantan_wordpress_s3', array(
'remove-local-file' => true,
));

$this->assertTrue(Tiny_AS3CF::remove_local_files_setting_enabled());
}
}
2 changes: 1 addition & 1 deletion tiny-compress-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: TinyPNG - JPEG, PNG & WebP image compression
* Description: Speed up your website. Optimize your JPEG, PNG, and WebP images automatically with TinyPNG.
* Version: 3.5.0
* Version: 3.5.1
* Author: TinyPNG
* Author URI: https://tinypng.com
* Text Domain: tiny-compress-images
Expand Down
Loading