Skip to content
Open
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
5 changes: 5 additions & 0 deletions Tests/Integration/inc/classes/ImagifyUser/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ abstract class TestCase extends BaseTestCase {
public function set_up() {
parent::set_up();

// Skip API-dependent tests when no API key is configured (e.g. fork PRs without repo secrets).
if ( '' === $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) {
$this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY is not configured.' );
}

$this->originalUserInstance = $this->resetPropertyValue( 'user', Imagify::class );

//Clean up the transients for API cache
Expand Down
3 changes: 3 additions & 0 deletions Tests/Integration/inc/classes/ImagifyUser/getError.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Test_GetError extends TestCase {
/**
* Test \Imagify\User\User->get_error() should return false when succesfully fetched user account data.
*/
/**
* @requires env IMAGIFY_TESTS_API_KEY
*/
public function testShouldReturnFalseWhenFetchedUserData() {
update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function testShouldReturnZeroWhenCouldNotFetchUserData() {
$this->assertSame( 0, ( new User() )->get_percent_consumed_quota() );
}

/**
* @requires env IMAGIFY_TESTS_API_KEY
*/
public function testShouldReturnQuotaWhenFetchedUserData() {
update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) );

Expand Down
9 changes: 9 additions & 0 deletions Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function testShouldReturnFalseWhenCouldNotFetchUserData() {
$this->assertFalse( ( new User() )->is_over_quota() );
}

/**
* @requires env IMAGIFY_TESTS_API_KEY
*/
public function testShouldReturnFalseWhenPaidAccount() {
update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) );

Expand All @@ -55,6 +58,9 @@ public function testShouldReturnFalseWhenPaidAccount() {
$this->assertFalse( $imagifyUser->is_over_quota() );
}

/**
* @requires env IMAGIFY_TESTS_API_KEY
*/
public function testShouldReturnFalseWhenFreeNotOverQuota() {
update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) );

Expand All @@ -72,6 +78,9 @@ public function testShouldReturnFalseWhenFreeNotOverQuota() {
$this->assertFalse( $imagifyUser->is_over_quota() );
}

/**
* @requires env IMAGIFY_TESTS_API_KEY
*/
public function testShouldReturnTrueWhenFreeOverQuota() {
update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) );

Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function setPropertyValue( $property, $class, $value ) {
} else {
$previous = $ref->getValue();
// Static property.
$ref->setValue( $value );
$ref->setValue( null, $value );
}

return $previous;
Expand Down
4 changes: 4 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ jQuery.extend( window.imagify, {
.on( 'click.imagify', '.imagify-modal .close-btn', function() {
var $modal = $( this ).closest( '.imagify-modal' );

// Move focus to body before hiding the modal to avoid Chrome warning:
// "Blocked aria-hidden on an element because its descendant retained focus".
$( d.body ).attr( 'tabindex', '-1' ).focus().removeAttr( 'tabindex' );

$modal.fadeOut( 400 ).attr( 'aria-hidden', 'true' ).removeClass( 'modal-is-open' ).trigger( 'modalClosed.imagify' );

$( 'body' ).removeClass( 'imagify-modal-is-open' );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/admin.min.js

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

4 changes: 4 additions & 0 deletions assets/js/pricing-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@
var viewId = $view.attr('id'),
$modalContent = imagifyModal.$modal.children('.imagify-modal-content');

// Move focus to body before hiding sibling views to avoid Chrome warning:
// "Blocked aria-hidden on an element because its descendant retained focus".
$(d.body).attr('tabindex', '-1').focus().removeAttr('tabindex');

$view.siblings('.imagify-modal-views').hide().attr('aria-hidden', 'true');

// Plans view has tabs: display the right one.
Expand Down
2 changes: 1 addition & 1 deletion assets/js/pricing-modal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion classes/Bulk/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public function bulk_info_seen_callback() {
public function bulk_get_stats_callback() {
imagify_check_nonce( 'imagify-bulk-optimize' );

$folder_types = filter_input( INPUT_GET, 'types', FILTER_REQUIRE_ARRAY );
$folder_types = filter_input( INPUT_GET, 'types', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
$folder_types = is_array( $folder_types ) ? $folder_types : [];

if ( ! $folder_types ) {
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/class-imagify-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public function update_site_option_on_network() {
return;
}

if ( version_compare( $wp_version, '5.5', '>=' ) ) {
if ( version_compare( (string) $wp_version, '5.5', '>=' ) ) {
$allowed_options = apply_filters_deprecated(
'whitelist_options',
[ [] ],
Expand Down
18 changes: 18 additions & 0 deletions inc/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
require_once IMAGIFY_PATH . 'vendor/autoload.php';
}

// Support Composer dependency install where Strauss prefixing hasn't run.
// Prefixed classes exist when installed as root package; unprefixed when installed as dependency.
if ( ! class_exists( 'Imagify\Dependencies\League\Container\Container', false ) ) {
if ( class_exists( 'League\Container\Container', false ) ) {
class_alias( 'League\Container\Container', 'Imagify\Dependencies\League\Container\Container' );
}
}
if ( ! interface_exists( 'Imagify\Dependencies\League\Container\ServiceProvider\ServiceProviderInterface', false ) ) {
if ( interface_exists( 'League\Container\ServiceProvider\ServiceProviderInterface', false ) ) {
class_alias( 'League\Container\ServiceProvider\ServiceProviderInterface', 'Imagify\Dependencies\League\Container\ServiceProvider\ServiceProviderInterface' );
}
}
if ( ! class_exists( 'Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider', false ) ) {
if ( class_exists( 'League\Container\ServiceProvider\AbstractServiceProvider', false ) ) {
class_alias( 'League\Container\ServiceProvider\AbstractServiceProvider', 'Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider' );
}
}

require_once IMAGIFY_PATH . 'inc/Dependencies/ActionScheduler/action-scheduler.php';

/**
Expand Down
Loading