Skip to content

Commit

Permalink
Release v2.2.3 (PR #911)
Browse files Browse the repository at this point in the history
Release v2.2.3
  • Loading branch information
wordpressfan authored Nov 7, 2024
2 parents 59710b7 + 8737aff commit a3e1630
Show file tree
Hide file tree
Showing 51 changed files with 1,502 additions and 303 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ When the plugin is disabled, your existing images remain optimized. Backups of t
Please report security bugs found in the site-reviews plugin's source code through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/imagify). The Patchstack team will assist you with verification, CVE assignment and take care of notifying the developers of this plugin.

## Changelog
### 2.2.3
- Enhancement: Cache the calls to the license API to avoid sending unnecessary requests
- 3rd-party compatibility: Update priority on `template_redirect` to improve compatibility with WP Rocket’s LazyLoad
- Bugfix: Fix `Uncaught TypeError: strpos() expects parameter 1 to be string` fatal error
- Enhancement: UI improvements
- Enhancement: Improve the code architecture

### 2.2.2
- Enhancement: Allow to choose which Next-Gen images should be generated in UI
- Enhancement: Guard against image size that’s not a string
Expand Down
23 changes: 23 additions & 0 deletions Tests/Fixtures/classes/Admin/AdminSubscriber/pluginActionLinks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

return [
'test_data' => [
'testShouldReturnDocumentationLinkAmongPluginLinksIfPlanLabelIsNotStarter' => [
'config' => [
'plan_id' => 2,
],
'expected' => [
'Documentation'
],
],
'testShouldReturnUpgradeLinkAmongPluginLinksIfPlanLabelIsStarter' => [
'config' => [
'plan_id' => 1,
],
'expected' => [
'Upgrade',
'class="imagify-plugin-upgrade"'
],
],
]
];
42 changes: 42 additions & 0 deletions Tests/Unit/classes/Admin/AdminSubscriber/pluginActionLinks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace Imagify\Tests\Unit\classes;

use Mockery;
use Brain\Monkey\Functions;
use Imagify\Tests\Unit\TestCase;
use Imagify\User\User;
use Imagify\Admin\AdminSubscriber;

/**
* Tests for \Imagify\Admin\AdminSubscriber->plugin_action_links().
*
* @covers \Imagify\Admin\AdminSubscriber::plugin_action_links
* @group ImagifyAPI
*/
class Test_PluginActionLinks extends TestCase {
protected $admin_subscriber, $user, $plan_id;

public function setUp(): void {
parent::setUp();

$this->user = Mockery::mock( User::class );
$this->admin_subscriber = new AdminSubscriber( $this->user );
}

/**
* @dataProvider configTestData
*/
public function testShouldReturnAsExpected( $config, $expected ) {
$this->user->plan_id = $config['plan_id'];

Functions\when( 'imagify_get_external_url' )->justReturn( 'https://example.org' );
Functions\when( 'get_imagify_admin_url' )->justReturn( 'https://example.org' );

$plugin_action_links = $this->admin_subscriber->plugin_action_links([]);
$plugin_action_links = implode( '|', $plugin_action_links );

foreach ( $expected as $text ) {
$this->assertStringContainsString( $text, $plugin_action_links );
}
}
}
29 changes: 29 additions & 0 deletions Tests/Unit/inc/classes/ImagifyUser/getError.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,47 @@ public function testShouldReturnFalseWhenFetchedUserData() {
'is_monthly' => true,
];

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $userData );
Functions\when( 'set_transient')->justReturn();

$this->assertFalse( ( new User() )->get_error() );
}

