Imagify Image Optimizer - Version 1.6.12

Version Description

  • New: added links to the documentation in the plugin's admin bar item and the plugin's row (plugins page). There is more to come.
  • Improvement: image attachments that don't have some mandatory WordPress metadata are not included in Imagify stats anymore.
  • Fix: the "Optimized size" progress bar in the bulk optimization page now behaves like the "Original size" one does.
  • Dev stuff: auto-optimization can be disabled on an attachment basis with the new filter imagify_auto_optimize_attachment. For example it can be used to disable auto-optimization for a specific file extension.
  • Dev stuff: classes are now auto-loaded. Some constants have been removed.
Download this release

Release Info

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

Code changes from version 1.6.11 to 1.6.12

Files changed (42) hide show
  1. assets/js/bulk.js +2 -2
  2. assets/js/bulk.min.js +1 -1
  3. imagify.php +26 -33
  4. inc/3rd-party/amazon-s3-and-cloudfront/amazon-s3-and-cloudfront.php +1 -4
  5. inc/3rd-party/amazon-s3-and-cloudfront/inc/classes/class-imagify-as3cf.php +19 -15
  6. inc/3rd-party/enable-media-replace/enable-media-replace.php +1 -3
  7. inc/3rd-party/enable-media-replace/inc/classes/class-imagify-enable-media-replace.php +0 -12
  8. inc/3rd-party/nextgen-gallery/inc/admin/db.php +1 -1
  9. inc/3rd-party/nextgen-gallery/inc/admin/enqueue.php +1 -1
  10. inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-attachment.php +33 -15
  11. inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-db.php +1 -13
  12. inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-storage.php +4 -4
  13. inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg.php +12 -26
  14. inc/3rd-party/nextgen-gallery/inc/common/attachments.php +37 -23
  15. inc/3rd-party/nextgen-gallery/inc/functions/admin-stats.php +9 -15
  16. inc/3rd-party/nextgen-gallery/nextgen-gallery.php +8 -12
  17. inc/admin/meta-boxes.php +4 -0
  18. inc/admin/plugins.php +1 -0
  19. inc/admin/ui/bulk.php +5 -6
  20. inc/admin/ui/notice-free-over-quota.php +1 -1
  21. inc/admin/ui/notice-rating.php +2 -4
  22. inc/admin/ui/notice-welcome-steps.php +2 -2
  23. inc/admin/ui/notice-wrong-api-key.php +1 -1
  24. inc/admin/ui/options.php +4 -5
  25. inc/classes/{abstracts/class-imagify-abstract-attachment.php → class-imagify-abstract-attachment.php} +12 -0
  26. inc/classes/{abstracts/class-imagify-abstract-db.php → class-imagify-abstract-db.php} +21 -0
  27. inc/classes/class-imagify-admin-ajax-post.php +17 -9
  28. inc/classes/class-imagify-attachment.php +1 -1
  29. inc/classes/class-imagify.php +0 -12
  30. inc/common/admin-bar.php +16 -2
  31. inc/common/attachments.php +16 -0
  32. inc/functions/admin-stats.php +59 -42
  33. inc/functions/admin-ui.php +20 -18
  34. inc/functions/admin.php +1 -1
  35. inc/functions/api.php +12 -0
  36. inc/functions/attachments.php +13 -0
  37. inc/functions/common.php +123 -0
  38. inc/functions/compat.php +105 -5
  39. inc/functions/deprecated.php +74 -4
  40. inc/functions/files.php +5 -1
  41. inc/functions/i18n.php +4 -5
  42. readme.txt +8 -1
assets/js/bulk.js CHANGED
@@ -148,7 +148,7 @@
148
  $( '#imagify-original-bar' ).find( '.imagify-barnb' ).html( data.original_human );
149
 
150
  // The optimized bar.
151
- $( '#imagify-optimized-bar' ).css( 'width', data.optimized_percent + '%' ).find( '.imagify-barnb' ).html( data.optimized_human );
152
 
153
  // The Percent data.
154
  $( '#imagify-total-optimized-attachments-pct' ).html( data.optimized_percent + '%' );
@@ -345,7 +345,7 @@
345
  text2share = text2share.replace( '%2$s', data.global_original_size_human );
346
  text2share = encodeURIComponent( text2share );
347
 
348
- $( '.imagify-sn-twitter' ).attr( 'href', 'https://twitter.com/intent/tweet?source=webclient&original_referer=' + imagifyBulk.labels.pluginURL + '&text=' + text2share + '&url=' + imagifyBulk.labels.pluginURL + '&related=imagify&hastags=performance,web,wordpress' );
349
 
350
  $( '.imagify-ac-chart' ).attr( 'data-percent', data.global_percent );
351
  drawMeCompleteChart( $( '.imagify-ac-chart' ).find( 'canvas' ) );
148
  $( '#imagify-original-bar' ).find( '.imagify-barnb' ).html( data.original_human );
149
 
150
  // The optimized bar.
151
+ $( '#imagify-optimized-bar' ).css( 'width', ( 100 - data.optimized_percent ) + '%' ).find( '.imagify-barnb' ).html( data.optimized_human );
152
 
153
  // The Percent data.
154
  $( '#imagify-total-optimized-attachments-pct' ).html( data.optimized_percent + '%' );
345
  text2share = text2share.replace( '%2$s', data.global_original_size_human );
346
  text2share = encodeURIComponent( text2share );
347
 
348
+ $( '.imagify-sn-twitter' ).attr( 'href', imagifyBulk.labels.twitterShareURL + '&text=' + text2share );
349
 
350
  $( '.imagify-ac-chart' ).attr( 'data-percent', data.global_percent );
351
  drawMeCompleteChart( $( '.imagify-ac-chart' ).find( 'canvas' ) );
assets/js/bulk.min.js CHANGED
@@ -1 +1 @@
1
- !function(a,b,c,d){function e(b){b.each(function(){var b=a(this),c=parseInt(b.closest(".imagify-chart").next(".imagipercent").text(),10),d=[{value:c,color:"#00B3D3"},{value:100-c,color:"#D8D8D8"}];new Chart(b[0].getContext("2d")).Doughnut(d,{segmentStrokeColor:"#FFF",segmentStrokeWidth:1,animateRotate:!0,tooltipEvents:[]})})}function f(b){b.each(function(){var b=a(this),c=parseInt(b.closest(".imagify-ac-chart").attr("data-percent"),10),d=[{value:c,color:"#40B1D0"},{value:100-c,color:"#FFFFFF"}];new Chart(b[0].getContext("2d")).Doughnut(d,{segmentStrokeColor:"transparent",segmentStrokeWidth:0,animateRotate:!0,animation:!0,percentageInnerCutout:70,tooltipEvents:[]})})}var g,h,i=b.getElementById("imagify-overview-chart"),j=[{value:imagifyBulk.totalUnoptimizedAttachments,color:"#D9E4EB",highlight:"#D9E4EB",label:imagifyBulk.labels.overviewChartLabels.unoptimized},{value:imagifyBulk.totalOptimizedAttachments,color:"#46B1CE",highlight:"#46B1CE",label:imagifyBulk.labels.overviewChartLabels.optimized},{value:imagifyBulk.totalErrorsAttachments,color:"#2E3242",highlight:"#2E3242",label:imagifyBulk.labels.overviewChartLabels.error}];i&&(g=new Chart(i.getContext("2d")).Doughnut(j,{segmentStrokeColor:"transparent",segmentStrokeWidth:0,animateRotate:!0,animation:!0,percentageInnerCutout:85,legendTemplate:'<ul class="imagify-<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>',tooltipTemplate:"<%= value %>"}),h='<ul class="imagify-doughnut-legend">',a(j).each(function(a){h+='<li><span style="background-color:'+j[a].color+'"></span>'+j[a].label+"</li>"}),h+="</ul>",b.getElementById("imagify-overview-chart-legend").innerHTML=h),a(b).on("heartbeat-send",function(a,b){b.imagify_heartbeat=imagifyBulk.heartbeatId}),a(b).on("heartbeat-tick",function(b,c){var d;c.imagify_bulk_data&&(c=c.imagify_bulk_data,d=g.segments,c.unoptimized_attachments===d[0].value&&c.optimized_attachments===d[1].value&&c.errors_attachments===d[2].value||(a("#imagify-overview-chart-percent").html(c.optimized_attachments_percent+"<span>%</span>"),a(".imagify-total-percent").html(c.optimized_attachments_percent+"%"),a(".imagify-unconsumed-percent").html(c.unconsumed_quota+"%"),a(".imagify-unconsumed-bar").css("width",c.unconsumed_quota+"%"),a("#imagify-total-optimized-attachments").html(c.already_optimized_attachments),a("#imagify-original-bar").find(".imagify-barnb").html(c.original_human),a("#imagify-optimized-bar").css("width",c.optimized_percent+"%").find(".imagify-barnb").html(c.optimized_human),a("#imagify-total-optimized-attachments-pct").html(c.optimized_percent+"%"),g.segments[0].value=c.unoptimized_attachments,g.segments[1].value=c.optimized_attachments,g.segments[2].value=c.errors_attachments,g.update()))}),a("#imagify-simulate-bulk-action").on("click",function(b){b.preventDefault(),a("#imagify-bulk-action").trigger("click")}),a("#imagify-bulk-action").on("click",function(b){var d,g=a(this),h=a('[name="optimization_level"]:checked').val();b.preventDefault(),void 0===h&&(h=-1),g.attr("disabled")||(g.attr("disabled","disabled"),g.find(".dashicons").addClass("rotate"),d=function(){return imagifyBulk.labels.processing},a(c).on("beforeunload",d),swal({title:imagifyBulk.labels.waitTitle,html:imagifyBulk.labels.waitText,showConfirmButton:!1,imageUrl:imagifyBulk.waitImageUrl}),a.get(ajaxurl+c.imagify.concat+"action="+imagifyBulk.ajaxAction+"&optimization_level="+h+"&imagifybulkuploadnonce="+a("#imagifybulkuploadnonce").val()).done(function(b){var h,i,j="",k="",l=0,m=0,n=0,o=0,p=0,q=0;if(!b.success)return g.removeAttr("disabled"),g.find(".dashicons").removeClass("rotate"),a(c).off("beforeunload",d),"invalid-api-key"===b.data.message?j=imagifyBulk.labels.invalidAPIKeyTitle:"over-quota"===b.data.message?(j=imagifyBulk.labels.overQuotaTitle,k=imagifyBulk.labels.overQuotaText):"no-images"===b.data.message&&(j=imagifyBulk.labels.noAttachmentToOptimizeTitle,k=imagifyBulk.labels.noAttachmentToOptimizeText),void swal({title:j,html:k,type:"info",customClass:"imagify-sweet-alert"});swal.close(),a(".imagify-row-progress").slideDown(),a(".imagify-no-uploaded-yet, .imagify-row-complete").hide(200),i=a(".imagify-bulk-table table tbody"),h=new ImagifyGulp({buffer_size:imagifyBulk.bufferSize,lib:ajaxurl+c.imagify.concat+"action=imagify_bulk_upload&imagifybulkuploadnonce="+a("#imagifybulkuploadnonce").val(),images:b.data,context:imagifyBulk.ajaxContext}),h.before(function(a){i.find(".imagify-row-progress").after('<tr id="attachment-'+a.id+'"><td class="imagify-cell-filename"><span class="imagiuploaded"><img src="'+a.thumbnail+'" alt=""/></span><span class="imagifilename">'+a.filename+'</span></td><td class="imagify-cell-status"><span class="imagistatus status-compressing"><span class="dashicons dashicons-admin-generic rotate"></span>'+imagifyBulk.labels.optimizing+'<span></span></span></td><td class="imagify-cell-original"></td><td class="imagify-cell-optimized"></td><td class="imagify-cell-percentage"></td><td class="imagify-cell-thumbnails"></td><td class="imagify-cell-savings"></td></tr>')}).each(function(b){var c=a("#imagify-progress-bar"),d="error",f="dismiss",g=imagifyBulk.labels.error,i=a("#attachment-"+b.image);if(c.css({width:b.progress+"%"}),c.find(".percent").html(b.progress+"%"),b.success)return++q,i.find(".imagify-cell-status").html('<span class="imagistatus status-complete"><span class="dashicons dashicons-yes"></span>'+imagifyBulk.labels.complete+"</span>"),i.find(".imagify-cell-original").html(b.original_size_human),i.find(".imagify-cell-optimized").html(b.new_size_human),i.find(".imagify-cell-percentage").html('<span class="imagify-chart"><span class="imagify-chart-container"><canvas height="18" width="18" id="imagify-consumption-chart-'+b.image+"-"+q+'" style="width: 18px; height: 18px;"></canvas></span></span><span class="imagipercent">'+b.percent+"</span>%"),e(i.find(".imagify-cell-percentage canvas")),i.find(".imagify-cell-thumbnails").html(b.thumbnails),i.find(".imagify-cell-savings").html(h.humanSize(b.overall_saving,1)),l=l+b.thumbnails+1,a(".imagify-cell-nb-files").html(imagifyBulk.labels.nbrFiles.replace("%s",l)),o+=b.original_overall_size,a(".imagify-total-original").html(h.humanSize(o,1)),p+=b.overall_saving,void a(".imagify-total-gain").html(h.humanSize(p,1));!n&&b.error.indexOf("You've consumed all your data")>=0&&(n=1,h.stopProcess(),swal({title:imagifyBulk.labels.overQuotaTitle,html:imagifyBulk.labels.overQuotaText,type:"error",customClass:"imagify-sweet-alert"}).then(function(){location.reload()})),b.error.indexOf("This image is already compressed")>=0?(d="warning",f="warning",g=imagifyBulk.labels.notice):(m++,a(".imagify-cell-errors").html(imagifyBulk.labels.nbrErrors.replace("%s",m))),i.after('<tr><td colspan="7"><span class="status-'+d+'">'+b.error+"</span></td></tr>"),i.find(".imagify-cell-status").html('<span class="imagistatus status-'+d+'"><span class="dashicons dashicons-'+f+'"></span>'+g+"</span>")}).done(function(b){var e;g.removeAttr("disabled").find(".dashicons").removeClass("rotate"),a(c).off("beforeunload",d),a(".imagify-row-progress").slideUp(),"NaN"!==b.global_percent&&(a(".imagify-row-complete").removeClass("hidden").addClass("done").attr("aria-hidden","false"),a("html, body").animate({scrollTop:a(".imagify-row-complete").offset().top},200),a(".imagify-ac-rt-total-gain").html(b.global_gain_human),a(".imagify-ac-rt-total-original").html(b.global_original_size_human),e=imagifyBulk.labels.textToShare,e=e.replace("%1$s",b.global_gain_human),e=e.replace("%2$s",b.global_original_size_human),e=encodeURIComponent(e),a(".imagify-sn-twitter").attr("href","https://twitter.com/intent/tweet?source=webclient&amp;original_referer="+imagifyBulk.labels.pluginURL+"&amp;text="+e+"&amp;url="+imagifyBulk.labels.pluginURL+"&amp;related=imagify&amp;hastags=performance,web,wordpress"),a(".imagify-ac-chart").attr("data-percent",b.global_percent),f(a(".imagify-ac-chart").find("canvas"))),n=0}).error(function(a){c.imagify.log("Can't optimize image with id "+a+".")}).run()}).fail(function(){swal({title:imagifyBulk.labels.getUnoptimizedImagesErrorTitle,html:imagifyBulk.labels.getUnoptimizedImagesErrorText,type:"error",customClass:"imagify-sweet-alert"}).then(function(){location.reload()})}))})}(jQuery,document,window),function(a,b,c,d){var e,f;c.innerWidth?(e=(c.innerWidth-700)/2,f=(c.innerHeight-290)/2):(e=(b.body.clientWidth-700)/2,f=(b.body.clientHeight-290)/2),[].forEach.call(b.querySelectorAll(".imagify-share-networks a"),function(a){a.addEventListener("click",function(a){c.open(this.href,"","status=no, scrollbars=no, menubar=no, top="+f+", left="+e+", width=700, height=290"),a.preventDefault()},!1)})}(jQuery,document,window);
1
+ !function(a,b,c,d){function e(b){b.each(function(){var b=a(this),c=parseInt(b.closest(".imagify-chart").next(".imagipercent").text(),10),d=[{value:c,color:"#00B3D3"},{value:100-c,color:"#D8D8D8"}];new Chart(b[0].getContext("2d")).Doughnut(d,{segmentStrokeColor:"#FFF",segmentStrokeWidth:1,animateRotate:!0,tooltipEvents:[]})})}function f(b){b.each(function(){var b=a(this),c=parseInt(b.closest(".imagify-ac-chart").attr("data-percent"),10),d=[{value:c,color:"#40B1D0"},{value:100-c,color:"#FFFFFF"}];new Chart(b[0].getContext("2d")).Doughnut(d,{segmentStrokeColor:"transparent",segmentStrokeWidth:0,animateRotate:!0,animation:!0,percentageInnerCutout:70,tooltipEvents:[]})})}var g,h,i=b.getElementById("imagify-overview-chart"),j=[{value:imagifyBulk.totalUnoptimizedAttachments,color:"#D9E4EB",highlight:"#D9E4EB",label:imagifyBulk.labels.overviewChartLabels.unoptimized},{value:imagifyBulk.totalOptimizedAttachments,color:"#46B1CE",highlight:"#46B1CE",label:imagifyBulk.labels.overviewChartLabels.optimized},{value:imagifyBulk.totalErrorsAttachments,color:"#2E3242",highlight:"#2E3242",label:imagifyBulk.labels.overviewChartLabels.error}];i&&(g=new Chart(i.getContext("2d")).Doughnut(j,{segmentStrokeColor:"transparent",segmentStrokeWidth:0,animateRotate:!0,animation:!0,percentageInnerCutout:85,legendTemplate:'<ul class="imagify-<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>',tooltipTemplate:"<%= value %>"}),h='<ul class="imagify-doughnut-legend">',a(j).each(function(a){h+='<li><span style="background-color:'+j[a].color+'"></span>'+j[a].label+"</li>"}),h+="</ul>",b.getElementById("imagify-overview-chart-legend").innerHTML=h),a(b).on("heartbeat-send",function(a,b){b.imagify_heartbeat=imagifyBulk.heartbeatId}),a(b).on("heartbeat-tick",function(b,c){var d;c.imagify_bulk_data&&(c=c.imagify_bulk_data,d=g.segments,c.unoptimized_attachments===d[0].value&&c.optimized_attachments===d[1].value&&c.errors_attachments===d[2].value||(a("#imagify-overview-chart-percent").html(c.optimized_attachments_percent+"<span>%</span>"),a(".imagify-total-percent").html(c.optimized_attachments_percent+"%"),a(".imagify-unconsumed-percent").html(c.unconsumed_quota+"%"),a(".imagify-unconsumed-bar").css("width",c.unconsumed_quota+"%"),a("#imagify-total-optimized-attachments").html(c.already_optimized_attachments),a("#imagify-original-bar").find(".imagify-barnb").html(c.original_human),a("#imagify-optimized-bar").css("width",100-c.optimized_percent+"%").find(".imagify-barnb").html(c.optimized_human),a("#imagify-total-optimized-attachments-pct").html(c.optimized_percent+"%"),g.segments[0].value=c.unoptimized_attachments,g.segments[1].value=c.optimized_attachments,g.segments[2].value=c.errors_attachments,g.update()))}),a("#imagify-simulate-bulk-action").on("click",function(b){b.preventDefault(),a("#imagify-bulk-action").trigger("click")}),a("#imagify-bulk-action").on("click",function(b){var d,g=a(this),h=a('[name="optimization_level"]:checked').val();b.preventDefault(),void 0===h&&(h=-1),g.attr("disabled")||(g.attr("disabled","disabled"),g.find(".dashicons").addClass("rotate"),d=function(){return imagifyBulk.labels.processing},a(c).on("beforeunload",d),swal({title:imagifyBulk.labels.waitTitle,html:imagifyBulk.labels.waitText,showConfirmButton:!1,imageUrl:imagifyBulk.waitImageUrl}),a.get(ajaxurl+c.imagify.concat+"action="+imagifyBulk.ajaxAction+"&optimization_level="+h+"&imagifybulkuploadnonce="+a("#imagifybulkuploadnonce").val()).done(function(b){var h,i,j="",k="",l=0,m=0,n=0,o=0,p=0,q=0;if(!b.success)return g.removeAttr("disabled"),g.find(".dashicons").removeClass("rotate"),a(c).off("beforeunload",d),"invalid-api-key"===b.data.message?j=imagifyBulk.labels.invalidAPIKeyTitle:"over-quota"===b.data.message?(j=imagifyBulk.labels.overQuotaTitle,k=imagifyBulk.labels.overQuotaText):"no-images"===b.data.message&&(j=imagifyBulk.labels.noAttachmentToOptimizeTitle,k=imagifyBulk.labels.noAttachmentToOptimizeText),void swal({title:j,html:k,type:"info",customClass:"imagify-sweet-alert"});swal.close(),a(".imagify-row-progress").slideDown(),a(".imagify-no-uploaded-yet, .imagify-row-complete").hide(200),i=a(".imagify-bulk-table table tbody"),h=new ImagifyGulp({buffer_size:imagifyBulk.bufferSize,lib:ajaxurl+c.imagify.concat+"action=imagify_bulk_upload&imagifybulkuploadnonce="+a("#imagifybulkuploadnonce").val(),images:b.data,context:imagifyBulk.ajaxContext}),h.before(function(a){i.find(".imagify-row-progress").after('<tr id="attachment-'+a.id+'"><td class="imagify-cell-filename"><span class="imagiuploaded"><img src="'+a.thumbnail+'" alt=""/></span><span class="imagifilename">'+a.filename+'</span></td><td class="imagify-cell-status"><span class="imagistatus status-compressing"><span class="dashicons dashicons-admin-generic rotate"></span>'+imagifyBulk.labels.optimizing+'<span></span></span></td><td class="imagify-cell-original"></td><td class="imagify-cell-optimized"></td><td class="imagify-cell-percentage"></td><td class="imagify-cell-thumbnails"></td><td class="imagify-cell-savings"></td></tr>')}).each(function(b){var c=a("#imagify-progress-bar"),d="error",f="dismiss",g=imagifyBulk.labels.error,i=a("#attachment-"+b.image);if(c.css({width:b.progress+"%"}),c.find(".percent").html(b.progress+"%"),b.success)return++q,i.find(".imagify-cell-status").html('<span class="imagistatus status-complete"><span class="dashicons dashicons-yes"></span>'+imagifyBulk.labels.complete+"</span>"),i.find(".imagify-cell-original").html(b.original_size_human),i.find(".imagify-cell-optimized").html(b.new_size_human),i.find(".imagify-cell-percentage").html('<span class="imagify-chart"><span class="imagify-chart-container"><canvas height="18" width="18" id="imagify-consumption-chart-'+b.image+"-"+q+'" style="width: 18px; height: 18px;"></canvas></span></span><span class="imagipercent">'+b.percent+"</span>%"),e(i.find(".imagify-cell-percentage canvas")),i.find(".imagify-cell-thumbnails").html(b.thumbnails),i.find(".imagify-cell-savings").html(h.humanSize(b.overall_saving,1)),l=l+b.thumbnails+1,a(".imagify-cell-nb-files").html(imagifyBulk.labels.nbrFiles.replace("%s",l)),o+=b.original_overall_size,a(".imagify-total-original").html(h.humanSize(o,1)),p+=b.overall_saving,void a(".imagify-total-gain").html(h.humanSize(p,1));!n&&b.error.indexOf("You've consumed all your data")>=0&&(n=1,h.stopProcess(),swal({title:imagifyBulk.labels.overQuotaTitle,html:imagifyBulk.labels.overQuotaText,type:"error",customClass:"imagify-sweet-alert"}).then(function(){location.reload()})),b.error.indexOf("This image is already compressed")>=0?(d="warning",f="warning",g=imagifyBulk.labels.notice):(m++,a(".imagify-cell-errors").html(imagifyBulk.labels.nbrErrors.replace("%s",m))),i.after('<tr><td colspan="7"><span class="status-'+d+'">'+b.error+"</span></td></tr>"),i.find(".imagify-cell-status").html('<span class="imagistatus status-'+d+'"><span class="dashicons dashicons-'+f+'"></span>'+g+"</span>")}).done(function(b){var e;g.removeAttr("disabled").find(".dashicons").removeClass("rotate"),a(c).off("beforeunload",d),a(".imagify-row-progress").slideUp(),"NaN"!==b.global_percent&&(a(".imagify-row-complete").removeClass("hidden").addClass("done").attr("aria-hidden","false"),a("html, body").animate({scrollTop:a(".imagify-row-complete").offset().top},200),a(".imagify-ac-rt-total-gain").html(b.global_gain_human),a(".imagify-ac-rt-total-original").html(b.global_original_size_human),e=imagifyBulk.labels.textToShare,e=e.replace("%1$s",b.global_gain_human),e=e.replace("%2$s",b.global_original_size_human),e=encodeURIComponent(e),a(".imagify-sn-twitter").attr("href",imagifyBulk.labels.twitterShareURL+"&amp;text="+e),a(".imagify-ac-chart").attr("data-percent",b.global_percent),f(a(".imagify-ac-chart").find("canvas"))),n=0}).error(function(a){c.imagify.log("Can't optimize image with id "+a+".")}).run()}).fail(function(){swal({title:imagifyBulk.labels.getUnoptimizedImagesErrorTitle,html:imagifyBulk.labels.getUnoptimizedImagesErrorText,type:"error",customClass:"imagify-sweet-alert"}).then(function(){location.reload()})}))})}(jQuery,document,window),function(a,b,c,d){var e,f;c.innerWidth?(e=(c.innerWidth-700)/2,f=(c.innerHeight-290)/2):(e=(b.body.clientWidth-700)/2,f=(b.body.clientHeight-290)/2),[].forEach.call(b.querySelectorAll(".imagify-share-networks a"),function(a){a.addEventListener("click",function(a){c.open(this.href,"","status=no, scrollbars=no, menubar=no, top="+f+", left="+e+", width=700, height=290"),a.preventDefault()},!1)})}(jQuery,document,window);
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.6.11
7
  * Author: WP Media
