Imagify Image Optimizer - Version 1.9.5

Version Description

  • 2019/07/16 =
  • Improvement: Basic Authentication support. If it does not work automatically, you can still define the constants IMAGIFY_AUTH_USER and IMAGIFY_AUTH_PASSWORD in your wp-config.php file.
  • Improvement: webp images are not created for animated gif images by default anymore. Use the filter imagify_pre_can_create_webp_version if you still want to create an unanimated webp version of them.
  • Improvement: when creating webp images from the settings page, we made more clear when all the images are missing a backup copy.
  • Improvement: clear the 5 minutes data cache when buying quota from the plugin.
  • Improvement: when displaying webp images with the <picture> tag, allow to use relative URLs (starting with /).
Download this release

Release Info

Developer wp_media
Plugin Icon 128x128 Imagify Image Optimizer
Version 1.9.5
Comparing to
See all releases

Code changes from version 1.9.4 to 1.9.5

assets/js/options.js CHANGED
@@ -566,7 +566,7 @@ window.imagify = window.imagify || {};
566
  }
567
 
568
  // Reset properties.
569
- e.data.imagifyOptionsBulk.fetchQueue = imagifyOptions.bulk.contexts;
570
  e.data.imagifyOptionsBulk.queue = [];
571
  e.data.imagifyOptionsBulk.processingQueue = [];
572
  e.data.imagifyOptionsBulk.fetchError = false;
@@ -912,6 +912,13 @@ window.imagify = window.imagify || {};
912
  html: imagifyOptions.bulk.labels.nothingToDoText,
913
  type: 'info'
914
  };
 
 
 
 
 
 
 
915
  } else {
916
  errorArgs = {
917
  title: imagifyOptions.bulk.labels.error,
566
  }
567
 
568
  // Reset properties.
569
+ e.data.imagifyOptionsBulk.fetchQueue = imagifyOptions.bulk.contexts.slice();
570
  e.data.imagifyOptionsBulk.queue = [];
571
  e.data.imagifyOptionsBulk.processingQueue = [];
572
  e.data.imagifyOptionsBulk.fetchError = false;
912
  html: imagifyOptions.bulk.labels.nothingToDoText,
913
  type: 'info'
914
  };