/**
* Test \Imagify\User\User() should return cached user data if available.
*/
public function testShouldReturnFromCachedUserDataIfAvailable() {
$userData = (object) [
'id' => 1,
'email' => '[email protected]',
'plan_id' => '1',
'plan_label' => 'free',
'quota' => 456,
'extra_quota' => 0,
'extra_quota_consumed' => 0,
'consumed_current_month_quota' => 123,
'next_date_update' => '',
'is_active' => 1,
'is_monthly' => true,
];

Functions\when( 'get_transient' )->justReturn( $userData );
Functions\expect( 'get_imagify_user' )->never();
Functions\when( 'set_transient')->justReturn();

$this->assertSame( '[email protected]', ( new User() )->email );
}

/**
* Test \Imagify\User\User->get_error() should return a WP_Error object when couldn’t fetch user account data.
*/
public function testShouldReturnErrorWhenCouldNotFetchUserData() {
$wp_error = new WP_Error( 'error_id', 'Error Message' );

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $wp_error );
Functions\when( 'set_transient')->justReturn();

$this->assertSame( $wp_error, ( new User() )->get_error() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Test_GetPercentConsumedQuota extends TestCase {
public function testShouldReturnZeroWhenCouldNotFetchUserData() {
$wp_error = new WP_Error( 'error_id', 'Error Message' );

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $wp_error );
Functions\when( 'set_transient')->justReturn();
Functions\expect( 'imagify_round_half_five' )->never();

$this->assertSame( ( new User() )->get_percent_consumed_quota(), 0 );
Expand All @@ -47,7 +49,9 @@ public function testShouldReturnQuotaWhenFetchedUserData() {
'is_monthly' => true,
];

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $userData );
Functions\when( 'set_transient')->justReturn();
Functions\expect( 'imagify_round_half_five' )
->twice()
->with( 0 ) // extra_quota_consumed.
Expand Down
6 changes: 6 additions & 0 deletions Tests/Unit/inc/classes/ImagifyUser/isOverQuota.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Test_IsOverQuota extends TestCase {
public function testShouldReturnFalseWhenCouldNotFetchUserData() {
$wp_error = new WP_Error( 'error_id', 'Error Message' );

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $wp_error );
Functions\when( 'set_transient')->justReturn();

$this->assertFalse( ( new User() )->is_over_quota() );
}
Expand All @@ -45,7 +47,9 @@ public function testShouldReturnFalseWhenPaidAccount() {
'is_monthly' => true,
];

Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $userData );
Functions\when( 'set_transient')->justReturn();

$this->assertFalse( ( new User() )->is_over_quota() );
}
Expand Down Expand Up @@ -97,7 +101,9 @@ public function testShouldReturnTrueWhenFreeOverQuota() {
}

private function createMocks( $userData, $dataPreviousQuotaPercent ) {
Functions\when( 'get_transient' )->justReturn( false );
Functions\when( 'get_imagify_user' )->justReturn( $userData );
Functions\when( 'set_transient')->justReturn();
Functions\expect( 'imagify_round_half_five' )
->once()
->with( 0 ) // extra_quota_consumed.
Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<testsuites>
<testsuite name="unit">
<directory suffix=".php">inc</directory>
<directory suffix=".php">classes</directory>
</testsuite>
</testsuites>

Expand Down
1 change: 1 addition & 0 deletions Tests/bootstrap-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ function init_constants( $test_suite_folder ) {

if ( 'Unit' === $test_suite_folder && ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', IMAGIFY_PLUGIN_ROOT );
define( 'MINUTE_IN_SECONDS', 60 );
}
}
33 changes: 28 additions & 5 deletions assets/css/admin-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@
}
#wpadminbar #wp-admin-bar-imagify-profile .ab-item {
height: auto;
padding: 0 13px;
padding: 0;
}
#wpadminbar #wp-admin-bar-imagify-profile {
min-width: 200px;
padding: 15px 0 10px;
margin-top: 0.7em;
background: #222;
}
Expand Down Expand Up @@ -193,7 +192,31 @@
#wpadminbar #wp-admin-bar-imagify-profile .imagify-upsell-dismiss::before {
position: absolute;
top: 5px;
right: 10px;
content: "\2715";
color: #fff;
right: 5px;
color: #fff;
}
.imagify-plugin-upgrade {
color: #6f9c3b;
font-weight: 600;
}