8
  * Author URI: https://wp-media.me/
9
  * Licence: GPLv2
@@ -17,31 +17,27 @@
17
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
18
 
19
  // Imagify defines.
20
- define( 'IMAGIFY_VERSION' , '1.6.11' );
21
- define( 'IMAGIFY_SLUG' , 'imagify' );
22
- define( 'IMAGIFY_SETTINGS_SLUG' , IMAGIFY_SLUG . '_settings' );
23
- define( 'IMAGIFY_WEB_MAIN' , 'https://imagify.io' );
24
- define( 'IMAGIFY_APP_MAIN' , 'https://app.imagify.io' );
25
- define( 'IMAGIFY_PAYMENT_URL' , IMAGIFY_APP_MAIN . '/#/plugin/' );
26
- define( 'IMAGIFY_FILE' , __FILE__ );
27
- define( 'IMAGIFY_PATH' , realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
28
- define( 'IMAGIFY_INC_PATH' , realpath( IMAGIFY_PATH . 'inc/' ) . '/' );
29
- define( 'IMAGIFY_ADMIN_PATH' , realpath( IMAGIFY_INC_PATH . 'admin' ) . '/' );
30
- define( 'IMAGIFY_ADMIN_UI_PATH' , realpath( IMAGIFY_ADMIN_PATH . 'ui' ) . '/' );
31
- define( 'IMAGIFY_COMMON_PATH' , realpath( IMAGIFY_INC_PATH . 'common' ) . '/' );
32
- define( 'IMAGIFY_FUNCTIONS_PATH' , realpath( IMAGIFY_INC_PATH . 'functions' ) . '/' );
33
- define( 'IMAGIFY_CLASSES_PATH' , realpath( IMAGIFY_INC_PATH . 'classes' ) . '/' );
34
- define( 'IMAGIFY_CLASSES_ABSTRACTS_PATH' , realpath( IMAGIFY_CLASSES_PATH . 'abstracts' ) . '/' );
35
- define( 'IMAGIFY_3RD_PARTY_PATH' , realpath( IMAGIFY_INC_PATH . '3rd-party' ) . '/' );
36
- define( 'IMAGIFY_URL' , plugin_dir_url( IMAGIFY_FILE ) );
37
- define( 'IMAGIFY_INC_URL' , IMAGIFY_URL . 'inc/' );
38
- define( 'IMAGIFY_ADMIN_URL' , IMAGIFY_INC_URL . 'admin/' );
39
- define( 'IMAGIFY_ASSETS_URL' , IMAGIFY_URL . 'assets/' );
40
- define( 'IMAGIFY_ASSETS_JS_URL' , IMAGIFY_ASSETS_URL . 'js/' );
41
- define( 'IMAGIFY_ASSETS_CSS_URL' , IMAGIFY_ASSETS_URL . 'css/' );
42
- define( 'IMAGIFY_ASSETS_IMG_URL' , IMAGIFY_ASSETS_URL . 'images/' );
43
- define( 'IMAGIFY_MAX_BYTES' , 5242880 );
44
- define( 'IMAGIFY_INT_MAX' , PHP_INT_MAX - 30 );
45
 
46
  add_action( 'plugins_loaded', '_imagify_init' );
47
  /**
@@ -61,6 +57,10 @@ function _imagify_init() {
61
  require( IMAGIFY_FUNCTIONS_PATH . 'compat.php' );
62
  require( IMAGIFY_FUNCTIONS_PATH . 'deprecated.php' );
63
  require( IMAGIFY_FUNCTIONS_PATH . 'common.php' );
 
 
 
 
64
  require( IMAGIFY_FUNCTIONS_PATH . 'options.php' );
65
  require( IMAGIFY_FUNCTIONS_PATH . 'formatting.php' );
66
  require( IMAGIFY_FUNCTIONS_PATH . 'files.php' );
@@ -71,13 +71,6 @@ function _imagify_init() {
71
  require( IMAGIFY_FUNCTIONS_PATH . 'admin-ui.php' );
72
  require( IMAGIFY_FUNCTIONS_PATH . 'admin-stats.php' );
73
  require( IMAGIFY_FUNCTIONS_PATH . 'i18n.php' );
74
- require( IMAGIFY_CLASSES_ABSTRACTS_PATH . 'class-imagify-abstract-db.php' );
75
- require( IMAGIFY_CLASSES_ABSTRACTS_PATH . 'class-imagify-abstract-attachment.php' );
76
- require( IMAGIFY_CLASSES_PATH . 'class-imagify.php' );
77
- require( IMAGIFY_CLASSES_PATH . 'class-imagify-user.php' );
78
- require( IMAGIFY_CLASSES_PATH . 'class-imagify-attachment.php' );
79
- require( IMAGIFY_CLASSES_PATH . 'class-imagify-notices.php' );
80
- require( IMAGIFY_CLASSES_PATH . 'class-imagify-assets.php' );
81
  require( IMAGIFY_COMMON_PATH . 'attachments.php' );
82
  require( IMAGIFY_COMMON_PATH . 'admin-bar.php' );
83
  require( IMAGIFY_COMMON_PATH . 'cron.php' );
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.6.12
7
  * Author: WP Media
8
  * Author URI: https://wp-media.me/
9
  * Licence: GPLv2
17
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
18
 
19
  // Imagify defines.
20
+ define( 'IMAGIFY_VERSION' , '1.6.12' );
21
+ define( 'IMAGIFY_SLUG' , 'imagify' );
22
+ define( 'IMAGIFY_SETTINGS_SLUG' , IMAGIFY_SLUG . '_settings' );
23
+ define( 'IMAGIFY_FILE' , __FILE__ );
24
+ define( 'IMAGIFY_PATH' , realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
25
+ define( 'IMAGIFY_INC_PATH' , realpath( IMAGIFY_PATH . 'inc/' ) . '/' );
26
+ define( 'IMAGIFY_ADMIN_PATH' , realpath( IMAGIFY_INC_PATH . 'admin' ) . '/' );
27
+ define( 'IMAGIFY_ADMIN_UI_PATH' , realpath( IMAGIFY_ADMIN_PATH . 'ui' ) . '/' );
28
+ define( 'IMAGIFY_COMMON_PATH' , realpath( IMAGIFY_INC_PATH . 'common' ) . '/' );
29
+ define( 'IMAGIFY_FUNCTIONS_PATH', realpath( IMAGIFY_INC_PATH . 'functions' ) . '/' );
30
+ define( 'IMAGIFY_CLASSES_PATH' , realpath( IMAGIFY_INC_PATH . 'classes' ) . '/' );
31
+ define( 'IMAGIFY_3RD_PARTY_PATH', realpath( IMAGIFY_INC_PATH . '3rd-party' ) . '/' );
32
+ define( 'IMAGIFY_URL' , plugin_dir_url( IMAGIFY_FILE ) );
33
+ define( 'IMAGIFY_INC_URL' , IMAGIFY_URL . 'inc/' );
34
+ define( 'IMAGIFY_ADMIN_URL' , IMAGIFY_INC_URL . 'admin/' );
35
+ define( 'IMAGIFY_ASSETS_URL' , IMAGIFY_URL . 'assets/' );
36
+ define( 'IMAGIFY_ASSETS_JS_URL' , IMAGIFY_ASSETS_URL . 'js/' );
37
+ define( 'IMAGIFY_ASSETS_CSS_URL', IMAGIFY_ASSETS_URL . 'css/' );
38
+ define( 'IMAGIFY_ASSETS_IMG_URL', IMAGIFY_ASSETS_URL . 'images/' );
39
+ define( 'IMAGIFY_MAX_BYTES' , 5242880 );
40
+ define( 'IMAGIFY_INT_MAX' , PHP_INT_MAX - 30 );
 
 
 
 
41
 
42
  add_action( 'plugins_loaded', '_imagify_init' );
43
  /**
57
  require( IMAGIFY_FUNCTIONS_PATH . 'compat.php' );
58
  require( IMAGIFY_FUNCTIONS_PATH . 'deprecated.php' );
59
  require( IMAGIFY_FUNCTIONS_PATH . 'common.php' );
60
+
61
+ // Register classes.
62
+ spl_autoload_register( 'imagify_autoload' );
63
+
64
  require( IMAGIFY_FUNCTIONS_PATH . 'options.php' );
65
  require( IMAGIFY_FUNCTIONS_PATH . 'formatting.php' );
66
  require( IMAGIFY_FUNCTIONS_PATH . 'files.php' );
71
  require( IMAGIFY_FUNCTIONS_PATH . 'admin-ui.php' );
72
  require( IMAGIFY_FUNCTIONS_PATH . 'admin-stats.php' );
73
  require( IMAGIFY_FUNCTIONS_PATH . 'i18n.php' );
 
 
 
 
 
 
 
74
  require( IMAGIFY_COMMON_PATH . 'attachments.php' );
75
  require( IMAGIFY_COMMON_PATH . 'admin-bar.php' );
76
  require( IMAGIFY_COMMON_PATH . 'cron.php' );
inc/3rd-party/amazon-s3-and-cloudfront/amazon-s3-and-cloudfront.php CHANGED
@@ -3,9 +3,6 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
 
4
  if ( is_admin() && ( function_exists( 'as3cf_init' ) || function_exists( 'as3cf_pro_init' ) ) ) :
5
 
6
- require( dirname( __FILE__ ) . '/inc/classes/class-imagify-as3cf.php' );
7
- require( dirname( __FILE__ ) . '/inc/classes/class-imagify-as3cf-attachment.php' );
8
-
9
- add_action( 'imagify_loaded', array( imagify_as3cf(), 'init' ), 1 );
10
 
11
  endif;
3
 
4
  if ( is_admin() && ( function_exists( 'as3cf_init' ) || function_exists( 'as3cf_pro_init' ) ) ) :
5
 
6
+ add_action( 'imagify_loaded', array( Imagify_AS3CF::get_instance(), 'init' ), 1 );
 
 
 
7
 
8
  endif;
inc/3rd-party/amazon-s3-and-cloudfront/inc/classes/class-imagify-as3cf.php CHANGED
@@ -173,6 +173,12 @@ class Imagify_AS3CF {
173
  $ids = array_flip( $ids );
174
 
175
  foreach ( $ids as $id => $i ) {
 
 
 
 
 
 
176
  $file_path = get_imagify_attached_file( $results['filenames'][ $id ] );
177
 
178
  /** This filter is documented in inc/functions/process.php. */
@@ -338,9 +344,19 @@ class Imagify_AS3CF {
338
  $auto_optimize = imagify_valid_key() && get_imagify_option( 'auto_optimize' );
339
  }
340
 
341
- if ( $is_new_upload && ! $auto_optimize ) {
342
- // It's a new upload and auto-optimization is disabled.
343
- return $metadata;
 
 
 
 
 
 
 
 
 
 
344
  }
345
 
346
  if ( ! $is_new_upload && ! get_post_meta( $attachment_id, '_imagify_data', true ) ) {
@@ -435,15 +451,3 @@ class Imagify_AS3CF {
435
  return imagify_is_attachment_mime_type_supported( $post_id );
436
  }
437
  }
438
-
439
- /**
440
- * Returns the main instance of the Imagify_AS3CF class.
441
- *
442
- * @since 1.6.6
443
- * @author Grégory Viguier
444
- *
445
- * @return object The Imagify_AS3CF instance.
446
- */
447
- function imagify_as3cf() {
448
- return Imagify_AS3CF::get_instance();
449
- }
173
  $ids = array_flip( $ids );
174
 
175
  foreach ( $ids as $id => $i ) {
176
+ if ( empty( $results['filenames'][ $id ] ) ) {
177
+ // Problem.
178
+ unset( $ids[ $id ] );
179
+ continue;
180
+ }
181
+
182
  $file_path = get_imagify_attached_file( $results['filenames'][ $id ] );
183
 
184
  /** This filter is documented in inc/functions/process.php. */
344
  $auto_optimize = imagify_valid_key() && get_imagify_option( 'auto_optimize' );
345
  }
346
 
347
+ if ( $is_new_upload ) {
348
+ // It's a new upload.
349
+ if ( ! $auto_optimize ) {
350
+ // Auto-optimization is disabled.
351
+ return $metadata;
352
+ }
353
+
354
+ /** This filter is documented in inc/common/attachments.php. */
355
+ $optimize = apply_filters( 'imagify_auto_optimize_attachment', true, $attachment_id, $metadata );
356
+
357
+ if ( ! $optimize ) {
358
+ return $metadata;
359
+ }
360
  }
361
 
362
  if ( ! $is_new_upload && ! get_post_meta( $attachment_id, '_imagify_data', true ) ) {
451
  return imagify_is_attachment_mime_type_supported( $post_id );
452
  }
453
  }
 
 
 
 
 
 
 
 
 
 
 
 
