diff --git a/Tests/Integration/inc/classes/ImagifyUser/getError.php b/Tests/Integration/inc/classes/ImagifyUser/getError.php index 9c0078f23..7302b1113 100644 --- a/Tests/Integration/inc/classes/ImagifyUser/getError.php +++ b/Tests/Integration/inc/classes/ImagifyUser/getError.php @@ -17,6 +17,10 @@ class Test_GetError extends TestCase { * Test \Imagify\User\User->get_error() should return false when succesfully fetched user account data. */ public function testShouldReturnFalseWhenFetchedUserData() { + if ( empty( $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) ) { + $this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY not available (fork PR limitation).' ); + } + update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ); // Verify the static $user property is null. diff --git a/Tests/Integration/inc/classes/ImagifyUser/getPercentConsumedQuota.php b/Tests/Integration/inc/classes/ImagifyUser/getPercentConsumedQuota.php index 97b39dc62..07c5a2e85 100644 --- a/Tests/Integration/inc/classes/ImagifyUser/getPercentConsumedQuota.php +++ b/Tests/Integration/inc/classes/ImagifyUser/getPercentConsumedQuota.php @@ -40,6 +40,10 @@ public function testShouldReturnZeroWhenCouldNotFetchUserData() { } public function testShouldReturnQuotaWhenFetchedUserData() { + if ( empty( $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) ) { + $this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY not available (fork PR limitation).' ); + } + update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ); // Verify the static $user property is null. diff --git a/Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php b/Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php index be760e319..480ed890d 100644 --- a/Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php +++ b/Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php @@ -38,6 +38,10 @@ public function testShouldReturnFalseWhenCouldNotFetchUserData() { } public function testShouldReturnFalseWhenPaidAccount() { + if ( empty( $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) ) { + $this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY not available (fork PR limitation).' ); + } + update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ); // Verify the static $user property is null. @@ -56,6 +60,10 @@ public function testShouldReturnFalseWhenPaidAccount() { } public function testShouldReturnFalseWhenFreeNotOverQuota() { + if ( empty( $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) ) { + $this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY not available (fork PR limitation).' ); + } + update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ); // Verify the static $user property is null. @@ -73,6 +81,10 @@ public function testShouldReturnFalseWhenFreeNotOverQuota() { } public function testShouldReturnTrueWhenFreeOverQuota() { + if ( empty( $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ) ) { + $this->markTestSkipped( 'IMAGIFY_TESTS_API_KEY not available (fork PR limitation).' ); + } + update_imagify_option( 'api_key', $this->getApiCredential( 'IMAGIFY_TESTS_API_KEY' ) ); // Verify the static $user property is null. diff --git a/assets/js/notices.js b/assets/js/notices.js index e815c199b..97e87ddfa 100755 --- a/assets/js/notices.js +++ b/assets/js/notices.js @@ -55,7 +55,7 @@ preConfirm: function( inputValue ) { return new Promise( function( resolve, reject ) { setTimeout( function() { - $.get( ajaxurl + w.imagify.concat + 'action=imagify_signup&email=' + inputValue + '&imagifysignupnonce=' + $( '#imagifysignupnonce' ).val() ) + $.get( ajaxurl + w.imagify.concat + 'action=imagify_signup&email=' + encodeURIComponent( inputValue ) + '&imagifysignupnonce=' + $( '#imagifysignupnonce' ).val() ) .done( function( response ) { if ( ! response.success ) { reject( response.data ); diff --git a/assets/js/notices.min.js b/assets/js/notices.min.js index 1d7f99778..4de0c9578 100755 --- a/assets/js/notices.min.js +++ b/assets/js/notices.min.js @@ -1 +1 @@ -!function(n){n(document).on("click",".imagify-notice-dismiss",function(i){var e=n(this),t=e.parents(".imagify-welcome, .imagify-notice, .imagify-rkt-notice, .imagify-upsell, .imagify-upsell-admin-bar"),e=e.attr("href");i.preventDefault(),t.fadeTo(100,0,function(){n(this).slideUp(100,function(){n(this).remove()})}),n.get(e.replace("admin-post.php","admin-ajax.php"))})}(jQuery,(document,window)),function(n,a){n("#imagify-signup").on("click.imagify",function(i){i.preventDefault(),swal({title:imagifyNotices.labels.signupTitle,html:imagifyNotices.labels.signupText,confirmButtonText:imagifyNotices.labels.signupConfirmButtonText,input:"email",padding:0,showLoaderOnConfirm:!0,customClass:"imagify-sweet-alert imagify-sweet-alert-signup",inputValidator:function(t){return new Promise(function(i,e){""!==String(t).trim()&&t?i():e(imagifyNotices.labels.signupErrorEmptyEmail)})},preConfirm:function(i){return new Promise(function(e,t){setTimeout(function(){n.get(ajaxurl+a.imagify.concat+"action=imagify_signup&email="+i+"&imagifysignupnonce="+n("#imagifysignupnonce").val()).done(function(i){i.success?e():t(i.data)})},2e3)})}}).then(function(){swal({title:imagifyNotices.labels.signupSuccessTitle,html:imagifyNotices.labels.signupSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"})})}),n("#imagify-save-api-key").on("click.imagify",function(i){i.preventDefault(),swal({title:imagifyNotices.labels.saveApiKeyTitle,html:imagifyNotices.labels.saveApiKeyText,confirmButtonText:imagifyNotices.labels.saveApiKeyConfirmButtonText,input:"text",padding:0,showLoaderOnConfirm:!0,customClass:"imagify-sweet-alert imagify-sweet-alert-signup",inputValidator:function(t){return new Promise(function(i,e){""!==String(t).trim()&&t?i():e(imagifyNotices.labels.ApiKeyErrorEmpty)})},preConfirm:function(i){return new Promise(function(e,t){n.get(ajaxurl+a.imagify.concat+"action=imagify_check_api_key_validity&api_key="+i+"&imagifycheckapikeynonce="+n("#imagifycheckapikeynonce").val()).done(function(i){i.success?e():t(i.data)})})}}).then(function(){swal({title:imagifyNotices.labels.ApiKeyCheckSuccessTitle,html:imagifyNotices.labels.ApiKeyCheckSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"})})})}(jQuery,(document,window)); \ No newline at end of file +(n=>{n(document).on("click",".imagify-notice-dismiss",function(i){var e=n(this),t=e.parents(".imagify-welcome, .imagify-notice, .imagify-rkt-notice, .imagify-upsell, .imagify-upsell-admin-bar"),e=e.attr("href");i.preventDefault(),t.fadeTo(100,0,function(){n(this).slideUp(100,function(){n(this).remove()})}),n.get(e.replace("admin-post.php","admin-ajax.php"))})})(jQuery,(document,window)),((n,a)=>{n("#imagify-signup").on("click.imagify",function(i){i.preventDefault(),swal({title:imagifyNotices.labels.signupTitle,html:imagifyNotices.labels.signupText,confirmButtonText:imagifyNotices.labels.signupConfirmButtonText,input:"email",padding:0,showLoaderOnConfirm:!0,customClass:"imagify-sweet-alert imagify-sweet-alert-signup",inputValidator:function(t){return new Promise(function(i,e){""!==String(t).trim()&&t?i():e(imagifyNotices.labels.signupErrorEmptyEmail)})},preConfirm:function(i){return new Promise(function(e,t){setTimeout(function(){n.get(ajaxurl+a.imagify.concat+"action=imagify_signup&email="+encodeURIComponent(i)+"&imagifysignupnonce="+n("#imagifysignupnonce").val()).done(function(i){i.success?e():t(i.data)})},2e3)})}}).then(function(){swal({title:imagifyNotices.labels.signupSuccessTitle,html:imagifyNotices.labels.signupSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"})})}),n("#imagify-save-api-key").on("click.imagify",function(i){i.preventDefault(),swal({title:imagifyNotices.labels.saveApiKeyTitle,html:imagifyNotices.labels.saveApiKeyText,confirmButtonText:imagifyNotices.labels.saveApiKeyConfirmButtonText,input:"text",padding:0,showLoaderOnConfirm:!0,customClass:"imagify-sweet-alert imagify-sweet-alert-signup",inputValidator:function(t){return new Promise(function(i,e){""!==String(t).trim()&&t?i():e(imagifyNotices.labels.ApiKeyErrorEmpty)})},preConfirm:function(i){return new Promise(function(e,t){n.get(ajaxurl+a.imagify.concat+"action=imagify_check_api_key_validity&api_key="+i+"&imagifycheckapikeynonce="+n("#imagifycheckapikeynonce").val()).done(function(i){i.success?e():t(i.data)})})}}).then(function(){swal({title:imagifyNotices.labels.ApiKeyCheckSuccessTitle,html:imagifyNotices.labels.ApiKeyCheckSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"})})})})(jQuery,(document,window)); \ No newline at end of file diff --git a/classes/Bulk/Bulk.php b/classes/Bulk/Bulk.php index 4e7eb4dd1..f24aa9c0f 100644 --- a/classes/Bulk/Bulk.php +++ b/classes/Bulk/Bulk.php @@ -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 ) { diff --git a/inc/main.php b/inc/main.php index aee493a64..44f2fbfe7 100644 --- a/inc/main.php +++ b/inc/main.php @@ -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'; /**