#wpadminbar #wp-admin-bar-imagify-upgrade-plan .ab-empty-item {
padding: 0;
}

#wpadminbar .imagify-admin-bar-upgrade-plan {
background: #8bc34a;
box-sizing: border-box;
border:none;
color: #fff;
cursor: pointer;
display: block;
font-weight: bold !important;
padding: 0 10px;
text-align: left;
width: 100% !important;
}

#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-quota {
padding: 13px 15px;
}
2 changes: 1 addition & 1 deletion assets/css/admin-bar.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 76 additions & 10 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ ul.imagify-datas-details.imagify-datas-details {
border-radius: 5px;
color: #c51161 !important;
font-weight: bold;
padding: 10px;
padding: 10px 0;
text-align: center;
text-decoration: none;
text-transform: uppercase;
Expand All @@ -1575,15 +1575,6 @@ ul.imagify-datas-details.imagify-datas-details {
vertical-align: top;
}

.imagify-upsell-dismiss::before {
position: absolute;
top: 5px;
right: 5px;
content: "\2715";
color: #2e3243;
font-size: 2em;
}

.imagify-upsell .imagify-meteo-icon {
filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(104deg) brightness(103%) contrast(103%);
}
Expand All @@ -1595,3 +1586,78 @@ ul.imagify-datas-details.imagify-datas-details {
.imagify-original-fize-size .value {
padding-left: 15px !important;
}
.imagify-card {
border: 1px solid #dfdfdf;
background-color: #f4f7f9;
border-radius: 5px;
width:95%;
}
.imagify-card-header {
margin-bottom: 10px;
padding-top: 25px;
}
.imagify-card-logo {
height: 42px;
}
.imagify-card-logo img {
display: block;
margin: 0 auto 0;
}
.imagify-card-header h4 {
text-align: center;
color: #323232;
font-size: 1.1em;
font-weight:bold;
}
.imagify-card-body {
margin-bottom: 10px;
padding: 0 10px 0 10px;
height: 87px;
}
.imagify-card-body p {
font-size: 1em;
color: #323232;
text-align:center;
line-height: 17px;
}
.imagify-card-footer {
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
height: 40px;
}
.imagify-card-footer span {
text-transform: uppercase;
font-weight:bold;
color: #6f9c3b;
}
.imagify-card-footer a {
margin: 0 15px 0 15px;
font-size: 1em;
font-weight: bold;
}
.imagify-card-footer a.imagify-card-btn {
text-transform: uppercase;
text-decoration: none;
background-color: #2f3242;
padding: 8px 20px 8px 20px;
color: white;
}
.imagify-plugin-family-col {
float: left;
width: 25%;
box-sizing: border-box;
-webkit-flex-basis: 25%;
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
}
.imagify-upsell-cta {
display: inline-flex;
align-items: center;
justify-content: center;
}
.imagify-upsell-cta .imagify-svg-icon {
margin-left: 7px;
margin-top: 2px;
}
2 changes: 1 addition & 1 deletion assets/css/admin.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions assets/css/bulk.css
Original file line number Diff line number Diff line change
Expand Up @@ -1304,3 +1304,14 @@ td.imagify-cell-filename {
}
}

.imagify-notice-dismiss {
text-decoration: none;
}

.imagify-notice-dismiss::before {
color: #fff;
}

.imagify-notice-dismiss.notice-dismiss:hover::before {
color: #fff;
}
2 changes: 1 addition & 1 deletion assets/css/bulk.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/css/notices.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
text-decoration: none;
}

.imagify-notice-dismiss.notice-dismiss::before {
color: #fff;
}

/* Notices in Imagify related pages */
.media_page_imagify-bulk-optimization .notice,
body[class*="_imagify-ngg-bulk-optimization"] .notice,
Expand Down
Loading

0 comments on commit a3e1630

Please sign in to comment.