inc/3rd-party/enable-media-replace/enable-media-replace.php CHANGED
@@ -3,8 +3,6 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
 
4
  if ( function_exists( 'enable_media_replace' ) ) :
5
 
6
- require( dirname( __FILE__ ) . '/inc/classes/class-imagify-enable-media-replace.php' );
7
-
8
- add_filter( 'emr_unfiltered_get_attached_file', array( imagify_enable_media_replace(), 'init' ) );
9
 
10
  endif;
3
 
4
  if ( function_exists( 'enable_media_replace' ) ) :
5
 
6
+ add_filter( 'emr_unfiltered_get_attached_file', array( Imagify_Enable_Media_Replace::get_instance(), 'init' ) );
 
 
7
 
8
  endif;
inc/3rd-party/enable-media-replace/inc/classes/class-imagify-enable-media-replace.php CHANGED
@@ -198,15 +198,3 @@ class Imagify_Enable_Media_Replace {
198
  return $this->attachment;
199
  }
200
  }
201
-
202
- /**
203
- * Returns the main instance of the Imagify_Enable_Media_Replace class.
204
- *
205
- * @since 1.6.9
206
- * @author Grégory Viguier
207
- *
208
- * @return object The Imagify_Enable_Media_Replace instance.
209
- */
210
- function imagify_enable_media_replace() {
211
- return Imagify_Enable_Media_Replace::get_instance();
212
- }
198
  return $this->attachment;
199
  }
200
  }
 
 
 
 
 
 
 
 
 
 
 
 
inc/3rd-party/nextgen-gallery/inc/admin/db.php CHANGED
@@ -12,6 +12,6 @@ function _imagify_create_ngg_table() {
12
  global $wpdb;
13
 
14
  if ( ! get_option( $wpdb->prefix . 'ngg_imagify_data_db_version' ) ) {
15
- imagify_ngg_db()->create_table();
16
  }
17
  }
12
  global $wpdb;
13
 
14
  if ( ! get_option( $wpdb->prefix . 'ngg_imagify_data_db_version' ) ) {
15
+ Imagify_NGG_DB::get_instance()->create_table();
16
  }
17
  }
inc/3rd-party/nextgen-gallery/inc/admin/enqueue.php CHANGED
@@ -17,7 +17,7 @@ function _imagify_ngg_admin_print_styles() {
17
  /**
18
  * Manage Gallery Images.
19
  */
20
- if ( imagify_is_screen( 'nggallery-manage-images' ) ) {
21
  $assets->enqueue_style( 'admin' )->enqueue_script( 'library' );
22
  return;
23
  }
17
  /**
18
  * Manage Gallery Images.
19
  */
20
+ if ( imagify_is_screen( 'nggallery-manage-images' ) || isset( $_GET['gid'] ) && ! empty( $_GET['pid'] ) && imagify_is_screen( 'nggallery-manage-gallery' ) ) { // WPCS: CSRF ok.
21
  $assets->enqueue_style( 'admin' )->enqueue_script( 'library' );
22
  return;
23
  }
inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-attachment.php CHANGED
@@ -14,7 +14,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
14
  *
15
  * @var string
16
  */
17
- const VERSION = '1.1.1';
18
 
19
  /**
20
  * The image object.
@@ -109,30 +109,30 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
109
  }
110
 
111
  /**
112
- * Get the attachment optimization data.
113
  *
114
  * @since 1.5
115
  * @author Jonathan Buttigieg
116
  *
117
  * @access public
118
- * @return array|bool
119
  */
120
- public function get_data() {
121
- $row = $this->row ? $this->row : $this->get_row();
122
- return isset( $row['data'] ) ? maybe_unserialize( $row['data'] ) : false;
123
  }
124
 
125
  /**
126
- * Get the attachment SQL data row.
127
  *
128
  * @since 1.5
129
  * @author Jonathan Buttigieg
130
  *
131
  * @access public
132
- * @return array
133
  */
134
- public function get_row() {
135
- return imagify_ngg_db()->get( $this->id );
 
136
  }
137
 
138
  /**
@@ -216,6 +216,24 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
216
  return $this->is_mime_type_supported;
217
  }
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  /**
220
  * Update the metadata size of the attachment.
221
  *
@@ -280,7 +298,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
280
  $error_status = 'already_optimized';
281
  }
282
 
283
- imagify_ngg_db()->update( $this->id, array(
284
  'pid' => $this->id,
285
  'status' => $error_status,
286
  'data' => serialize( $data ),
@@ -395,7 +413,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
395
  $data = $this->fill_data( null, $response, $attachment_url );
396
 
397
  // Save the optimization level.
398
- imagify_ngg_db()->update( $this->id, array(
399
  'pid' => $this->id,
400
  'optimization_level' => $optimization_level,
401
  ) );
@@ -416,7 +434,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
416
  $data = $this->optimize_thumbnails( $optimization_level, $data );
417
 
418
  // Save the status to success.
419
- imagify_ngg_db()->update( $this->id, array(
420
  'pid' => $this->id,
421
  'status' => 'success',
422
  ) );
@@ -537,7 +555,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
537
  $data = apply_filters( 'imagify_fill_ngg_thumbnail_data', $data, $response, $this->id, $thumbnail_path, $thumbnail_url, $size_key, $optimization_level );
538
  }
539
 
540
- imagify_ngg_db()->update( $this->id, array(
541
  'pid' => $this->id,
542
  'data' => serialize( $data ),
543
  ) );
@@ -617,7 +635,7 @@ class Imagify_NGG_Attachment extends Imagify_Attachment {
617
  /**
618
  * Remove Imagify data.
619
  */
620
- imagify_ngg_db()->delete( $image->pid );
621
  $this->row = null;
622
 
623
  /**
14
  *
15
  * @var string
16
  */
17
+ const VERSION = '1.1.2';
18
 
19
  /**
20
  * The image object.
109
  }
110
 
111
  /**
112
+ * Get the attachment SQL data row.
113
  *
114
  * @since 1.5
115
  * @author Jonathan Buttigieg
116
  *
117
  * @access public
118
+ * @return array
119
  */
120
+ public function get_row() {
121
+ return Imagify_NGG_DB::get_instance()->get( $this->id );
 
122
  }
123
 
124
  /**
125
+ * Get the attachment optimization data.
126
  *
127
  * @since 1.5
128
  * @author Jonathan Buttigieg
129
  *
130
  * @access public
131
+ * @return array|bool
132
  */
133
+ public function get_data() {
134
+ $row = $this->row ? $this->row : $this->get_row();
135
+ return isset( $row['data'] ) ? maybe_unserialize( $row['data'] ) : false;
136
  }
137
 
138
  /**
216
  return $this->is_mime_type_supported;
217
  }
218
 
219
+ /**
220
+ * Tell if the current attachment has the required WP metadata.
221
+ *
222
+ * @since 1.6.12
223
+ * @author Grégory Viguier
224
+ *
225
+ * @return bool
226
+ */
227
+ public function has_required_metadata() {
228
+ static $sizes;
229
+
230
+ if ( ! isset( $sizes ) ) {
231
+ $sizes = C_Gallery_Storage::get_instance()->get_image_sizes();
232
+ }
233
+
234
+ return $sizes && $this->get_original_path();
235
+ }
236
+
237
  /**
238
  * Update the metadata size of the attachment.
239
  *
298
  $error_status = 'already_optimized';
299
  }
300
 
301
+ Imagify_NGG_DB::get_instance()->update( $this->id, array(
302
  'pid' => $this->id,
303
  'status' => $error_status,
304
  'data' => serialize( $data ),
413
  $data = $this->fill_data( null, $response, $attachment_url );
414
 
415
  // Save the optimization level.
416
+ Imagify_NGG_DB::get_instance()->update( $this->id, array(
417
  'pid' => $this->id,
418
  'optimization_level' => $optimization_level,
419
  ) );
434
  $data = $this->optimize_thumbnails( $optimization_level, $data );
435
 
436
  // Save the status to success.
437
+ Imagify_NGG_DB::get_instance()->update( $this->id, array(
438
  'pid' => $this->id,
439
  'status' => 'success',
440
  ) );
555
  $data = apply_filters( 'imagify_fill_ngg_thumbnail_data', $data, $response, $this->id, $thumbnail_path, $thumbnail_url, $size_key, $optimization_level );
556
  }
557
 
558
+ Imagify_NGG_DB::get_instance()->update( $this->id, array(
559
  'pid' => $this->id,
560
  'data' => serialize( $data ),
561
  ) );
635
  /**
636
  * Remove Imagify data.
637
  */
638
+ Imagify_NGG_DB::get_instance()->delete( $image->pid );
639
  $this->row = null;
640
 
641
  /**
inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-db.php CHANGED
@@ -148,19 +148,7 @@ class Imagify_NGG_DB extends Imagify_Abstract_DB {
148
  */
149
  public static function instance() {
150
  $class_name = get_class( $this );
151
- _deprecated_function( $class_name . '::' . __FUNCTION__ . '()', '1.6.5', 'imagify_ngg_db()' );
152
  return self::get_instance();
153
  }
154
  }
155
-
156
- /**
157
- * Returns the main instance of the Imagify_NGG_DB class.
158
- *
159
- * @since 1.6.5
160
- * @author Jonathan Buttigieg
161
- *
162
- * @return object The Imagify_NGG_DB instance.
163
- */
164
- function imagify_ngg_db() {
165
- return Imagify_NGG_DB::get_instance();
166
- }
148
  */
149
  public static function instance() {
150
  $class_name = get_class( $this );
151
+ _deprecated_function( $class_name . '::' . __FUNCTION__ . '()', '1.6.5', 'Imagify_NGG_DB::get_instance()' );
152
  return self::get_instance();
153
  }
154
  }
 
 
 
 
 
 
 
 
 
 
 
 
inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-storage.php CHANGED
@@ -14,7 +14,7 @@ class Imagify_NGG_Storage extends Mixin {
14
  *
15
  * @var string
16
  */
17
- const VERSION = '1.0.1';
18
 
19
  /**
20
  * Delete a gallery AND all the pictures associated to this gallery!
@@ -30,7 +30,7 @@ class Imagify_NGG_Storage extends Mixin {
30
  $images_id = nggdb::get_ids_from_gallery( $gallery_id );
31
 
32
  foreach ( $images_id as $pid ) {
33
- imagify_ngg_db()->delete( $pid );
34
  }
35
 
36
  return $this->call_parent( 'delete_gallery', $gallery );
@@ -60,7 +60,7 @@ class Imagify_NGG_Storage extends Mixin {
60
  $attachment = new Imagify_NGG_Attachment( $image->pid );
61
 
62
  if ( $attachment->is_optimized() ) {
63
- imagify_ngg_db()->delete( $image->pid );
64
  }
65
  }
66
 
@@ -88,7 +88,7 @@ class Imagify_NGG_Storage extends Mixin {
88
 
89
  // Remove Imagify data.
90
  if ( isset( $image->pid ) ) {
91
- imagify_ngg_db()->delete( $image->pid );
92
  }
93
 
94
  return $this->call_parent( 'recover_image', $image );
14
  *
15
  * @var string
16
  */
17
+ const VERSION = '1.0.2';
18
 
19
  /**
20
  * Delete a gallery AND all the pictures associated to this gallery!
30
  $images_id = nggdb::get_ids_from_gallery( $gallery_id );
31
 
32
  foreach ( $images_id as $pid ) {
33
+ Imagify_NGG_DB::get_instance()->delete( $pid );
34
  }
35
 
36
  return $this->call_parent( 'delete_gallery', $gallery );
60
  $attachment = new Imagify_NGG_Attachment( $image->pid );
61
 
62
  if ( $attachment->is_optimized() ) {
63
+ Imagify_NGG_DB::get_instance()->delete( $image->pid );
64
  }
65
  }
66
 
88
 
89
  // Remove Imagify data.
90
  if ( isset( $image->pid ) ) {
91
+ Imagify_NGG_DB::get_instance()->delete( $image->pid );
92
  }
93
 
94
  return $this->call_parent( 'recover_image', $image );
inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
4
  /**
5
  * Imagify NextGen Gallery class.
6
  *
7
- * @since 1.5
8
  * @author Jonathan Buttigieg
9
  */
10
  class Imagify_NGG {
@@ -14,13 +14,13 @@ class Imagify_NGG {
14
  *
15
  * @var string
16
  */
17
- const VERSION = '1.0.2';
18
 
19
  /**
20
  * The single instance of the class.
21
  *
22
- * @access protected
23
- * @since 1.5
24
  *
25
  * @var object
26
  */
@@ -32,8 +32,7 @@ class Imagify_NGG {
32
  * @since 1.5
33
  * @since 1.6.5 Doesn't launch the hooks anymore.
34
  * @author Jonathan Buttigieg
35
- *
36
- * @return void
37
  */
38
  protected function __construct() {}
39
 
@@ -42,6 +41,7 @@ class Imagify_NGG {
42
  *
43
  * @since 1.6.5
44
  * @author Grégory Viguier
 
45
  */
46
  public function init() {
47
  static $done = false;
@@ -59,9 +59,9 @@ class Imagify_NGG {
59
  *
60
  * Ensures only one instance of class is loaded or can be loaded.
61
  *
62
- * @access public
63
- * @since 1.6.5
64
- * @author Grégory Viguier
65
  *
66
  * @return object Main instance.
67
  */
@@ -76,25 +76,11 @@ class Imagify_NGG {
76
  /**
77
  * Add custom NGG mixin to override its functions.
78
  *
79
- * @since 1.5
80
  * @author Jonathan Buttigieg
81
- *
82
- * @return void
83
  */
84
- function add_mixin() {
85
- include_once( 'class-imagify-ngg-storage.php' );
86
  C_Gallery_Storage::get_instance()->get_wrapped_instance()->add_mixin( 'Imagify_NGG_Storage' );
87
  }
88
  }
89
-
90
- /**
91
- * Returns the main instance of the Imagify_NGG class.
92
- *
93
- * @since 1.6.5
94
- * @author Grégory Viguier
95
- *
96
- * @return object The Imagify_NGG instance.
97
- */
98
- function imagify_ngg() {
99
- return Imagify_NGG::get_instance();
100
- }
4
  /**
5
  * Imagify NextGen Gallery class.
6
  *
7
+ * @since 1.5
8
  * @author Jonathan Buttigieg
9
  */
10
  class Imagify_NGG {
14
  *
15
  * @var string
16
  */
17
+ const VERSION = '1.0.3';
18
 
19
  /**
20
  * The single instance of the class.
21
  *
22
+ * @since 1.5
23
+ * @access protected
24
  *
25
  * @var object
26
  */
32
  * @since 1.5
33
  * @since 1.6.5 Doesn't launch the hooks anymore.
34
  * @author Jonathan Buttigieg
35
+ * @access protected
 
36
  */
37
  protected function __construct() {}
38
 
41
  *
42
  * @since 1.6.5
43
  * @author Grégory Viguier
44
+ * @access public
45
  */
46
  public function init() {
47
  static $done = false;
59
  *
60
  * Ensures only one instance of class is loaded or can be loaded.
61
  *
62
+ * @since 1.6.5
63
+ * @author Grégory Viguier
64
+ * @access public
65
  *
66
  * @return object Main instance.
67
  */
76
  /**
77
  * Add custom NGG mixin to override its functions.
78
  *
79
+ * @since 1.5
80
  * @author Jonathan Buttigieg
81
+ * @access public
 
82
  */
83
+ public function add_mixin() {
 
84
  C_Gallery_Storage::get_instance()->get_wrapped_instance()->add_mixin( 'Imagify_NGG_Storage' );
85
  }
86
  }
 
 
 
 
 
 
 
 
 
 
 
 
inc/3rd-party/nextgen-gallery/inc/common/attachments.php CHANGED
@@ -5,26 +5,41 @@ add_action( 'ngg_after_new_images_added', '_imagify_ngg_optimize_attachment', IM
5
  /**
6
  * Auto-optimize when a new attachment is generated.
7
  *
8
- * @since 1.5
9
  * @author Jonathan Buttigieg
10
  *
11
  * @param int $gallery_id A Gallery ID.
12
  * @param array $image_ids Id's which are sucessfully added.
13
  */
14
  function _imagify_ngg_optimize_attachment( $gallery_id, $image_ids ) {
15
- $api_key = get_imagify_option( 'api_key', false );
16
 
17
- if ( ! $api_key || ! get_imagify_option( 'auto_optimize', false ) ) {
18
  return;
19
  }
20
 
21
- foreach ( $image_ids as $id ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  imagify_do_async_job( array(
23
  'action' => 'imagify_async_optimize_upload_new_media',
24
- '_ajax_nonce' => wp_create_nonce( 'new_media-' . $id ),
25
  'metadata' => 1,
26
  'context' => 'NGG',
27
- 'attachment_id' => $id,
28
  ) );
29
  }
30
  }
@@ -33,24 +48,24 @@ add_action( 'ngg_delete_picture', '_imagify_ngg_delete_picture' );
33
  /**
34
  * Delete the Imagify data when an image is deleted.
35
  *
36
- * @since 1.5
37
  * @author Jonathan Buttigieg
38
  *
39
  * @param int $image_id An image ID.
40
  */
41
  function _imagify_ngg_delete_picture( $image_id ) {
42
- imagify_ngg_db()->delete( $image_id );
43
  }
44
 
45
  add_filter( 'ngg_medialibrary_imported_image', '_imagify_ngg_media_library_imported_image_data', 10, 2 );
46
  /**
47
  * Import Imagify data from a WordPress image to a new NGG image
48
  *
49
- * @since 1.5
50
  * @author Jonathan Buttigieg
51
  *
52
- * @param object $image A NGG image object.
53
- * @param object $attachment An attachment object.
54
  * @return object
55
  */
56
  function _imagify_ngg_media_library_imported_image_data( $image, $attachment ) {
@@ -62,24 +77,23 @@ function _imagify_ngg_media_library_imported_image_data( $image, $attachment ) {
62
  }
63
 
64
  $full_size = $attachment->get_size_data();
65
- $data = array(
66
- 'stats' => array(
67
- 'original_size' => $full_size['original_size'],
68
- 'optimized_size' => $full_size['optimized_size'],
69
- 'percent' => $full_size['percent'],
70
- ),
71
- 'sizes' => array( 'full' => $full_size ),
72
- );
73
 
74
- imagify_ngg_db()->update( $image->pid, array(
75
  'pid' => $image->pid,
76
  'optimization_level' => $attachment->get_optimization_level(),
77
  'status' => $attachment->get_status(),
78
- 'data' => maybe_serialize( $data ),
 
 
 
 
 
 
 
79
  ) );
80
 
81
- $image = new Imagify_NGG_Attachment( $image->pid );
82
- $image->optimize_thumbnails();
83
 
84
  return $image;
85
  }
5
  /**
6
  * Auto-optimize when a new attachment is generated.
7
  *
8
+ * @since 1.5
9
  * @author Jonathan Buttigieg
10
  *
11
  * @param int $gallery_id A Gallery ID.
12
  * @param array $image_ids Id's which are sucessfully added.
13
  */
14
  function _imagify_ngg_optimize_attachment( $gallery_id, $image_ids ) {
 
15
 
16
+ if ( ! imagify_valid_key() || ! get_imagify_option( 'auto_optimize' ) ) {
17
  return;
18
  }
19
 
20
+ foreach ( $image_ids as $image_id ) {
21
+ /**
22
+ * Allow to prevent automatic optimization for a specific NGG gallery image.
23
+ *
24
+ * @since 1.6.12
25
+ * @author Grégory Viguier
26
+ *
27
+ * @param bool $optimize True to optimize, false otherwise.
28
+ * @param int $image_id Image ID.
29
+ * @param int $gallery_id Gallery ID.
30
+ */
31
+ $optimize = apply_filters( 'imagify_auto_optimize_ngg_gallery_image', true, $image_id, $gallery_id );
32
+
33
+ if ( ! $optimize ) {
34
+ continue;
35
+ }
36
+
37
  imagify_do_async_job( array(
38
  'action' => 'imagify_async_optimize_upload_new_media',
39
+ '_ajax_nonce' => wp_create_nonce( 'new_media-' . $image_id ),
40
  'metadata' => 1,
41
  'context' => 'NGG',
42
+ 'attachment_id' => $image_id,
43
  ) );
44
  }
45
  }
48
  /**
49
  * Delete the Imagify data when an image is deleted.
50
  *
51
+ * @since 1.5
52
  * @author Jonathan Buttigieg
53
  *
54
  * @param int $image_id An image ID.
55
  */
56
  function _imagify_ngg_delete_picture( $image_id ) {
57
+ Imagify_NGG_DB::get_instance()->delete( $image_id );
58
  }
59
 
60
  add_filter( 'ngg_medialibrary_imported_image', '_imagify_ngg_media_library_imported_image_data', 10, 2 );
61
  /**
62
  * Import Imagify data from a WordPress image to a new NGG image
63
  *
64
+ * @since 1.5
65
  * @author Jonathan Buttigieg
66
  *
67
+ * @param object $image A NGG image object.
68
+ * @param object $attachment An attachment object.
69
  * @return object
70
  */
71
  function _imagify_ngg_media_library_imported_image_data( $image, $attachment ) {
77
  }
78
 
79
  $full_size = $attachment->get_size_data();
 
 
 
 
 
 
 
 
80
 
81
+ Imagify_NGG_DB::get_instance()->update( $image->pid, array(
82
  'pid' => $image->pid,
83
  'optimization_level' => $attachment->get_optimization_level(),
84
  'status' => $attachment->get_status(),
85
+ 'data' => maybe_serialize( array(
86
+ 'stats' => array(
87
+ 'original_size' => $full_size['original_size'],
88
+ 'optimized_size' => $full_size['optimized_size'],
89
+ 'percent' => $full_size['percent'],
90
+ ),
91
+ 'sizes' => array( 'full' => $full_size ),
92
+ ) ),
93
  ) );
94
 
95
+ $imagify_image = new Imagify_NGG_Attachment( $image->pid );
96
+ $imagify_image->optimize_thumbnails();
97
 
98
  return $image;
99
  }
inc/3rd-party/nextgen-gallery/inc/functions/admin-stats.php CHANGED
@@ -38,7 +38,7 @@ function imagify_ngg_count_error_attachments() {
38
  return $count;
39
  }
40
 
41
- $count = (int) imagify_ngg_db()->get_column_by( 'COUNT(*)', 'status', 'error' );
42
 
43
  return $count;
44
  }
@@ -58,7 +58,7 @@ function imagify_ngg_count_optimized_attachments() {
58
  return $count;
59
  }
60
 
61
- $count = (int) imagify_ngg_db()->get_column_by( 'COUNT(*)', 'status', 'success' );
62
 
63
  return $count;
64
  }
@@ -121,7 +121,6 @@ function imagify_ngg_count_saving_data( $attachments ) {
121
  return $attachments;
122
  }
123
 
124
- $table_name = $wpdb->ngg_imagify_data;
125
  $original_size = 0;
126
  $optimized_size = 0;
127
  $count = 0;
@@ -130,13 +129,13 @@ function imagify_ngg_count_saving_data( $attachments ) {
130
  $limit = apply_filters( 'imagify_count_saving_data_limit', 15000 );
131
  $limit = absint( $limit );
132
  $offset = 0;
 
 
 
 
 
133
 
134
- $attachments = $wpdb->get_col( // WPCS: unprepared SQL ok.
135
- "SELECT $table_name.data
136
- FROM {$wpdb->ngg_imagify_data}
137
- WHERE status = 'success'
138
- LIMIT $offset, $limit"
139
- );
140
  $wpdb->flush();
141
 
142
  while ( $attachments ) {
@@ -173,12 +172,7 @@ function imagify_ngg_count_saving_data( $attachments ) {
173
  // Unless we are really unlucky, we still have attachments to fetch.
174
  $offset += $limit;
175
 
176
- $attachments = $wpdb->get_col( // WPCS: unprepared SQL ok.
177
- "SELECT $table_name.data
178
- FROM {$wpdb->ngg_imagify_data}
179
- WHERE status = 'success'
180
- LIMIT $offset, $limit"
181
- );
182
  $wpdb->flush();
183
  } else {
184
  // Save one request, don't go back to the beginning of the loop.
38
  return $count;
39
  }
40
 
41
+ $count = (int) Imagify_NGG_DB::get_instance()->get_column_by( 'COUNT(*)', 'status', 'error' );
42
 
43
  return $count;
44
  }
58
  return $count;
59
  }
60
 
61
+ $count = (int) Imagify_NGG_DB::get_instance()->get_column_in( 'COUNT(*)', 'status', array( 'success', 'already_optimized' ) );
62
 
63
  return $count;
64
  }
121
  return $attachments;
122
  }
123
 
 
124
  $original_size = 0;
125
  $optimized_size = 0;
126
  $count = 0;
129
  $limit = apply_filters( 'imagify_count_saving_data_limit', 15000 );
130
  $limit = absint( $limit );
131
  $offset = 0;
132
+ $query = "
133
+ SELECT data
134
+ FROM $wpdb->ngg_imagify_data
135
+ WHERE status = 'success'
136
+ LIMIT %d, %d";
137
 
138
+ $attachments = $wpdb->get_col( $wpdb->prepare( $query, $offset, $limit ) ); // WPCS: unprepared SQL ok.
 
 
 
 
 
139
  $wpdb->flush();
140
 
141
  while ( $attachments ) {
172
  // Unless we are really unlucky, we still have attachments to fetch.
173
  $offset += $limit;
174
 
175
+ $attachments = $wpdb->get_col( $wpdb->prepare( $query, $offset, $limit ) ); // WPCS: unprepared SQL ok.
 
 
 
 
 
176
  $wpdb->flush();
177
  } else {
178
  // Save one request, don't go back to the beginning of the loop.
inc/3rd-party/nextgen-gallery/nextgen-gallery.php CHANGED
@@ -5,24 +5,20 @@ if ( ! class_exists( 'C_NextGEN_Bootstrap' ) || ! class_exists( 'Mixin' ) || ! g
5
  return;
6
  }
7
 
8
- define( 'IMAGIFY_NGG_FILE' , __FILE__ );
9
- define( 'IMAGIFY_NGG_PATH' , realpath( plugin_dir_path( IMAGIFY_NGG_FILE ) ) . '/' );
10
- define( 'IMAGIFY_NGG_INC_PATH' , realpath( IMAGIFY_NGG_PATH . 'inc/' ) . '/' );
11
- define( 'IMAGIFY_NGG_ADMIN_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'admin' ) . '/' );
12
- define( 'IMAGIFY_NGG_COMMON_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'common' ) . '/' );
13
- define( 'IMAGIFY_NGG_FUNCTIONS_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'functions' ) . '/' );
14
- define( 'IMAGIFY_NGG_CLASSES_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'classes' ) . '/' );
15
 
16
- require( IMAGIFY_NGG_CLASSES_PATH . 'class-imagify-ngg.php' );
17
- require( IMAGIFY_NGG_CLASSES_PATH . 'class-imagify-ngg-db.php' );
18
- require( IMAGIFY_NGG_CLASSES_PATH . 'class-imagify-ngg-attachment.php' );
19
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'admin-stats.php' );
20
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'attachments.php' );
21
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'common.php' );
22
  require( IMAGIFY_NGG_COMMON_PATH . 'attachments.php' );
23
 
24
- imagify_ngg()->init();
25
- imagify_ngg_db();
26
 
27
  if ( is_admin() ) {
28
  require( IMAGIFY_NGG_ADMIN_PATH . 'enqueue.php' );
5
  return;
6
  }
7
 
8
+ define( 'IMAGIFY_NGG_FILE' , __FILE__ );
9
+ define( 'IMAGIFY_NGG_PATH' , realpath( plugin_dir_path( IMAGIFY_NGG_FILE ) ) . '/' );
10
+ define( 'IMAGIFY_NGG_INC_PATH' , realpath( IMAGIFY_NGG_PATH . 'inc/' ) . '/' );
11
+ define( 'IMAGIFY_NGG_ADMIN_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'admin' ) . '/' );
12
+ define( 'IMAGIFY_NGG_COMMON_PATH' , realpath( IMAGIFY_NGG_INC_PATH . 'common' ) . '/' );
13
+ define( 'IMAGIFY_NGG_FUNCTIONS_PATH', realpath( IMAGIFY_NGG_INC_PATH . 'functions' ) . '/' );
 
14
 
 
 
 
15
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'admin-stats.php' );
16
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'attachments.php' );
17
  require( IMAGIFY_NGG_FUNCTIONS_PATH . 'common.php' );
18
  require( IMAGIFY_NGG_COMMON_PATH . 'attachments.php' );
19
 
20
+ Imagify_NGG::get_instance()->init();
21
+ Imagify_NGG_DB::get_instance(); // Required to set $wpdb->ngg_imagify_data.
22
 
23
  if ( is_admin() ) {
24
  require( IMAGIFY_NGG_ADMIN_PATH . 'enqueue.php' );
inc/admin/meta-boxes.php CHANGED
@@ -18,6 +18,10 @@ function _imagify_attachment_submitbox_misc_actions() {
18
  return;
19
  }
20
 
 
 
 
 
21
  $class_name = get_imagify_attachment_class_name( 'wp', $post->ID, 'attachment_submitbox_misc_actions' );
22
  $attachment = new $class_name( $post->ID );
23
 
18
  return;
19
  }
20
 
21
+ if ( ! imagify_attachment_has_required_metadata( $post->ID ) ) {
22
+ return;
23
+ }
24
+
25
  $class_name = get_imagify_attachment_class_name( 'wp', $post->ID, 'attachment_submitbox_misc_actions' );
26
  $attachment = new $class_name( $post->ID );
27
 
inc/admin/plugins.php CHANGED
@@ -12,6 +12,7 @@ add_filter( 'network_admin_plugin_action_links_' . plugin_basename( IMAGIFY_FILE
12
  * @return array
13
  */
14
  function _imagify_plugin_action_links( $actions ) {
 
15
  array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url( 'bulk-optimization' ) ), __( 'Bulk Optimization', 'imagify' ) ) );
16
  array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url() ), __( 'Settings' ) ) );
17
  return $actions;
12
  * @return array
13
  */
14
  function _imagify_plugin_action_links( $actions ) {
15
+ array_unshift( $actions, sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( imagify_get_external_url( 'documentation' ) ), __( 'Documentation', 'imagify' ) ) );
16
  array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url( 'bulk-optimization' ) ), __( 'Bulk Optimization', 'imagify' ) ) );
17
  array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url() ), __( 'Settings' ) ) );
18
  return $actions;