915
+ }
916
+ else if ( 'no-backup' === this.error ) {
917
+ errorArgs = {
918
+ title: imagifyOptions.bulk.labels.nothingToDoTitle,
919
+ html: imagifyOptions.bulk.labels.nothingToDoNoBackupText,
920
+ type: 'info'
921
+ };
922
  } else {
923
  errorArgs = {
924
  title: imagifyOptions.bulk.labels.error,
assets/js/options.min.js CHANGED
@@ -1 +1 @@
1
- window.imagify=window.imagify||{},function(a,b,c,d){var e=!1,f=!1;a("#imagify-settings #api_key").on("blur.imagify",function(){var b=a(this),d=b.val();return""!==a.trim(d)&&(a("#check_api_key").val()===d?(a("#imagify-check-api-container").html('<span class="dashicons dashicons-yes"></span> '+imagifyOptions.labels.ValidApiKeyText),!1):(!0===e?f.abort():(a("#imagify-check-api-container").remove(),b.after('<span id="imagify-check-api-container"><span class="imagify-spinner"></span>'+imagifyOptions.labels.waitApiKeyCheckText+"</span>")),e=!0,void(f=a.get(ajaxurl+c.imagify.concat+"action=imagify_check_api_key_validity&api_key="+b.val()+"&imagifycheckapikeynonce="+a("#imagifycheckapikeynonce").val()).done(function(b){b.success?(a("#imagify-check-api-container").remove(),swal({title:imagifyOptions.labels.ApiKeyCheckSuccessTitle,html:imagifyOptions.labels.ApiKeyCheckSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"}).then(function(){location.reload()})):a("#imagify-check-api-container").html('<span class="dashicons dashicons-no"></span> '+b.data),e=!1}))))}),a(".imagify-options-line").css("cursor","pointer").on("click.imagify",function(b){"INPUT"!==b.target.nodeName&&a('input[aria-describedby="'+a(this).attr("id")+'"]').trigger("click.imagify")}),a(".imagify-settings th span").on("click.imagify",function(){var b=a(this).parent().next("td").find(":checkbox");1===b.length&&b.trigger("click.imagify")}),a(".imagify-options-line").find("input").on("change.imagify focus.imagify",function(){var b;("checkbox"!==this.type||this.checked)&&(b=a(this).closest(".imagify-options-line").prev("label").prev(":checkbox"),b.length&&!b[0].checked&&b.prop("checked",!0))}),a('[name="imagify_settings[backup]"]').on("change.imagify",function(){var b=a(this),c=b.siblings("#backup-dir-is-writable"),d={action:"imagify_check_backup_dir_is_writable",_wpnonce:c.data("nonce")};if(b.is(":checked"))return void a.getJSON(ajaxurl,d).done(function(b){a.isPlainObject(b)&&b.success&&(b.data.is_writable?c.addClass("hidden"):c.removeClass("hidden"))});swal({title:imagifyOptions.labels.noBackupTitle,html:imagifyOptions.labels.noBackupText,type:"warning",customClass:"imagify-sweet-alert",padding:0,showCancelButton:!0,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){c.addClass("hidden")},function(){b.prop("checked",!0)})}),a('[name="imagify_settings[display_webp_method]"]').on("change.imagify init.imagify",function(b){"picture"===b.target.value?a(b.target).closest(".imagify-radio-group").next(".imagify-options-line").removeClass("imagify-faded"):a(b.target).closest(".imagify-radio-group").next(".imagify-options-line").addClass("imagify-faded")}).filter(":checked").trigger("init.imagify")}(jQuery,document,window),function(a,b,c,d){a.imagifyUser&&c.getJSON(ajaxurl,a.imagifyUser).done(function(a){c.isPlainObject(a)&&a.success&&(a.data.id=null,a.data.plan_id=null,a.data.is=[],c.each(a.data,function(b,d){var e=".imagify-user-"+b.replace(/_/g,"-");0===b.indexOf("is_")?d&&a.data.is.push(e):"is"!==b&&c(e).text(d)}),a.data.is.push("best-plan"),c(a.data.is.join(",")).removeClass("hidden"))})}(window,document,jQuery),function(a,b,c,d){function e(b){var d,e,f,g,h,i=!1,j=null;b&&(f=c("#imagify-custom-folders-selected"),g=f.find(".imagify-custom-folder-line"),h=g.find('[value="'+b+'"]'),h.length||(b=b.split("#///#"),d=b[1].replace(/\/+$/,"").toLowerCase(),e=a.imagify.template("imagify-custom-folder"),g.each(function(){var a=c(this),h=a.data("path").replace(/\/+$/,"").toLowerCase();return""!==h&&0===d.indexOf(h)?(i=!0,!1):d<h?(a.before(e({value:b[0],label:b[1]})),g=f.find(".imagify-custom-folder-line"),i=!0,!1):void 0}),i||(f.append(e({value:b[0],label:b[1]})),g=f.find(".imagify-custom-folder-line")),""!==d&&g.each(function(){var a=c(this),b=a.data("path").toLowerCase();null!==j&&0===b.indexOf(j)?a.find(".imagify-custom-folders-remove").trigger("click.imagify"):j=b}),f.next(".hidden").removeClass("hidden")))}imagifyOptions.getFilesTree&&(c("#imagify-add-custom-folder").on("click.imagify",function(){var a,b=c(this),d=[];b.attr("disabled")||(b.attr("disabled","disabled").next("img").attr("aria-hidden","false"),a=c("#imagify-custom-folders-selected"),a.find("input").each(function(){d.push(this.value)}),c.post(imagifyOptions.getFilesTree,{folder:"/",selected:d},null,"json").done(function(a){if(!a.success)return void swal({title:imagifyOptions.labels.error,html:a.data||"",type:"error",padding:0,customClass:"imagify-sweet-alert"});swal({title:imagifyOptions.labels.filesTreeTitle,html:'<div class="imagify-swal-subtitle">'+imagifyOptions.labels.filesTreeSubTitle+'</div><div class="imagify-swal-content"><p class="imagify-folders-information"><i class="dashicons dashicons-info" aria-hidden="true"></i>'+imagifyOptions.labels.cleaningInfo+'</p><ul id="imagify-folders-tree" class="imagify-folders-tree">'+a.data+"</ul></div>",type:"",customClass:"imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection",showCancelButton:!0,padding:0,confirmButtonText:imagifyOptions.labels.confirmFilesTreeBtn,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){var a=c("#imagify-folders-tree input").serializeArray();a.length&&c.each(a,function(a,b){e(b.value)})}).catch(swal.noop)}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",customClass:"imagify-sweet-alert",padding:0})}).always(function(){b.removeAttr("disabled").next("img").attr("aria-hidden","true")}))}),c(b).on("click.imagify","#imagify-folders-tree [data-folder]",function(){var a=c(this),b=a.nextAll(".imagify-folders-sub-tree"),d=[];if(!a.attr("disabled")&&!a.siblings(":checkbox").is(":checked")){if(a.attr("disabled","disabled").addClass("imagify-loading"),b.length)return a.hasClass("imagify-is-open")?(b.addClass("hidden"),a.removeClass(" imagify-is-open")):(b.removeClass("hidden"),a.addClass("imagify-is-open")),void a.removeAttr("disabled").removeClass("imagify-loading");c("#imagify-custom-folders-selected").find("input").each(function(){d.push(this.value)}),c.post(imagifyOptions.getFilesTree,{folder:a.data("folder"),selected:d},null,"json").done(function(b){if(!b.success)return void swal({title:imagifyOptions.labels.error,html:b.data||"",type:"error",padding:0,customClass:"imagify-sweet-alert"});a.addClass("imagify-is-open").parent().append('<ul class="imagify-folders-sub-tree">'+b.data+"</ul>")}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",padding:0,customClass:"imagify-sweet-alert"})}).always(function(){a.removeAttr("disabled").removeClass("imagify-loading")})}}),c("#imagify-custom-folders").on("click.imagify",".imagify-custom-folders-remove",function(){var b=c(this).closest(".imagify-custom-folder-line").addClass("imagify-will-remove");a.setTimeout(function(){b.remove(),c("#imagify-custom-folders-selected").siblings(".imagify-success.hidden").removeClass("hidden")},750)}),c("#imagify-add-themes-to-custom-folder").on("click.imagify",function(){var a=c(this);e(a.data("theme")),e(a.data("theme-parent")),a.replaceWith("<p>"+imagifyOptions.labels.themesAdded+"</p>")}))}(window,document,jQuery),function(a,b,c,d){imagifyOptions.bulk&&(a.imagify.optionsBulk={fetchQueue:[],queue:[],processingQueue:[],fetchError:!1,error:!1,working:!1,processIsStopped:!0,processedMedia:0,totalMedia:0,$button:null,$progressWrap:null,$progressBar:null,$progressText:null,init:function(){this.$button=c("#imagify-generate-webp-versions"),this.$progressWrap=this.$button.siblings(".imagify-progress"),this.$progressBar=this.$progressWrap.find(".bar"),this.$progressText=this.$progressBar.find(".percent"),c("#imagify_convert_to_webp").on("change.imagify init.imagify",{imagifyOptionsBulk:this},this.toggleButton).trigger("init.imagify"),this.$button.on("click.imagify",{imagifyOptionsBulk:this},this.maybeLaunchAllProcesses),c(b).on("imagifybeat-send",{imagifyOptionsBulk:this},this.addQueueImagifybeat).on("imagifybeat-tick",{imagifyOptionsBulk:this},this.processQueueImagifybeat).on("imagifybeat-send",this.addRequirementsImagifybeat).on("imagifybeat-tick",{imagifyOptionsBulk:this},this.processRequirementsImagifybeat)},toggleButton:function(a){this.checked?a.data.imagifyOptionsBulk.$button.removeAttr("disabled"):a.data.imagifyOptionsBulk.$button.attr("disabled","disabled")},maybeLaunchAllProcesses:function(b){b.data.imagifyOptionsBulk&&!b.data.imagifyOptionsBulk.working&&(b.data.imagifyOptionsBulk.hasBlockingError(!0)||(b.data.imagifyOptionsBulk.fetchQueue=imagifyOptions.bulk.contexts,b.data.imagifyOptionsBulk.queue=[],b.data.imagifyOptionsBulk.processingQueue=[],b.data.imagifyOptionsBulk.fetchError=!1,b.data.imagifyOptionsBulk.error=!1,b.data.imagifyOptionsBulk.working=!0,b.data.imagifyOptionsBulk.processIsStopped=!1,b.data.imagifyOptionsBulk.processedMedia=0,b.data.imagifyOptionsBulk.totalMedia=0,b.data.imagifyOptionsBulk.$button.attr("disabled","disabled").find(".dashicons").addClass("rotate"),c(a).on("beforeunload.imagify",b.data.imagifyOptionsBulk.getConfirmMessage),a.imagify.beat.interval(15),a.imagify.beat.disableSuspend(),b.data.imagifyOptionsBulk.fetchIDs()))},getConfirmMessage:function(){return imagifyOptions.bulk.labels.processing},addQueueImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&a.data.imagifyOptionsBulk.processingQueue.length&&(b[imagifyOptions.bulk.imagifybeatIDs.queue]=a.data.imagifyOptionsBulk.processingQueue)},processQueueImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&void 0!==b[imagifyOptions.bulk.imagifybeatIDs.queue]&&c.each(b[imagifyOptions.bulk.imagifybeatIDs.queue],function(b,c){a.data.imagifyOptionsBulk.mediaProcessed(c)})},addRequirementsImagifybeat:function(a,b){b[imagifyOptions.bulk.imagifybeatIDs.requirements]=1},processRequirementsImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&void 0===b[imagifyOptions.bulk.imagifybeatIDs.requirements]||(b=b[imagifyOptions.bulk.imagifybeatIDs.requirements],imagifyOptions.bulk.curlMissing=b.curl_missing,imagifyOptions.bulk.editorMissing=b.editor_missing,imagifyOptions.bulk.extHttpBlocked=b.external_http_blocked,imagifyOptions.bulk.apiDown=b.api_down,imagifyOptions.bulk.keyIsValid=b.key_is_valid,imagifyOptions.bulk.isOverQuota=b.is_over_quota)},fetchIDs:function(){var a,b;if(!this.processIsStopped){if(!this.fetchQueue.length)return this.queue.length?(this.$progressBar.removeAttr("style"),this.$progressText.text("0"+(this.totalMedia?"/"+this.totalMedia:"")),this.$progressWrap.slideDown().attr("aria-hidden","false"),void this.processQueue()):(this.fetchError||(this.fetchError="no-images"),this.stopProcess(this.fetchError),void(this.fetchError=!1));a=this,b=this.fetchQueue.shift(),c.get(this.getAjaxUrl("getMediaIds",b)).done(function(d){var e;if(!a.processIsStopped)return e=d.data&&d.data.message?d.data.message:imagifyOptions.bulk.ajaxErrorText,d.success&&c.isArray(d.data)?void(d.data.length&&(a.totalMedia+=d.data.length,a.queue.push({context:b,optimizeURL:a.getAjaxUrl("bulkProcess",b),mediaIDs:d.data}))):void(a.fetchError||(a.fetchError=e))}).fail(function(){a.fetchError||(a.fetchError="get-unoptimized-images")}).always(function(){a.fetchIDs()})}},processQueue:function(){var a=this;this.processIsStopped||(this.queue.length||this.processingQueue.length)&&c.each(this.queue,function(b,d){if(a.processingQueue.length>=imagifyOptions.bulk.bufferSize)return!1;c.each(d.mediaIDs,function(){if(a.processMedia({context:d.context,mediaID:d.mediaIDs.shift(),optimizeURL:d.optimizeURL}),d.mediaIDs.length||a.queue.shift(),a.processingQueue.length>=imagifyOptions.bulk.bufferSize)return!1})})},processMedia:function(a){var b=this,d={context:a.context,mediaID:a.mediaID};this.processingQueue.push({context:a.context,mediaID:a.mediaID}),c.post({url:a.optimizeURL,data:{media_id:a.mediaID,context:a.context},dataType:"json"}).done(function(a){a.success||b.mediaProcessed(d)}).fail(function(){b.mediaProcessed(d)})},mediaProcessed:function(a){var b=this;this.processIsStopped||(c.each(this.processingQueue,function(c,d){if(a.context===d.context&&a.mediaID===d.mediaID)return b.processingQueue.splice(c,1),!1}),++this.processedMedia,a.progress=Math.floor(this.processedMedia/this.totalMedia*100),this.$progressBar.css("width",a.progress+"%"),this.$progressText.text(this.processedMedia+"/"+this.totalMedia),this.queue.length||this.processingQueue.length?this.processQueue():this.totalMedia===this.processedMedia&&this.queueEmpty())},queueEmpty:function(){var b={};!1!==this.error&&(b="invalid-api-key"===this.error?{title:imagifyOptions.bulk.labels.invalidAPIKeyTitle,type:"info"}:"over-quota"===this.error?{title:imagifyOptions.bulk.labels.overQuotaTitle,html:c("#tmpl-imagify-overquota-alert").html(),type:"info",customClass:"imagify-swal-has-subtitle imagify-swal-error-header",showConfirmButton:!1}:"get-unoptimized-images"===this.error||"consumed-all-data"===this.error?{title:imagifyOptions.bulk.labels.getUnoptimizedImagesErrorTitle,html:imagifyOptions.bulk.labels.getUnoptimizedImagesErrorText,type:"info"}:"no-images"===this.error?{title:imagifyOptions.bulk.labels.nothingToDoTitle,html:imagifyOptions.bulk.labels.nothingToDoText,type:"info"}:{title:imagifyOptions.bulk.labels.error,html:this.error,type:"info"},this.displayError(b),this.error=!1),this.fetchQueue=[],this.queue=[],this.processingQueue=[],this.fetchError=!1,this.working=!1,this.processIsStopped=!1,this.processedMedia=0,this.totalMedia=0,a.imagify.beat.resetInterval(),a.imagify.beat.enableSuspend(),c(a).off("beforeunload.imagify",this.getConfirmMessage),this.$progressWrap.slideUp().attr("aria-hidden","true"),this.$progressBar.removeAttr("style"),this.$progressText.text("0"),this.$button.removeAttr("disabled").find(".dashicons").removeClass("rotate")},hasBlockingError:function(a){return a=void 0!==a&&a,imagifyOptions.bulk.curlMissing?(a&&this.displayError({html:imagifyOptions.bulk.labels.curlMissing}),!0):imagifyOptions.bulk.editorMissing?(a&&this.displayError({html:imagifyOptions.bulk.labels.editorMissing}),!0):imagifyOptions.bulk.extHttpBlocked?(a&&this.displayError({html:imagifyOptions.bulk.labels.extHttpBlocked}),!0):imagifyOptions.bulk.apiDown?(a&&this.displayError({html:imagifyOptions.bulk.labels.apiDown}),!0):imagifyOptions.bulk.keyIsValid?!!imagifyOptions.bulk.isOverQuota&&(a&&this.displayError({title:imagifyOptions.bulk.labels.overQuotaTitle,html:c("#tmpl-imagify-overquota-alert").html(),type:"info",customClass:"imagify-swal-has-subtitle imagify-swal-error-header",showConfirmButton:!1}),!0):(a&&this.displayError({title:imagifyOptions.bulk.labels.invalidAPIKeyTitle,type:"info"}),!0)},displayError:function(a,b,d){var e={title:"",html:"",type:"error",customClass:"",width:620,padding:0,showCloseButton:!0,showConfirmButton:!0};c.isPlainObject(a)?d=c.extend({},e,a):(d=d||{},d=c.extend({},e,{title:a||"",html:b||""},d)),d.title=d.title||imagifyOptions.bulk.labels.error,d.customClass+=" imagify-sweet-alert",swal(d).catch(swal.noop)},getAjaxUrl:function(b,c){var d;return d=ajaxurl+a.imagify.concat+"_wpnonce="+imagifyOptions.bulk.ajaxNonce,d+="&action="+imagifyOptions.bulk.ajaxActions[b],d+="&context="+c,d+="&imagify_action=generate_webp"},stopProcess:function(a){this.processIsStopped=!0,this.error=a,this.queueEmpty()}},a.imagify.optionsBulk.init())}(window,document,jQuery),function(a,b,c,d){var e=c.propHooks.checked;c.propHooks.checked={set:function(a,b,d){var f;return f=void 0===e?a[d]=b:e(a,b,d),c(a).trigger("change.imagify"),f}},c(".imagify-select-all").on("click.imagify",function(){var a=c(this),b=a.data("action"),d=a.closest(".imagify-select-all-buttons"),e=d.prev(".imagify-check-group"),f="imagify-is-inactive";if(a.hasClass(f))return!1;d.find(".imagify-select-all").removeClass(f).attr("aria-disabled","false"),a.addClass(f).attr("aria-disabled","true"),e.find(".imagify-row-check").prop("checked",function(){return!c(this).is(":hidden,:disabled")&&"select"===b})}),c(".imagify-check-group .imagify-row-check").on("change.imagify",function(){var a=c(this).closest(".imagify-check-group"),b=a.find(".imagify-row-check"),d=b.filter(":visible:enabled").length,e=b.filter(":visible:enabled:checked").length,f=a.next(".imagify-select-all-buttons"),g="imagify-is-inactive";0===e&&f.find('[data-action="unselect"]').addClass(g).attr("aria-disabled","true"),e===d&&f.find('[data-action="select"]').addClass(g).attr("aria-disabled","true"),e!==d&&e>0&&f.find(".imagify-select-all").removeClass(g).attr("aria-disabled","false")})}(window,document,jQuery);
1
+ window.imagify=window.imagify||{},function(a,b,c,d){var e=!1,f=!1;a("#imagify-settings #api_key").on("blur.imagify",function(){var b=a(this),d=b.val();return""!==a.trim(d)&&(a("#check_api_key").val()===d?(a("#imagify-check-api-container").html('<span class="dashicons dashicons-yes"></span> '+imagifyOptions.labels.ValidApiKeyText),!1):(!0===e?f.abort():(a("#imagify-check-api-container").remove(),b.after('<span id="imagify-check-api-container"><span class="imagify-spinner"></span>'+imagifyOptions.labels.waitApiKeyCheckText+"</span>")),e=!0,void(f=a.get(ajaxurl+c.imagify.concat+"action=imagify_check_api_key_validity&api_key="+b.val()+"&imagifycheckapikeynonce="+a("#imagifycheckapikeynonce").val()).done(function(b){b.success?(a("#imagify-check-api-container").remove(),swal({title:imagifyOptions.labels.ApiKeyCheckSuccessTitle,html:imagifyOptions.labels.ApiKeyCheckSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"}).then(function(){location.reload()})):a("#imagify-check-api-container").html('<span class="dashicons dashicons-no"></span> '+b.data),e=!1}))))}),a(".imagify-options-line").css("cursor","pointer").on("click.imagify",function(b){"INPUT"!==b.target.nodeName&&a('input[aria-describedby="'+a(this).attr("id")+'"]').trigger("click.imagify")}),a(".imagify-settings th span").on("click.imagify",function(){var b=a(this).parent().next("td").find(":checkbox");1===b.length&&b.trigger("click.imagify")}),a(".imagify-options-line").find("input").on("change.imagify focus.imagify",function(){var b;("checkbox"!==this.type||this.checked)&&(b=a(this).closest(".imagify-options-line").prev("label").prev(":checkbox"),b.length&&!b[0].checked&&b.prop("checked",!0))}),a('[name="imagify_settings[backup]"]').on("change.imagify",function(){var b=a(this),c=b.siblings("#backup-dir-is-writable"),d={action:"imagify_check_backup_dir_is_writable",_wpnonce:c.data("nonce")};if(b.is(":checked"))return void a.getJSON(ajaxurl,d).done(function(b){a.isPlainObject(b)&&b.success&&(b.data.is_writable?c.addClass("hidden"):c.removeClass("hidden"))});swal({title:imagifyOptions.labels.noBackupTitle,html:imagifyOptions.labels.noBackupText,type:"warning",customClass:"imagify-sweet-alert",padding:0,showCancelButton:!0,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){c.addClass("hidden")},function(){b.prop("checked",!0)})}),a('[name="imagify_settings[display_webp_method]"]').on("change.imagify init.imagify",function(b){"picture"===b.target.value?a(b.target).closest(".imagify-radio-group").next(".imagify-options-line").removeClass("imagify-faded"):a(b.target).closest(".imagify-radio-group").next(".imagify-options-line").addClass("imagify-faded")}).filter(":checked").trigger("init.imagify")}(jQuery,document,window),function(a,b,c,d){a.imagifyUser&&c.getJSON(ajaxurl,a.imagifyUser).done(function(a){c.isPlainObject(a)&&a.success&&(a.data.id=null,a.data.plan_id=null,a.data.is=[],c.each(a.data,function(b,d){var e=".imagify-user-"+b.replace(/_/g,"-");0===b.indexOf("is_")?d&&a.data.is.push(e):"is"!==b&&c(e).text(d)}),a.data.is.push("best-plan"),c(a.data.is.join(",")).removeClass("hidden"))})}(window,document,jQuery),function(a,b,c,d){function e(b){var d,e,f,g,h,i=!1,j=null;b&&(f=c("#imagify-custom-folders-selected"),g=f.find(".imagify-custom-folder-line"),h=g.find('[value="'+b+'"]'),h.length||(b=b.split("#///#"),d=b[1].replace(/\/+$/,"").toLowerCase(),e=a.imagify.template("imagify-custom-folder"),g.each(function(){var a=c(this),h=a.data("path").replace(/\/+$/,"").toLowerCase();return""!==h&&0===d.indexOf(h)?(i=!0,!1):d<h?(a.before(e({value:b[0],label:b[1]})),g=f.find(".imagify-custom-folder-line"),i=!0,!1):void 0}),i||(f.append(e({value:b[0],label:b[1]})),g=f.find(".imagify-custom-folder-line")),""!==d&&g.each(function(){var a=c(this),b=a.data("path").toLowerCase();null!==j&&0===b.indexOf(j)?a.find(".imagify-custom-folders-remove").trigger("click.imagify"):j=b}),f.next(".hidden").removeClass("hidden")))}imagifyOptions.getFilesTree&&(c("#imagify-add-custom-folder").on("click.imagify",function(){var a,b=c(this),d=[];b.attr("disabled")||(b.attr("disabled","disabled").next("img").attr("aria-hidden","false"),a=c("#imagify-custom-folders-selected"),a.find("input").each(function(){d.push(this.value)}),c.post(imagifyOptions.getFilesTree,{folder:"/",selected:d},null,"json").done(function(a){if(!a.success)return void swal({title:imagifyOptions.labels.error,html:a.data||"",type:"error",padding:0,customClass:"imagify-sweet-alert"});swal({title:imagifyOptions.labels.filesTreeTitle,html:'<div class="imagify-swal-subtitle">'+imagifyOptions.labels.filesTreeSubTitle+'</div><div class="imagify-swal-content"><p class="imagify-folders-information"><i class="dashicons dashicons-info" aria-hidden="true"></i>'+imagifyOptions.labels.cleaningInfo+'</p><ul id="imagify-folders-tree" class="imagify-folders-tree">'+a.data+"</ul></div>",type:"",customClass:"imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection",showCancelButton:!0,padding:0,confirmButtonText:imagifyOptions.labels.confirmFilesTreeBtn,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){var a=c("#imagify-folders-tree input").serializeArray();a.length&&c.each(a,function(a,b){e(b.value)})}).catch(swal.noop)}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",customClass:"imagify-sweet-alert",padding:0})}).always(function(){b.removeAttr("disabled").next("img").attr("aria-hidden","true")}))}),c(b).on("click.imagify","#imagify-folders-tree [data-folder]",function(){var a=c(this),b=a.nextAll(".imagify-folders-sub-tree"),d=[];if(!a.attr("disabled")&&!a.siblings(":checkbox").is(":checked")){if(a.attr("disabled","disabled").addClass("imagify-loading"),b.length)return a.hasClass("imagify-is-open")?(b.addClass("hidden"),a.removeClass(" imagify-is-open")):(b.removeClass("hidden"),a.addClass("imagify-is-open")),void a.removeAttr("disabled").removeClass("imagify-loading");c("#imagify-custom-folders-selected").find("input").each(function(){d.push(this.value)}),c.post(imagifyOptions.getFilesTree,{folder:a.data("folder"),selected:d},null,"json").done(function(b){if(!b.success)return void swal({title:imagifyOptions.labels.error,html:b.data||"",type:"error",padding:0,customClass:"imagify-sweet-alert"});a.addClass("imagify-is-open").parent().append('<ul class="imagify-folders-sub-tree">'+b.data+"</ul>")}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",padding:0,customClass:"imagify-sweet-alert"})}).always(function(){a.removeAttr("disabled").removeClass("imagify-loading")})}}),c("#imagify-custom-folders").on("click.imagify",".imagify-custom-folders-remove",function(){var b=c(this).closest(".imagify-custom-folder-line").addClass("imagify-will-remove");a.setTimeout(function(){b.remove(),c("#imagify-custom-folders-selected").siblings(".imagify-success.hidden").removeClass("hidden")},750)}),c("#imagify-add-themes-to-custom-folder").on("click.imagify",function(){var a=c(this);e(a.data("theme")),e(a.data("theme-parent")),a.replaceWith("<p>"+imagifyOptions.labels.themesAdded+"</p>")}))}(window,document,jQuery),function(a,b,c,d){imagifyOptions.bulk&&(a.imagify.optionsBulk={fetchQueue:[],queue:[],processingQueue:[],fetchError:!1,error:!1,working:!1,processIsStopped:!0,processedMedia:0,totalMedia:0,$button:null,$progressWrap:null,$progressBar:null,$progressText:null,init:function(){this.$button=c("#imagify-generate-webp-versions"),this.$progressWrap=this.$button.siblings(".imagify-progress"),this.$progressBar=this.$progressWrap.find(".bar"),this.$progressText=this.$progressBar.find(".percent"),c("#imagify_convert_to_webp").on("change.imagify init.imagify",{imagifyOptionsBulk:this},this.toggleButton).trigger("init.imagify"),this.$button.on("click.imagify",{imagifyOptionsBulk:this},this.maybeLaunchAllProcesses),c(b).on("imagifybeat-send",{imagifyOptionsBulk:this},this.addQueueImagifybeat).on("imagifybeat-tick",{imagifyOptionsBulk:this},this.processQueueImagifybeat).on("imagifybeat-send",this.addRequirementsImagifybeat).on("imagifybeat-tick",{imagifyOptionsBulk:this},this.processRequirementsImagifybeat)},toggleButton:function(a){this.checked?a.data.imagifyOptionsBulk.$button.removeAttr("disabled"):a.data.imagifyOptionsBulk.$button.attr("disabled","disabled")},maybeLaunchAllProcesses:function(b){b.data.imagifyOptionsBulk&&!b.data.imagifyOptionsBulk.working&&(b.data.imagifyOptionsBulk.hasBlockingError(!0)||(b.data.imagifyOptionsBulk.fetchQueue=imagifyOptions.bulk.contexts.slice(),b.data.imagifyOptionsBulk.queue=[],b.data.imagifyOptionsBulk.processingQueue=[],b.data.imagifyOptionsBulk.fetchError=!1,b.data.imagifyOptionsBulk.error=!1,b.data.imagifyOptionsBulk.working=!0,b.data.imagifyOptionsBulk.processIsStopped=!1,b.data.imagifyOptionsBulk.processedMedia=0,b.data.imagifyOptionsBulk.totalMedia=0,b.data.imagifyOptionsBulk.$button.attr("disabled","disabled").find(".dashicons").addClass("rotate"),c(a).on("beforeunload.imagify",b.data.imagifyOptionsBulk.getConfirmMessage),a.imagify.beat.interval(15),a.imagify.beat.disableSuspend(),b.data.imagifyOptionsBulk.fetchIDs()))},getConfirmMessage:function(){return imagifyOptions.bulk.labels.processing},addQueueImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&a.data.imagifyOptionsBulk.processingQueue.length&&(b[imagifyOptions.bulk.imagifybeatIDs.queue]=a.data.imagifyOptionsBulk.processingQueue)},processQueueImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&void 0!==b[imagifyOptions.bulk.imagifybeatIDs.queue]&&c.each(b[imagifyOptions.bulk.imagifybeatIDs.queue],function(b,c){a.data.imagifyOptionsBulk.mediaProcessed(c)})},addRequirementsImagifybeat:function(a,b){b[imagifyOptions.bulk.imagifybeatIDs.requirements]=1},processRequirementsImagifybeat:function(a,b){a.data.imagifyOptionsBulk&&void 0===b[imagifyOptions.bulk.imagifybeatIDs.requirements]||(b=b[imagifyOptions.bulk.imagifybeatIDs.requirements],imagifyOptions.bulk.curlMissing=b.curl_missing,imagifyOptions.bulk.editorMissing=b.editor_missing,imagifyOptions.bulk.extHttpBlocked=b.external_http_blocked,imagifyOptions.bulk.apiDown=b.api_down,imagifyOptions.bulk.keyIsValid=b.key_is_valid,imagifyOptions.bulk.isOverQuota=b.is_over_quota)},fetchIDs:function(){var a,b;if(!this.processIsStopped){if(!this.fetchQueue.length)return this.queue.length?(this.$progressBar.removeAttr("style"),this.$progressText.text("0"+(this.totalMedia?"/"+this.totalMedia:"")),this.$progressWrap.slideDown().attr("aria-hidden","false"),void this.processQueue()):(this.fetchError||(this.fetchError="no-images"),this.stopProcess(this.fetchError),void(this.fetchError=!1));a=this,b=this.fetchQueue.shift(),c.get(this.getAjaxUrl("getMediaIds",b)).done(function(d){var e;if(!a.processIsStopped)return e=d.data&&d.data.message?d.data.message:imagifyOptions.bulk.ajaxErrorText,d.success&&c.isArray(d.data)?void(d.data.length&&(a.totalMedia+=d.data.length,a.queue.push({context:b,optimizeURL:a.getAjaxUrl("bulkProcess",b),mediaIDs:d.data}))):void(a.fetchError||(a.fetchError=e))}).fail(function(){a.fetchError||(a.fetchError="get-unoptimized-images")}).always(function(){a.fetchIDs()})}},processQueue:function(){var a=this;this.processIsStopped||(this.queue.length||this.processingQueue.length)&&c.each(this.queue,function(b,d){if(a.processingQueue.length>=imagifyOptions.bulk.bufferSize)return!1;c.each(d.mediaIDs,function(){if(a.processMedia({context:d.context,mediaID:d.mediaIDs.shift(),optimizeURL:d.optimizeURL}),d.mediaIDs.length||a.queue.shift(),a.processingQueue.length>=imagifyOptions.bulk.bufferSize)return!1})})},processMedia:function(a){var b=this,d={context:a.context,mediaID:a.mediaID};this.processingQueue.push({context:a.context,mediaID:a.mediaID}),c.post({url:a.optimizeURL,data:{media_id:a.mediaID,context:a.context},dataType:"json"}).done(function(a){a.success||b.mediaProcessed(d)}).fail(function(){b.mediaProcessed(d)})},mediaProcessed:function(a){var b=this;this.processIsStopped||(c.each(this.processingQueue,function(c,d){if(a.context===d.context&&a.mediaID===d.mediaID)return b.processingQueue.splice(c,1),!1}),++this.processedMedia,a.progress=Math.floor(this.processedMedia/this.totalMedia*100),this.$progressBar.css("width",a.progress+"%"),this.$progressText.text(this.processedMedia+"/"+this.totalMedia),this.queue.length||this.processingQueue.length?this.processQueue():this.totalMedia===this.processedMedia&&this.queueEmpty())},queueEmpty:function(){var b={};!1!==this.error&&(b="invalid-api-key"===this.error?{title:imagifyOptions.bulk.labels.invalidAPIKeyTitle,type:"info"}:"over-quota"===this.error?{title:imagifyOptions.bulk.labels.overQuotaTitle,html:c("#tmpl-imagify-overquota-alert").html(),type:"info",customClass:"imagify-swal-has-subtitle imagify-swal-error-header",showConfirmButton:!1}:"get-unoptimized-images"===this.error||"consumed-all-data"===this.error?{title:imagifyOptions.bulk.labels.getUnoptimizedImagesErrorTitle,html:imagifyOptions.bulk.labels.getUnoptimizedImagesErrorText,type:"info"}:"no-images"===this.error?{title:imagifyOptions.bulk.labels.nothingToDoTitle,html:imagifyOptions.bulk.labels.nothingToDoText,type:"info"}:"no-backup"===this.error?{title:imagifyOptions.bulk.labels.nothingToDoTitle,html:imagifyOptions.bulk.labels.nothingToDoNoBackupText,type:"info"}:{title:imagifyOptions.bulk.labels.error,html:this.error,type:"info"},this.displayError(b),this.error=!1),this.fetchQueue=[],this.queue=[],this.processingQueue=[],this.fetchError=!1,this.working=!1,this.processIsStopped=!1,this.processedMedia=0,this.totalMedia=0,a.imagify.beat.resetInterval(),a.imagify.beat.enableSuspend(),c(a).off("beforeunload.imagify",this.getConfirmMessage),this.$progressWrap.slideUp().attr("aria-hidden","true"),this.$progressBar.removeAttr("style"),this.$progressText.text("0"),this.$button.removeAttr("disabled").find(".dashicons").removeClass("rotate")},hasBlockingError:function(a){return a=void 0!==a&&a,imagifyOptions.bulk.curlMissing?(a&&this.displayError({html:imagifyOptions.bulk.labels.curlMissing}),!0):imagifyOptions.bulk.editorMissing?(a&&this.displayError({html:imagifyOptions.bulk.labels.editorMissing}),!0):imagifyOptions.bulk.extHttpBlocked?(a&&this.displayError({html:imagifyOptions.bulk.labels.extHttpBlocked}),!0):imagifyOptions.bulk.apiDown?(a&&this.displayError({html:imagifyOptions.bulk.labels.apiDown}),!0):imagifyOptions.bulk.keyIsValid?!!imagifyOptions.bulk.isOverQuota&&(a&&this.displayError({title:imagifyOptions.bulk.labels.overQuotaTitle,html:c("#tmpl-imagify-overquota-alert").html(),type:"info",customClass:"imagify-swal-has-subtitle imagify-swal-error-header",showConfirmButton:!1}),!0):(a&&this.displayError({title:imagifyOptions.bulk.labels.invalidAPIKeyTitle,type:"info"}),!0)},displayError:function(a,b,d){var e={title:"",html:"",type:"error",customClass:"",width:620,padding:0,showCloseButton:!0,showConfirmButton:!0};c.isPlainObject(a)?d=c.extend({},e,a):(d=d||{},d=c.extend({},e,{title:a||"",html:b||""},d)),d.title=d.title||imagifyOptions.bulk.labels.error,d.customClass+=" imagify-sweet-alert",swal(d).catch(swal.noop)},getAjaxUrl:function(b,c){var d;return d=ajaxurl+a.imagify.concat+"_wpnonce="+imagifyOptions.bulk.ajaxNonce,d+="&action="+imagifyOptions.bulk.ajaxActions[b],d+="&context="+c,d+="&imagify_action=generate_webp"},stopProcess:function(a){this.processIsStopped=!0,this.error=a,this.queueEmpty()}},a.imagify.optionsBulk.init())}(window,document,jQuery),function(a,b,c,d){var e=c.propHooks.checked;c.propHooks.checked={set:function(a,b,d){var f;return f=void 0===e?a[d]=b:e(a,b,d),c(a).trigger("change.imagify"),f}},c(".imagify-select-all").on("click.imagify",function(){var a=c(this),b=a.data("action"),d=a.closest(".imagify-select-all-buttons"),e=d.prev(".imagify-check-group"),f="imagify-is-inactive";if(a.hasClass(f))return!1;d.find(".imagify-select-all").removeClass(f).attr("aria-disabled","false"),a.addClass(f).attr("aria-disabled","true"),e.find(".imagify-row-check").prop("checked",function(){return!c(this).is(":hidden,:disabled")&&"select"===b})}),c(".imagify-check-group .imagify-row-check").on("change.imagify",function(){var a=c(this).closest(".imagify-check-group"),b=a.find(".imagify-row-check"),d=b.filter(":visible:enabled").length,e=b.filter(":visible:enabled:checked").length,f=a.next(".imagify-select-all-buttons"),g="imagify-is-inactive";0===e&&f.find('[data-action="unselect"]').addClass(g).attr("aria-disabled","true"),e===d&&f.find('[data-action="select"]').addClass(g).attr("aria-disabled","true"),e!==d&&e>0&&f.find(".imagify-select-all").removeClass(g).attr("aria-disabled","false")})}(window,document,jQuery);
assets/js/pricing-modal.js CHANGED
@@ -1106,6 +1106,14 @@
1106
  checkout_datas.onetime = JSON.parse( $onetime_offer.attr( 'data-offer' ) );
1107
  }
1108
 
 
 
 
 
 
 
 
 
1109
  // Change views to go to checkout/payment view.
1110
  imagifyModal.switchToView( imagifyModal.$paymentView );
1111
 
1106
  checkout_datas.onetime = JSON.parse( $onetime_offer.attr( 'data-offer' ) );
1107
  }
1108
 
1109
+ // Clear user account cache.
1110
+ if ( imagifyPricingModal.userDataCache ) {
1111
+ $.post( ajaxurl, {
1112
+ action: imagifyPricingModal.userDataCache.deleteAction,
1113
+ _wpnonce: imagifyPricingModal.userDataCache.deleteNonce
1114
+ } );
1115
+ }
1116
+
1117
  // Change views to go to checkout/payment view.
1118
  imagifyModal.switchToView( imagifyModal.$paymentView );
1119
 
assets/js/pricing-modal.min.js CHANGED
@@ -1 +1 @@
1
- !function(a,b,c,d){a(b).on("click.imagify",".imagify-tab",function(b){var c,d=a(this);b.preventDefault(),d.hasClass("imagify-current")||(c=d.find("a").attr("href")||"#"+d.find("a").attr("aria-controls"),d.closest(".imagify-tabs").next(".imagify-tabs-contents").find(".imagify-tab-content").hide().attr("aria-hidden","true"),a(c).fadeIn(275).attr("aria-hidden","false"),d.closest(".imagify-tabs").find(".imagify-tab").removeClass("imagify-current").attr("aria-selected","false"),d.addClass("imagify-current").attr("aria-selected","true"))})}(jQuery,document,window),function(a,b,c,d){var e={};a("#imagify-pricing-modal").length&&(e={$modal:a("#imagify-pricing-modal"),$checkboxes:a(".imagify-offer-line .imagify-checkbox"),$radios:a(".imagify-payment-modal .imagify-radio-line input"),$preView:a("#imagify-pre-checkout-view"),$plansView:a("#imagify-plans-selection-view").hide(),$paymentView:a("#imagify-payment-process-view").hide(),$successView:a("#imagify-success-view").hide(),$anotherBtn:a(".imagify-choose-another-plan"),speedFadeIn:300,getHtmlPrice:function(a,b){var c,d,e,f,g;return b||(b=null),"object"!=typeof a?(a+="",a=a.split("."),a[1]=1===a[1].length?a[1]+"0":(""+a[1]).substring(0,2),g='<span class="imagify-price-big">'+a[0]+"</span> ",g+='<span class="imagify-price-mini">.'+a[1]+"</span>"):(c=a.monthly+"",d=a.yearly+"",e=c.split("."),f=d.split("."),g='<span class="imagify-switch-my">',g+='<span aria-hidden="'+("monthly"===b?"false":"true")+'" class="imagify-monthly">',g+='<span class="imagify-price-big">'+e[0]+"</span> ",g+='<span class="imagify-price-mini">.'+(1===e[1].length?e[1]+"0":(""+e[1]).substring(0,2))+"</span>",g+="</span> ",g+='<span aria-hidden="'+("yearly"===b?"false":"true")+'" class="imagify-yearly">',g+='<span class="imagify-price-big">'+f[0]+"</span> ",g+='<span class="imagify-price-mini">.'+(1===f[1].length?f[1]+"0":(""+f[1]).substring(0,2))+"</span>",g+="</span>",g+="</span>")},getHtmlDiscountPrice:function(a,b){var c,d,e="";return b||(b=null),"object"==typeof a?(c=a.monthly+"",d=a.yearly+"",e+='<span class="imagify-price-discount">',e+='<span class="imagify-price-discount-dollar">$</span>',e+='<span class="imagify-switch-my">',e+='<span aria-hidden="'+("monthly"===b?"false":"true")+'" class="imagify-monthly">',e+='<span class="imagify-price-discount-number">'+c+"</span>",e+="</span>",e+='<span aria-hidden="'+("yearly"===b?"false":"true")+'" class="imagify-yearly">',e+='<span class="imagify-price-discount-number">'+d+"</span>",e+="</span>",e+="</span>",e+="</span>"):(a+="",e+='<span class="imagify-price-discount">',e+='<span class="imagify-price-discount-dollar">$</span>',e+='<span class="imagify-price-discount-number">'+a+"</span>",e+="</span>"),e},populateOffer:function(a,b,d,f){var g,h,i,j=c.imagify_discount_datas,k=b.additional_gb,l=b.annual_cost,m=b.id,n=b.label,o=b.monthly_cost,p=b.quota,q=b.cost,r=p>=1e3?p/1e3+" GB":p+" MB",s="monthly"===d?{monthly:o,yearly:Math.round(l/12*100)/100}:q,t=s;return j.is_active&&"percentage"===j.coupon_type&&"monthly"===d&&(g=(100-j.coupon_value)/100,s="monthly"===d?{monthly:o*g,yearly:Math.round(l*g/12*100)/100}:q*g),void 0!==f&&a.addClass("imagify-"+d+"-"+n+f),a.find(".imagify-offer-size").text(r),a.find(".imagify-number-block").html(e.getHtmlPrice(s,"monthly")),j.is_active&&"percentage"===j.coupon_type&&"monthly"===d&&(a.find(".imagify-price-block").prev(".imagify-price-discount").remove(),a.find(".imagify-price-block").before(e.getHtmlDiscountPrice(t,"monthly"))),a.find(".imagify-approx-nb").text(5*p),"monthly"===d&&a.find(".imagify-price-add-data").text("$"+k),h=a.find(".imagify-payment-btn-select-plan").length?a.find(".imagify-payment-btn-select-plan"):a,i="monthly"===d?'{"'+n+'":{"id":'+m+',"name":"'+r+'","data":'+p+',"dataf":"'+r+'","imgs":'+5*p+',"prices":{"monthly":'+s.monthly+',"yearly":'+s.yearly+',"add":'+k+"}}}":'{"ot'+n+'":{"id":'+m+',"name":"'+r+'","data":'+p+',"dataf":"'+r+'","imgs":'+5*p+',"price":'+s+"}}",h.attr("data-offer",i),a},populatePayBtn:function(){var b=JSON.parse(a(".imagify-offer-monthly").attr("data-offer")),c=JSON.parse(a(".imagify-offer-onetime").attr("data-offer")),d=0,e=0,f=0;a(".imagify-offer-monthly").hasClass("imagify-offer-selected")&&(e=a("#imagify-subscription-monthly").filter(":checked").length?b[Object.keys(b)[0]].prices.monthly:12*b[Object.keys(b)[0]].prices.yearly),a(".imagify-offer-onetime").hasClass("imagify-offer-selected")&&(f=c[Object.keys(c)[0]].price),d=parseFloat(f+e).toFixed(2),"0.00"===d||0===d?a("#imagify-modal-checkout-btn").attr("disabled","disabled").addClass("imagify-button-disabled"):a("#imagify-modal-checkout-btn").removeAttr("disabled").removeClass("imagify-button-disabled")},checkCoupon:function(){var b,c,d,e,f=a("#imagify-coupon-code").val();""!==f&&(b=a(".imagify-coupon-text"),c=b.find("label"),d=a(".imagify-coupon-section"),e=a("#imagify-get-pricing-modal").data("nonce"),b.addClass("checking"),a.post(ajaxurl,{action:"imagify_check_coupon",coupon:f,imagifynonce:e},function(a){var e;b.removeClass("checking"),a.success?a.data.success?(e="percentage"===a.data.coupon_type?a.data.value+"%":"$"+a.data.value,d.removeClass("invalid").addClass("validated"),c.html(imagifyPricingModal.labels.successCouponAPI),c.find(".imagify-coupon-offer").text(e),c.find(".imagify-coupon-word").text(f)):(d.removeClass("validated").addClass("invalid"),c.text(a.data.detail)):(d.removeClass("validated").addClass("invalid"),c.text(imagifyPricingModal.labels.errorCouponAPI))}))},getPricing:function(b){var d=b.data("nonce"),f={action:"imagify_get_prices",imagifynonce:d},g={action:"imagify_get_images_counts",imagifynonce:d},h={action:"imagify_get_discount",imagifynonce:d};e.$modal.find(".imagify-modal-loader").hide().show(),a.post(ajaxurl,f,function(b){if(!b.success)return void e.populatePayBtn();a.post(ajaxurl,g,function(d){d.success&&a.post(ajaxurl,h,function(f){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w=25,x="",y="";if(f.success){if(g=d.data,h=b.data,i=f.data,j={mo:h.monthlies,ot:h.onetimes},k={month:g.average_month_size.raw/Math.pow(1024,2),total:g.total_library_size.raw/Math.pow(1024,2)},m=a("#imagify-offer-monthly-template"),n=a("#imagify-offer-onetime-template"),o=n.html(),p=m.html(),q=a(".imagify-estimation-block"),a.each(j.mo,function(a,b){if("free"===b.label)return w=b.quota,j.mo.splice(a,1),!1}),q.removeClass("imagify-analyzing"),q.find(".average-month-size").text(g.average_month_size.human),q.find(".total-library-size").text(g.total_library_size.human),k.total+k.month<w?a(".imagify-pre-checkout-offers .imagify-modal-title").addClass("imagify-enough-free"):a(".imagify-enough-free").removeClass("imagify-enough-free"),a(".imagify-offer-selected").removeClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!1),null===j.mo||null===j.ot)return r=a(".imagify-pre-checkout-offers"),r.hide().attr("aria-hidden",!0),r.closest(".imagify-modal-views").find(".imagify-popin-message").remove(),r.after('<div class="imagify-popin-message imagify-error"><p>'+imagifyPricingModal.labels.errorPriceAPI+"</p></div>"),void e.$modal.find(".imagify-modal-loader").fadeOut(300);c.imagify_discount_datas=i,i.is_active&&(s=a(".imagify-modal-promotion"),t=i.date_end.split("T")[0],u=i.coupon_value,v="percentage"===i.coupon_type?u+"%":"$"+u,a("#imagify-coupon-code").val(i.label).attr("readonly",!0),s.addClass("active").attr("aria-hidden","false"),s.find(".imagify-promotion-number").text(v),s.find(".imagify-promotion-date").text(t),e.checkCoupon()),l=e.getSuggestedOffers(j,k,w),a.each(j.mo,function(b,c){var d,f,g="";if(b-l.mo.index>2)return!0;b===l.mo.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-monthly"),l.mo.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"monthly")),d=a(p).clone(),d=e.populateOffer(d,c,"monthly",g),y+=d[0].outerHTML}),a.each(j.ot,function(b,c){var d,f,g="";b===l.ot.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-onetime"),l.ot.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"onetime")),d=a(o).clone(),d=e.populateOffer(d,c,"onetime",g),x+=d[0].outerHTML}),m.parent().find(".imagify-offer-line")&&m.parent().find(".imagify-offer-line").remove(),m.before(y),n.parent().find(".imagify-offer-line")&&n.parent().find(".imagify-offer-line").remove(),n.before(x),e.$modal.find(".imagify-modal-loader").fadeOut(300)}})}),e.populatePayBtn()})},getSuggestedOffers:function(b,c,d){var e=c.total+c.month,f={mo:!1,ot:!1};return c.month<=d?(f.mo={index:0,selected:0},e-=d):(a.each(b.mo,function(a,b){return b.quota<c.month||(f.mo={index:a,selected:1},!1)}),!1===f.mo&&(f.mo={index:b.mo.length-1,selected:1}),e-=b.mo[f.mo.index].quota),e<=0?(a.each(b.ot,function(a,b){return b.quota<c.total||(f.ot={index:a,selected:0},!1)}),!1===f.ot&&(f.ot={index:b.ot.length-1,selected:0}),f):(a.each(b.ot,function(a,b){return b.quota<e||(f.ot={index:a,selected:1},!1)}),!1!==f.ot?f:(f.ot={index:b.ot.length-1,selected:1},f.mo=!1,e=c.total+c.month-b.ot[f.ot.index].quota,a.each(b.mo,function(a,b){return b.quota<e||(f.mo={index:a,selected:1},!1)}),!1===f.mo&&(f.mo={index:b.mo.length-1,selected:1}),f))},checkCheckbox:function(b){b.each(function(){var b=a(this);b.is(":checked")?b.closest(".imagify-offer-line").addClass("imagify-offer-selected"):b.closest(".imagify-offer-line").removeClass("imagify-offer-selected")}),e.populatePayBtn()},checkRadio:function(b){return b.each(function(){var b,c,d=a(this);b=d.parent(".imagify-cart-list-switcher").length?d.closest(".imagify-cart"):d.parent(".imagify-small-options").length?d.parent(".imagify-small-options").next(".imagify-pricing-table"):d.closest(".imagify-offer-line"),c=b.find(".imagify-switch-my"),"yearly"===d.val()?(b.addClass("imagify-year-selected").removeClass("imagify-month-selected"),c.find(".imagify-monthly").attr("aria-hidden","true"),c.find(".imagify-yearly").attr("aria-hidden","false")):(b.addClass("imagify-month-selected").removeClass("imagify-year-selected"),c.find(".imagify-monthly").attr("aria-hidden","false"),c.find(".imagify-yearly").attr("aria-hidden","true"))}),e.populatePayBtn(),b},populateBtnPrice:setInterval(function(){e.populatePayBtn()},1e3),getPeriod:function(){return a(".imagify-offer-monthly").hasClass("imagify-month-selected")?"monthly":"yearly"},getApiKey:function(){return a("#imagify-payment-iframe").data("imagify-api")},switchToView:function(a,b){var c=a.attr("id"),d=e.$modal.children(".imagify-modal-content");a.siblings(".imagify-modal-views").hide().attr("aria-hidden","true"),b&&b.tab&&a.find('a[href="#'+b.tab+'"]').trigger("click.imagify"),"imagify-payment-process-view"===c?d.addClass("imagify-iframe-viewing"):d.removeClass("imagify-iframe-viewing"),"imagify-success-view"===c?(d.addClass("imagify-success-viewing"),e.$modal.attr("aria-labelledby","imagify-success-view")):(d.removeClass("imagify-success-viewing"),e.$modal.removeAttr("aria-labelledby")),a.fadeIn(e.speedFadeIn).attr("aria-hidden","false")},iframeSetSrc:function(b){var d,f,g,h,i,j,k,l=a("#imagify-payment-iframe"),m=l.attr("src"),n=l.data("src"),o=0,p=0;if("string"==typeof b&&""!==m)return k="monthly"===b?"yearly":"monthly",m=m.replace(k,b),void l.attr("src",m);if("object"==typeof b){if(b.monthly&&(o=b.monthly[Object.keys(b.monthly)[0]].id),b.onetime&&(p=b.onetime[Object.keys(b.onetime)[0]].id,p=p+""=="999"?b.onetime[Object.keys(b.onetime)[0]].data:p),!b.period)return void c.imagify.info("No period defined");e.getApiKey(),d=p,f="yearly"===b.period?o:0,g="monthly"===b.period?o:0,h=a("#imagify-coupon-code").val(),i=""===h?"none":h,parseFloat(a(".imagify-global-amount").text()).toFixed(2),n=n+d+"/"+g+"/"+f+"/"+i+"/",j=l.remove().attr("src",n),e.$paymentView.html(j)}},paymentClose:function(){a(".imagify-iframe-viewing .close-btn").trigger("click.imagify"),a(".imagify-iframe-viewing").removeClass("imagify-iframe-viewing")},paymentBack:function(){e.switchToView(e.$preView)},paymentSuccess:function(){e.switchToView(e.$successView)},checkPluginMessage:function(a){var b=a.origin||a.originalEvent.origin;if("https://app.imagify.io"===b||"http://dapp.imagify.io"===b)switch(a.data){case"cancel":e.paymentClose();break;case"back":e.paymentBack();break;case"success":e.paymentSuccess()}}},e.checkCheckbox(e.$checkboxes),e.checkRadio(e.$radios.filter(":checked")),e.checkCoupon(),e.$checkboxes.on("change.imagify",function(){e.checkCheckbox(a(this))}),e.$radios.on("change.imagify",function(){e.checkRadio(a(this))}),a("#imagify-get-pricing-modal").on("click.imagify-ajax",function(){e.getPricing(a(this))}),a(b).on("modalClosed.imagify",".imagify-payment-modal",function(){a(this).find(".imagify-modal-content").removeClass("imagify-success-viewing imagify-iframe-viewing"),setTimeout(function(){a(".imagify-modal-views").hide(),a("#imagify-pre-checkout-view").show()},300)}),a("#imagify-coupon-code").on("blur.imagify",function(){a(this).attr("readonly")||e.checkCoupon()}).on("keydown.imagify",function(b){var c=a(this);if(!c.attr("readonly"))return 13===b.keyCode||32===b.keyCode?(e.checkCoupon(),!1):void(c.val().length>=3?c.closest(".imagify-coupon-input").addClass("imagify-canbe-validate"):c.closest(".imagify-coupon-input").removeClass("imagify-canbe-validate"))}),a("#imagify-coupon-validate").on("click.imagify",function(){e.checkCoupon(),a(this).closest(".imagify-canbe-validate").removeClass("imagify-canbe-validate")}),e.$anotherBtn.on("click.imagify",function(b){var c=a(this).data("imagify-choose"),d="imagify-pricing-tab-"+("plan"===c?"monthly":"onetime");b.preventDefault(),e.switchToView(e.$plansView,{tab:d})}),e.$modal.on("click.imagify",".imagify-payment-btn-select-plan",function(b){var c=a(this),d=c.closest(".imagify-offer-line"),f=c.data("offer"),g=c.attr("data-offer"),h="imagify-pricing-tab-monthly"!==c.closest(".imagify-tab-content").attr("id"),i=h?e.$preView.find(".imagify-offer-onetime"):e.$preView.find(".imagify-offer-monthly"),j=h?null:c.closest(".imagify-pricing-table").hasClass("imagify-month-selected")?"monthly":"yearly",k=h?e.getHtmlPrice(f[Object.keys(f)[0]].price):e.getHtmlPrice(f[Object.keys(f)[0]].prices,j),l=h?"":'<span class="imagify-price-by">'+d.find(".imagify-price-by").text()+"</span>",m=d.find(".imagify-price-discount").html(),n=d.find(".imagify-approx-nb").text(),o=d.find(".imagify-offer-size").text();b.preventDefault(),e.switchToView(e.$preView),i.find(".imagify-number-block").html(k+l),i.find(".imagify-price-discount").html(m),i.find(".imagify-approx-nb").text(n),i.find(".imagify-offer-size").text(o),i.attr("data-offer",g),h||(i.find(".imagify-price-add-data").text(d.find(".imagify-price-add-data").text()),"monthly"===j?i.find("#imagify-subscription-monthly").trigger("click.imagify"):i.find("#imagify-subscription-yearly").trigger("click.imagify"),i.find(".imagify-inline-options").find("input:radio:checked").trigger("change.imagify")),e.populatePayBtn()}),a("#imagify-modal-checkout-btn").on("click.imagify",function(b){var c,d,f;b.preventDefault(),a(this).hasClass("imagify-button-disabled")||(c=a(".imagify-offer-monthly"),d=a(".imagify-offer-onetime"),f={},c.hasClass("imagify-offer-selected")&&(f.monthly=JSON.parse(c.attr("data-offer"))),d.hasClass("imagify-offer-selected")&&(f.onetime=JSON.parse(d.attr("data-offer"))),e.switchToView(e.$paymentView),f.period=e.getPeriod(),e.iframeSetSrc(f))}),a(".imagify-back-to-plans").on("click.imagify",function(b){var c=a(this),d=c.closest(".imagify-cart-item").hasClass("imagify-cart-item-onetime");b.preventDefault(),d?a(".imagify-offer-onetime").find(".imagify-choose-another-plan").trigger("click.imagify"):a(".imagify-offer-monthly").find(".imagify-choose-another-plan").trigger("click.imagify")}),c.addEventListener("message",e.checkPluginMessage,!0))}(jQuery,document,window);
1
+ !function(a,b,c,d){a(b).on("click.imagify",".imagify-tab",function(b){var c,d=a(this);b.preventDefault(),d.hasClass("imagify-current")||(c=d.find("a").attr("href")||"#"+d.find("a").attr("aria-controls"),d.closest(".imagify-tabs").next(".imagify-tabs-contents").find(".imagify-tab-content").hide().attr("aria-hidden","true"),a(c).fadeIn(275).attr("aria-hidden","false"),d.closest(".imagify-tabs").find(".imagify-tab").removeClass("imagify-current").attr("aria-selected","false"),d.addClass("imagify-current").attr("aria-selected","true"))})}(jQuery,document,window),function(a,b,c,d){var e={};a("#imagify-pricing-modal").length&&(e={$modal:a("#imagify-pricing-modal"),$checkboxes:a(".imagify-offer-line .imagify-checkbox"),$radios:a(".imagify-payment-modal .imagify-radio-line input"),$preView:a("#imagify-pre-checkout-view"),$plansView:a("#imagify-plans-selection-view").hide(),$paymentView:a("#imagify-payment-process-view").hide(),$successView:a("#imagify-success-view").hide(),$anotherBtn:a(".imagify-choose-another-plan"),speedFadeIn:300,getHtmlPrice:function(a,b){var c,d,e,f,g;return b||(b=null),"object"!=typeof a?(a+="",a=a.split("."),a[1]=1===a[1].length?a[1]+"0":(""+a[1]).substring(0,2),g='<span class="imagify-price-big">'+a[0]+"</span> ",g+='<span class="imagify-price-mini">.'+a[1]+"</span>"):(c=a.monthly+"",d=a.yearly+"",e=c.split("."),f=d.split("."),g='<span class="imagify-switch-my">',g+='<span aria-hidden="'+("monthly"===b?"false":"true")+'" class="imagify-monthly">',g+='<span class="imagify-price-big">'+e[0]+"</span> ",g+='<span class="imagify-price-mini">.'+(1===e[1].length?e[1]+"0":(""+e[1]).substring(0,2))+"</span>",g+="</span> ",g+='<span aria-hidden="'+("yearly"===b?"false":"true")+'" class="imagify-yearly">',g+='<span class="imagify-price-big">'+f[0]+"</span> ",g+='<span class="imagify-price-mini">.'+(1===f[1].length?f[1]+"0":(""+f[1]).substring(0,2))+"</span>",g+="</span>",g+="</span>")},getHtmlDiscountPrice:function(a,b){var c,d,e="";return b||(b=null),"object"==typeof a?(c=a.monthly+"",d=a.yearly+"",e+='<span class="imagify-price-discount">',e+='<span class="imagify-price-discount-dollar">$</span>',e+='<span class="imagify-switch-my">',e+='<span aria-hidden="'+("monthly"===b?"false":"true")+'" class="imagify-monthly">',e+='<span class="imagify-price-discount-number">'+c+"</span>",e+="</span>",e+='<span aria-hidden="'+("yearly"===b?"false":"true")+'" class="imagify-yearly">',e+='<span class="imagify-price-discount-number">'+d+"</span>",e+="</span>",e+="</span>",e+="</span>"):(a+="",e+='<span class="imagify-price-discount">',e+='<span class="imagify-price-discount-dollar">$</span>',e+='<span class="imagify-price-discount-number">'+a+"</span>",e+="</span>"),e},populateOffer:function(a,b,d,f){var g,h,i,j=c.imagify_discount_datas,k=b.additional_gb,l=b.annual_cost,m=b.id,n=b.label,o=b.monthly_cost,p=b.quota,q=b.cost,r=p>=1e3?p/1e3+" GB":p+" MB",s="monthly"===d?{monthly:o,yearly:Math.round(l/12*100)/100}:q,t=s;return j.is_active&&"percentage"===j.coupon_type&&"monthly"===d&&(g=(100-j.coupon_value)/100,s="monthly"===d?{monthly:o*g,yearly:Math.round(l*g/12*100)/100}:q*g),void 0!==f&&a.addClass("imagify-"+d+"-"+n+f),a.find(".imagify-offer-size").text(r),a.find(".imagify-number-block").html(e.getHtmlPrice(s,"monthly")),j.is_active&&"percentage"===j.coupon_type&&"monthly"===d&&(a.find(".imagify-price-block").prev(".imagify-price-discount").remove(),a.find(".imagify-price-block").before(e.getHtmlDiscountPrice(t,"monthly"))),a.find(".imagify-approx-nb").text(5*p),"monthly"===d&&a.find(".imagify-price-add-data").text("$"+k),h=a.find(".imagify-payment-btn-select-plan").length?a.find(".imagify-payment-btn-select-plan"):a,i="monthly"===d?'{"'+n+'":{"id":'+m+',"name":"'+r+'","data":'+p+',"dataf":"'+r+'","imgs":'+5*p+',"prices":{"monthly":'+s.monthly+',"yearly":'+s.yearly+',"add":'+k+"}}}":'{"ot'+n+'":{"id":'+m+',"name":"'+r+'","data":'+p+',"dataf":"'+r+'","imgs":'+5*p+',"price":'+s+"}}",h.attr("data-offer",i),a},populatePayBtn:function(){var b=JSON.parse(a(".imagify-offer-monthly").attr("data-offer")),c=JSON.parse(a(".imagify-offer-onetime").attr("data-offer")),d=0,e=0,f=0;a(".imagify-offer-monthly").hasClass("imagify-offer-selected")&&(e=a("#imagify-subscription-monthly").filter(":checked").length?b[Object.keys(b)[0]].prices.monthly:12*b[Object.keys(b)[0]].prices.yearly),a(".imagify-offer-onetime").hasClass("imagify-offer-selected")&&(f=c[Object.keys(c)[0]].price),d=parseFloat(f+e).toFixed(2),"0.00"===d||0===d?a("#imagify-modal-checkout-btn").attr("disabled","disabled").addClass("imagify-button-disabled"):a("#imagify-modal-checkout-btn").removeAttr("disabled").removeClass("imagify-button-disabled")},checkCoupon:function(){var b,c,d,e,f=a("#imagify-coupon-code").val();""!==f&&(b=a(".imagify-coupon-text"),c=b.find("label"),d=a(".imagify-coupon-section"),e=a("#imagify-get-pricing-modal").data("nonce"),b.addClass("checking"),a.post(ajaxurl,{action:"imagify_check_coupon",coupon:f,imagifynonce:e},function(a){var e;b.removeClass("checking"),a.success?a.data.success?(e="percentage"===a.data.coupon_type?a.data.value+"%":"$"+a.data.value,d.removeClass("invalid").addClass("validated"),c.html(imagifyPricingModal.labels.successCouponAPI),c.find(".imagify-coupon-offer").text(e),c.find(".imagify-coupon-word").text(f)):(d.removeClass("validated").addClass("invalid"),c.text(a.data.detail)):(d.removeClass("validated").addClass("invalid"),c.text(imagifyPricingModal.labels.errorCouponAPI))}))},getPricing:function(b){var d=b.data("nonce"),f={action:"imagify_get_prices",imagifynonce:d},g={action:"imagify_get_images_counts",imagifynonce:d},h={action:"imagify_get_discount",imagifynonce:d};e.$modal.find(".imagify-modal-loader").hide().show(),a.post(ajaxurl,f,function(b){if(!b.success)return void e.populatePayBtn();a.post(ajaxurl,g,function(d){d.success&&a.post(ajaxurl,h,function(f){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w=25,x="",y="";if(f.success){if(g=d.data,h=b.data,i=f.data,j={mo:h.monthlies,ot:h.onetimes},k={month:g.average_month_size.raw/Math.pow(1024,2),total:g.total_library_size.raw/Math.pow(1024,2)},m=a("#imagify-offer-monthly-template"),n=a("#imagify-offer-onetime-template"),o=n.html(),p=m.html(),q=a(".imagify-estimation-block"),a.each(j.mo,function(a,b){if("free"===b.label)return w=b.quota,j.mo.splice(a,1),!1}),q.removeClass("imagify-analyzing"),q.find(".average-month-size").text(g.average_month_size.human),q.find(".total-library-size").text(g.total_library_size.human),k.total+k.month<w?a(".imagify-pre-checkout-offers .imagify-modal-title").addClass("imagify-enough-free"):a(".imagify-enough-free").removeClass("imagify-enough-free"),a(".imagify-offer-selected").removeClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!1),null===j.mo||null===j.ot)return r=a(".imagify-pre-checkout-offers"),r.hide().attr("aria-hidden",!0),r.closest(".imagify-modal-views").find(".imagify-popin-message").remove(),r.after('<div class="imagify-popin-message imagify-error"><p>'+imagifyPricingModal.labels.errorPriceAPI+"</p></div>"),void e.$modal.find(".imagify-modal-loader").fadeOut(300);c.imagify_discount_datas=i,i.is_active&&(s=a(".imagify-modal-promotion"),t=i.date_end.split("T")[0],u=i.coupon_value,v="percentage"===i.coupon_type?u+"%":"$"+u,a("#imagify-coupon-code").val(i.label).attr("readonly",!0),s.addClass("active").attr("aria-hidden","false"),s.find(".imagify-promotion-number").text(v),s.find(".imagify-promotion-date").text(t),e.checkCoupon()),l=e.getSuggestedOffers(j,k,w),a.each(j.mo,function(b,c){var d,f,g="";if(b-l.mo.index>2)return!0;b===l.mo.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-monthly"),l.mo.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"monthly")),d=a(p).clone(),d=e.populateOffer(d,c,"monthly",g),y+=d[0].outerHTML}),a.each(j.ot,function(b,c){var d,f,g="";b===l.ot.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-onetime"),l.ot.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"onetime")),d=a(o).clone(),d=e.populateOffer(d,c,"onetime",g),x+=d[0].outerHTML}),m.parent().find(".imagify-offer-line")&&m.parent().find(".imagify-offer-line").remove(),m.before(y),n.parent().find(".imagify-offer-line")&&n.parent().find(".imagify-offer-line").remove(),n.before(x),e.$modal.find(".imagify-modal-loader").fadeOut(300)}})}),e.populatePayBtn()})},getSuggestedOffers:function(b,c,d){var e=c.total+c.month,f={mo:!1,ot:!1};return c.month<=d?(f.mo={index:0,selected:0},e-=d):(a.each(b.mo,function(a,b){return b.quota<c.month||(f.mo={index:a,selected:1},!1)}),!1===f.mo&&(f.mo={index:b.mo.length-1,selected:1}),e-=b.mo[f.mo.index].quota),e<=0?(a.each(b.ot,function(a,b){return b.quota<c.total||(f.ot={index:a,selected:0},!1)}),!1===f.ot&&(f.ot={index:b.ot.length-1,selected:0}),f):(a.each(b.ot,function(a,b){return b.quota<e||(f.ot={index:a,selected:1},!1)}),!1!==f.ot?f:(f.ot={index:b.ot.length-1,selected:1},f.mo=!1,e=c.total+c.month-b.ot[f.ot.index].quota,a.each(b.mo,function(a,b){return b.quota<e||(f.mo={index:a,selected:1},!1)}),!1===f.mo&&(f.mo={index:b.mo.length-1,selected:1}),f))},checkCheckbox:function(b){b.each(function(){var b=a(this);b.is(":checked")?b.closest(".imagify-offer-line").addClass("imagify-offer-selected"):b.closest(".imagify-offer-line").removeClass("imagify-offer-selected")}),e.populatePayBtn()},checkRadio:function(b){return b.each(function(){var b,c,d=a(this);b=d.parent(".imagify-cart-list-switcher").length?d.closest(".imagify-cart"):d.parent(".imagify-small-options").length?d.parent(".imagify-small-options").next(".imagify-pricing-table"):d.closest(".imagify-offer-line"),c=b.find(".imagify-switch-my"),"yearly"===d.val()?(b.addClass("imagify-year-selected").removeClass("imagify-month-selected"),c.find(".imagify-monthly").attr("aria-hidden","true"),c.find(".imagify-yearly").attr("aria-hidden","false")):(b.addClass("imagify-month-selected").removeClass("imagify-year-selected"),c.find(".imagify-monthly").attr("aria-hidden","false"),c.find(".imagify-yearly").attr("aria-hidden","true"))}),e.populatePayBtn(),b},populateBtnPrice:setInterval(function(){e.populatePayBtn()},1e3),getPeriod:function(){return a(".imagify-offer-monthly").hasClass("imagify-month-selected")?"monthly":"yearly"},getApiKey:function(){return a("#imagify-payment-iframe").data("imagify-api")},switchToView:function(a,b){var c=a.attr("id"),d=e.$modal.children(".imagify-modal-content");a.siblings(".imagify-modal-views").hide().attr("aria-hidden","true"),b&&b.tab&&a.find('a[href="#'+b.tab+'"]').trigger("click.imagify"),"imagify-payment-process-view"===c?d.addClass("imagify-iframe-viewing"):d.removeClass("imagify-iframe-viewing"),"imagify-success-view"===c?(d.addClass("imagify-success-viewing"),e.$modal.attr("aria-labelledby","imagify-success-view")):(d.removeClass("imagify-success-viewing"),e.$modal.removeAttr("aria-labelledby")),a.fadeIn(e.speedFadeIn).attr("aria-hidden","false")},iframeSetSrc:function(b){var d,f,g,h,i,j,k,l=a("#imagify-payment-iframe"),m=l.attr("src"),n=l.data("src"),o=0,p=0;if("string"==typeof b&&""!==m)return k="monthly"===b?"yearly":"monthly",m=m.replace(k,b),void l.attr("src",m);if("object"==typeof b){if(b.monthly&&(o=b.monthly[Object.keys(b.monthly)[0]].id),b.onetime&&(p=b.onetime[Object.keys(b.onetime)[0]].id,p=p+""=="999"?b.onetime[Object.keys(b.onetime)[0]].data:p),!b.period)return void c.imagify.info("No period defined");e.getApiKey(),d=p,f="yearly"===b.period?o:0,g="monthly"===b.period?o:0,h=a("#imagify-coupon-code").val(),i=""===h?"none":h,parseFloat(a(".imagify-global-amount").text()).toFixed(2),n=n+d+"/"+g+"/"+f+"/"+i+"/",j=l.remove().attr("src",n),e.$paymentView.html(j)}},paymentClose:function(){a(".imagify-iframe-viewing .close-btn").trigger("click.imagify"),a(".imagify-iframe-viewing").removeClass("imagify-iframe-viewing")},paymentBack:function(){e.switchToView(e.$preView)},paymentSuccess:function(){e.switchToView(e.$successView)},checkPluginMessage:function(a){var b=a.origin||a.originalEvent.origin;if("https://app.imagify.io"===b||"http://dapp.imagify.io"===b)switch(a.data){case"cancel":e.paymentClose();break;case"back":e.paymentBack();break;case"success":e.paymentSuccess()}}},e.checkCheckbox(e.$checkboxes),e.checkRadio(e.$radios.filter(":checked")),e.checkCoupon(),e.$checkboxes.on("change.imagify",function(){e.checkCheckbox(a(this))}),e.$radios.on("change.imagify",function(){e.checkRadio(a(this))}),a("#imagify-get-pricing-modal").on("click.imagify-ajax",function(){e.getPricing(a(this))}),a(b).on("modalClosed.imagify",".imagify-payment-modal",function(){a(this).find(".imagify-modal-content").removeClass("imagify-success-viewing imagify-iframe-viewing"),setTimeout(function(){a(".imagify-modal-views").hide(),a("#imagify-pre-checkout-view").show()},300)}),a("#imagify-coupon-code").on("blur.imagify",function(){a(this).attr("readonly")||e.checkCoupon()}).on("keydown.imagify",function(b){var c=a(this);if(!c.attr("readonly"))return 13===b.keyCode||32===b.keyCode?(e.checkCoupon(),!1):void(c.val().length>=3?c.closest(".imagify-coupon-input").addClass("imagify-canbe-validate"):c.closest(".imagify-coupon-input").removeClass("imagify-canbe-validate"))}),a("#imagify-coupon-validate").on("click.imagify",function(){e.checkCoupon(),a(this).closest(".imagify-canbe-validate").removeClass("imagify-canbe-validate")}),e.$anotherBtn.on("click.imagify",function(b){var c=a(this).data("imagify-choose"),d="imagify-pricing-tab-"+("plan"===c?"monthly":"onetime");b.preventDefault(),e.switchToView(e.$plansView,{tab:d})}),e.$modal.on("click.imagify",".imagify-payment-btn-select-plan",function(b){var c=a(this),d=c.closest(".imagify-offer-line"),f=c.data("offer"),g=c.attr("data-offer"),h="imagify-pricing-tab-monthly"!==c.closest(".imagify-tab-content").attr("id"),i=h?e.$preView.find(".imagify-offer-onetime"):e.$preView.find(".imagify-offer-monthly"),j=h?null:c.closest(".imagify-pricing-table").hasClass("imagify-month-selected")?"monthly":"yearly",k=h?e.getHtmlPrice(f[Object.keys(f)[0]].price):e.getHtmlPrice(f[Object.keys(f)[0]].prices,j),l=h?"":'<span class="imagify-price-by">'+d.find(".imagify-price-by").text()+"</span>",m=d.find(".imagify-price-discount").html(),n=d.find(".imagify-approx-nb").text(),o=d.find(".imagify-offer-size").text();b.preventDefault(),e.switchToView(e.$preView),i.find(".imagify-number-block").html(k+l),i.find(".imagify-price-discount").html(m),i.find(".imagify-approx-nb").text(n),i.find(".imagify-offer-size").text(o),i.attr("data-offer",g),h||(i.find(".imagify-price-add-data").text(d.find(".imagify-price-add-data").text()),"monthly"===j?i.find("#imagify-subscription-monthly").trigger("click.imagify"):i.find("#imagify-subscription-yearly").trigger("click.imagify"),i.find(".imagify-inline-options").find("input:radio:checked").trigger("change.imagify")),e.populatePayBtn()}),a("#imagify-modal-checkout-btn").on("click.imagify",function(b){var c,d,f;b.preventDefault(),a(this).hasClass("imagify-button-disabled")||(c=a(".imagify-offer-monthly"),d=a(".imagify-offer-onetime"),f={},c.hasClass("imagify-offer-selected")&&(f.monthly=JSON.parse(c.attr("data-offer"))),d.hasClass("imagify-offer-selected")&&(f.onetime=JSON.parse(d.attr("data-offer"))),imagifyPricingModal.userDataCache&&a.post(ajaxurl,{action:imagifyPricingModal.userDataCache.deleteAction,_wpnonce:imagifyPricingModal.userDataCache.deleteNonce}),e.switchToView(e.$paymentView),f.period=e.getPeriod(),e.iframeSetSrc(f))}),a(".imagify-back-to-plans").on("click.imagify",function(b){var c=a(this),d=c.closest(".imagify-cart-item").hasClass("imagify-cart-item-onetime");b.preventDefault(),d?a(".imagify-offer-onetime").find(".imagify-choose-another-plan").trigger("click.imagify"):a(".imagify-offer-monthly").find(".imagify-choose-another-plan").trigger("click.imagify")}),c.addEventListener("message",e.checkPluginMessage,!0))}(jQuery,document,window);
classes/Auth/Basic.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Imagify\Auth;
3
+
4
+ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
5
+
6
+ /**
7
+ * Class that allows the use of Basic Auth for internal requests.
8
+ * If this doesn’t work automatically, define the constants IMAGIFY_AUTH_USER and IMAGIFY_AUTH_PASSWORD.
9
+ *
10
+ * @since 1.9.5
11
+ * @author Grégory Viguier
12
+ */
13
+ class Basic {
14
+ use \Imagify\Traits\InstanceGetterTrait;
15
+
16
+ /**
17
+ * Class init: launch hooks.
18
+ *
19
+ * @since 1.9.5
20
+ * @access public
21
+ * @author Grégory Viguier
22
+ */
23
+ public function init() {
24
+ add_filter( 'imagify_background_process_url', [ $this, 'get_auth_url' ] );
25
+ add_filter( 'imagify_async_job_url', [ $this, 'get_auth_url' ] );
26
+ add_filter( 'imagify_internal_request_url', [ $this, 'get_auth_url' ] );
27
+ add_filter( 'cron_request', [ $this, 'cron_request_args' ] );
28
+ }
29
+
30
+ /**
31
+ * If the site uses basic authentication, add the required user and password to the given URL.
32
+ *
33
+ * @since 1.9.5
34
+ * @access public
35
+ * @author Grégory Viguier
36
+ *
37
+ * @param string $url An URL.
38
+ * @return string
39
+ */
40
+ public function get_auth_url( $url ) {
41
+ if ( ! $url || ! is_string( $url ) ) {
42
+ // Invalid.
43
+ return '';
44
+ }
45
+
46
+ if ( preg_match( '%.+?//(.+?):(.+?)@%', $url ) ) {
47
+ // Credentials already in the URL.
48
+ return $url;
49
+ }
50
+
51
+ if ( defined( 'IMAGIFY_AUTH_USER' ) && defined( 'IMAGIFY_AUTH_PASSWORD' ) && IMAGIFY_AUTH_USER && IMAGIFY_AUTH_PASSWORD ) {
52
+ $user = IMAGIFY_AUTH_USER;
53
+ $pass = IMAGIFY_AUTH_PASSWORD;
54
+ } else {
55
+ $auth_type = ! empty( $_SERVER['AUTH_TYPE'] ) ? strtolower( wp_unslash( $_SERVER['AUTH_TYPE'] ) ) : '';
56
+
57
+ if ( 'basic' === $auth_type && ! empty( $_SERVER['PHP_AUTH_USER'] ) && ! empty( $_SERVER['PHP_AUTH_PW'] ) ) {
58
+ $user = sanitize_text_field( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) );
59
+ $pass = sanitize_text_field( wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
60
+ }
61
+ }
62
+
63
+ if ( empty( $user ) || empty( $pass ) ) {
64
+ // No credentials.
65
+ return $url;
66
+ }
67
+
68
+ return preg_replace( '%^(.+?//)(.+?)$%', '$1' . rawurlencode( $user ) . ':' . rawurlencode( $pass ) . '@$2', $url );
69
+ }
70
+
71
+ /**
72
+ * If the site uses basic authentication, add the required user and password to the given URL.
73
+ *
74
+ * @since 1.9.5
75
+ * @access public
76
+ * @author Grégory Viguier
77
+ *
78
+ * @param array $args {
79
+ * An array of cron request URL arguments.
80
+ *
81
+ * @type string $url The cron request URL.
82
+ * @type int $key The 22 digit GMT microtime.
83
+ * @type array $args {
84
+ * An array of cron request arguments.
85
+ *
86
+ * @type int $timeout The request timeout in seconds. Default .01 seconds.
87
+ * @type bool $blocking Whether to set blocking for the request. Default false.
88
+ * @type bool $sslverify Whether SSL should be verified for the request. Default false.
89
+ * }
90
+ * }
91
+ * @return array
92
+ */
93
+ public function cron_request_args( $args ) {
94
+ if ( ! empty( $args['url'] ) ) {
95
+ $args['url'] = $this->get_auth_url( $args['url'] );
96
+ }
97
+
98
+ return $args;
99
+ }
100
+ }
classes/Bulk/BulkInterface.php CHANGED
@@ -27,10 +27,17 @@ interface BulkInterface {
27
  * Get ids of all optimized media without webp versions.
28
  *
29
  * @since 1.9
 
30
  * @access public
31
  * @author Grégory Viguier
32
  *
33
- * @return array A list of media IDs.
 
 
 
 
 
 
34
  */
35
  public function get_optimized_media_ids_without_webp();
36
 
27
  * Get ids of all optimized media without webp versions.
28
  *
29
  * @since 1.9
30
+ * @since 1.9.5 The method doesn't return the IDs directly anymore.
31
  * @access public
32
  * @author Grégory Viguier
33
  *
34
+ * @return array {
35
+ * @type array $ids A list of media IDs.
36
+ * @type array $errors {
37
+ * @type array $no_file_path A list of media IDs.
38
+ * @type array $no_backup A list of media IDs.
39
+ * }
40
+ * }
41
  */
42
  public function get_optimized_media_ids_without_webp();
43
 
classes/Bulk/CustomFolders.php CHANGED
@@ -79,10 +79,17 @@ class CustomFolders extends AbstractBulk {
79
  * Get ids of all optimized media without webp versions.
80
  *
81
  * @since 1.9
 
82
  * @access public
83
  * @author Grégory Viguier
84
  *
85
- * @return array A list of media IDs.
 
 
 
 
 
 
86
  */
87
  public function get_optimized_media_ids_without_webp() {
88
  global $wpdb;
@@ -110,28 +117,37 @@ class CustomFolders extends AbstractBulk {
110
  $wpdb->flush();
111
  unset( $mime_types, $files_table, $folders_table, $webp_suffix );
112
 
 
 
 
 
 
 
 
 
113
  if ( ! $files ) {
114
- return [];
115
  }
116
 
117
- $data = [];
118
-
119
  foreach ( $files as $file ) {
 
 
120
  if ( empty( $file->path ) ) {
121
  // Problem.
 
122
  continue;
123
  }
124
 
125
- $file_id = absint( $file->file_id );
126
  $file_path = \Imagify_Files_Scan::remove_placeholder( $file->path );
127
  $backup_path = \Imagify_Custom_Folders::get_file_backup_path( $file_path );
128
 
129
  if ( ! $this->filesystem->exists( $backup_path ) ) {
130
  // No backup, no webp.
 
131
  continue;
132
  }
133
 
134
- $data[] = $file_id;
135
  } // End foreach().
136
 
137
  return $data;
79
  * Get ids of all optimized media without webp versions.
80
  *
81
  * @since 1.9
82
+ * @since 1.9.5 The method doesn't return the IDs directly anymore.
83
  * @access public
84
  * @author Grégory Viguier
85
  *
86
+ * @return array {
87
+ * @type array $ids A list of media IDs.
88
+ * @type array $errors {
89
+ * @type array $no_file_path A list of media IDs.
90
+ * @type array $no_backup A list of media IDs.
91
+ * }
92
+ * }
93
  */
94
  public function get_optimized_media_ids_without_webp() {
95
  global $wpdb;
117
  $wpdb->flush();
118
  unset( $mime_types, $files_table, $folders_table, $webp_suffix );
119
 
120
+ $data = [
121
+ 'ids' => [],
122
+ 'errors' => [
123
+ 'no_file_path' => [],
124
+ 'no_backup' => [],
125
+ ],
126
+ ];
127
+
128
  if ( ! $files ) {
129
+ return $data;
130
  }
131
 
 
 
132
  foreach ( $files as $file ) {
133
+ $file_id = absint( $file->file_id );
134
+
135
  if ( empty( $file->path ) ) {
136
  // Problem.
137
+ $data['errors']['no_file_path'][] = $file_id;
138
  continue;
139
  }
140
 
 
141
  $file_path = \Imagify_Files_Scan::remove_placeholder( $file->path );
142
  $backup_path = \Imagify_Custom_Folders::get_file_backup_path( $file_path );
143
 
144
  if ( ! $this->filesystem->exists( $backup_path ) ) {
145
  // No backup, no webp.
146
+ $data['errors']['no_backup'][] = $file_id;
147
  continue;
148
  }
149
 
150
+ $data['ids'][] = $file_id;
151
  } // End foreach().
152
 
153
  return $data;
classes/Bulk/Noop.php CHANGED
@@ -29,13 +29,26 @@ class Noop implements BulkInterface {
29
  * Get ids of all optimized media without webp versions.
30
  *
31
  * @since 1.9
 
32
  * @access public
33
  * @author Grégory Viguier
34
  *
35
- * @return array A list of media IDs.
 
 
 
 
 
 
36
  */
37
  public function get_optimized_media_ids_without_webp() {
38
- return [];
 
 
 
 
 
 
39
  }
40
 
41
  /**
29
  * Get ids of all optimized media without webp versions.
30
  *
31
  * @since 1.9
32
+ * @since 1.9.5 The method doesn't return the IDs directly anymore.
33
  * @access public
34
  * @author Grégory Viguier
35
  *
36
+ * @return array {
37
+ * @type array $ids A list of media IDs.
38
+ * @type array $errors {
39
+ * @type array $no_file_path A list of media IDs.
40
+ * @type array $no_backup A list of media IDs.
41
+ * }
42
+ * }
43
  */
44
  public function get_optimized_media_ids_without_webp() {
45
+ return [
46
+ 'ids' => [],
47
+ 'errors' => [
48
+ 'no_file_path' => [],
49
+ 'no_backup' => [],
50
+ ],
51
+ ];
52
  }
53
 
54
  /**
classes/Bulk/WP.php CHANGED
@@ -175,10 +175,17 @@ class WP extends AbstractBulk {
175
  * Get ids of all optimized media without webp versions.
176
  *
177
  * @since 1.9
 
178
  * @access public
179
  * @author Grégory Viguier
180
  *
181
- * @return array A list of media IDs.
 
 
 
 
 
 
182
  */
183
  public function get_optimized_media_ids_without_webp() {
184
  global $wpdb;
@@ -216,10 +223,18 @@ class WP extends AbstractBulk {
216
 
217
  $wpdb->flush();
218
  unset( $mime_types, $statuses, $webp_suffix );
219
- $ids = array_filter( array_map( 'absint', $ids ) );
 
 
 
 
 
 
 
 
220
 
221
  if ( ! $ids ) {
222
- return [];
223
  }
224
 
225
  $metas = \Imagify_DB::get_metas( [
@@ -239,17 +254,18 @@ class WP extends AbstractBulk {
239
  */
240
  do_action( 'imagify_bulk_generate_webp_before_file_existence_tests', $ids, $metas, 'wp' );
241
 
242
- $data = [];
243
-
244
  foreach ( $ids as $i => $id ) {
245
  if ( empty( $metas['filenames'][ $id ] ) ) {
246
- // Problem.
 
247
  continue;
248
  }
249
 
250
  $file_path = get_imagify_attached_file( $metas['filenames'][ $id ] );
251
 
252
- if ( ! $file_path || ! $this->filesystem->exists( $file_path ) ) {
 
 
253
  continue;
254
  }
255
 
@@ -257,10 +273,11 @@ class WP extends AbstractBulk {
257
 
258
  if ( ! $this->filesystem->exists( $backup_path ) ) {
259
  // No backup, no webp.
 
260
  continue;
261
  }
262
 
263
- $data[] = $id;
264
  } // End foreach().
265
 
266
  return $data;
175
  * Get ids of all optimized media without webp versions.
176
  *
177
  * @since 1.9
178
+ * @since 1.9.5 The method doesn't return the IDs directly anymore.
179
  * @access public
180
  * @author Grégory Viguier
181
  *
182
+ * @return array {
183
+ * @type array $ids A list of media IDs.
184
+ * @type array $errors {
185
+ * @type array $no_file_path A list of media IDs.
186
+ * @type array $no_backup A list of media IDs.
187
+ * }
188
+ * }
189
  */
190
  public function get_optimized_media_ids_without_webp() {
191
  global $wpdb;
223
 
224
  $wpdb->flush();
225
  unset( $mime_types, $statuses, $webp_suffix );
226
+
227
+ $ids = array_filter( array_map( 'absint', $ids ) );
228
+ $data = [
229
+ 'ids' => [],
230
+ 'errors' => [
231
+ 'no_file_path' => [],
232
+ 'no_backup' => [],
233
+ ],
234
+ ];
235
 
236
  if ( ! $ids ) {
237
+ return $data;
238
  }
239
 
240
  $metas = \Imagify_DB::get_metas( [
254
  */
255
  do_action( 'imagify_bulk_generate_webp_before_file_existence_tests', $ids, $metas, 'wp' );
256
 
 
 
257
  foreach ( $ids as $i => $id ) {
258
  if ( empty( $metas['filenames'][ $id ] ) ) {
259
+ // Problem. Should not happen, thanks to the wpdb query.
260
+ $data['errors']['no_file_path'][] = $id;
261
  continue;
262
  }
263
 
264
  $file_path = get_imagify_attached_file( $metas['filenames'][ $id ] );
265
 
266
+ if ( ! $file_path ) {
267
+ // Main file not found.
268
+ $data['errors']['no_file_path'][] = $id;
269
  continue;
270
  }
271
 
273
 
274
  if ( ! $this->filesystem->exists( $backup_path ) ) {
275
  // No backup, no webp.
276
+ $data['errors']['no_backup'][] = $id;
277
  continue;
278
  }
279
 
280
+ $data['ids'][] = $id;
281
  } // End foreach().
282
 
283
  return $data;
classes/Optimization/Process/AbstractProcess.php CHANGED
@@ -617,6 +617,11 @@ abstract class AbstractProcess implements ProcessInterface {
617
  '<code>' . esc_html( $this->filesystem->make_path_relative( $file->get_path() ) ) . '</code>'
618
  )
619
  );
 
 
 
 
 
620
  } elseif ( ! $this->filesystem->is_writable( $file->get_path() ) ) {
621
  $response = new \WP_Error(
622
  'file_not_writable',
@@ -1513,6 +1518,49 @@ abstract class AbstractProcess implements ProcessInterface {
1513
  return is_string( $data ) && strpos( $data, $needle );
1514
  }
1515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1516
 
1517
  /** ----------------------------------------------------------------------------------------- */
1518
  /** PROCESS STATUS ========================================================================== */
617
  '<code>' . esc_html( $this->filesystem->make_path_relative( $file->get_path() ) ) . '</code>'
618
  )
619
  );
620
+ } elseif ( $webp && ! $this->can_create_webp_version( $file->get_path() ) ) {
621
+ $response = new \WP_Error(
622
+ 'is_animated_gif',
623
+ __( 'This file is an animated gif: since Imagify does not support animated webp, webp creation for animated gif is disabled.', 'imagify' )
624
+ );
625
  } elseif ( ! $this->filesystem->is_writable( $file->get_path() ) ) {
626
  $response = new \WP_Error(
627
  'file_not_writable',
1518
  return is_string( $data ) && strpos( $data, $needle );
1519
  }
1520
 
1521
+ /**
1522
+ * Tell if a webp version can be created for the given file.
1523
+ * Make sure the file is an image before using this method.
1524
+ *
1525
+ * @since 1.9.5
1526
+ * @access public
1527
+ * @author Grégory Viguier
1528
+ *
1529
+ * @param string $file_path Path to the file.
1530
+ * @return bool
1531
+ */
1532
+ public function can_create_webp_version( $file_path ) {
1533
+ if ( ! $file_path ) {
1534
+ return false;
1535
+ }
1536
+
1537
+ /**
1538
+ * Tell if a webp version can be created for the given file.
1539
+ * The file is an image.
1540
+ *
1541
+ * @since 1.9.5
1542
+ * @author Grégory Viguier
1543
+ *
1544
+ * @param bool $can True to create a webp version, false otherwise. Null by default.
1545
+ * @param string $file_path Path to the file.
1546
+ */
1547
+ $can = apply_filters( 'imagify_pre_can_create_webp_version', null, $file_path );
1548
+
1549
+ if ( isset( $can ) ) {
1550
+ return (bool) $can;
1551
+ }
1552
+
1553
+ $is_animated_gif = $this->filesystem->is_animated_gif( $file_path );
1554
+
1555
+ if ( is_bool( $is_animated_gif ) ) {
1556
+ // Ok if it’s not an animated gif.
1557
+ return ! $is_animated_gif;
1558
+ }
1559
+
1560
+ // At this point $is_animated_gif is null, which means the file cannot be read (yet).
1561
+ return true;
1562
+ }
1563
+
1564
 
1565
  /** ----------------------------------------------------------------------------------------- */
1566
  /** PROCESS STATUS ========================================================================== */
classes/Webp/Picture/Display.php CHANGED
@@ -475,7 +475,7 @@ class Display {
475
  $extensions = implode( '|', $extensions );
476
  }
477
 
478
- if ( ! preg_match( '@^(?<src>(?:https?:)?//.+\.(?<extension>' . $extensions . '))(?<query>\?.*)?$@i', $attributes[ $src_source ], $src ) ) {
479
  // Not a supported image format.
480
  return false;
481
  }
@@ -603,6 +603,9 @@ class Display {
603
  static $cdn_url;
604
  static $domain_url;
605
 
 
 
 
606
  if ( ! isset( $uploads_url ) ) {
607
  $uploads_url = set_url_scheme( $this->filesystem->get_upload_baseurl() );
608
  $uploads_dir = $this->filesystem->get_upload_basedir( true );
@@ -610,23 +613,29 @@ class Display {
610
  $root_dir = $this->filesystem->get_site_root();
611
  $cdn_url = $this->get_cdn_source();
612
  $cdn_url = $cdn_url['url'] ? set_url_scheme( $cdn_url['url'] ) : false;
613
- $domain_url = false;
614
-
615
- if ( $cdn_url ) {
616
- $domain_url = wp_parse_url( $root_url );
617
 
618
- if ( ! empty( $domain_url['scheme'] ) && ! empty( $domain_url['host'] ) ) {
619
- $domain_url = $domain_url['scheme'] . '://' . $domain_url['host'] . '/';
620
- }
 
621
  }
622
  }
623
 
 
 
 
 
 
 
624
  $url = set_url_scheme( $url );
625
 
626
  if ( $domain_url && stripos( $url, $cdn_url ) === 0 ) {
 
627
  $url = str_ireplace( $cdn_url, $domain_url, $url );
628
  }
629
 
 
630
  if ( stripos( $url, $uploads_url ) === 0 ) {
631
  return str_ireplace( $uploads_url, $uploads_dir, $url );
632
  }
475
  $extensions = implode( '|', $extensions );
476
  }
477
 
478
+ if ( ! preg_match( '@^(?<src>(?:(?:https?:)?//|/).+\.(?<extension>' . $extensions . '))(?<query>\?.*)?$@i', $attributes[ $src_source ], $src ) ) {
479
  // Not a supported image format.
480
  return false;
481
  }
603
  static $cdn_url;
604
  static $domain_url;
605
 
606
+ /**
607
+ * $url, $uploads_url, $root_url, and $cdn_url are passed through `set_url_scheme()` only to make sure `stripos()` doesn't fail over a stupid http/https difference.
608
+ */
609
  if ( ! isset( $uploads_url ) ) {
610
  $uploads_url = set_url_scheme( $this->filesystem->get_upload_baseurl() );
611
  $uploads_dir = $this->filesystem->get_upload_basedir( true );
613
  $root_dir = $this->filesystem->get_site_root();
614
  $cdn_url = $this->get_cdn_source();
615
  $cdn_url = $cdn_url['url'] ? set_url_scheme( $cdn_url['url'] ) : false;
616
+ $domain_url = wp_parse_url( $root_url );
 
 
 
617
 
618
+ if ( ! empty( $domain_url['scheme'] ) && ! empty( $domain_url['host'] ) ) {
619
+ $domain_url = $domain_url['scheme'] . '://' . $domain_url['host'] . '/';
620
+ } else {
621
+ $domain_url = false;
622
  }
623
  }
624
 
625
+ // Get the right URL format.
626
+ if ( $domain_url && strpos( $url, '/' ) === 0 ) {
627
+ // URL like `/path/to/image.jpg.webp`.
628
+ $url = $domain_url . ltrim( $url, '/' );
629
+ }
630
+
631
  $url = set_url_scheme( $url );
632
 
633
  if ( $domain_url && stripos( $url, $cdn_url ) === 0 ) {
634
+ // CDN.
635
  $url = str_ireplace( $cdn_url, $domain_url, $url );
636
  }
637
 
638
+ // Return the path.
639
  if ( stripos( $url, $uploads_url ) === 0 ) {
640
  return str_ireplace( $uploads_url, $uploads_dir, $url );
641
  }
imagify.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Imagify
4
  * Plugin URI: https://wordpress.org/plugins/imagify/
5
  * Description: Dramaticaly reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool.
6
- * Version: 1.9.4
7
  * Requires PHP: 5.4
8
  * Author: WP Media
9
  * Author URI: https://wp-media.me/
@@ -20,7 +20,7 @@
20
  defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
21
 
22
  // Imagify defines.
23
- define( 'IMAGIFY_VERSION', '1.9.4' );
24
  define( 'IMAGIFY_SLUG', 'imagify' );
25
  define( 'IMAGIFY_FILE', __FILE__ );
26
  define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
3
  * Plugin Name: Imagify
4
  * Plugin URI: https://wordpress.org/plugins/imagify/
5
  * Description: Dramaticaly reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool.
6
+ * Version: 1.9.5
7
  * Requires PHP: 5.4
8
  * Author: WP Media
9
  * Author URI: https://wp-media.me/
20
  defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
21
 
22
  // Imagify defines.
23
+ define( 'IMAGIFY_VERSION', '1.9.5' );
24
  define( 'IMAGIFY_SLUG', 'imagify' );
25
  define( 'IMAGIFY_FILE', __FILE__ );
26
  define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
inc/3rd-party/nextgen-gallery/classes/Bulk/NGG.php CHANGED
@@ -109,10 +109,17 @@ class NGG extends \Imagify\Bulk\AbstractBulk {
109
  * Get ids of all optimized media without webp versions.
110
  *
111
  * @since 1.9
 
112
  * @access public
113
  * @author Grégory Viguier
114
  *
115
- * @return array A list of media IDs.
 
 
 
 
 
 
116
  */
117
  public function get_optimized_media_ids_without_webp() {
118
  global $wpdb;
@@ -139,23 +146,37 @@ class NGG extends \Imagify\Bulk\AbstractBulk {
139
  $wpdb->flush();
140
  unset( $ngg_table, $data_table, $webp_suffix );
141
 
 
 
 
 
 
 
 
 
142
  if ( ! $files ) {
143
- return [];
144
  }
145
 
146
- $data = [];
147
-
148
  foreach ( $files as $file_id ) {
149
- $file_id = absint( $file_id );
150
- $file_path = $storage->get_image_abspath( $file_id );
 
 
 
 
 
 
 
151
  $backup_path = get_imagify_ngg_attachment_backup_path( $file_path );
152
 
153
  if ( ! $this->filesystem->exists( $backup_path ) ) {
154
  // No backup, no webp.
 
155
  continue;
156
  }
157
 
158
- $data[] = $file_id;
159
  } // End foreach().
160
 
161
  return $data;
109
  * Get ids of all optimized media without webp versions.
110
  *
111
  * @since 1.9
112
+ * @since 1.9.5 The method doesn't return the IDs directly anymore.
113
  * @access public
114
  * @author Grégory Viguier
115
  *
116
+ * @return array {
117
+ * @type array $ids A list of media IDs.
118
+ * @type array $errors {
119
+ * @type array $no_file_path A list of media IDs.
120
+ * @type array $no_backup A list of media IDs.
121
+ * }
122
+ * }
123
  */
124
  public function get_optimized_media_ids_without_webp() {
125
  global $wpdb;
146
  $wpdb->flush();
147
  unset( $ngg_table, $data_table, $webp_suffix );
148
 
149
+ $data = [
150
+ 'ids' => [],
151
+ 'errors' => [
152
+ 'no_file_path' => [],
153
+ 'no_backup' => [],
154
+ ],
155
+ ];
156
+
157
  if ( ! $files ) {
158
+ return $data;
159
  }
160
 
 
 
161
  foreach ( $files as $file_id ) {
162
+ $file_id = absint( $file_id );
163
+ $file_path = $storage->get_image_abspath( $file_id );
164
+
165
+ if ( ! $file_path ) {
166
+ // Problem.
167
+ $data['errors']['no_file_path'][] = $file_id;
168
+ continue;
169
+ }
170
+
171
  $backup_path = get_imagify_ngg_attachment_backup_path( $file_path );
172
 
173
  if ( ! $this->filesystem->exists( $backup_path ) ) {
174
  // No backup, no webp.
175
+ $data['errors']['no_backup'][] = $file_id;
176
  continue;
177
  }
178
 
179
+ $data['ids'][] = $file_id;
180
  } // End foreach().
181
 
182
  return $data;
inc/classes/class-imagify-abstract-background-process.php CHANGED
@@ -77,6 +77,24 @@ abstract class Imagify_Abstract_Background_Process extends WP_Background_Process
77
  * @author Grégory Viguier
78
  */
79
  public function init() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  if ( did_action( static::get_deactivation_hook_name() ) ) {
81
  $this->cancel_process();
82
  } else {
77
  * @author Grégory Viguier
78
  */
79
  public function init() {
80
+ $this->query_url = admin_url( 'admin-ajax.php' );
81
+
82
+ /**
83
+ * Filter the URL to use for background processes.
84
+ *
85
+ * @since 1.9.5
86
+ * @author Grégory Viguier
87
+ *
88
+ * @param string $query_url An URL.
89
+ * @param object $this This class instance.
90
+ */
91
+ $this->query_url = apply_filters( 'imagify_background_process_url', $this->query_url, $this );
92
+
93
+ if ( ! $this->query_url || ! is_string( $this->query_url ) || ! preg_match( '@^https?://@', $this->query_url ) ) {
94
+ $this->query_url = admin_url( 'admin-ajax.php' );
95
+ }
96
+
97
+ // Deactivation hook.
98
  if ( did_action( static::get_deactivation_hook_name() ) ) {
99
  $this->cancel_process();
100
  } else {
inc/classes/class-imagify-admin-ajax-post.php CHANGED
@@ -69,6 +69,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
69
  'imagify_get_images_counts',
70
  'imagify_update_estimate_sizes',
71
  'imagify_get_user_data',
 
72
  // Various.
73
  'nopriv_imagify_rpc',
74
  ];
@@ -287,12 +288,27 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
287
  case 'generate_webp':
288
  $this->check_can_optimize();
289
  $data = $bulk->get_optimized_media_ids_without_webp();
 
 
 
 
 
 
 
 
 
 
 
290
  break;
291
 
292
  default:
293
  $data = [];
294
  }
295
 
 
 
 
 
296
  wp_send_json_success( $data );
297
  }
298
 
@@ -1234,6 +1250,25 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
1234
  wp_send_json_success( $user );
1235
  }
1236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1237
 
1238
  /** ----------------------------------------------------------------------------------------- */
1239
  /** VARIOUS CALLBACKS ======================================================================= */
69
  'imagify_get_images_counts',
70
  'imagify_update_estimate_sizes',
71
  'imagify_get_user_data',
72
+ 'imagify_delete_user_data_cache',
73
  // Various.
74
  'nopriv_imagify_rpc',
75
  ];
288
  case 'generate_webp':
289
  $this->check_can_optimize();
290
  $data = $bulk->get_optimized_media_ids_without_webp();
291
+
292
+ if ( ! $data['ids'] && $data['errors']['no_backup'] ) {
293
+ // No backup, no webp.
294
+ $data = 'no-backup';
295
+ } elseif ( ! $data['ids'] && $data['errors']['no_file_path'] ) {
296
+ // Error.
297
+ $data = __( 'The path to the selected files could not be retrieved.', 'imagify' );
298
+ } else {
299
+ // OK.
300
+ $data = $data['ids'];
301
+ }
302
  break;
303
 
304
  default:
305
  $data = [];
306
  }
307
 
308
+ if ( ! is_array( $data ) ) {
309
+ wp_send_json_error( [ 'message' => $data ] );
310
+ }
311
+
312
  wp_send_json_success( $data );
313
  }
314
 
1250
  wp_send_json_success( $user );
1251
  }
1252
 
1253
+ /**
1254
+ * Delete the Imagify User data cache.
1255
+ *
1256
+ * @since 1.9.5
1257
+ * @access public
1258
+ * @author Grégory Viguier
1259
+ */
1260
+ public function imagify_delete_user_data_cache_callback() {
1261
+ imagify_check_nonce( 'imagify_delete_user_data_cache' );
1262
+
1263
+ if ( ! imagify_get_context( 'wp' )->current_user_can( 'manage' ) ) {
1264
+ imagify_die();
1265
+ }
1266
+
1267
+ imagify_delete_cached_user();
1268
+
1269
+ wp_send_json_success();
1270
+ }
1271
+
1272
 
1273
  /** ----------------------------------------------------------------------------------------- */
1274
  /** VARIOUS CALLBACKS ======================================================================= */
inc/classes/class-imagify-filesystem.php CHANGED
@@ -594,6 +594,50 @@ class Imagify_Filesystem extends WP_Filesystem_Direct {
594
  return is_array( $exif ) ? $exif : array();
595
  }
596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
 
598
  /** ----------------------------------------------------------------------------------------- */
599
  /** WORK WITH PATHS ========================================================================= */
594
  return is_array( $exif ) ? $exif : array();
595
  }
596
 
597
+ /**
598
+ * Tell if a file is an animated gif.
599
+ *
600
+ * @since 1.9.5
601
+ * @access public
602
+ * @source https://www.php.net/manual/en/function.imagecreatefromgif.php#104473
603
+ * @author Grégory Viguier
604
+ *
605
+ * @param string $file_path Path to the file.
606
+ * @return bool|null Null if the file cannot be read.
607
+ */
608
+ public function is_animated_gif( $file_path ) {
609
+ if ( $this->path_info( $file_path, 'extension' ) !== 'gif' ) {
610
+ // Not a gif file.
611
+ return false;
612
+ }
613
+
614
+ $fh = @fopen( $file_path, 'rb' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
615
+
616
+ if ( ! $fh ) {
617
+ // Could not open the file.
618
+ return null;
619
+ }
620
+
621
+ /**
622
+ * An animated gif contains multiple "frames", with each frame having a header made up of:
623
+ * - a static 4-byte sequence (\x00\x21\xF9\x04),
624
+ * - 4 variable bytes,
625
+ * - a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?).
626
+ */
627
+ $count = 0;
628
+
629
+ // We read through the file til we reach the end of the file, or we've found at least 2 frame headers.
630
+ while ( ! feof( $fh ) && $count < 2 ) {
631
+ // Read 100kb at a time.
632
+ $chunk = fread( $fh, 1024 * 100 ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fread
633
+ $count += preg_match_all( '#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $chunk, $matches );
634
+ }
635
+
636
+ fclose( $fh ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
637
+
638
+ return $count > 1;
639
+ }
640
+
641
 
642
  /** ----------------------------------------------------------------------------------------- */
643
  /** WORK WITH PATHS ========================================================================= */
inc/classes/class-imagify-plugin.php CHANGED
@@ -52,6 +52,7 @@ class Imagify_Plugin {
52
  Imagify_Cron_Library_Size::get_instance()->init();
53
  Imagify_Cron_Rating::get_instance()->init();
54
  Imagify_Cron_Sync_Files::get_instance()->init();
 
55
  \Imagify\Job\MediaOptimization::get_instance()->init();
56
  \Imagify\Stats\OptimizedMediaWithoutWebp::get_instance()->init();
57
 
52
  Imagify_Cron_Library_Size::get_instance()->init();
53
  Imagify_Cron_Rating::get_instance()->init();
54
  Imagify_Cron_Sync_Files::get_instance()->init();
55
+ \Imagify\Auth\Basic::get_instance()->init();
56
  \Imagify\Job\MediaOptimization::get_instance()->init();
57
  \Imagify\Stats\OptimizedMediaWithoutWebp::get_instance()->init();
58
 
inc/functions/admin.php CHANGED
@@ -419,3 +419,17 @@ function imagify_cache_user() {
419
 
420
  return $data;
421
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
  return $data;
421
  }
422
+
423
+ /**
424
+ * Delete cached Imagify user data.
425
+ *
426
+ * @since 1.9.5
427
+ * @author Grégory Viguier
428
+ */
429
+ function imagify_delete_cached_user() {
430
+ if ( imagify_is_active_for_network() ) {
431
+ delete_site_transient( 'imagify_user' );
432
+ } else {
433
+ delete_transient( 'imagify_user' );
434
+ }
435
+ }
inc/functions/i18n.php CHANGED
@@ -107,6 +107,7 @@ function get_imagify_localize_script_translations( $context ) {
107
  'processing' => __( 'Imagify is still processing. Are you sure you want to leave this page?', 'imagify' ),
108
  'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
109
  'nothingToDoText' => __( 'All your optimized images already have a webp version. Congratulations!', 'imagify' ),
 
110
  'error' => __( 'Error', 'imagify' ),
111
  'ajaxErrorText' => __( 'The operation failed.', 'imagify' ),
112
  'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
@@ -129,7 +130,7 @@ function get_imagify_localize_script_translations( $context ) {
129
  return $translations;
130
 
131
  case 'pricing-modal':
132
- return [
133
  'labels' => [
134
  'errorCouponAPI' => __( 'Error with checking this coupon.', 'imagify' ),
135
  /* translators: 1 is a percentage, 2 is a coupon code. */
@@ -138,6 +139,15 @@ function get_imagify_localize_script_translations( $context ) {
138
  ],
139
  ];
140
 
 
 
 
 
 
 
 
 
 
141
  case 'twentytwenty':
142
  $image = [
143
  'src' => '',
107
  'processing' => __( 'Imagify is still processing. Are you sure you want to leave this page?', 'imagify' ),
108
  'nothingToDoTitle' => __( 'Hold on!', 'imagify' ),
109
  'nothingToDoText' => __( 'All your optimized images already have a webp version. Congratulations!', 'imagify' ),
110
+ 'nothingToDoNoBackupText' => __( 'Because the selected images did not have a backup copy, Imagify was unable to create webp versions.', 'imagify' ),
111
  'error' => __( 'Error', 'imagify' ),
112
  'ajaxErrorText' => __( 'The operation failed.', 'imagify' ),
113
  'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
130
  return $translations;
131
 
132
  case 'pricing-modal':
133
+ $translations = [
134
  'labels' => [
135
  'errorCouponAPI' => __( 'Error with checking this coupon.', 'imagify' ),
136
  /* translators: 1 is a percentage, 2 is a coupon code. */
139
  ],
140
  ];
141
 
142
+ if ( Imagify_Requirements::is_api_key_valid() ) {
143
+ $translations['userDataCache'] = [
144
+ 'deleteAction' => 'imagify_delete_user_data_cache',
145
+ 'deleteNonce' => wp_create_nonce( 'imagify_delete_user_data_cache' ),
146
+ ];
147
+ }
148
+
149
+ return $translations;
150
+
151
  case 'twentytwenty':
152
  $image = [
153
  'src' => '',
inc/functions/process.php CHANGED
@@ -9,13 +9,13 @@ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
9
  * @since 1.4
10
  */
11
  function imagify_do_async_job( $body ) {
12
- $args = array(
13
  'timeout' => 0.01,
14
  'blocking' => false,
15
  'body' => $body,
16
- 'cookies' => isset( $_COOKIE ) && is_array( $_COOKIE ) ? $_COOKIE : array(),
17
  'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
18
- );
19
 
20
  /**
21
  * Filter the arguments used to launch an async job.
@@ -35,7 +35,7 @@ function imagify_do_async_job( $body ) {
35
  * In old WP versions, the field "option_name" in the wp_options table was limited to 64 characters.
36
  * From 64, remove 19 characters for "_transient_timeout_" = 45.
37
  * Then remove 12 characters for "imagify_rpc_" (transient name) = 33.
38
- * Hopefully, a md5 is 32 characters long.
39
  */
40
  $rpc_id = md5( maybe_serialize( $body ) );
41
 
@@ -49,5 +49,18 @@ function imagify_do_async_job( $body ) {
49
  set_transient( 'imagify_rpc_' . $rpc_id, get_current_user_id(), 30 );
50
  }
51
 
52
- wp_remote_post( admin_url( 'admin-ajax.php' ), $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
9
  * @since 1.4
10
  */
11
  function imagify_do_async_job( $body ) {
12
+ $args = [
13
  'timeout' => 0.01,
14
  'blocking' => false,
15
  'body' => $body,
16
+ 'cookies' => isset( $_COOKIE ) && is_array( $_COOKIE ) ? $_COOKIE : [],
17
  'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
18
+ ];
19
 
20
  /**
21
  * Filter the arguments used to launch an async job.
35
  * In old WP versions, the field "option_name" in the wp_options table was limited to 64 characters.
36
  * From 64, remove 19 characters for "_transient_timeout_" = 45.
37
  * Then remove 12 characters for "imagify_rpc_" (transient name) = 33.
38
+ * Luckily, a md5 is 32 characters long.
39
  */
40
  $rpc_id = md5( maybe_serialize( $body ) );
41
 
49
  set_transient( 'imagify_rpc_' . $rpc_id, get_current_user_id(), 30 );
50
  }
51
 
52
+ $url = admin_url( 'admin-ajax.php' );
53
+
54
+ /**
55
+ * Filter the URL to use for async jobs.
56
+ *
57
+ * @since 1.9.5
58
+ * @author Grégory Viguier
59
+ *
60
+ * @param string $url An URL.
61
+ * @param array $args An array of arguments passed to wp_remote_post().
62
+ */
63
+ $url = apply_filters( 'imagify_async_job_url', $url, $args );
64
+
65
+ wp_remote_post( $url, $args );
66
  }
package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "imagify",
3
  "description": "Imagify Image Optimizer. Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth.",
4
- "version": "1.9.4",
5
  "homepage": "https://wordpress.org/plugins/imagify/",
6
  "license": "GPL-2.0",
7
  "private": true,
1
  {
2
  "name": "imagify",
3
  "description": "Imagify Image Optimizer. Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth.",
4
+ "version": "1.9.5",
5
  "homepage": "https://wordpress.org/plugins/imagify/",
6
  "license": "GPL-2.0",
7
  "private": true,
readme.txt CHANGED
@@ -1,15 +1,15 @@
1
  === Imagify - WebP & Image Compression ===
2
  Contributors: wp_media, GregLone
3
- Tags: compress image, images, performance, optimization, webp
4
  Requires at least: 4.0.0
5
  Tested up to: 5.2.2
6
- Stable tag: 1.9.4
7
 
8
- Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth.
9
 
10
  == Description ==
11
 
12
- Speed up your website with lighter images without losing quality.
13
 
14
  Imagify is the most advanced tool to optimize images. You can now use this power directly in WordPress.
15
  After enabling it, all your images including thumbnails will be automatically optimized when uploaded into WordPress. You can also use Imagify to convert WebP images for free.
@@ -18,7 +18,7 @@ WooCommerce and NextGen Gallery compatible.
18
 
19
  = What is Image Compression? =
20
 
21
- Learn more about image compression, check that: [https://imagify.io/images-compression](https://imagify.io/images-compression)
22
 
23
  = Why use Imagify to optimize your images? =
24
 
@@ -35,7 +35,7 @@ Three level of compression are available:
35
  With the backup option, you can change your mind whenever you want by restoring your images to their original version or optimize them to another compression level.
36
 
37
  = HOW ABOUT WEBP IMAGES? =
38
- Now, for each image you optimize with the Imagify plugin, you’ll also get its **WebP version** (if you tick the option in the settings); in your Media library, this will result in the following image versions:
39
  - full-sized optimized image,
40
  - full-sized WebP image,
41
  - optimized thumbnails,
@@ -104,7 +104,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
104
 
105
  = Which formats can be optimized? =
106
 
107
- Imagify can optimize jpg, png and gif (whether animated or not) formats.
108
 
109
  = Can I use the plugin with a free account? =
110
 
@@ -153,13 +153,20 @@ When the plugin is disabled, your existing images remain optimized. Backups of t
153
  4. Other Media Page
154
 
155
  == Changelog ==
 
 
 
 
 
 
 
156
  = 1.9.4 - 2019/07/10 =
157
  * Improvement: if a webp image is larger than its non-webp version, it is now possible to not keep it. This can be done by using the filter `imagify_keep_large_webp`.
158
  * Improvement: compatibility with Pressable.
159
  * Improvement: renamed a php class to prevent some hosts to wrongly flag it as "suspicious" and trigger a fatal error.
160
  * Improvement: better compatibility with WP Real Media Library plugin.
161
  * Fix: rewrite rules for webp could not work on some servers.
162
- * Fix: when using `&lt;picture&gt;` tags for webp, some attributes could disappear if they were written on multiple lines.
163
  * Fix: the bulk method would not work in the NextGen Gallery list.
164
  * Fix: php notice `Trying to get property "namespace" for a non object`.
165
 
@@ -167,7 +174,7 @@ When the plugin is disabled, your existing images remain optimized. Backups of t
167
  * Fix: conflict with plugins using an ancient version of Composer.
168
 
169
  = 1.9.3 - 2019/06/17 =
170
- * Improvement: better compatibility with CDNs when displaying webp images with `&lt;picture&gt;` tags. There is now a new setting field to fill in the CDN URL in use.
171
  * Improvement: don’t use Heartbeat anymore. This speeds up the optimization process and prevents other plugins to break everything when they remove Heartbeat.
172
  * Fix: a fatal error upon plugin deactivation.
173
  * Fix: an occasional fatal error preventing the optimization process to work.
1
  === Imagify - WebP & Image Compression ===
2
  Contributors: wp_media, GregLone
3
+ Tags: compress image, images, optimize, performance, webp
4
  Requires at least: 4.0.0
5
  Tested up to: 5.2.2
6
+ Stable tag: 1.9.5
7
 
8
+ Optimize images in one click: reduce image file sizes, convert WebP, keep your images beautiful… and boost your loading time and your SEO!
9
 
10
  == Description ==
11
 
12
+ Speed up your website with our image optimizer and get lighter images without losing quality.
13
 
14
  Imagify is the most advanced tool to optimize images. You can now use this power directly in WordPress.
15
  After enabling it, all your images including thumbnails will be automatically optimized when uploaded into WordPress. You can also use Imagify to convert WebP images for free.
18
 
19
  = What is Image Compression? =
20
 
21
+ Learn more about image compression, check that: [https://imagify.io/images-compression](https://imagify.io/images-compression).
22
 
23
  = Why use Imagify to optimize your images? =
24
 
35
  With the backup option, you can change your mind whenever you want by restoring your images to their original version or optimize them to another compression level.
36
 
37
  = HOW ABOUT WEBP IMAGES? =
38
+ Now, for each image you optimize with the Imagify plugin, you will also get its **WebP version** (if you tick the option in the settings); in your Media library, this will result in the following image versions:
39
  - full-sized optimized image,
40
  - full-sized WebP image,
41
  - optimized thumbnails,
104
 
105
  = Which formats can be optimized? =
106
 
107
+ Imagify can optimize images such as jpg, png and gif (whether animated or not) formats and for each image you optimize you also get its WebP version if you tick the option in the settings (except for animated gif).
108
 
109
  = Can I use the plugin with a free account? =
110
 
153
  4. Other Media Page
154
 
155
  == Changelog ==
156
+ = 1.9.5 - 2019/07/16 =
157
+ * Improvement: Basic Authentication support. If it does not work automatically, you can still define the constants `IMAGIFY_AUTH_USER` and `IMAGIFY_AUTH_PASSWORD` in your `wp-config.php` file.
158
+ * Improvement: webp images are not created for animated gif images by default anymore. Use the filter `imagify_pre_can_create_webp_version` if you still want to create an unanimated webp version of them.
159
+ * Improvement: when creating webp images from the settings page, we made more clear when all the images are missing a backup copy.
160
+ * Improvement: clear the 5 minutes data cache when buying quota from the plugin.
161
+ * Improvement: when displaying webp images with the `<picture>` tag, allow to use relative URLs (starting with `/`).
162
+
163
  = 1.9.4 - 2019/07/10 =
164
  * Improvement: if a webp image is larger than its non-webp version, it is now possible to not keep it. This can be done by using the filter `imagify_keep_large_webp`.
165
  * Improvement: compatibility with Pressable.
166
  * Improvement: renamed a php class to prevent some hosts to wrongly flag it as "suspicious" and trigger a fatal error.
167
  * Improvement: better compatibility with WP Real Media Library plugin.
168
  * Fix: rewrite rules for webp could not work on some servers.
169
+ * Fix: when using `<picture>` tags for webp, some attributes could disappear if they were written on multiple lines.
170
  * Fix: the bulk method would not work in the NextGen Gallery list.
171
  * Fix: php notice `Trying to get property "namespace" for a non object`.
172
 
174
  * Fix: conflict with plugins using an ancient version of Composer.
175
 
176
  = 1.9.3 - 2019/06/17 =
177
+ * Improvement: better compatibility with CDNs when displaying webp images with `<picture>` tags. There is now a new setting field to fill in the CDN URL in use.
178
  * Improvement: don’t use Heartbeat anymore. This speeds up the optimization process and prevents other plugins to break everything when they remove Heartbeat.
179
  * Fix: a fatal error upon plugin deactivation.
180
  * Fix: an occasional fatal error preventing the optimization process to work.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit227da79a48485de04a5bdc367a98073e::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitc75cefd5fcd7d6d644e0342a0ffbe040::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -98,6 +98,7 @@ return array(
98
  'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
99
  'Dangoodman\\ComposerForWordpress\\ComposerForWordpress' => $vendorDir . '/dangoodman/composer-for-wordpress/ComposerForWordpress.php',
100
  'Imagify' => $baseDir . '/inc/classes/class-imagify.php',
 
101
  'Imagify\\Bulk\\AbstractBulk' => $baseDir . '/classes/Bulk/AbstractBulk.php',
102
  'Imagify\\Bulk\\BulkInterface' => $baseDir . '/classes/Bulk/BulkInterface.php',
103
  'Imagify\\Bulk\\CustomFolders' => $baseDir . '/classes/Bulk/CustomFolders.php',
98
  'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
99
  'Dangoodman\\ComposerForWordpress\\ComposerForWordpress' => $vendorDir . '/dangoodman/composer-for-wordpress/ComposerForWordpress.php',
100
  'Imagify' => $baseDir . '/inc/classes/class-imagify.php',
101
+ 'Imagify\\Auth\\Basic' => $baseDir . '/classes/Auth/Basic.php',
102
  'Imagify\\Bulk\\AbstractBulk' => $baseDir . '/classes/Bulk/AbstractBulk.php',
103
  'Imagify\\Bulk\\BulkInterface' => $baseDir . '/classes/Bulk/BulkInterface.php',
104
  'Imagify\\Bulk\\CustomFolders' => $baseDir . '/classes/Bulk/CustomFolders.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit227da79a48485de04a5bdc367a98073e
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit227da79a48485de04a5bdc367a98073e
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit227da79a48485de04a5bdc367a98073e', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit227da79a48485de04a5bdc367a98073e', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit227da79a48485de04a5bdc367a98073e::getInitializer($loader));
31
  } else {
32
  $classMap = require __DIR__ . '/autoload_classmap.php';
33
  if ($classMap) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitc75cefd5fcd7d6d644e0342a0ffbe040
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitc75cefd5fcd7d6d644e0342a0ffbe040', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitc75cefd5fcd7d6d644e0342a0ffbe040', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitc75cefd5fcd7d6d644e0342a0ffbe040::getInitializer($loader));
31
  } else {
32
  $classMap = require __DIR__ . '/autoload_classmap.php';
33
  if ($classMap) {
vendor/composer/autoload_static.php CHANGED
@@ -7,7 +7,7 @@ namespace Composer\Autoload;
7
  use Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader as ClassLoaderWPMediaImagifyWordPressPlugin;
8
 
9
 
10
- class ComposerStaticInit227da79a48485de04a5bdc367a98073e
11
  {
12
  public static $prefixLengthsPsr4 = array (
13
  'I' =>
@@ -162,6 +162,7 @@ class ComposerStaticInit227da79a48485de04a5bdc367a98073e
162
  'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
163
  'Dangoodman\\ComposerForWordpress\\ComposerForWordpress' => __DIR__ . '/..' . '/dangoodman/composer-for-wordpress/ComposerForWordpress.php',
164
  'Imagify' => __DIR__ . '/../..' . '/inc/classes/class-imagify.php',
 
165
  'Imagify\\Bulk\\AbstractBulk' => __DIR__ . '/../..' . '/classes/Bulk/AbstractBulk.php',
166
  'Imagify\\Bulk\\BulkInterface' => __DIR__ . '/../..' . '/classes/Bulk/BulkInterface.php',
167
  'Imagify\\Bulk\\CustomFolders' => __DIR__ . '/../..' . '/classes/Bulk/CustomFolders.php',
@@ -272,9 +273,9 @@ class ComposerStaticInit227da79a48485de04a5bdc367a98073e
272
  public static function getInitializer(ClassLoaderWPMediaImagifyWordPressPlugin $loader)
273
  {
274
  return \Closure::bind(function () use ($loader) {
275
- $loader->prefixLengthsPsr4 = ComposerStaticInit227da79a48485de04a5bdc367a98073e::$prefixLengthsPsr4;
276
- $loader->prefixDirsPsr4 = ComposerStaticInit227da79a48485de04a5bdc367a98073e::$prefixDirsPsr4;
277
- $loader->classMap = ComposerStaticInit227da79a48485de04a5bdc367a98073e::$classMap;
278
 
279
  }, null, ClassLoaderWPMediaImagifyWordPressPlugin::class);
280
  }
7
  use Composer\AutoloadWPMediaImagifyWordPressPlugin\ClassLoader as ClassLoaderWPMediaImagifyWordPressPlugin;
8
 
9
 
10
+ class ComposerStaticInitc75cefd5fcd7d6d644e0342a0ffbe040
11
  {
12
  public static $prefixLengthsPsr4 = array (
13
  'I' =>
162
  'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php',
163
  'Dangoodman\\ComposerForWordpress\\ComposerForWordpress' => __DIR__ . '/..' . '/dangoodman/composer-for-wordpress/ComposerForWordpress.php',
164
  'Imagify' => __DIR__ . '/../..' . '/inc/classes/class-imagify.php',
165
+ 'Imagify\\Auth\\Basic' => __DIR__ . '/../..' . '/classes/Auth/Basic.php',
166
  'Imagify\\Bulk\\AbstractBulk' => __DIR__ . '/../..' . '/classes/Bulk/AbstractBulk.php',
167
  'Imagify\\Bulk\\BulkInterface' => __DIR__ . '/../..' . '/classes/Bulk/BulkInterface.php',
168
  'Imagify\\Bulk\\CustomFolders' => __DIR__ . '/../..' . '/classes/Bulk/CustomFolders.php',
273
  public static function getInitializer(ClassLoaderWPMediaImagifyWordPressPlugin $loader)
274
  {
275
  return \Closure::bind(function () use ($loader) {
276
+ $loader->prefixLengthsPsr4 = ComposerStaticInitc75cefd5fcd7d6d644e0342a0ffbe040::$prefixLengthsPsr4;
277
+ $loader->prefixDirsPsr4 = ComposerStaticInitc75cefd5fcd7d6d644e0342a0ffbe040::$prefixDirsPsr4;
278
+ $loader->classMap = ComposerStaticInitc75cefd5fcd7d6d644e0342a0ffbe040::$classMap;
279
 
280
  }, null, ClassLoaderWPMediaImagifyWordPressPlugin::class);
281
  }
vendor/composer/installed.json CHANGED
@@ -1,35 +1,4 @@
1
  [
2
- {
3
- "name": "dangoodman/composer-for-wordpress",
4
- "version": "2.0.0",
5
- "version_normalized": "2.0.0.0",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/dangoodman/composer-for-wordpress.git",
9
- "reference": "be478117ee9b2fbcdb5a6580a5ec69b66e711e20"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/dangoodman/composer-for-wordpress/zipball/be478117ee9b2fbcdb5a6580a5ec69b66e711e20",
14
- "reference": "be478117ee9b2fbcdb5a6580a5ec69b66e711e20",
15
- "shasum": ""
16
- },
17
- "require": {
18
- "composer-plugin-api": "^1.0"
19
- },
20
- "time": "2018-06-20T15:01:37+00:00",
21
- "type": "composer-plugin",
22
- "extra": {
23
- "class": "Dangoodman\\ComposerForWordpress\\ComposerForWordpress"
24
- },
25
- "installation-source": "dist",
26
- "autoload": {
27
- "psr-4": {
28
- "Dangoodman\\ComposerForWordpress\\": "."
29
- }
30
- },
31
- "notification-url": "https://packagist.org/downloads/"
32
- },
33
  {
34
  "name": "composer/installers",
35
  "version": "v1.6.0",
@@ -152,6 +121,37 @@
152
  "zikula"
153
  ]
154
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  {
156
  "name": "a5hleyrich/wp-background-processing",
157
  "version": "1.0.1",
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "name": "composer/installers",
4
  "version": "v1.6.0",
121
  "zikula"
122
  ]
123
  },
124
+ {
125
+ "name": "dangoodman/composer-for-wordpress",
126
+ "version": "2.0.0",
127
+ "version_normalized": "2.0.0.0",
128
+ "source": {
129
+ "type": "git",
130
+ "url": "https://github.com/dangoodman/composer-for-wordpress.git",
131
+ "reference": "be478117ee9b2fbcdb5a6580a5ec69b66e711e20"
132
+ },
133
+ "dist": {
134
+ "type": "zip",
135
+ "url": "https://api.github.com/repos/dangoodman/composer-for-wordpress/zipball/be478117ee9b2fbcdb5a6580a5ec69b66e711e20",
136
+ "reference": "be478117ee9b2fbcdb5a6580a5ec69b66e711e20",
137
+ "shasum": ""
138
+ },
139
+ "require": {
140
+ "composer-plugin-api": "^1.0"
141
+ },
142
+ "time": "2018-06-20T15:01:37+00:00",
143
+ "type": "composer-plugin",
144
+ "extra": {
145
+ "class": "Dangoodman\\ComposerForWordpress\\ComposerForWordpress"
146
+ },
147
+ "installation-source": "dist",
148
+ "autoload": {
149
+ "psr-4": {
150
+ "Dangoodman\\ComposerForWordpress\\": "."
151
+ }
152
+ },
153
+ "notification-url": "https://packagist.org/downloads/"
154
+ },
155
  {
156
  "name": "a5hleyrich/wp-background-processing",
157
  "version": "1.0.1",