inc/admin/ui/bulk.php CHANGED
@@ -20,7 +20,7 @@ function _imagify_display_bulk_page() {
20
  <p class="imagify-meteo-subs"><?php _e( 'Your subscription:', 'imagify' ); ?>&nbsp;<strong class="imagify-user-plan"><?php echo $user->plan_label; ?></strong></p>
21
  </div>
22
  <div class="imagify-account-link">
23
- <a href="<?php echo IMAGIFY_APP_MAIN; ?>/#/subscription" class="button button-ghost" target="_blank">
24
  <span class="dashicons dashicons-admin-users"></span>
25
  <span class="button-text"><?php _e( 'View My Subscription', 'imagify' ); ?></span>
26
  </a>
@@ -72,7 +72,7 @@ function _imagify_display_bulk_page() {
72
  </div>
73
  <div class="cell-sep"></div>
74
  <div class="cell-cta">
75
- <a href="<?php echo IMAGIFY_APP_MAIN; ?>/#/subscription" target="_blank"><?php _e( 'More info', 'imagify' ); ?></a>
76
  </div>
77
  </div>
78
  </div>
@@ -154,8 +154,7 @@ function _imagify_display_bulk_page() {
154
 
155
  <p><?php _e( 'Optimized size', 'imagify' ); ?></p>
156
  <div class="imagify-bar-positive base-transparent right-outside-number">
157
-
158
- <div id="imagify-optimized-bar" class="imagify-progress" style="width: <?php echo $optimized_percent; ?>%"><span class="imagify-barnb"><?php echo size_format( $optimized_nb, 1 ); ?></span></div>
159
  </div>
160
 
161
  </div>
@@ -320,10 +319,10 @@ function _imagify_display_bulk_page() {
320
  <p><?php _e( 'Share your awesome result', 'imagify' ); ?></p>
321
  <ul class="imagify-share-networks">
322
  <li>
323
- <a target="_blank" class="imagify-sn-twitter" href=""><svg viewBox="0 0 23 18" width="23" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><title>Twitter</title><path d="m244.15 12.13c-.815.361-1.691.606-2.61.716.939-.563 1.659-1.453 1.998-2.514-.878.521-1.851.898-2.886 1.103-.829-.883-2.01-1.435-3.317-1.435-2.51 0-4.544 2.034-4.544 4.544 0 .356.04.703.118 1.035-3.777-.19-7.125-1.999-9.367-4.748-.391.671-.615 1.452-.615 2.285 0 1.576.802 2.967 2.02 3.782-.745-.024-1.445-.228-2.058-.568-.001.019-.001.038-.001.057 0 2.202 1.566 4.04 3.646 4.456-.381.104-.783.159-1.197.159-.293 0-.577-.028-.855-.081.578 1.805 2.256 3.119 4.245 3.156-1.555 1.219-3.515 1.945-5.644 1.945-.367 0-.728-.021-1.084-.063 2.01 1.289 4.399 2.041 6.966 2.041 8.359 0 12.929-6.925 12.929-12.929 0-.197-.004-.393-.013-.588.888-.64 1.658-1.44 2.268-2.352" transform="translate(-222-10)" fill="#fff"/></g></svg></a>
324
  </li>
325
  <li>
326
- <a target="_blank" class="imagify-sn-twitter-facebook" href="<?php echo esc_url( 'https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/imagify' ); ?>"><svg viewBox="0 0 18 18" width="18" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><title>Facebook</title><path d="m203.25 10h-16.5c-.415 0-.75.336-.75.75v16.5c0 .414.336.75.75.75h8.812v-6.75h-2.25v-2.813h2.25v-2.25c0-2.325 1.472-3.469 3.546-3.469.993 0 1.847.074 2.096.107v2.43h-1.438c-1.128 0-1.391.536-1.391 1.322v1.859h2.813l-.563 2.813h-2.25l.045 6.75h4.83c.414 0 .75-.336.75-.75v-16.5c0-.414-.336-.75-.75-.75" transform="translate(-186-10)" fill="#fff"/></g></svg></a>
327
  </li>
328
  </ul>
329
  </div>
20
  <p class="imagify-meteo-subs"><?php _e( 'Your subscription:', 'imagify' ); ?>&nbsp;<strong class="imagify-user-plan"><?php echo $user->plan_label; ?></strong></p>
21
  </div>
22
  <div class="imagify-account-link">
23
+ <a href="<?php echo esc_url( imagify_get_external_url( 'subscription' ) ); ?>" class="button button-ghost" target="_blank">
24
  <span class="dashicons dashicons-admin-users"></span>
25
  <span class="button-text"><?php _e( 'View My Subscription', 'imagify' ); ?></span>
26
  </a>
72
  </div>
73
  <div class="cell-sep"></div>
74
  <div class="cell-cta">
75
+ <a href="<?php echo esc_url( imagify_get_external_url( 'subscription' ) ); ?>" target="_blank"><?php _e( 'More info', 'imagify' ); ?></a>
76
  </div>
77
  </div>
78
  </div>
154
 
155
  <p><?php _e( 'Optimized size', 'imagify' ); ?></p>
156
  <div class="imagify-bar-positive base-transparent right-outside-number">
157
+ <div id="imagify-optimized-bar" class="imagify-progress" style="width: <?php echo ( 100 - $optimized_percent ); ?>%"><span class="imagify-barnb"><?php echo size_format( $optimized_nb, 1 ); ?></span></div>
 
158
  </div>
159
 
160
  </div>
319
  <p><?php _e( 'Share your awesome result', 'imagify' ); ?></p>
320
  <ul class="imagify-share-networks">
321
  <li>
322
+ <a target="_blank" class="imagify-sn-twitter" href="<?php echo esc_url( imagify_get_external_url( 'share-twitter' ) ); ?>"><svg viewBox="0 0 23 18" width="23" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><title>Twitter</title><path d="m244.15 12.13c-.815.361-1.691.606-2.61.716.939-.563 1.659-1.453 1.998-2.514-.878.521-1.851.898-2.886 1.103-.829-.883-2.01-1.435-3.317-1.435-2.51 0-4.544 2.034-4.544 4.544 0 .356.04.703.118 1.035-3.777-.19-7.125-1.999-9.367-4.748-.391.671-.615 1.452-.615 2.285 0 1.576.802 2.967 2.02 3.782-.745-.024-1.445-.228-2.058-.568-.001.019-.001.038-.001.057 0 2.202 1.566 4.04 3.646 4.456-.381.104-.783.159-1.197.159-.293 0-.577-.028-.855-.081.578 1.805 2.256 3.119 4.245 3.156-1.555 1.219-3.515 1.945-5.644 1.945-.367 0-.728-.021-1.084-.063 2.01 1.289 4.399 2.041 6.966 2.041 8.359 0 12.929-6.925 12.929-12.929 0-.197-.004-.393-.013-.588.888-.64 1.658-1.44 2.268-2.352" transform="translate(-222-10)" fill="#fff"/></g></svg></a>
323
  </li>
324
  <li>
325
+ <a target="_blank" class="imagify-sn-facebook" href="<?php echo esc_url( imagify_get_external_url( 'share-facebook' ) ); ?>"><svg viewBox="0 0 18 18" width="18" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><title>Facebook</title><path d="m203.25 10h-16.5c-.415 0-.75.336-.75.75v16.5c0 .414.336.75.75.75h8.812v-6.75h-2.25v-2.813h2.25v-2.25c0-2.325 1.472-3.469 3.546-3.469.993 0 1.847.074 2.096.107v2.43h-1.438c-1.128 0-1.391.536-1.391 1.322v1.859h2.813l-.563 2.813h-2.25l.045 6.75h4.83c.414 0 .75-.336.75-.75v-16.5c0-.414-.336-.75-.75-.75" transform="translate(-186-10)" fill="#fff"/></g></svg></a>
326
  </li>
327
  </ul>
328
  </div>
inc/admin/ui/notice-free-over-quota.php CHANGED
@@ -19,7 +19,7 @@ $this->render_view( 'header', array(
19
  printf(
20
  /* translators: 1 is a link tag start, 2 is the link tag end. */
21
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
22
- '<a target="_blank" href="' . IMAGIFY_APP_MAIN . '/#/subscription">',
23
  '</a>'
24
  );
25
  ?>
19
  printf(
20
  /* translators: 1 is a link tag start, 2 is the link tag end. */
21
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
22
+ '<a target="_blank" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '">',
23
  '</a>'
24
  );
25
  ?>
inc/admin/ui/notice-rating.php CHANGED
@@ -16,19 +16,17 @@ $this->render_view( 'header' );
16
  </p>
17
  <p class="imagify-rate-us">
18
  <?php
19
- $imagify_rate_url = 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform';
20
-
21
  printf(
22
  /* translators: 1 is a "bold" tag start, 2 is the "bold" tag end + a line break tag, 3 is a link tag start, 4 is the link tag end. */
23
  __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'imagify' ),
24
  '<strong>',
25
  '</strong><br />',
26
- '<a target="_blank" href="' . $imagify_rate_url . '">',
27
  '</a>'
28
  );
29
  ?>
30
  <br>
31
- <a class="stars" target="_blank" href="<?php echo $imagify_rate_url; ?>">☆☆☆☆☆</a>
32
  </p>
33
  <?php
34
  $this->render_view( 'footer', array(
16
  </p>
17
  <p class="imagify-rate-us">
18
  <?php
 
 
19
  printf(
20
  /* translators: 1 is a "bold" tag start, 2 is the "bold" tag end + a line break tag, 3 is a link tag start, 4 is the link tag end. */
21
  __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'imagify' ),
22
  '<strong>',
23
  '</strong><br />',
24
+ '<a target="_blank" href="' . esc_url( imagify_get_external_url( 'rate' ) ) . '">',
25
  '</a>'
26
  );
27
  ?>
28
  <br>
29
+ <a class="stars" target="_blank" href="<?php echo esc_url( imagify_get_external_url( 'rate' ) ); ?>">☆☆☆☆☆</a>
30
  </p>
31
  <?php
32
  $this->render_view( 'footer', array(
inc/admin/ui/notice-welcome-steps.php CHANGED
@@ -18,7 +18,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
18
  <p class="imagify-col-desc"><?php _e( 'Don\'t have an Imagify account yet? Optimize your images by creating an account in a few seconds!', 'imagify' ); ?></p>
19
  <p>
20
  <?php wp_nonce_field( 'imagify-signup', 'imagifysignupnonce', false ); ?>
21
- <a id="imagify-signup" target="_blank" href="<?php echo IMAGIFY_APP_MAIN; ?>/#/register" class="button button-primary"><?php _e( 'Sign up, It\'s FREE!', 'imagify' ); ?></a>
22
  </p>
23
  </div>
24
  </div>
@@ -31,7 +31,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
31
  printf(
32
  /* translators: 1 is a link tag start, 2 is the link tag end. */
33
  __( 'Save your API Key you have received by email or you can get it on your %1$sImagify account page%2$s.', 'imagify' ),
34
- '<a target="_blank" href="' . IMAGIFY_APP_MAIN . '/#/api">',
35
  '</a>'
36
  );
37
  ?>
18
  <p class="imagify-col-desc"><?php _e( 'Don\'t have an Imagify account yet? Optimize your images by creating an account in a few seconds!', 'imagify' ); ?></p>
19
  <p>
20
  <?php wp_nonce_field( 'imagify-signup', 'imagifysignupnonce', false ); ?>
21
+ <a id="imagify-signup" target="_blank" href="<?php echo esc_url( imagify_get_external_url( 'register' ) ); ?>" class="button button-primary"><?php _e( 'Sign up, It\'s FREE!', 'imagify' ); ?></a>
22
  </p>
23
  </div>
24
  </div>
31
  printf(
32
  /* translators: 1 is a link tag start, 2 is the link tag end. */
33
  __( 'Save your API Key you have received by email or you can get it on your %1$sImagify account page%2$s.', 'imagify' ),
34
+ '<a target="_blank" href="' . esc_url( imagify_get_external_url( 'get-api-key' ) ) . '">',
35
  '</a>'
36
  );
37
  ?>
inc/admin/ui/notice-wrong-api-key.php CHANGED
@@ -12,7 +12,7 @@ $this->render_view( 'header', array(
12
  /* translators: 1 and 2 are link tag starts, 3 is a link tag end. */
13
  __( 'Go to your Imagify account page to get your API Key and specify it on %1$syour settings%3$s or %2$screate an account for free%3$s if you don\'t have one yet.', 'imagify' ),
14
  '<a href="' . esc_url( get_imagify_admin_url() ) . '">',
15
- '<a id="imagify-signup" target="_blank" href="' . IMAGIFY_WEB_MAIN . '">',
16
  '</a>'
17
  );
18
  ?>
12
  /* translators: 1 and 2 are link tag starts, 3 is a link tag end. */
13
  __( 'Go to your Imagify account page to get your API Key and specify it on %1$syour settings%3$s or %2$screate an account for free%3$s if you don\'t have one yet.', 'imagify' ),
14
  '<a href="' . esc_url( get_imagify_admin_url() ) . '">',
15
+ '<a id="imagify-signup" target="_blank" href="' . esc_url( imagify_get_external_url( 'register' ) ) . '">',
16
  '</a>'
17
  );
18
  ?>
inc/admin/ui/options.php CHANGED
@@ -68,7 +68,6 @@ function _imagify_display_options_page() {
68
  </small>
69
  </div>
70
 
71
- <?php $imagify_rate_url = 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform'; ?>
72
  <p class="imagify-rate-us">
73
  <?php
74
  printf(
@@ -76,12 +75,12 @@ function _imagify_display_options_page() {
76
  __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'imagify' ),
77
  '<strong>',
78
  '</strong><br />',
79
- '<a href="' . $imagify_rate_url . '">',
80
  '</a>'
81
  );
82
  ?>
83
  <br>
84
- <a class="stars" href="<?php echo $imagify_rate_url; ?>"><?php echo str_repeat( '<span class="dashicons dashicons-star-filled"></span>', 5 ); ?></a>
85
  </p>
86
  </div>
87
  <?php $form_action = ( imagify_is_active_for_network() ) ? admin_url( 'admin-post.php' ) : admin_url( 'options.php' ); ?>
@@ -131,7 +130,7 @@ function _imagify_display_options_page() {
131
  printf(
132
  /* translators: 1 is a link tag start, 2 is the link tag end. */
133
  __( 'Don\'t have an API Key yet? %1$sCreate one, it\'s FREE%2$s.', 'imagify' ),
134
- '<a id="imagify-signup" target="_blank" href="' . IMAGIFY_APP_MAIN . '/#/register">',
135
  '</a>'
136
  );
137
  echo '</p>';
@@ -267,7 +266,7 @@ function _imagify_display_options_page() {
267
  <span id="describe-exif" class="imagify-info">
268
  <span class="dashicons dashicons-info"></span>
269
  <?php _e( 'Keep all EXIF data from your images. EXIF are informations stored in your pictures like shutter speed, exposure compensation, ISO, etc...', 'imagify' ); ?>
270
- <a href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format" target="_blank"><?php _e( 'Learn more', 'imagify' ); ?></a>
271
  <br/><br/>
272
  <?php _e( 'If you are a photographer, you may be interested in this option if you are displaying on your pages some info like the model of your camera.', 'imagify' ); ?>
273
 
68
  </small>
69
  </div>
70
 
 
71
  <p class="imagify-rate-us">
72
  <?php
73
  printf(
75
  __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'imagify' ),
76
  '<strong>',
77
  '</strong><br />',
78
+ '<a href="' . esc_url( imagify_get_external_url( 'rate' ) ) . '" target="_blank">',
79
  '</a>'
80
  );
81
  ?>
82
  <br>
83
+ <a class="stars" href="<?php echo esc_url( imagify_get_external_url( 'rate' ) ); ?>" target="_blank"><?php echo str_repeat( '<span class="dashicons dashicons-star-filled"></span>', 5 ); ?></a>
84
  </p>
85
  </div>
86
  <?php $form_action = ( imagify_is_active_for_network() ) ? admin_url( 'admin-post.php' ) : admin_url( 'options.php' ); ?>
130
  printf(
131
  /* translators: 1 is a link tag start, 2 is the link tag end. */
132
  __( 'Don\'t have an API Key yet? %1$sCreate one, it\'s FREE%2$s.', 'imagify' ),
133
+ '<a id="imagify-signup" href="' . esc_url( imagify_get_external_url( 'register' ) ) . '" target="_blank">',
134
  '</a>'
135
  );
136
  echo '</p>';
266
  <span id="describe-exif" class="imagify-info">
267
  <span class="dashicons dashicons-info"></span>
268
  <?php _e( 'Keep all EXIF data from your images. EXIF are informations stored in your pictures like shutter speed, exposure compensation, ISO, etc...', 'imagify' ); ?>
269
+ <a href="<?php echo esc_url( imagify_get_external_url( 'exif' ) ); ?>" target="_blank"><?php _e( 'Learn more', 'imagify' ); ?></a>
270
  <br/><br/>
271
  <?php _e( 'If you are a photographer, you may be interested in this option if you are displaying on your pages some info like the model of your camera.', 'imagify' ); ?>
272
 
inc/classes/{abstracts/class-imagify-abstract-attachment.php → class-imagify-abstract-attachment.php} RENAMED
@@ -110,6 +110,18 @@ class Imagify_Abstract_Attachment {
110
  return imagify_is_attachment_mime_type_supported( $this->id );
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * Get the attachment error if there is one.
115
  *
110
  return imagify_is_attachment_mime_type_supported( $this->id );
111
  }
112
 
113
+ /**
114
+ * Tell if the current attachment has the required WP metadata.
115
+ *
116
+ * @since 1.6.12
117
+ * @author Grégory Viguier
118
+ *
119
+ * @return bool
120
+ */
121
+ public function has_required_metadata() {
122
+ return imagify_attachment_has_required_metadata( $this->id );
123
+ }
124
+
125
  /**
126
  * Get the attachment error if there is one.
127
  *
inc/classes/{abstracts/class-imagify-abstract-db.php → class-imagify-abstract-db.php} RENAMED
@@ -166,6 +166,27 @@ abstract class Imagify_Abstract_DB {
166
  return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); // WPCS: unprepared SQL ok.
167
  }
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  /**
170
  * Insert a new row.
171
  *
166
  return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); // WPCS: unprepared SQL ok.
167
  }
168
 
169
+ /**
170
+ * Retrieve a specific column's value by the the specified column / values.
171
+ *
172
+ * @access public
173
+ * @since 1.6.12
174
+ * @author Grégory Viguier
175
+ *
176
+ * @param string $column A column name.
177
+ * @param string $column_where A column name.
178
+ * @param array $column_values An array of values.
179
+ * @return string
180
+ */
181
+ public function get_column_in( $column, $column_where, $column_values ) {
182
+ global $wpdb;
183
+ $column = esc_sql( $column );
184
+ $column_where = esc_sql( $column_where );
185
+ $column_values = esc_sql( $column_values );
186
+ $column_values = "'" . implode( "','", $column_values ) . "'";
187
+ return $wpdb->get_var( "SELECT $column FROM $this->table_name WHERE $column_where IN ( $column_values ) LIMIT 1;" ); // WPCS: unprepared SQL ok.
188
+ }
189
+
190
  /**
191
  * Insert a new row.
192
  *
inc/classes/class-imagify-admin-ajax-post.php CHANGED
@@ -427,10 +427,14 @@ class Imagify_Admin_Ajax_Post {
427
  $ids = $wpdb->get_col( $wpdb->prepare( // WPCS: unprepared SQL ok.
428
  "SELECT $wpdb->posts.ID
429
  FROM $wpdb->posts
430
- LEFT JOIN $wpdb->postmeta
431
- ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_imagify_optimization_level' )
432
- LEFT JOIN $wpdb->postmeta AS mt1
433
- ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_imagify_status' )
 
 
 
 
434
  WHERE
435
  $wpdb->posts.post_mime_type IN ( $mime_types )
436
  AND (
@@ -441,8 +445,7 @@ class Imagify_Admin_Ajax_Post {
441
  mt1.meta_value = 'error'
442
  )
443
  AND $wpdb->posts.post_type = 'attachment'
444
- AND $wpdb->posts.post_status <> 'trash'
445
- AND $wpdb->posts.post_status <> 'auto-draft'
446
  GROUP BY $wpdb->posts.ID
447
  ORDER BY
448
  CASE mt1.meta_value
@@ -528,6 +531,11 @@ class Imagify_Admin_Ajax_Post {
528
  $data = array();
529
 
530
  foreach ( $ids as $i => $id ) {
 
 
 
 
 
531
  $file_path = get_imagify_attached_file( $results['filenames'][ $id ] );
532
 
533
  /** This filter is documented in inc/functions/process.php. */
@@ -714,7 +722,7 @@ class Imagify_Admin_Ajax_Post {
714
  $message .= '<p><i class="dashicons dashicons-warning" aria-hidden="true"></i><strong>' . __( 'Oops, It\'s almost over!', 'imagify' ) . '</strong></p>';
715
  /* translators: %s is a line break. */
716
  $message .= '<p>' . sprintf( __( 'You have almost used all your credit.%sDon\'t forget to upgrade your subscription to continue optimizing your images.', 'imagify' ), '<br/><br/>' ) . '</p>';
717
- $message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . IMAGIFY_APP_MAIN . '/#/subscription" target="_blank">' . __( 'View My Subscription', 'imagify' ) . '</a></p>';
718
  $message .= '</div>';
719
  }
720
 
@@ -727,7 +735,7 @@ class Imagify_Admin_Ajax_Post {
727
  size_format( $user->quota * 1048576 ),
728
  date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) )
729
  ) . '</p>';
730
- $message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . IMAGIFY_APP_MAIN . '/#/subscription" target="_blank">' . __( 'Upgrade My Subscription', 'imagify' ) . '</a></p>';
731
  $message .= '</div>';
732
  }
733
 
@@ -758,7 +766,7 @@ class Imagify_Admin_Ajax_Post {
758
  }
759
 
760
  $quota_section .= '<p class="imagify-abq-row">';
761
- $quota_section .= '<a class="imagify-account-link" href="' . IMAGIFY_APP_MAIN . '/#/subscription" target="_blank">';
762
  $quota_section .= '<span class="dashicons dashicons-admin-users"></span>';
763
  $quota_section .= '<span class="button-text">' . __( 'View my subscription', 'imagify' ) . '</span>';
764
  $quota_section .= '</a>'; // .imagify-account-link
427
  $ids = $wpdb->get_col( $wpdb->prepare( // WPCS: unprepared SQL ok.
428
  "SELECT $wpdb->posts.ID
429
  FROM $wpdb->posts
430
+ LEFT JOIN $wpdb->postmeta
431
+ ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_imagify_optimization_level' )
432
+ LEFT JOIN $wpdb->postmeta AS mt1
433
+ ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_imagify_status' )
434
+ INNER JOIN $wpdb->postmeta AS mt2
435
+ ON ( $wpdb->posts.ID = mt2.post_id AND mt2.meta_key = '_wp_attached_file' )
436
+ INNER JOIN $wpdb->postmeta AS mt3
437
+ ON ( $wpdb->posts.ID = mt3.post_id AND mt3.meta_key = '_wp_attachment_metadata' )
438
  WHERE
439
  $wpdb->posts.post_mime_type IN ( $mime_types )
440
  AND (
445
  mt1.meta_value = 'error'
446
  )
447
  AND $wpdb->posts.post_type = 'attachment'
448
+ AND $wpdb->posts.post_status = 'inherit'
 
449
  GROUP BY $wpdb->posts.ID
450
  ORDER BY
451
  CASE mt1.meta_value
531
  $data = array();
532
 
533
  foreach ( $ids as $i => $id ) {
534
+ if ( empty( $results['filenames'][ $id ] ) ) {
535
+ // Problem.
536
+ continue;
537
+ }
538
+
539
  $file_path = get_imagify_attached_file( $results['filenames'][ $id ] );
540
 
541
  /** This filter is documented in inc/functions/process.php. */
722
  $message .= '<p><i class="dashicons dashicons-warning" aria-hidden="true"></i><strong>' . __( 'Oops, It\'s almost over!', 'imagify' ) . '</strong></p>';
723
  /* translators: %s is a line break. */
724
  $message .= '<p>' . sprintf( __( 'You have almost used all your credit.%sDon\'t forget to upgrade your subscription to continue optimizing your images.', 'imagify' ), '<br/><br/>' ) . '</p>';
725
+ $message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">' . __( 'View My Subscription', 'imagify' ) . '</a></p>';
726
  $message .= '</div>';
727
  }
728
 
735
  size_format( $user->quota * 1048576 ),
736
  date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) )
737
  ) . '</p>';
738
+ $message .= '<p class="center txt-center text-center"><a class="btn imagify-btn-ghost" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">' . __( 'Upgrade My Subscription', 'imagify' ) . '</a></p>';
739
  $message .= '</div>';
740
  }
741
 
766
  }
767
 
768
  $quota_section .= '<p class="imagify-abq-row">';
769
+ $quota_section .= '<a class="imagify-account-link" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '" target="_blank">';
770
  $quota_section .= '<span class="dashicons dashicons-admin-users"></span>';
771
  $quota_section .= '<span class="button-text">' . __( 'View my subscription', 'imagify' ) . '</span>';
772
  $quota_section .= '</a>'; // .imagify-account-link
inc/classes/class-imagify-attachment.php CHANGED
@@ -221,6 +221,7 @@ class Imagify_Attachment extends Imagify_Abstract_Attachment {
221
 
222
  $original_dirname = trailingslashit( dirname( $this->get_original_path() ) );
223
  $thumbnail_path = $original_dirname . $thumbnail_data['file'];
 
224
 
225
  if ( ! empty( $metadata_sizes[ $thumbnail_size ] ) && $filesystem->exists( $thumbnail_path ) ) {
226
  imagify_chmod_file( $thumbnail_path );
@@ -243,7 +244,6 @@ class Imagify_Attachment extends Imagify_Abstract_Attachment {
243
  return new WP_Error( 'image_resize_error' );
244
  }
245
 
246
- $filesystem = imagify_get_filesystem();
247
  // The file name can change from what we expected (1px wider, etc).
248
  $backup_dirname = trailingslashit( dirname( $this->get_backup_path() ) );
249
  $backup_thumb_path = $backup_dirname . $result[ $thumbnail_size ]['file'];
221
 
222
  $original_dirname = trailingslashit( dirname( $this->get_original_path() ) );
223
  $thumbnail_path = $original_dirname . $thumbnail_data['file'];
224
+ $filesystem = imagify_get_filesystem();
225
 
226
  if ( ! empty( $metadata_sizes[ $thumbnail_size ] ) && $filesystem->exists( $thumbnail_path ) ) {
227
  imagify_chmod_file( $thumbnail_path );
244
  return new WP_Error( 'image_resize_error' );
245
  }
246
 
 
247
  // The file name can change from what we expected (1px wider, etc).
248
  $backup_dirname = trailingslashit( dirname( $this->get_backup_path() ) );
249
  $backup_thumb_path = $backup_dirname . $result[ $thumbnail_size ]['file'];
inc/classes/class-imagify.php CHANGED
@@ -500,15 +500,3 @@ class Imagify extends Imagify_Deprecated {
500
  return $response;
501
  }
502
  }
503
-
504
- /**
505
- * Returns the main instance of the Imagify class.
506
- *
507
- * @since 1.6.5
508
- * @author Grégory Viguier
509
- *
510
- * @return object The Imagify instance.
511
- */
512
- function imagify() {
513
- return Imagify::get_instance();
514
- }
500
  return $response;
501
  }
502
  }
 
 
 
 
 
 
 
 
 
 
 
 
inc/common/admin-bar.php CHANGED
@@ -39,13 +39,27 @@ function _imagify_admin_bar( $wp_admin_bar ) {
39
  ) );
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  // Rate it.
43
  $wp_admin_bar->add_menu(array(
44
  'parent' => 'imagify',
45
  'id' => 'imagify-rate-it',
46
  /* translators: %s is WordPress.org. */
47
  'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ),
48
- 'href' => 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform',
 
 
 
49
  ) );
50
 
51
  // Quota & Profile informations.
@@ -57,7 +71,7 @@ function _imagify_admin_bar( $wp_admin_bar ) {
57
  $wp_admin_bar->add_menu( array(
58
  'parent' => 'imagify',
59
  'id' => 'imagify-profile',
60
- 'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '<div id="wp-admin-bar-imagify-profile-loading">' . __( 'Loading...', 'imagify' ) . '</div><div id="wp-admin-bar-imagify-profile-content"></div>',
61
  ) );
62
  }
63
  }
39
  ) );
40
  }
41
 
42
+ // Documentation.
43
+ $wp_admin_bar->add_menu(array(
44
+ 'parent' => 'imagify',
45
+ 'id' => 'imagify-documentation',
46
+ 'title' => __( 'Documentation', 'imagify' ),
47
+ 'href' => imagify_get_external_url( 'documentation' ),
48
+ 'meta' => array(
49
+ 'target' => '_blank',
50
+ ),
51
+ ) );
52
+
53
  // Rate it.
54
  $wp_admin_bar->add_menu(array(
55
  'parent' => 'imagify',
56
  'id' => 'imagify-rate-it',
57
  /* translators: %s is WordPress.org. */
58
  'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ),
59
+ 'href' => imagify_get_external_url( 'rate' ),
60
+ 'meta' => array(
61
+ 'target' => '_blank',
62
+ ),
63
  ) );
64
 
65
  // Quota & Profile informations.
71
  $wp_admin_bar->add_menu( array(
72
  'parent' => 'imagify',
73
  'id' => 'imagify-profile',
74
+ 'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '<div id="wp-admin-bar-imagify-profile-loading" class="hide-if-no-js">' . __( 'Loading...', 'imagify' ) . '</div><div id="wp-admin-bar-imagify-profile-content" class="hide-if-no-js"></div>',
75
  ) );
76
  }
77
  }
inc/common/attachments.php CHANGED
@@ -19,6 +19,22 @@ function _imagify_optimize_attachment( $metadata, $attachment_id ) {
19
  return $metadata;
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  $context = 'wp';
23
  $action = 'imagify_async_optimize_upload_new_media';
24
  $_ajax_nonce = wp_create_nonce( 'new_media-' . $attachment_id );
19
  return $metadata;
20
  }
21
 
22
+ /**
23
+ * Allow to prevent automatic optimization for a specific attachment.
24
+ *
25
+ * @since 1.6.12
26
+ * @author Grégory Viguier
27
+ *
28
+ * @param bool $optimize True to optimize, false otherwise.
29
+ * @param int $attachment_id Attachment ID.
30
+ * @param array $metadata An array of attachment meta data.
31
+ */
32
+ $optimize = apply_filters( 'imagify_auto_optimize_attachment', true, $attachment_id, $metadata );
33
+
34
+ if ( ! $optimize ) {
35
+ return $metadata;
36
+ }
37
+
38
  $context = 'wp';
39
  $action = 'imagify_async_optimize_upload_new_media';
40
  $_ajax_nonce = wp_create_nonce( 'new_media-' . $attachment_id );
inc/functions/admin-stats.php CHANGED
@@ -39,9 +39,13 @@ function imagify_count_attachments() {
39
  "
40
  SELECT COUNT( ID )
41
  FROM $wpdb->posts
42
- WHERE post_mime_type IN ( $mime_types )
43
- AND post_type = 'attachment'
44
- AND post_status != 'trash'"
 
 
 
 
45
  );
46
 
47
  /**
@@ -98,11 +102,15 @@ function imagify_count_error_attachments() {
98
  SELECT COUNT( $wpdb->posts.ID )
99
  FROM $wpdb->posts
100
  INNER JOIN $wpdb->postmeta
101
- ON $wpdb->posts.ID = $wpdb->postmeta.post_id
 
 
 
 
102
  WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
103
  AND $wpdb->posts.post_type = 'attachment'
104
  AND $wpdb->posts.post_status = 'inherit'
105
- AND $wpdb->postmeta.meta_key = '_imagify_status' AND CAST( $wpdb->postmeta.meta_value AS CHAR ) = 'error'"
106
  );
107
 
108
  return $count;
@@ -147,14 +155,18 @@ function imagify_count_optimized_attachments() {
147
  SELECT COUNT( $wpdb->posts.ID )
148
  FROM $wpdb->posts
149
  INNER JOIN $wpdb->postmeta
150
- ON $wpdb->posts.ID = $wpdb->postmeta.post_id
 
 
 
 
151
  WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
152
  AND $wpdb->posts.post_type = 'attachment'
153
  AND $wpdb->posts.post_status = 'inherit'
154
  AND (
155
- ( $wpdb->postmeta.meta_key = '_imagify_status' AND CAST( $wpdb->postmeta.meta_value AS CHAR ) = 'success' )
156
  OR
157
- ( $wpdb->postmeta.meta_key = '_imagify_status' AND CAST( $wpdb->postmeta.meta_value AS CHAR ) = 'already_optimized' )
158
  )"
159
  );
160
 
@@ -298,11 +310,15 @@ function imagify_count_saving_data( $key = '' ) {
298
  $limit = absint( $limit );
299
 
300
  $attachment_ids = $wpdb->get_col(
301
- "SELECT post_id
302
  FROM $wpdb->postmeta
303
- WHERE meta_key = '_imagify_status'
304
- AND meta_value = 'success'
305
- ORDER BY CAST( post_id AS UNSIGNED )"
 
 
 
 
306
  );
307
  $wpdb->flush();
308
 
@@ -395,9 +411,13 @@ function imagify_calculate_total_size_images_library() {
395
  "
396
  SELECT ID
397
  FROM $wpdb->posts
398
- WHERE post_mime_type IN ( $mime_types )
399
- AND post_type = 'attachment'
400
- AND post_status = 'inherit'
 
 
 
 
401
  LIMIT 250
402
  " );
403
 
@@ -424,49 +444,50 @@ function imagify_calculate_total_size_images_library() {
424
  * @return int The current estimated average size of images uploaded per month.
425
  */
426
  function imagify_calculate_average_size_images_per_month() {
427
- $imagify_mime_types = get_imagify_mime_type();
428
-
429
- $partial_images_uploaded_last_month = new WP_Query( array(
430
  'post_type' => 'attachment',
431
  'post_status' => 'inherit',
432
- 'post_mime_type' => $imagify_mime_types,
433
  'posts_per_page' => 250,
434
  'fields' => 'ids',
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  'date_query' => array(
436
  array(
437
  'before' => 'now',
438
  'after' => '1 month ago',
439
  ),
440
  ),
441
- ) );
442
 
443
- $partial_images_uploaded_two_months_ago = new WP_Query( array(
444
- 'post_type' => 'attachment',
445
- 'post_status' => 'inherit',
446
- 'post_mime_type' => $imagify_mime_types,
447
- 'posts_per_page' => 250,
448
- 'fields' => 'ids',
449
- 'date_query' => array(
450
  array(
451
  'before' => '1 month ago',
452
  'after' => '2 months ago',
453
  ),
454
  ),
455
- ) );
456
 
457
- $partial_images_uploaded_three_months_ago = new WP_Query( array(
458
- 'post_type' => 'attachment',
459
- 'post_status' => 'inherit',
460
- 'post_mime_type' => $imagify_mime_types,
461
- 'posts_per_page' => 250,
462
- 'fields' => 'ids',
463
- 'date_query' => array(
464
  array(
465
  'before' => '2 months ago',
466
  'after' => '3 months ago',
467
  ),
468
  ),
469
- ) );
470
 
471
  $partial_images_uploaded_id = array_merge( $partial_images_uploaded_last_month->posts, $partial_images_uploaded_two_months_ago->posts, $partial_images_uploaded_three_months_ago->posts );
472
 
@@ -474,19 +495,15 @@ function imagify_calculate_average_size_images_per_month() {
474
  return 0;
475
  }
476
 
477
- $images_uploaded_id = new WP_Query( array(
478
- 'post_type' => 'attachment',
479
- 'post_status' => 'inherit',
480
- 'post_mime_type' => $imagify_mime_types,
481
  'posts_per_page' => -1,
482
- 'fields' => 'ids',
483
  'date_query' => array(
484
  array(
485
  'before' => 'now',
486
  'after' => '3 months ago',
487
  ),
488
  ),
489
- ) );
490
 
491
  if ( ! $images_uploaded_id->posts ) {
492
  return 0;
39
  "
40
  SELECT COUNT( ID )
41
  FROM $wpdb->posts
42
+ INNER JOIN $wpdb->postmeta
43
+ ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_wp_attached_file' )
44
+ INNER JOIN $wpdb->postmeta AS mt1
45
+ ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_wp_attachment_metadata' )
46
+ WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
47
+ AND $wpdb->posts.post_type = 'attachment'
48
+ AND $wpdb->posts.post_status = 'inherit'"
49
  );
50
 
51
  /**
102
  SELECT COUNT( $wpdb->posts.ID )
103
  FROM $wpdb->posts
104
  INNER JOIN $wpdb->postmeta
105
+ ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_imagify_status' )
106
+ INNER JOIN $wpdb->postmeta AS mt1
107
+ ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_wp_attached_file' )
108
+ INNER JOIN $wpdb->postmeta AS mt2
109
+ ON ( $wpdb->posts.ID = mt2.post_id AND mt2.meta_key = '_wp_attachment_metadata' )
110
  WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
111
  AND $wpdb->posts.post_type = 'attachment'
112
  AND $wpdb->posts.post_status = 'inherit'
113
+ AND $wpdb->postmeta.meta_value = 'error'"
114
  );
115
 
116
  return $count;
155
  SELECT COUNT( $wpdb->posts.ID )
156
  FROM $wpdb->posts
157
  INNER JOIN $wpdb->postmeta
158
+ ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_imagify_status' )
159
+ INNER JOIN $wpdb->postmeta AS mt1
160
+ ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_wp_attached_file' )
161
+ INNER JOIN $wpdb->postmeta AS mt2
162
+ ON ( $wpdb->posts.ID = mt2.post_id AND mt2.meta_key = '_wp_attachment_metadata' )
163
  WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
164
  AND $wpdb->posts.post_type = 'attachment'
165
  AND $wpdb->posts.post_status = 'inherit'
166
  AND (
167
+ $wpdb->postmeta.meta_value = 'success'
168
  OR
169
+ $wpdb->postmeta.meta_value = 'already_optimized'
170
  )"
171
  );
172
 
310
  $limit = absint( $limit );
311
 
312
  $attachment_ids = $wpdb->get_col(
313
+ "SELECT $wpdb->postmeta.post_id
314
  FROM $wpdb->postmeta
315
+ INNER JOIN $wpdb->postmeta AS mt1
316
+ ON ( $wpdb->postmeta.post_id = mt1.post_id AND mt1.meta_key = '_wp_attached_file' )
317
+ INNER JOIN $wpdb->postmeta AS mt2
318
+ ON ( $wpdb->postmeta.post_id = mt2.post_id AND mt2.meta_key = '_wp_attachment_metadata' )
319
+ WHERE $wpdb->postmeta.meta_key = '_imagify_status'
320
+ AND $wpdb->postmeta.meta_value = 'success'
321
+ ORDER BY CAST( $wpdb->postmeta.post_id AS UNSIGNED )"
322
  );
323
  $wpdb->flush();
324
 
411
  "
412
  SELECT ID
413
  FROM $wpdb->posts
414
+ INNER JOIN $wpdb->postmeta
415
+ ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '_wp_attached_file' )
416
+ INNER JOIN $wpdb->postmeta AS mt1
417
+ ON ( $wpdb->posts.ID = mt1.post_id AND mt1.meta_key = '_wp_attachment_metadata' )
418
+ WHERE $wpdb->posts.post_mime_type IN ( $mime_types )
419
+ AND $wpdb->posts.post_type = 'attachment'
420
+ AND $wpdb->posts.post_status = 'inherit'
421
  LIMIT 250
422
  " );
423
 
444
  * @return int The current estimated average size of images uploaded per month.
445
  */
446
  function imagify_calculate_average_size_images_per_month() {
447
+ $query = array(
 
 
448
  'post_type' => 'attachment',
449
  'post_status' => 'inherit',
450
+ 'post_mime_type' => get_imagify_mime_type(),
451
  'posts_per_page' => 250,
452
  'fields' => 'ids',
453
+ 'meta_query' => array(
454
+ array(
455
+ 'key' => '_wp_attached_file',
456
+ 'compare' => 'EXISTS',
457
+ ),
458
+ array(
459
+ 'key' => '_wp_attachment_metadata',
460
+ 'compare' => 'EXISTS',
461
+ ),
462
+ ),
463
+ );
464
+
465
+ $partial_images_uploaded_last_month = new WP_Query( array_merge( $query, array(
466
  'date_query' => array(
467
  array(
468
  'before' => 'now',
469
  'after' => '1 month ago',
470
  ),
471
  ),
472
+ ) ) );
473
 
474
+ $partial_images_uploaded_two_months_ago = new WP_Query( array_merge( $query, array(
475
+ 'date_query' => array(
 
 
 
 
 
476
  array(
477
  'before' => '1 month ago',
478
  'after' => '2 months ago',
479
  ),
480
  ),
481
+ ) ) );
482
 
483
+ $partial_images_uploaded_three_months_ago = new WP_Query( array_merge( $query, array(
484
+ 'date_query' => array(
 
 
 
 
 
485
  array(
486
  'before' => '2 months ago',
487
  'after' => '3 months ago',
488
  ),
489
  ),
490
+ ) ) );
491
 
492
  $partial_images_uploaded_id = array_merge( $partial_images_uploaded_last_month->posts, $partial_images_uploaded_two_months_ago->posts, $partial_images_uploaded_three_months_ago->posts );
493
 
495
  return 0;
496
  }
497
 
498
+ $images_uploaded_id = new WP_Query( array_merge( $query, array(
 
 
 
499
  'posts_per_page' => -1,
 
500
  'date_query' => array(
501
  array(
502
  'before' => 'now',
503
  'after' => '3 months ago',
504
  ),
505
  ),
506
+ ) ) );
507
 
508
  if ( ! $images_uploaded_id->posts ) {
509
  return 0;
inc/functions/admin-ui.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
4
  /**
5
  * Get the optimization data list for a specific attachment.
6
  *
7
- * @since 1.0
8
  * @author Jonathan Buttigieg
9
  *
10
  * @param object $attachment The attachment object.
@@ -129,7 +129,7 @@ function get_imagify_attachment_optimization_text( $attachment, $context = 'wp'
129
  /**
130
  * Get the error message for a specific attachment.
131
  *
132
- * @since 1.0
133
  * @author Jonathan Buttigieg
134
  *
135
  * @param object $attachment The attachement object.
@@ -161,7 +161,7 @@ function get_imagify_attachment_error_text( $attachment, $context = 'wp' ) {
161
  /**
162
  * Get the re-optimize link for a specific attachment.
163
  *
164
- * @since 1.0
165
  * @author Jonathan Buttigieg
166
  *
167
  * @param object $attachment The attachement object.
@@ -274,7 +274,7 @@ function get_imagify_attachment_optimize_missing_thumbnails_link( $attachment, $
274
  /**
275
  * Get all data to diplay for a specific attachment.
276
  *
277
- * @since 1.2
278
  * @author Jonathan Buttigieg
279
  *
280
  * @param object $attachment The attachement object.
@@ -282,19 +282,23 @@ function get_imagify_attachment_optimize_missing_thumbnails_link( $attachment, $
282
  * @return string The output to print.
283
  */
284
  function get_imagify_media_column_content( $attachment, $context = 'wp' ) {
285
- $attachment_id = $attachment->id;
286
- $attachment_ext = $attachment->get_extension();
287
-
288
- if ( ! imagify_current_user_can( 'manual-optimize', $attachment_id ) ) {
289
  return __( 'You are not allowed to optimize this file.', 'imagify' );
290
  }
291
 
292
  // Check if the attachment extension is allowed.
293
  if ( ! $attachment->is_mime_type_supported() ) {
 
 
294
  /* translators: %s is a file extension. */
295
  return sprintf( __( '%s can\'t be optimized', 'imagify' ), strtoupper( $attachment_ext ) );
296
  }
297
 
 
 
 
 
 
298
  // Check if the API key is valid.
299
  if ( ! imagify_valid_key() && ! $attachment->is_optimized() ) {
300
  $output = __( 'Invalid API key', 'imagify' );
@@ -304,7 +308,7 @@ function get_imagify_media_column_content( $attachment, $context = 'wp' ) {
304
  }
305
 
306
  $transient_context = ( 'wp' !== $context ) ? strtolower( $context ) . '-' : '';
307
- $transient_name = 'imagify-' . $transient_context . 'async-in-progress-' . $attachment_id;
308
 
309
  if ( false !== get_transient( $transient_name ) ) {
310
  return '<div class="button"><span class="imagify-spinner"></span>' . __( 'Optimizing...', 'imagify' ) . '</div>';
@@ -313,10 +317,10 @@ function get_imagify_media_column_content( $attachment, $context = 'wp' ) {
313
  // Check if the image was optimized.
314
  if ( ! $attachment->is_optimized() && ! $attachment->has_error() ) {
315
  $args = array(
316
- 'attachment_id' => $attachment_id,
317
  'context' => $context,
318
  );
319
- $output = '<a id="imagify-upload-' . $attachment_id . '" href="' . esc_url( get_imagify_admin_url( 'manual-upload', $args ) ) . '" class="button-primary button-imagify-manual-upload" data-waiting-label="' . esc_attr__( 'Optimizing...', 'imagify' ) . '">' . __( 'Optimize', 'imagify' ) . '</a>';
320
 
321
  if ( $attachment->has_backup() ) {
322
  $output .= '<span class="attachment-has-backup hidden"></span>';
@@ -388,8 +392,8 @@ function get_imagify_price_table_format( $value ) {
388
  /**
389
  * Get the payment modal HTML.
390
  *
391
- * @since 1.6
392
- * @since 1.6.3 Include discount banners.
393
  * @author Geoffrey
394
  *
395
  * @todo Make first offers dynamic thanks to consumption estimation.
@@ -701,7 +705,7 @@ function imagify_payment_modal() {
701
  </p>
702
  </div>
703
  <div class="imagify-col imagify-txt-end">
704
- <p><a class="button imagify-button-ghost imagify-button-medium imagify-mt1 imagify-mb1 imagify-mr1" href="https://imagify.io/<?php echo ( get_locale() === 'fr_FR' ? 'fr/' : '' ); ?>contact" target="_blank"><i class="dashicons dashicons-email" aria-hidden="true"></i>&nbsp;<?php esc_html_e( 'Contact Us', 'imagify' ); ?></a></p>
705
  </div>
706
  </div>
707
 
@@ -757,9 +761,7 @@ function imagify_payment_modal() {
757
 
758
  <div class="imagify-modal-views imagify-payment-process-view" id="imagify-payment-process-view" aria-hidden="true">
759
 
760
- <?php $imagify_api_key = get_imagify_option( 'api_key', false ); ?>
761
-
762
- <iframe data-imagify-api="<?php echo $imagify_api_key; ?>" id="imagify-payment-iframe" data-src="<?php echo IMAGIFY_PAYMENT_URL; ?>" name="imagify-payment-iframe" src="" frameborder="0"></iframe>
763
 
764
  </div><!-- .imagify-modal-views -->
765
 
@@ -832,8 +834,8 @@ function imagify_payment_modal() {
832
  /**
833
  * Print the discount banner used inside Payment Modal.
834
  *
835
- * @author Geoffrey Crofte
836
  * @since 1.6.3
 
837
  *
838
  * @return void
839
  */
4
  /**
5
  * Get the optimization data list for a specific attachment.
6
  *
7
+ * @since 1.0
8
  * @author Jonathan Buttigieg
9
  *
10
  * @param object $attachment The attachment object.
129
  /**
130
  * Get the error message for a specific attachment.
131
  *
132
+ * @since 1.0
133
  * @author Jonathan Buttigieg
134
  *
135
  * @param object $attachment The attachement object.
161
  /**
162
  * Get the re-optimize link for a specific attachment.
163
  *
164
+ * @since 1.0
165
  * @author Jonathan Buttigieg
166
  *
167
  * @param object $attachment The attachement object.
274
  /**
275
  * Get all data to diplay for a specific attachment.
276
  *
277
+ * @since 1.2
278
  * @author Jonathan Buttigieg
279
  *
280
  * @param object $attachment The attachement object.
282
  * @return string The output to print.
283
  */
284
  function get_imagify_media_column_content( $attachment, $context = 'wp' ) {
285
+ if ( ! imagify_current_user_can( 'manual-optimize', $attachment->id ) ) {
 
 
 
286
  return __( 'You are not allowed to optimize this file.', 'imagify' );
287
  }
288
 
289
  // Check if the attachment extension is allowed.
290
  if ( ! $attachment->is_mime_type_supported() ) {
291
+ $attachment_ext = $attachment->get_extension();
292
+
293
  /* translators: %s is a file extension. */
294
  return sprintf( __( '%s can\'t be optimized', 'imagify' ), strtoupper( $attachment_ext ) );
295
  }
296
 
297
+ // Check if the attachment has the required WP metadata.
298
+ if ( ! $attachment->has_required_metadata() ) {
299
+ return __( 'This media lacks the required metadata and can\'t be optimized.', 'imagify' );
300
+ }
301
+
302
  // Check if the API key is valid.
303
  if ( ! imagify_valid_key() && ! $attachment->is_optimized() ) {
304
  $output = __( 'Invalid API key', 'imagify' );
308
  }
309
 
310
  $transient_context = ( 'wp' !== $context ) ? strtolower( $context ) . '-' : '';
311
+ $transient_name = 'imagify-' . $transient_context . 'async-in-progress-' . $attachment->id;
312
 
313
  if ( false !== get_transient( $transient_name ) ) {
314
  return '<div class="button"><span class="imagify-spinner"></span>' . __( 'Optimizing...', 'imagify' ) . '</div>';
317
  // Check if the image was optimized.
318
  if ( ! $attachment->is_optimized() && ! $attachment->has_error() ) {
319
  $args = array(
320
+ 'attachment_id' => $attachment->id,
321
  'context' => $context,
322
  );
323
+ $output = '<a id="imagify-upload-' . $attachment->id . '" href="' . esc_url( get_imagify_admin_url( 'manual-upload', $args ) ) . '" class="button-primary button-imagify-manual-upload" data-waiting-label="' . esc_attr__( 'Optimizing...', 'imagify' ) . '">' . __( 'Optimize', 'imagify' ) . '</a>';
324
 
325
  if ( $attachment->has_backup() ) {
326
  $output .= '<span class="attachment-has-backup hidden"></span>';
392
  /**
393
  * Get the payment modal HTML.
394
  *
395
+ * @since 1.6
396
+ * @since 1.6.3 Include discount banners.
397
  * @author Geoffrey
398
  *
399
  * @todo Make first offers dynamic thanks to consumption estimation.
705
  </p>
706
  </div>
707
  <div class="imagify-col imagify-txt-end">
708
+ <p><a class="button imagify-button-ghost imagify-button-medium imagify-mt1 imagify-mb1 imagify-mr1" href="<?php echo esc_html( imagify_get_external_url( 'contact' ) ); ?>" target="_blank"><i class="dashicons dashicons-email" aria-hidden="true"></i>&nbsp;<?php esc_html_e( 'Contact Us', 'imagify' ); ?></a></p>
709
  </div>
710
  </div>
711
 
761
 
762
  <div class="imagify-modal-views imagify-payment-process-view" id="imagify-payment-process-view" aria-hidden="true">
763
 
764
+ <iframe data-imagify-api="<?php echo esc_attr( get_imagify_option( 'api_key' ) ); ?>" id="imagify-payment-iframe" data-src="<?php echo esc_url( imagify_get_external_url( 'payment' ) ); ?>" name="imagify-payment-iframe" src="" frameborder="0"></iframe>
 
 
765
 
766
  </div><!-- .imagify-modal-views -->
767
 
834
  /**
835
  * Print the discount banner used inside Payment Modal.
836
  *
 
837
  * @since 1.6.3
838
+ * @author Geoffrey Crofte
839
  *
840
  * @return void
841
  */
inc/functions/admin.php CHANGED
@@ -6,7 +6,7 @@ defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
6
  *
7
  * @since 1.0
8
  *
9
- * return bool True if Imagify is activated on the network
10
  */
11
  function imagify_is_active_for_network() {
12
  static $is;
6
  *
7
  * @since 1.0
8
  *
9
+ * return bool True if Imagify is activated on the network.
10
  */
11
  function imagify_is_active_for_network() {
12
  static $is;
inc/functions/api.php CHANGED
@@ -1,6 +1,18 @@
1
  <?php
2
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  /**
5
  * Create a new user on Imagify.
6
  *
1
  <?php
2
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
 
4
+ /**
5
+ * Returns the main instance of the Imagify class.
6
+ *
7
+ * @since 1.6.5
8
+ * @author Grégory Viguier
9
+ *
10
+ * @return object The Imagify instance.
11
+ */
12
+ function imagify() {
13
+ return Imagify::get_instance();
14
+ }
15
+
16
  /**
17
  * Create a new user on Imagify.
18
  *
inc/functions/attachments.php CHANGED
@@ -80,6 +80,19 @@ function imagify_is_attachment_mime_type_supported( $attachment_id ) {
80
  return $is[ $attachment_id ];
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  * Get the path to the backups directory.
85
  *
80
  return $is[ $attachment_id ];
81
  }
82
 
83
+ /**
84
+ * Tell if the attachment has the required WP metadata.
85
+ *
86
+ * @since 1.6.12
87
+ * @author Grégory Viguier
88
+ *
89
+ * @param int $attachment_id The attachment ID.
90
+ * @return bool
91
+ */
92
+ function imagify_attachment_has_required_metadata( $attachment_id ) {
93
+ return get_attached_file( $attachment_id, true ) && wp_get_attachment_metadata( $attachment_id, true );
94
+ }
95
+
96
  /**
97
  * Get the path to the backups directory.
98
  *
inc/functions/common.php CHANGED
@@ -124,3 +124,126 @@ function imagify_sanitize_context( $context ) {
124
  $context = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $context );
125
  return $context ? $context : 'wp';
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  $context = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $context );
125
  return $context ? $context : 'wp';
126
  }
127
+
128
+ /**
129
+ * Classes autoloader.
130
+ *
131
+ * @since 1.6.12
132
+ * @author Grégory Viguier
133
+ *
134
+ * @param string $class Name of the class to include.
135
+ */
136
+ function imagify_autoload( $class ) {
137
+ // Generic classes.
138
+ $classes = array(
139
+ 'Imagify_Abstract_Attachment' => 1,
140
+ 'Imagify_Abstract_DB' => 1,
141
+ 'Imagify_Admin_Ajax_Post' => 1,
142
+ 'Imagify_Assets' => 1,
143
+ 'Imagify_Attachment' => 1,
144
+ 'Imagify_Notices' => 1,
145
+ 'Imagify_User' => 1,
146
+ 'Imagify' => 1,
147
+ );
148
+
149
+ if ( isset( $classes[ $class ] ) ) {
150
+ $class = str_replace( '_', '-', strtolower( $class ) );
151
+ include IMAGIFY_CLASSES_PATH . 'class-' . $class . '.php';
152
+ return;
153
+ }
154
+
155
+ // Third party classes.
156
+ $classes = array(
157
+ 'Imagify_AS3CF_Attachment' => 'amazon-s3-and-cloudfront',
158
+ 'Imagify_AS3CF' => 'amazon-s3-and-cloudfront',
159
+ 'Imagify_Enable_Media_Replace' => 'enable-media-replace',
160
+ 'Imagify_NGG_Attachment' => 'nextgen-gallery',
161
+ 'Imagify_NGG_DB' => 'nextgen-gallery',
162
+ 'Imagify_NGG_Storage' => 'nextgen-gallery',
163
+ 'Imagify_NGG' => 'nextgen-gallery',
164
+ );
165
+
166
+ if ( isset( $classes[ $class ] ) ) {
167
+ $folder = $classes[ $class ];
168
+ $class = str_replace( '_', '-', strtolower( $class ) );
169
+ include IMAGIFY_3RD_PARTY_PATH . $folder . '/inc/classes/class-' . $class . '.php';
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Simple helper to get some external URLs, like to the documentation.
175
+ *
176
+ * @since 1.6.12
177
+ * @author Grégory Viguier
178
+ *
179
+ * @param string $target What we want.
180
+ * @param array $query_args An array of query arguments.
181
+ * @return string The URL.
182
+ */
183
+ function imagify_get_external_url( $target, $query_args = array() ) {
184
+ $site_url = 'https://imagify.io/';
185
+ $app_url = 'https://app.imagify.io/#/';
186
+
187
+ switch ( $target ) {
188
+ case 'plugin':
189
+ /* translators: Plugin URI of the plugin/theme */
190
+ $url = __( 'https://wordpress.org/plugins/imagify/', 'imagify' );
191
+ break;
192
+
193
+ case 'rate':
194
+ $url = 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform';
195
+ break;
196
+
197
+ case 'share-twitter':
198
+ $url = rawurlencode( imagify_get_external_url( 'plugin' ) );
199
+ $url = 'https://twitter.com/intent/tweet?source=webclient&original_referer=' . $url . '&url=' . $url . '&related=imagify&hastags=performance,web,wordpress';
200
+ break;
201
+
202
+ case 'share-facebook':
203
+ $url = rawurlencode( imagify_get_external_url( 'plugin' ) );
204
+ $url = 'https://www.facebook.com/sharer/sharer.php?u=' . $url;
205
+ break;
206
+
207
+ case 'exif':
208
+ /* translators: URL to a Wikipedia page explaining what EXIF means. */
209
+ $url = __( 'https://en.wikipedia.org/wiki/Exchangeable_image_file_format', 'imagify' );
210
+ break;
211
+
212
+ case 'contact':
213
+ $locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
214
+ $paths = array(
215
+ 'default' => 'contact',
216
+ 'fr_FR' => 'fr/contact',
217
+ );
218
+
219
+ $url = isset( $paths[ $locale ] ) ? $paths[ $locale ] : $paths['default'];
220
+ $url = $site_url . $url . '/';
221
+ break;
222
+
223
+ case 'documentation':
224
+ $url = $site_url . 'documentation/';
225
+ break;
226
+
227
+ case 'register':
228
+ return $app_url . 'register';
229
+
230
+ case 'subscription':
231
+ return $app_url . 'subscription';
232
+
233
+ case 'get-api-key':
234
+ return $app_url . 'api';
235
+
236
+ case 'payment':
237
+ // Don't remove the trailing slash.
238
+ return $app_url . 'plugin/';
239
+
240
+ default:
241
+ return '';
242
+ }
243
+
244
+ if ( $query_args ) {
245
+ $url = add_query_arg( $query_args, $url );
246
+ }
247
+
248
+ return $url;
249
+ }
inc/functions/compat.php CHANGED
@@ -9,9 +9,9 @@ if ( ! function_exists( 'curl_file_create' ) ) :
9
  /**
10
  * PHP-agnostic version of curl_file_create(): create a CURLFile object.
11
  *
12
- * @since 1.0
13
- * @since PHP 5.5
14
- * @see http://dk2.php.net/manual/en/function.curl-file-create.php
15
  *
16
  * @param string $filename Path to the file which will be uploaded.
17
  * @param string $mimetype Mimetype of the file.
@@ -31,8 +31,7 @@ if ( ! function_exists( 'array_replace' ) ) :
31
  *
32
  * @since 1.6.9
33
  * @since PHP 5.3
34
- * @see http://dk2.php.net/manual/en/function.array-replace.php
35
- * @author Grégory Viguier
36
  *
37
  * @param array $target The array in which elements are replaced.
38
  * @param array $replacements The array from which elements will be extracted.
@@ -58,6 +57,107 @@ if ( ! function_exists( 'array_replace' ) ) :
58
  }
59
  endif;
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /** --------------------------------------------------------------------------------------------- */
62
  /** WORDPRESS =================================================================================== */
63
  /** --------------------------------------------------------------------------------------------- */
9
  /**
10
  * PHP-agnostic version of curl_file_create(): create a CURLFile object.
11
  *
12
+ * @since 1.0
13
+ * @since PHP 5.5
14
+ * @source http://dk2.php.net/manual/en/function.curl-file-create.php
15
  *
16
  * @param string $filename Path to the file which will be uploaded.
17
  * @param string $mimetype Mimetype of the file.
31
  *
32
  * @since 1.6.9
33
  * @since PHP 5.3
34
+ * @source http://dk2.php.net/manual/en/function.array-replace.php
 
35
  *
36
  * @param array $target The array in which elements are replaced.
37
  * @param array $replacements The array from which elements will be extracted.
57
  }
58
  endif;
59
 
60
+ // SPL can be disabled on PHP 5.2.
61
+ if ( ! function_exists( 'spl_autoload_register' ) ) :
62
+ $_wp_spl_autoloaders = array();
63
+
64
+ /**
65
+ * Autoloader compatibility callback.
66
+ *
67
+ * @since 1.6.12
68
+ * @since WP 4.6.0
69
+ * @source WordPress
70
+ *
71
+ * @param string $classname Class to attempt autoloading.
72
+ */
73
+ function __autoload( $classname ) {
74
+ global $_wp_spl_autoloaders;
75
+ foreach ( $_wp_spl_autoloaders as $autoloader ) {
76
+ if ( ! is_callable( $autoloader ) ) {
77
+ // Avoid the extra warning if the autoloader isn't callable.
78
+ continue;
79
+ }
80
+
81
+ call_user_func( $autoloader, $classname );
82
+
83
+ // If it has been autoloaded, stop processing.
84
+ if ( class_exists( $classname, false ) ) {
85
+ return;
86
+ }
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Registers a function to be autoloaded.
92
+ *
93
+ * @since 1.6.12
94
+ * @since WP 4.6.0
95
+ * @source WordPress
96
+ *
97
+ * @throws Exception If the function to register is not callable.
98
+ *
99
+ * @param callable $autoload_function The function to register.
100
+ * @param bool $throw Optional. Whether the function should throw an exception
101
+ * if the function isn't callable. Default true.
102
+ * @param bool $prepend Whether the function should be prepended to the stack.
103
+ * Default false.
104
+ */
105
+ function spl_autoload_register( $autoload_function, $throw = true, $prepend = false ) {
106
+ if ( $throw && ! is_callable( $autoload_function ) ) {
107
+ // String not translated to match PHP core.
108
+ throw new Exception( 'Function not callable' );
109
+ }
110
+
111
+ global $_wp_spl_autoloaders;
112
+
113
+ // Don't allow multiple registration.
114
+ if ( in_array( $autoload_function, $_wp_spl_autoloaders, true ) ) {
115
+ return;
116
+ }
117
+
118
+ if ( $prepend ) {
119
+ array_unshift( $_wp_spl_autoloaders, $autoload_function );
120
+ } else {
121
+ $_wp_spl_autoloaders[] = $autoload_function;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Unregisters an autoloader function.
127
+ *
128
+ * @since 1.6.12
129
+ * @since WP 4.6.0
130
+ * @source WordPress
131
+ *
132
+ * @param callable $function The function to unregister.
133
+ * @return bool True if the function was unregistered, false if it could not be.
134
+ */
135
+ function spl_autoload_unregister( $function ) {
136
+ global $_wp_spl_autoloaders;
137
+ foreach ( $_wp_spl_autoloaders as &$autoloader ) {
138
+ if ( $autoloader === $function ) {
139
+ unset( $autoloader );
140
+ return true;
141
+ }
142
+ }
143
+
144
+ return false;
145
+ }
146
+
147
+ /**
148
+ * Retrieves the registered autoloader functions.
149
+ *
150
+ * @since 1.6.12
151
+ * @since WP 4.6.0
152
+ * @source WordPress
153
+ *
154
+ * @return array List of autoloader functions.
155
+ */
156
+ function spl_autoload_functions() {
157
+ return $GLOBALS['_wp_spl_autoloaders'];
158
+ }
159
+ endif;
160
+
161
  /** --------------------------------------------------------------------------------------------- */
162
  /** WORDPRESS =================================================================================== */
163
  /** --------------------------------------------------------------------------------------------- */
inc/functions/deprecated.php CHANGED
@@ -11,7 +11,7 @@ class Imagify_Deprecated {
11
  /**
12
  * A shorthand to display a message about a deprecated method.
13
  *
14
- * @since 1.6.5
15
  * @author Grégory Viguier
16
  *
17
  * @param string $method_name The deprecated method.
@@ -31,7 +31,7 @@ class Imagify_Deprecated {
31
  */
32
  public static function instance() {
33
  $class_name = get_class( $this );
34
- _deprecated_function( $class_name . '::' . __FUNCTION__ . '()', '1.6.5', 'imagify()' );
35
  return Imagify::get_instance();
36
  }
37
 
@@ -184,7 +184,6 @@ class Imagify_Deprecated {
184
  }
185
  }
186
 
187
-
188
  if ( class_exists( 'WpeCommon' ) ) :
189
 
190
  /**
@@ -253,7 +252,6 @@ function _imagify_admin_bar_styles() {
253
  }
254
  }
255
 
256
-
257
  /**
258
  * Make an absolute path relative to WordPress' root folder.
259
  * Also works for files from registered symlinked plugins.
@@ -271,6 +269,78 @@ function imagify_make_file_path_replative( $file_path ) {
271
  return imagify_make_file_path_relative( $file_path );
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  if ( is_admin() ) :
275
 
276
  /**
11
  /**
12
  * A shorthand to display a message about a deprecated method.
13
  *
14
+ * @since 1.6.5
15
  * @author Grégory Viguier
16
  *
17
  * @param string $method_name The deprecated method.
31
  */
32
  public static function instance() {
33
  $class_name = get_class( $this );
34
+ _deprecated_function( $class_name . '::' . __FUNCTION__ . '()', '1.6.5', 'Imagify::get_instance()' );
35
  return Imagify::get_instance();
36
  }
37
 
184
  }
185
  }
186
 
 
187
  if ( class_exists( 'WpeCommon' ) ) :
188
 
189
  /**
252
  }
253
  }
254
 
 
255
  /**
256
  * Make an absolute path relative to WordPress' root folder.
257
  * Also works for files from registered symlinked plugins.
269
  return imagify_make_file_path_relative( $file_path );
270
  }
271
 
272
+ if ( is_admin() && ( function_exists( 'as3cf_init' ) || function_exists( 'as3cf_pro_init' ) ) ) :
273
+
274
+ /**
275
+ * Returns the main instance of the Imagify_AS3CF class.
276
+ *
277
+ * @since 1.6.6
278
+ * @since 1.6.12 Deprecated.
279
+ * @author Grégory Viguier
280
+ *
281
+ * @return object The Imagify_AS3CF instance.
282
+ */
283
+ function imagify_as3cf() {
284
+ _deprecated_function( __FUNCTION__ . '()', '1.6.12', 'Imagify_AS3CF::get_instance()' );
285
+
286
+ return Imagify_AS3CF::get_instance();
287
+ }
288
+
289
+ endif;
290
+
291
+ if ( function_exists( 'enable_media_replace' ) ) :
292
+
293
+ /**
294
+ * Returns the main instance of the Imagify_Enable_Media_Replace class.
295
+ *
296
+ * @since 1.6.9
297
+ * @since 1.6.12 Deprecated.
298
+ * @author Grégory Viguier
299
+ *
300
+ * @return object The Imagify_Enable_Media_Replace instance.
301
+ */
302
+ function imagify_enable_media_replace() {
303
+ _deprecated_function( __FUNCTION__ . '()', '1.6.12', 'Imagify_Enable_Media_Replace::get_instance()' );
304
+
305
+ return Imagify_Enable_Media_Replace::get_instance();
306
+ }
307
+
308
+ endif;
309
+
310
+ if ( class_exists( 'C_NextGEN_Bootstrap' ) && class_exists( 'Mixin' ) && get_site_option( 'ngg_options' ) ) :
311
+
312
+ /**
313
+ * Returns the main instance of the Imagify_NGG class.
314
+ *
315
+ * @since 1.6.5
316
+ * @since 1.6.12 Deprecated.
317
+ * @author Grégory Viguier
318
+ *
319
+ * @return object The Imagify_NGG instance.
320
+ */
321
+ function imagify_ngg() {
322
+ _deprecated_function( __FUNCTION__ . '()', '1.6.12', 'Imagify_NGG::get_instance()' );
323
+
324
+ return Imagify_NGG::get_instance();
325
+ }
326
+
327
+ /**
328
+ * Returns the main instance of the Imagify_NGG_DB class.
329
+ *
330
+ * @since 1.6.5
331
+ * @since 1.6.12 Deprecated.
332
+ * @author Jonathan Buttigieg
333
+ *
334
+ * @return object The Imagify_NGG_DB instance.
335
+ */
336
+ function imagify_ngg_db() {
337
+ _deprecated_function( __FUNCTION__ . '()', '1.6.12', 'Imagify_NGG_DB::get_instance()' );
338
+
339
+ return Imagify_NGG_DB::get_instance();
340
+ }
341
+
342
+ endif;
343
+
344
  if ( is_admin() ) :
345
 
346
  /**
inc/functions/files.php CHANGED
@@ -98,7 +98,7 @@ function imagify_get_abspath() {
98
  * @author Grégory Viguier
99
  *
100
  * @param string $file_path An absolute path.
101
- * @return string A relative path. Can return the absolute path in case of a failure.
102
  */
103
  function imagify_make_file_path_relative( $file_path ) {
104
  static $abspath;
@@ -108,6 +108,10 @@ function imagify_make_file_path_relative( $file_path ) {
108
  $abspath = wp_normalize_path( ABSPATH );
109
  }
110
 
 
 
 
 
111
  $file_path = wp_normalize_path( $file_path );
112
  $pos = strpos( $file_path, $abspath );
113
 
98
  * @author Grégory Viguier
99
  *
100
  * @param string $file_path An absolute path.
101
+ * @return string|bool A relative path. Can return the absolute path or false in case of a failure.
102
  */
103
  function imagify_make_file_path_relative( $file_path ) {
104
  static $abspath;
108
  $abspath = wp_normalize_path( ABSPATH );
109
  }
110
 
111
+ if ( ! $file_path ) {
112
+ return false;
113
+ }
114
+
115
  $file_path = wp_normalize_path( $file_path );
116
  $pos = strpos( $file_path, $abspath );
117
 
inc/functions/i18n.php CHANGED
@@ -139,10 +139,9 @@ function get_imagify_localize_script_translations( $context ) {
139
  'notice' => _x( 'Notice', 'noun', 'imagify' ),
140
  /* translators: %s is a number. Don't use %d. */
141
  'nbrErrors' => __( '%s error(s)', 'imagify' ),
142
- /* translators: 1 and 2 are file sizes. */
143
  'textToShare' => __( 'Discover @imagify, the new compression tool to optimize your images for free. I saved %1$s out of %2$s!', 'imagify' ),
144
- /* translators: Plugin URI of the plugin/theme */
145
- 'pluginURL' => __( 'https://wordpress.org/plugins/imagify/', 'imagify' ),
146
  'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
147
  'getUnoptimizedImagesErrorText' => __( 'An unknown error occurred when we tried to get all your unoptimized images. Try again and if the issue still persists, please contact us!', 'imagify' ),
148
  ),
@@ -167,7 +166,7 @@ function get_imagify_localize_script_translations( $context ) {
167
  $translations['labels']['overQuotaText'] = sprintf(
168
  /* translators: 1 is a link tag start, 2 is the link tag end. */
169
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
170
- '<a target="_blank" href="' . IMAGIFY_APP_MAIN . '/#/subscription">',
171
  '</a>'
172
  );
173
  } else {
@@ -181,7 +180,7 @@ function get_imagify_localize_script_translations( $context ) {
181
  $translations['labels']['overQuotaText'] .= sprintf(
182
  /* translators: 1 is a link tag start, 2 is the link tag end. */
183
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
184
- '<a target="_blank" href="' . IMAGIFY_APP_MAIN . '/#/subscription">',
185
  '</a>'
186
  );
187
  }
139
  'notice' => _x( 'Notice', 'noun', 'imagify' ),
140
  /* translators: %s is a number. Don't use %d. */
141
  'nbrErrors' => __( '%s error(s)', 'imagify' ),
142
+ /* translators: 1 and 2 are file sizes. Don't use HTML entities here (like &nbsp;). */
143
  'textToShare' => __( 'Discover @imagify, the new compression tool to optimize your images for free. I saved %1$s out of %2$s!', 'imagify' ),
144
+ 'twitterShareURL' => imagify_get_external_url( 'share-twitter' ),
 
145
  'getUnoptimizedImagesErrorTitle' => __( 'Oops, There is something wrong!', 'imagify' ),
146
  'getUnoptimizedImagesErrorText' => __( 'An unknown error occurred when we tried to get all your unoptimized images. Try again and if the issue still persists, please contact us!', 'imagify' ),
147
  ),
166
  $translations['labels']['overQuotaText'] = sprintf(
167
  /* translators: 1 is a link tag start, 2 is the link tag end. */
168
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
169
+ '<a target="_blank" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '">',
170
  '</a>'
171
  );
172
  } else {
180
  $translations['labels']['overQuotaText'] .= sprintf(
181
  /* translators: 1 is a link tag start, 2 is the link tag end. */
182
  __( 'To continue to optimize your images, log in to your Imagify account to %1$sbuy a pack or subscribe to a plan%2$s.', 'imagify' ),
183
+ '<a target="_blank" href="' . esc_url( imagify_get_external_url( 'subscription' ) ) . '">',
184
  '</a>'
185
  );
186
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wp_media, GregLone
3
  Tags: compress image, images, performance, optimization, photos, upload, resize, gif, png, jpg, reduce image size, retina
4
  Requires at least: 3.7.0
5
  Tested up to: 4.8.2
6
- Stable tag: 1.6.11
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
 
@@ -136,6 +136,13 @@ When the plugin is disabled, your existing images remain optimized. Backups of t
136
  3. Media Page
137
 
138
  == Changelog ==
 
 
 
 
 
 
 
139
  = 1.6.11 =
140
  * Improvement: Imagify now works with the iOS app, and with XML-RPC in general.
141
  * Improvement: we harmonized and improved how user roles are handled.
3
  Tags: compress image, images, performance, optimization, photos, upload, resize, gif, png, jpg, reduce image size, retina
4
  Requires at least: 3.7.0
5
  Tested up to: 4.8.2
6
+ Stable tag: 1.6.12
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
 
136
  3. Media Page
137
 
138
  == Changelog ==
139
+ = 1.6.12 =
140
+ * New: added links to the documentation in the plugin's admin bar item and the plugin's row (plugins page). There is more to come.
141
+ * Improvement: image attachments that don't have some mandatory WordPress metadata are not included in Imagify stats anymore.
142
+ * Fix: the "Optimized size" progress bar in the bulk optimization page now behaves like the "Original size" one does.
143
+ * Dev stuff: auto-optimization can be disabled on an attachment basis with the new filter `imagify_auto_optimize_attachment`. For example it can be used to disable auto-optimization for a specific file extension.
144
+ * Dev stuff: classes are now auto-loaded. Some constants have been removed.
145
+
146
  = 1.6.11 =
147
  * Improvement: Imagify now works with the iOS app, and with XML-RPC in general.
148
  * Improvement: we harmonized and improved how user roles are handled.