From dee44bb9dcd4579cb37b539cb5197c6614663965 Mon Sep 17 00:00:00 2001 From: Ashley Rich Date: Tue, 13 Dec 2016 11:58:26 +0000 Subject: [PATCH] Deploying version 1.1.4 --- README.md | 10 +- assets/js/script.js | 12 +- assets/js/script.min.js | 2 +- classes/amazon-s3-and-cloudfront.php | 116 ++++++------ classes/as3cf-filter.php | 3 +- ...urls.php => as3cf-upgrade-filter-post.php} | 101 ++++------ classes/as3cf-upgrade.php | 51 +++-- classes/upgrades/as3cf-file-sizes.php | 27 ++- ...-replace-urls.php => as3cf-filter-edd.php} | 27 ++- .../upgrades/as3cf-filter-post-content.php | 93 ++++++++++ .../upgrades/as3cf-filter-post-excerpt.php | 50 +++++ classes/upgrades/as3cf-meta-wp-error.php | 27 ++- classes/upgrades/as3cf-region-meta.php | 27 ++- classes/wp-aws-compatibility-check.php | 4 +- languages/amazon-s3-and-cloudfront-en.pot | 175 ++++++++++-------- readme.txt | 10 +- view/bucket-select.php | 20 +- view/bucket-setting.php | 2 +- view/checkbox.php | 7 +- view/cloudfront-setting.php | 7 +- view/settings.php | 6 +- wordpress-s3.php | 12 +- 22 files changed, 500 insertions(+), 289 deletions(-) rename classes/{upgrades/as3cf-content-replace-urls.php => as3cf-upgrade-filter-post.php} (84%) rename classes/upgrades/{as3cf-edd-replace-urls.php => as3cf-filter-edd.php} (82%) create mode 100644 classes/upgrades/as3cf-filter-post-content.php create mode 100644 classes/upgrades/as3cf-filter-post-excerpt.php diff --git a/README.md b/README.md index 2d0626c4..27f45384 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **Contributors:** bradt, deliciousbrains **Tags:** uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront **Requires at least:** 4.4 -**Tested up to:** 4.6.1 -**Stable tag:** 1.1.3 +**Tested up to:** 4.7 +**Stable tag:** 1.1.4 **License:** GPLv3 Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery. @@ -69,6 +69,12 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog ## +### WP Offload S3 Lite 1.1.4 - 2016-12-13 ### +* New: Upgrade routine to replace all S3 URLs in post excerpts with local URLs +* Improvement: Performance improvements +* Improvement: Allow expires time to be filtered for private content using the `as3cf_expires` filter +* Bug fix: Image `srcset` not correctly applied when file names contain special characters + ### WP Offload S3 Lite 1.1.3 - 2016-11-28 ### * Bug fix: Private URL signing params stripped in some circumstances * Improvement: Performance improvements for URL filtering, especially on large sites diff --git a/assets/js/script.js b/assets/js/script.js index ceca3e94..4e4271f3 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -430,8 +430,8 @@ if ( 'as3cf' === as3cfModal.prefix && 0 === $activeBucket.text().trim().length ) { // First time bucket select - enable main options by default - setCheckbox( 'copy-to-s3-wrap' ); - setCheckbox( 'serve-from-s3-wrap' ); + setCheckbox( 'as3cf-copy-to-s3-wrap' ); + setCheckbox( 'as3cf-serve-from-s3-wrap' ); // Update the saved settings string so we don't trigger the navigation alert var id = $activeTab.attr( 'id' ); @@ -636,7 +636,7 @@ * Toggle the lost files notice */ function toggleLostFilesNotice() { - if ( $( '#remove-local-file' ).is( ':checked' ) && $( '#serve-from-s3' ).is( ':not(:checked)' ) ) { + if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) && $( '#as3cf-serve-from-s3' ).is( ':not(:checked)' ) ) { $( '#as3cf-lost-files-notice' ).show(); } else { $( '#as3cf-lost-files-notice' ).hide(); @@ -647,7 +647,7 @@ * Toggle the remove local files notice */ function toggleRemoveLocalNotice() { - if ( $( '#remove-local-file' ).is( ':checked' ) ) { + if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) ) { $( '#as3cf-remove-local-notice' ).show(); } else { $( '#as3cf-remove-local-notice' ).hide(); @@ -749,12 +749,12 @@ } ); toggleLostFilesNotice(); - $( '#serve-from-s3,#remove-local-file' ).on( 'change', function( e ) { + $( '#as3cf-serve-from-s3,#as3cf-remove-local-file' ).on( 'change', function( e ) { toggleLostFilesNotice(); } ); toggleRemoveLocalNotice(); - $( '#remove-local-file' ).on( 'change', function( e ) { + $( '#as3cf-remove-local-file' ).on( 'change', function( e ) { toggleRemoveLocalNotice(); } ); diff --git a/assets/js/script.min.js b/assets/js/script.min.js index 5c7b24ad..d44524a1 100644 --- a/assets/js/script.min.js +++ b/assets/js/script.min.js @@ -1 +1 @@ -!function(a,b){function c(b){return a("#"+b+" .as3cf-main-settings form").find("input:not(.no-compare)").serialize()}function d(a){var b=k.find("#"+a),c=b.find("input[type=checkbox]");b.toggleClass("on").find("span").toggleClass("checked");var d=b.find("span.on").hasClass("checked");c.attr("checked",d).trigger("change")}function e(b){var c=b.next(".as3cf-validation-error"),d=a("#"+k.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\.\-]/;e.test(b.val())?(c.show(),d.attr("disabled",!0)):(c.hide(),d.attr("disabled",!1))}function f(){var c=a("#"+b.prefix+"-bucket").val(),d=k.find('input[name="object-prefix"]'),e=d.val();""!==e&&(e="&prefix="+encodeURIComponent(e));var f=as3cf.aws_bucket_link+c+e;a("#"+b.prefix+"-view-bucket").attr("href",f)}function g(){a(".as3cf-url-preview").html("Generating...");var b={_nonce:as3cf.nonces.get_url_preview};a.each(a("#tab-"+as3cf.tabs.defaultTab+" .as3cf-main-settings form").serializeArray(),function(c,d){var e=d.name,f=d.value;e=e.replace("[]",""),b[e]=void 0===b[e]?f:a.isArray(b[e])?b[e].concat(f):[b[e],f]}),b.action="as3cf-get-url-preview",a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){alert(as3cf.strings.get_url_preview_error+c)},success:function(b,c,d){"undefined"!=typeof b.success?a(".as3cf-url-preview").html(b.url):alert(as3cf.strings.get_url_preview_error+b.error)}})}function h(a){as3cf.buckets.bucketSelectLock=!1}function i(){a("#remove-local-file").is(":checked")&&a("#serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function j(){a("#remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}var k,l={},m=/[^a-z0-9.-]/,n=!1,o=a(".as3cf-tab");as3cf.tabs={defaultTab:"media",toggle:function(c,d){c=as3cf.tabs.sanitizeHash(c),o.hide(),k=a("#tab-"+c),k.show(),a(".nav-tab").removeClass("nav-tab-active"),a('a.nav-tab[data-tab="'+c+'"]').addClass("nav-tab-active"),a(".aws-main").attr("data-tab",c),k.attr("data-prefix")&&(b.prefix=k.attr("data-prefix")),d||a(".as3cf-updated").removeClass("show"),"support"===c&&as3cf.tabs.getDiagnosticInfo()},getDiagnosticInfo:function(){var b=a(".debug-log-textarea");b.html(as3cf.strings.get_diagnostic_info);var c={action:"as3cf-get-diagnostic-info",_nonce:as3cf.nonces.get_diagnostic_info};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:c,error:function(a,c,d){b.html(d)},success:function(a,c,d){"undefined"!=typeof a.success?b.html(a.diagnostic_info):(b.html(as3cf.strings.get_diagnostic_info_error),b.append(a.error))}})},sanitizeHash:function(b){var c=a("#tab-"+b);return 0===c.length&&(b=as3cf.tabs.defaultTab),b}},as3cf.buckets={validLength:3,bucketSelectLock:!1,loadList:function(c){"undefined"==typeof c&&(c=!1);var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-list"),e=a("#"+b.prefix+"-bucket").val();if(!1===c&&d.find("li").length>1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected"),void this.scrollToSelected();d.html('
  • '+d.attr("data-working")+"
  • ");var f={action:b.prefix+"-get-buckets",_nonce:window[b.prefix.replace(/-/g,"_")].nonces.get_buckets},g=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:f,error:function(a,b,c){d.html(""),g.showError(as3cf.strings.get_buckets_error,c,"as3cf-bucket-select")},success:function(b,c,f){d.html(""),"undefined"!=typeof b.success?(a(".as3cf-bucket-error").hide(),a(b.buckets).each(function(a,b){var c=b.Name===e?"selected":"";d.append('
  • '+b.Name+'
  • ')}),g.scrollToSelected()):g.showError(as3cf.strings.get_buckets_error,b.error,"as3cf-bucket-select")}})},scrollToSelected:function(){if(a(".as3cf-bucket-list a.selected").length){var b=a("ul.as3cf-bucket-list li").first().position().top+150;a(".as3cf-bucket-list").animate({scrollTop:a("ul.as3cf-bucket-list li a.selected").position().top-b})}},resetModal:function(){var c=a(".as3cf-bucket-container."+b.prefix);!1===k.hasClass("as3cf-has-bucket")||"manual"===a("#"+b.prefix+"-bucket-select").val()?(c.find(".as3cf-bucket-manual").show().siblings().hide(),c.find(".bucket-actions.manual").show().siblings(".bucket-actions").hide()):(c.find(".as3cf-bucket-select").show().siblings().hide(),c.find(".bucket-actions.select").show().siblings(".bucket-actions").hide(),this.loadList(n),n=!1),c.find(".as3cf-bucket-error").hide();var d=a("#"+b.prefix+"-bucket").val();c.find(".as3cf-bucket-manual .as3cf-bucket-name").val(d),this.bucketSelectLock=!1},saveManual:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),d=c.find(".as3cf-bucket-name"),e=c.find("button[type=submit]"),f=d.val(),g=e.first().text();if(f===a("#"+b.prefix+"-active-bucket").text())return a(".as3cf-bucket-error").hide(),k.addClass("as3cf-has-bucket"),void b.close();a(".as3cf-bucket-error").hide(),e.text(e.attr("data-working")),e.prop("disabled",!0);var h={action:b.prefix+"-manual-save-bucket",bucket_name:f,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.manual_bucket},i=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:h,error:function(a,b,c){e.text(g),i.showError(as3cf.strings.save_bucket_error,c,"as3cf-bucket-manual")},success:function(c,d,h){e.text(g),e.prop("disabled",!1),"undefined"!=typeof c.success?(i.set(f,c.region,c.can_write),a("#"+b.prefix+"-bucket-select").val("manual"),a(".as3cf-bucket-list a").removeClass("selected").filter('[data-bucket="'+f+'"]').addClass("selected"),n=!0):i.showError(as3cf.strings.save_bucket_error,c.error,"as3cf-bucket-manual")}})},saveSelected:function(c){var d=a(".as3cf-bucket-list");if(!this.bucketSelectLock){if(this.bucketSelectLock=!0,c.hasClass("selected"))return k.addClass("as3cf-has-bucket"),void b.close();var e=a(".as3cf-bucket-list a.selected").attr("data-bucket");a(".as3cf-bucket-list a").removeClass("selected"),c.addClass("selected"),d.addClass("saving"),c.find(".spinner").show().css("visibility","visible");var f=c.attr("data-bucket"),g={action:b.prefix+"-save-bucket",bucket_name:f,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.save_bucket},h=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:g,error:function(b,c,f){d.removeClass("saving"),h.showError(as3cf.strings.save_bucket_error,f,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected")},success:function(g,i,j){c.find(".spinner").hide().css("visibility","hidden"),d.removeClass("saving"),"undefined"!=typeof g.success?(h.set(f,g.region,g.can_write),a("#"+b.prefix+"-bucket-select").val("")):(h.showError(as3cf.strings.save_bucket_error,g.error,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected"))}})}},disabledButtons:function(){if(0!==a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form").length){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form"),d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form");c.find(".as3cf-bucket-name").val().length<3?c.find("button[type=submit]").attr("disabled",!0):c.find("button[type=submit]").attr("disabled",!1),d.find(".as3cf-bucket-name").val().length<3?d.find("button[type=submit]").attr("disabled",!0):d.find("button[type=submit]").attr("disabled",!1)}},showError:function(b,c,d){var e=a(".as3cf-bucket-container").children(":visible"),f=e.find(".as3cf-bucket-error");d="undefined"==typeof d?null:d,d&&!e.hasClass(d)||(f.find("span.title").html(b+" —"),f.find("span.message").html(c),f.show(),this.bucketSelectLock=!1)},set:function(e,i,j){var m=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),n=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===n.text().trim().length){d("copy-to-s3-wrap"),d("serve-from-s3-wrap");var o=k.attr("id");l[o]=c(o)}a(".as3cf-error.fatal").hide(),n.text(e),m.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(i),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!j),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(h)},create:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form"),d=c.find(".as3cf-bucket-name"),e=c.find(".bucket-create-region"),f=c.find("button[type=submit]"),g=d.val(),h=f.text();a(".as3cf-bucket-error").hide(),f.text(f.attr("data-working")),f.prop("disabled",!0);var i={action:b.prefix+"-create-bucket",bucket_name:g,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.create_bucket};e.val()&&(i.region=e.val());var j=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:i,error:function(a,b,c){f.text(h),j.showError(as3cf.strings.create_bucket_error,c,"as3cf-bucket-create")},success:function(b,c,e){f.text(h),f.prop("disabled",!1),"undefined"!=typeof b.success?(j.set(g,b.region,b.can_write),a(".as3cf-bucket-select-region").hide(),a(".as3cf-bucket-select-region").removeAttr("selected"),d.val(""),f.attr("disabled",!0),n=!0):j.showError(as3cf.strings.create_bucket_error,b.error,"as3cf-bucket-create")}})},isValidName:function(a){return!(a.length<3||a.length>63)&&!0!==m.test(a)},updateNameNotice:function(b){var c=null;!0===m.test(b)?c=as3cf.strings.create_bucket_invalid_chars:b.length<3?c=as3cf.strings.create_bucket_name_short:b.length>63&&(c=as3cf.strings.create_bucket_name_long),c&&b.length>0?a(".as3cf-invalid-bucket-name").html(c):a(".as3cf-invalid-bucket-name").html("")}},a(document).ready(function(){var h=a(".wrap.aws-main .nav-tab-wrapper");if(a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(h),window.location.hash){var m=window.location.hash.substring(1);as3cf.tabs.toggle(m,!0)}else k=a("#tab-"+as3cf.tabs.defaultTab),a(".aws-main").attr("data-tab",as3cf.tabs.defaultTab);a(".aws-main").on("click",".nav-tab",function(b){if(b.preventDefault(),!a(this).hasClass("nav-tab-active")){var c=a(this).attr("data-tab");as3cf.tabs.toggle(c),"media"===c?(window.location.hash="","function"==typeof window.history.replaceState&&"#"===window.location.href.slice(-1)&&history.replaceState({},"",window.location.href.slice(0,-1))):window.location.hash=c}}),o.length&&o.each(function(a,b){l[b.id]=c(b.id)}),a(window).on("beforeunload.as3cf-settings",function(){if(!a.isEmptyObject(l)){var b=k.attr("id");return c(b)!==l[b]?as3cf.strings.save_alert:void 0}}),a(document).on("submit",".as3cf-main-settings form",function(b){a(window).off("beforeunload.as3cf-settings")}),a(".as3cf-switch").on("click",function(b){a(this).hasClass("disabled")||d(a(this).attr("id"))}),o.on("change",".sub-toggle",function(b){var c=a(this).attr("id");a(".as3cf-setting."+c).toggleClass("hide")}),a(".as3cf-domain").on("change",'input[type="radio"]',function(b){var c=a(this).closest('input:radio[name="domain"]:checked'),d=c.val(),e=a(this).parents(".as3cf-domain").find(".as3cf-setting.cloudfront"),f="cloudfront"===d;e.toggleClass("hide",!f)}),a(".url-preview").on("change","input",function(a){g()}),i(),a("#serve-from-s3,#remove-local-file").on("change",function(a){i()}),j(),a("#remove-local-file").on("change",function(a){j()}),a('.as3cf-setting input[type="text"]').keypress(function(a){if(13===a.which)return a.preventDefault(),!1}),a('input[name="cloudfront"]').on("keyup",function(b){e(a(this))}),a('input[name="domain"]').on("change",function(b){var c=a(this),d=a("#"+k.attr("id")+' form button[type="submit"]');"cloudfront"!==c.val()?d.attr("disabled",!1):e(c.next(".as3cf-setting").find('input[name="cloudfront"]'))}),a('input[name="object-prefix"]').on("change",function(a){f()}),a("#tab-media > .as3cf-bucket-error").detach().insertAfter(".as3cf-bucket-container h3"),a("body").on("click",".bucket-action-manual",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual").show().siblings().hide()}),a("body").on("click",".bucket-action-browse",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select").show().siblings().hide(),as3cf.buckets.loadList(n),n=!1}),a("body").on("click",".bucket-action-create",function(c){c.preventDefault(),a(".as3cf-bucket-name").val(""),a(".as3cf-invalid-bucket-name").html(""),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-create").show().siblings().hide()}),a("body").on("click",".bucket-action-cancel",function(a){a.preventDefault(),as3cf.buckets.resetModal()}),a("body").on("click",".bucket-action-save",function(a){a.preventDefault(),as3cf.buckets.saveManual()}),a("body").on("click",'.as3cf-create-bucket-form button[type="submit"]',function(a){a.preventDefault(),as3cf.buckets.create()}),a("body").on("click",".bucket-action-refresh",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),a("body").on("click",".as3cf-bucket-list a",function(b){b.preventDefault(),as3cf.buckets.saveSelected(a(this))}),a(".as3cf-bucket-container").on("click","a.js-link",function(b){return b.preventDefault(),window.open(a(this).attr("href")),!1}),a("body").on("as3cf-modal-open",function(c,d){if(".as3cf-bucket-container."+b.prefix===d){as3cf.buckets.resetModal();var e=a(".as3cf-bucket-manual h3").data("modal-title");a(".as3cf-bucket-manual h3").text(e),as3cf.buckets.disabledButtons()}}),as3cf.buckets.disabledButtons(),a("body").on("input keyup",".as3cf-create-bucket-form .as3cf-bucket-name",function(c){var d=a(this).val(),e=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form");as3cf.buckets.isValidName(d)?e.find("button[type=submit]").removeAttr("disabled"):e.find("button[type=submit]").attr("disabled",!0),as3cf.buckets.updateNameNotice(d)}),a("body").on("input keyup",".as3cf-manual-save-bucket-form .as3cf-bucket-name",function(c){var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form");d.find(".as3cf-bucket-name").val().length1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected"),void this.scrollToSelected();d.html('
  • '+d.attr("data-working")+"
  • ");var f={action:b.prefix+"-get-buckets",_nonce:window[b.prefix.replace(/-/g,"_")].nonces.get_buckets},g=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:f,error:function(a,b,c){d.html(""),g.showError(as3cf.strings.get_buckets_error,c,"as3cf-bucket-select")},success:function(b,c,f){d.html(""),"undefined"!=typeof b.success?(a(".as3cf-bucket-error").hide(),a(b.buckets).each(function(a,b){var c=b.Name===e?"selected":"";d.append('
  • '+b.Name+'
  • ')}),g.scrollToSelected()):g.showError(as3cf.strings.get_buckets_error,b.error,"as3cf-bucket-select")}})},scrollToSelected:function(){if(a(".as3cf-bucket-list a.selected").length){var b=a("ul.as3cf-bucket-list li").first().position().top+150;a(".as3cf-bucket-list").animate({scrollTop:a("ul.as3cf-bucket-list li a.selected").position().top-b})}},resetModal:function(){var c=a(".as3cf-bucket-container."+b.prefix);!1===k.hasClass("as3cf-has-bucket")||"manual"===a("#"+b.prefix+"-bucket-select").val()?(c.find(".as3cf-bucket-manual").show().siblings().hide(),c.find(".bucket-actions.manual").show().siblings(".bucket-actions").hide()):(c.find(".as3cf-bucket-select").show().siblings().hide(),c.find(".bucket-actions.select").show().siblings(".bucket-actions").hide(),this.loadList(n),n=!1),c.find(".as3cf-bucket-error").hide();var d=a("#"+b.prefix+"-bucket").val();c.find(".as3cf-bucket-manual .as3cf-bucket-name").val(d),this.bucketSelectLock=!1},saveManual:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),d=c.find(".as3cf-bucket-name"),e=c.find("button[type=submit]"),f=d.val(),g=e.first().text();if(f===a("#"+b.prefix+"-active-bucket").text())return a(".as3cf-bucket-error").hide(),k.addClass("as3cf-has-bucket"),void b.close();a(".as3cf-bucket-error").hide(),e.text(e.attr("data-working")),e.prop("disabled",!0);var h={action:b.prefix+"-manual-save-bucket",bucket_name:f,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.manual_bucket},i=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:h,error:function(a,b,c){e.text(g),i.showError(as3cf.strings.save_bucket_error,c,"as3cf-bucket-manual")},success:function(c,d,h){e.text(g),e.prop("disabled",!1),"undefined"!=typeof c.success?(i.set(f,c.region,c.can_write),a("#"+b.prefix+"-bucket-select").val("manual"),a(".as3cf-bucket-list a").removeClass("selected").filter('[data-bucket="'+f+'"]').addClass("selected"),n=!0):i.showError(as3cf.strings.save_bucket_error,c.error,"as3cf-bucket-manual")}})},saveSelected:function(c){var d=a(".as3cf-bucket-list");if(!this.bucketSelectLock){if(this.bucketSelectLock=!0,c.hasClass("selected"))return k.addClass("as3cf-has-bucket"),void b.close();var e=a(".as3cf-bucket-list a.selected").attr("data-bucket");a(".as3cf-bucket-list a").removeClass("selected"),c.addClass("selected"),d.addClass("saving"),c.find(".spinner").show().css("visibility","visible");var f=c.attr("data-bucket"),g={action:b.prefix+"-save-bucket",bucket_name:f,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.save_bucket},h=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:g,error:function(b,c,f){d.removeClass("saving"),h.showError(as3cf.strings.save_bucket_error,f,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected")},success:function(g,i,j){c.find(".spinner").hide().css("visibility","hidden"),d.removeClass("saving"),"undefined"!=typeof g.success?(h.set(f,g.region,g.can_write),a("#"+b.prefix+"-bucket-select").val("")):(h.showError(as3cf.strings.save_bucket_error,g.error,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+e+'"]').addClass("selected"))}})}},disabledButtons:function(){if(0!==a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form").length){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form"),d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form");c.find(".as3cf-bucket-name").val().length<3?c.find("button[type=submit]").attr("disabled",!0):c.find("button[type=submit]").attr("disabled",!1),d.find(".as3cf-bucket-name").val().length<3?d.find("button[type=submit]").attr("disabled",!0):d.find("button[type=submit]").attr("disabled",!1)}},showError:function(b,c,d){var e=a(".as3cf-bucket-container").children(":visible"),f=e.find(".as3cf-bucket-error");d="undefined"==typeof d?null:d,d&&!e.hasClass(d)||(f.find("span.title").html(b+" —"),f.find("span.message").html(c),f.show(),this.bucketSelectLock=!1)},set:function(e,i,j){var m=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),n=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===n.text().trim().length){d("as3cf-copy-to-s3-wrap"),d("as3cf-serve-from-s3-wrap");var o=k.attr("id");l[o]=c(o)}a(".as3cf-error.fatal").hide(),n.text(e),m.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(i),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!j),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(h)},create:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form"),d=c.find(".as3cf-bucket-name"),e=c.find(".bucket-create-region"),f=c.find("button[type=submit]"),g=d.val(),h=f.text();a(".as3cf-bucket-error").hide(),f.text(f.attr("data-working")),f.prop("disabled",!0);var i={action:b.prefix+"-create-bucket",bucket_name:g,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.create_bucket};e.val()&&(i.region=e.val());var j=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:i,error:function(a,b,c){f.text(h),j.showError(as3cf.strings.create_bucket_error,c,"as3cf-bucket-create")},success:function(b,c,e){f.text(h),f.prop("disabled",!1),"undefined"!=typeof b.success?(j.set(g,b.region,b.can_write),a(".as3cf-bucket-select-region").hide(),a(".as3cf-bucket-select-region").removeAttr("selected"),d.val(""),f.attr("disabled",!0),n=!0):j.showError(as3cf.strings.create_bucket_error,b.error,"as3cf-bucket-create")}})},isValidName:function(a){return!(a.length<3||a.length>63)&&!0!==m.test(a)},updateNameNotice:function(b){var c=null;!0===m.test(b)?c=as3cf.strings.create_bucket_invalid_chars:b.length<3?c=as3cf.strings.create_bucket_name_short:b.length>63&&(c=as3cf.strings.create_bucket_name_long),c&&b.length>0?a(".as3cf-invalid-bucket-name").html(c):a(".as3cf-invalid-bucket-name").html("")}},a(document).ready(function(){var h=a(".wrap.aws-main .nav-tab-wrapper");if(a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(h),window.location.hash){var m=window.location.hash.substring(1);as3cf.tabs.toggle(m,!0)}else k=a("#tab-"+as3cf.tabs.defaultTab),a(".aws-main").attr("data-tab",as3cf.tabs.defaultTab);a(".aws-main").on("click",".nav-tab",function(b){if(b.preventDefault(),!a(this).hasClass("nav-tab-active")){var c=a(this).attr("data-tab");as3cf.tabs.toggle(c),"media"===c?(window.location.hash="","function"==typeof window.history.replaceState&&"#"===window.location.href.slice(-1)&&history.replaceState({},"",window.location.href.slice(0,-1))):window.location.hash=c}}),o.length&&o.each(function(a,b){l[b.id]=c(b.id)}),a(window).on("beforeunload.as3cf-settings",function(){if(!a.isEmptyObject(l)){var b=k.attr("id");return c(b)!==l[b]?as3cf.strings.save_alert:void 0}}),a(document).on("submit",".as3cf-main-settings form",function(b){a(window).off("beforeunload.as3cf-settings")}),a(".as3cf-switch").on("click",function(b){a(this).hasClass("disabled")||d(a(this).attr("id"))}),o.on("change",".sub-toggle",function(b){var c=a(this).attr("id");a(".as3cf-setting."+c).toggleClass("hide")}),a(".as3cf-domain").on("change",'input[type="radio"]',function(b){var c=a(this).closest('input:radio[name="domain"]:checked'),d=c.val(),e=a(this).parents(".as3cf-domain").find(".as3cf-setting.cloudfront"),f="cloudfront"===d;e.toggleClass("hide",!f)}),a(".url-preview").on("change","input",function(a){g()}),i(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){i()}),j(),a("#as3cf-remove-local-file").on("change",function(a){j()}),a('.as3cf-setting input[type="text"]').keypress(function(a){if(13===a.which)return a.preventDefault(),!1}),a('input[name="cloudfront"]').on("keyup",function(b){e(a(this))}),a('input[name="domain"]').on("change",function(b){var c=a(this),d=a("#"+k.attr("id")+' form button[type="submit"]');"cloudfront"!==c.val()?d.attr("disabled",!1):e(c.next(".as3cf-setting").find('input[name="cloudfront"]'))}),a('input[name="object-prefix"]').on("change",function(a){f()}),a("#tab-media > .as3cf-bucket-error").detach().insertAfter(".as3cf-bucket-container h3"),a("body").on("click",".bucket-action-manual",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual").show().siblings().hide()}),a("body").on("click",".bucket-action-browse",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select").show().siblings().hide(),as3cf.buckets.loadList(n),n=!1}),a("body").on("click",".bucket-action-create",function(c){c.preventDefault(),a(".as3cf-bucket-name").val(""),a(".as3cf-invalid-bucket-name").html(""),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-create").show().siblings().hide()}),a("body").on("click",".bucket-action-cancel",function(a){a.preventDefault(),as3cf.buckets.resetModal()}),a("body").on("click",".bucket-action-save",function(a){a.preventDefault(),as3cf.buckets.saveManual()}),a("body").on("click",'.as3cf-create-bucket-form button[type="submit"]',function(a){a.preventDefault(),as3cf.buckets.create()}),a("body").on("click",".bucket-action-refresh",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),a("body").on("click",".as3cf-bucket-list a",function(b){b.preventDefault(),as3cf.buckets.saveSelected(a(this))}),a(".as3cf-bucket-container").on("click","a.js-link",function(b){return b.preventDefault(),window.open(a(this).attr("href")),!1}),a("body").on("as3cf-modal-open",function(c,d){if(".as3cf-bucket-container."+b.prefix===d){as3cf.buckets.resetModal();var e=a(".as3cf-bucket-manual h3").data("modal-title");a(".as3cf-bucket-manual h3").text(e),as3cf.buckets.disabledButtons()}}),as3cf.buckets.disabledButtons(),a("body").on("input keyup",".as3cf-create-bucket-form .as3cf-bucket-name",function(c){var d=a(this).val(),e=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form");as3cf.buckets.isValidName(d)?e.find("button[type=submit]").removeAttr("disabled"):e.find("button[type=submit]").attr("disabled",!0),as3cf.buckets.updateNameNotice(d)}),a("body").on("input keyup",".as3cf-manual-save-bucket-form .as3cf-bucket-name",function(c){var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form");d.find(".as3cf-bucket-name").val().lengthremove_setting( 'region' ); + if ( ! empty( $value ) ) { + // Clear bucket + $this->remove_setting( 'bucket' ); $this->save_settings(); } + $this->remove_region_on_constant_change( $bucket, $constant ); + return $bucket; } return false; } + /** + * Remove region on constant change. + * + * @param string $bucket + * @param string $constant + */ + private function remove_region_on_constant_change( $bucket, $constant ) { + $key = 'as3cf_constant_' . strtolower( $constant ); + $value = get_site_transient( $key ); + + if ( false === $value || $bucket !== $value ) { + set_site_transient( $key, $bucket ); + } + + if ( false !== $value && $bucket !== $value ) { + // Clear region + $this->remove_setting( 'region' ); + $this->save_settings(); + } + } + /** * Filter in defined settings with sensible defaults. * @@ -746,6 +768,7 @@ function remove_attachment_files_from_s3( $post_id, $s3object, $remove_backup_si $bucket = $s3object['bucket']; $region = $this->get_s3object_region( $s3object ); $paths = $this->get_attachment_file_paths( $post_id, false, false, $remove_backup_sizes ); + $paths = apply_filters( 'as3cf_remove_attachment_paths', $paths, $post_id, $s3object, $remove_backup_sizes ); if ( is_wp_error( $region ) ) { $region = ''; @@ -1145,7 +1168,15 @@ function remove_local_files( $file_paths ) { } if ( ! @unlink( $path ) ) { - AS3CF_Error::log( 'Error removing local file ' . $path ); + $message = 'Error removing local file '; + + if ( ! file_exists( $path ) ) { + $message = "Error removing local file. Couldn't find the file at "; + } else if ( ! is_writable( $path ) ) { + $message = 'Error removing local file. Ownership or permissions are mis-configured for '; + } + + AS3CF_Error::log( $message . $path ); } } } @@ -1750,7 +1781,7 @@ public function get_attachment_s3_url( $post_id, $s3object, $expires = null, $si if ( ! is_null( $expires ) && $this->is_plugin_setup() ) { try { - $expires = time() + $expires; + $expires = time() + apply_filters( 'as3cf_expires', $expires ); $secure_url = $this->get_s3client( $region )->getObjectUrl( $s3object['bucket'], $s3object['key'], $expires, $headers ); return apply_filters( 'as3cf_get_attachment_secure_url', $secure_url, $s3object, $post_id, $expires, $headers ); @@ -2030,7 +2061,12 @@ public function encode_filename_in_path( $file ) { return $file; } - $file_name = basename( $url['path'] ); + if ( isset( $url['query'] ) ) { + // Manually strip query string, as passing $url['path'] to basename results in corrupt � characters + $file_name = basename( str_replace( '?' . $url['query'], '', $file ) ); + } else { + $file_name = basename( $file ); + } if ( false !== strpos( $file_name, '%' ) ) { // File name already encoded, return original @@ -2339,32 +2375,6 @@ function save_bucket( $bucket_name, $manual = false, $region = null ) { return false; } - /** - * Get all AWS regions - * - * @return array - */ - function get_aws_regions() { - $regionEnum = new ReflectionClass( 'Aws\Common\Enum\Region' ); - $all_regions = $regionEnum->getConstants(); - - $regions = array(); - foreach ( $all_regions as $label => $region ) { - // Nicely format region name - if ( self::DEFAULT_REGION === $region ) { - $label = 'US Standard'; - } else { - $label = strtolower( $label ); - $label = str_replace( '_', ' ', $label ); - $label = ucwords( $label ); - } - - $regions[ $region ] = $label; - } - - return $regions; - } - /** * Add the settings menu item * @@ -2934,7 +2944,8 @@ public function get_blog_ids() { } $args = array( - 'limit' => false, + 'limit' => false, // Deprecated + 'number' => false, // WordPress 4.6+ 'spam' => 0, 'deleted' => 0, 'archived' => 0, @@ -3122,10 +3133,13 @@ function output_diagnostic_info( $escape = true ) { $output .= 'WordPress: '; $output .= get_bloginfo( 'version', 'display' ); if ( is_multisite() ) { - $output .= ' Multisite'; + $output .= ' Multisite '; + $output .= '(' . ( is_subdomain_install() ? 'subdomain' : 'subdirectory' ) . ')'; $output .= "\r\n"; $output .= 'Multisite Site Count: '; $output .= esc_html( get_blog_count() ); + $output .= "\r\n"; + $output .= 'Domain Mapping: ' . ( defined( 'SUNRISE' ) && SUNRISE ? 'Enabled' : 'Disabled' ); } $output .= "\r\n"; @@ -3444,6 +3458,17 @@ function output_diagnostic_info( $escape = true ) { $output .= implode( '', $mu_plugin_details ); } + $dropins = get_dropins(); + if ( $dropins ) { + $output .= "\r\n\r\n"; + $output .= "Drop-ins:\r\n"; + + foreach ( $dropins as $file => $dropin ) { + $output .= $file . ( isset( $dropin['Name'] ) ? ' - ' . $dropin['Name'] : '' ); + $output .= "\r\n"; + } + } + return $output; } @@ -4317,21 +4342,4 @@ public function remove_size_from_filename( $url, $remove_extension = false ) { return $url; } - - /** - * Update site option. - * - * @param string $option - * @param mixed $value - * @param bool $autoload - * - * @return bool - */ - public function update_site_option( $option, $value, $autoload = true ) { - if ( is_multisite() ) { - return update_site_option( $option, $value ); - } - - return update_option( $option, $value, $autoload ); - } } diff --git a/classes/as3cf-filter.php b/classes/as3cf-filter.php index 8dd12614..b0327c0a 100644 --- a/classes/as3cf-filter.php +++ b/classes/as3cf-filter.php @@ -344,8 +344,7 @@ protected function is_failure( $value ) { * @return bool */ protected function attachment_id_matches_src( $attachment_id, $url ) { - $base_urls = array(); - $meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); if ( ! isset( $meta['sizes'] ) ) { // No sizes found, return diff --git a/classes/upgrades/as3cf-content-replace-urls.php b/classes/as3cf-upgrade-filter-post.php similarity index 84% rename from classes/upgrades/as3cf-content-replace-urls.php rename to classes/as3cf-upgrade-filter-post.php index b64014e6..0b4fe819 100644 --- a/classes/upgrades/as3cf-content-replace-urls.php +++ b/classes/as3cf-upgrade-filter-post.php @@ -6,14 +6,19 @@ } /** - * AS3CF_Upgrade_Content_Replace_URLs Class + * AS3CF_Upgrade_Filter Class * - * This class handles replacing all S3 URLs in post - * content with the local URL. + * The base upgrade class for handling find and replace + * on the posts tables for content filtering. * - * @since 1.2 + * @since 1.3 */ -class AS3CF_Upgrade_Content_Replace_URLs extends AS3CF_Upgrade { +abstract class AS3CF_Upgrade_Filter_Post extends AS3CF_Upgrade { + + /** + * @var string 'metadata', 'attachment' + */ + protected $upgrade_type = 'posts'; /** * @var int Current blog ID @@ -31,19 +36,9 @@ class AS3CF_Upgrade_Content_Replace_URLs extends AS3CF_Upgrade { protected $session; /** - * Initiate the upgrade - * - * @param object $as3cf Instance of calling class + * @var string */ - public function __construct( $as3cf ) { - $this->upgrade_id = 4; - $this->upgrade_name = 'replace_s3_urls'; - $this->upgrade_type = 'posts'; - - $this->running_update_text = __( 'and ensuring that only the local URL exists in post content.', 'amazon-s3-and-cloudfront' ); - - parent::__construct( $as3cf ); - } + protected $column_name; /** * Fire up the upgrade @@ -94,6 +89,8 @@ protected function count_items_to_process() { * Cron job to update post content, ensuring no S3 URLs exist. */ public function do_upgrade() { + $this->lock_upgrade(); + // Check if the cron should even be running if ( $this->get_saved_upgrade_id() >= $this->upgrade_id || $this->get_upgrade_status() !== self::STATUS_RUNNING ) { $this->unschedule(); @@ -162,6 +159,19 @@ public function do_upgrade() { $this->as3cf->restore_current_blog(); } + $this->maybe_finish_upgrade(); + } + + /** + * Maybe finish the upgrade process. + */ + protected function maybe_finish_upgrade() { + if ( $this->session['processed_attachments'] >= $this->session['total_attachments']) { + $this->upgrade_finished(); + + return; + } + $this->save_session( $this->session ); } @@ -183,8 +193,9 @@ protected function maybe_process_blogs() { } if ( is_null( $blog['total_attachments'] ) ) { - // Handle theme mods - $this->upgrade_theme_mods( $blog['prefix'] ); + if ( method_exists( $this, 'process_blog' ) ) { + $this->process_blog( $blog ); + } // Count total attachments $count = $this->as3cf->count_attachments( $blog['prefix'], true ); @@ -235,39 +246,6 @@ protected function all_blogs_processed() { return true; } - /** - * Upgrade theme mods. Ensures background and header images have local URLs saved to the database. - * - * @param string $prefix - */ - protected function upgrade_theme_mods( $prefix ) { - global $wpdb; - - $mods = $wpdb->get_results( "SELECT * FROM `{$prefix}options` WHERE option_name LIKE 'theme_mods_%'" ); - - foreach ( $mods as $mod ) { - $value = maybe_unserialize( $mod->option_value ); - - if ( isset( $value['background_image'] ) ) { - $value['background_image'] = $this->as3cf->filter_s3->filter_customizer_image( $value['background_image'] ); - } - - if ( isset( $value['header_image'] ) ) { - $value['header_image'] = $this->as3cf->filter_s3->filter_customizer_image( $value['header_image'] ); - } - - if ( isset( $value['header_image_data'] ) ) { - $value['header_image_data'] = $this->as3cf->filter_s3->filter_header_image_data( $value['header_image_data'] ); - } - - $value = maybe_serialize( $value ); - - if ( $value !== $mod->option_value ) { - $wpdb->query( "UPDATE `{$prefix}options` SET option_value = '{$value}' WHERE option_id = '{$mod->option_id}'" ); - } - } - } - /** * Get items to process. * @@ -411,7 +389,7 @@ protected function get_find_and_replace_urls( $file_path, $old_url, $new_url, $m $url_pairs[ $key ]['new_url'] = $this->as3cf->remove_scheme( $url_pair['new_url'] ); } - return apply_filters( 'as3cf_find_replace_url_pairs', $url_pairs, $file_path, $old_url, $new_url, $meta ); + return apply_filters( 'as3cf_update_' . $this->upgrade_name . '_url_pairs', $url_pairs, $file_path, $old_url, $new_url, $meta ); } /** @@ -519,7 +497,7 @@ protected function generate_select_sql( $url_pairs, $where_lowest_id, $where_hig $sql .= " OR "; } - $sql .= "post_content LIKE '%{$path}%'"; + $sql .= "{$this->column_name} LIKE '%{$path}%'"; } return "SELECT ID FROM {$wpdb->posts} WHERE ID > {$where_lowest_id} AND ID <= {$where_highest_id} AND ({$sql})"; @@ -547,23 +525,14 @@ protected function generate_update_sql( $url_pairs, $ids ) { if ( empty( $sql ) ) { // First replace statement - $sql = "REPLACE(post_content, '{$pair['old_url']}', '{$pair['new_url']}')"; + $sql = "REPLACE({$this->column_name}, '{$pair['old_url']}', '{$pair['new_url']}')"; } else { // Nested replace statement $sql = "REPLACE({$sql}, '{$pair['old_url']}', '{$pair['new_url']}')"; } } - return "UPDATE {$wpdb->posts} SET `post_content` = {$sql} WHERE `ID` IN({$ids})"; - } - - /** - * Get running message. - * - * @return string - */ - protected function get_running_message() { - return sprintf( __( 'Running 1.2 Upgrade%1$s
    A find & replace is running in the background to update URLs in your content. %2$s', 'amazon-s3-and-cloudfront' ), $this->get_progress_text(), $this->get_generic_message() ); + return "UPDATE {$wpdb->posts} SET `{$this->column_name}` = {$sql} WHERE `ID` IN({$ids})"; } /** @@ -572,7 +541,7 @@ protected function get_running_message() { * @return string */ protected function get_paused_message() { - return sprintf( __( 'Paused 1.2 Upgrade
    The find & replace to update URLs in your content has been paused. %s', 'amazon-s3-and-cloudfront' ), $this->get_generic_message() ); + return sprintf( __( 'Paused Upgrade
    The find & replace to update URLs has been paused. %s', 'amazon-s3-and-cloudfront' ), $this->get_generic_message() ); } /** diff --git a/classes/as3cf-upgrade.php b/classes/as3cf-upgrade.php index d7c81103..1240dc0f 100644 --- a/classes/as3cf-upgrade.php +++ b/classes/as3cf-upgrade.php @@ -78,6 +78,11 @@ abstract class AS3CF_Upgrade { */ protected $error_count; + /** + * @var string + */ + protected $lock_key = 'as3cf_upgrade_lock'; + const STATUS_RUNNING = 1; const STATUS_ERROR = 2; const STATUS_PAUSED = 3; @@ -90,8 +95,9 @@ abstract class AS3CF_Upgrade { public function __construct( $as3cf ) { $this->as3cf = $as3cf; - $this->cron_hook = 'as3cf_cron_update_' . $this->upgrade_name; - $this->cron_schedule_key = 'as3cf_update_' . $this->upgrade_name . '_interval'; + $this->running_update_text = $this->get_running_update_text(); + $this->cron_hook = 'as3cf_cron_update_' . $this->upgrade_name; + $this->cron_schedule_key = 'as3cf_update_' . $this->upgrade_name . '_interval'; $this->cron_interval_in_minutes = apply_filters( 'as3cf_update_' . $this->upgrade_name . '_interval', 2 ); $this->error_threshold = apply_filters( 'as3cf_update_' . $this->upgrade_name . '_error_threshold', 20 ); @@ -128,16 +134,6 @@ protected function maybe_init() { return false; } - // If the upgrade status is already set, then we've already initialized the upgrade - if ( $upgrade_status = $this->get_upgrade_status() ) { - if ( self::STATUS_RUNNING === $upgrade_status ) { - // Make sure cron job is persisted in case it has dropped - $this->schedule(); - } - - return false; - } - // Have we completed the upgrade? if ( $this->get_saved_upgrade_id() >= $this->upgrade_id ) { return false; @@ -148,6 +144,11 @@ protected function maybe_init() { return false; } + // Does the upgrade lock exist? + if ( false !== get_site_transient( $this->lock_key ) ) { + return false; + } + // Do we actually have attachments to process? if ( 0 === $this->count_items_to_process() ) { $this->upgrade_finished(); @@ -155,6 +156,16 @@ protected function maybe_init() { return false; } + // If the upgrade status is already set, then we've already initialized the upgrade + if ( $upgrade_status = $this->get_upgrade_status() ) { + if ( self::STATUS_RUNNING === $upgrade_status ) { + // Make sure cron job is persisted in case it has dropped + $this->schedule(); + } + + return false; + } + return true; } @@ -185,6 +196,13 @@ abstract protected function get_items_to_process( $prefix, $limit, $offset = fal */ abstract protected function upgrade_item( $attachment ); + /** + * Get running update text. + * + * @return string + */ + abstract protected function get_running_update_text(); + /** * Fire up the upgrade */ @@ -199,6 +217,8 @@ protected function init() { * Cron job to update the region of the bucket in s3 metadata */ public function do_upgrade() { + $this->lock_upgrade(); + // Check if the cron should even be running if ( $this->get_saved_upgrade_id() >= $this->upgrade_id || $this->get_upgrade_status() !== self::STATUS_RUNNING ) { $this->unschedule(); @@ -570,4 +590,11 @@ protected function has_previous_upgrade_completed() { return true; } + + /** + * Lock upgrade. + */ + protected function lock_upgrade() { + set_site_transient( $this->lock_key, $this->upgrade_id, MINUTE_IN_SECONDS * 3 ); + } } diff --git a/classes/upgrades/as3cf-file-sizes.php b/classes/upgrades/as3cf-file-sizes.php index 29f9e87b..ab44c704 100644 --- a/classes/upgrades/as3cf-file-sizes.php +++ b/classes/upgrades/as3cf-file-sizes.php @@ -25,18 +25,27 @@ class AS3CF_Upgrade_File_Sizes extends AS3CF_Upgrade { /** - * Initiate the upgrade - * - * @param object $as3cf Instance of calling class + * @var int */ - public function __construct( $as3cf ) { - $this->upgrade_id = 2; - $this->upgrade_name = 'file_sizes'; - $this->upgrade_type = 'attachments'; + protected $upgrade_id = 2; - $this->running_update_text = __( 'and updating the metadata with the sizes of files that have been removed from the server. This will allow us to serve the correct size for media items and the total space used in Multisite subsites.', 'amazon-s3-and-cloudfront' ); + /** + * @var string + */ + protected $upgrade_name = 'file_sizes'; - parent::__construct( $as3cf ); + /** + * @var string 'metadata', 'attachment' + */ + protected $upgrade_type = 'attachments'; + + /** + * Get running update text. + * + * @return string + */ + protected function get_running_update_text() { + return __( 'and updating the metadata with the sizes of files that have been removed from the server. This will allow us to serve the correct size for media items and the total space used in Multisite subsites.', 'amazon-s3-and-cloudfront' ); } /** diff --git a/classes/upgrades/as3cf-edd-replace-urls.php b/classes/upgrades/as3cf-filter-edd.php similarity index 82% rename from classes/upgrades/as3cf-edd-replace-urls.php rename to classes/upgrades/as3cf-filter-edd.php index 2db6faa4..61a7d9bf 100644 --- a/classes/upgrades/as3cf-edd-replace-urls.php +++ b/classes/upgrades/as3cf-filter-edd.php @@ -16,18 +16,27 @@ class AS3CF_Upgrade_EDD_Replace_URLs extends AS3CF_Upgrade { /** - * Initiate the upgrade - * - * @param object $as3cf Instance of calling class + * @var int */ - public function __construct( $as3cf ) { - $this->upgrade_id = 5; - $this->upgrade_name = 'replace_edd_urls'; - $this->upgrade_type = 'post meta'; + protected $upgrade_id = 5; - $this->running_update_text = __( 'and ensuring that only the local URL exists in EDD post meta.', 'amazon-s3-and-cloudfront' ); + /** + * @var string + */ + protected $upgrade_name = 'replace_edd_urls'; - parent::__construct( $as3cf ); + /** + * @var string 'metadata', 'attachment' + */ + protected $upgrade_type = 'post meta'; + + /** + * Get running update text. + * + * @return string + */ + protected function get_running_update_text() { + return __( 'and ensuring that only the local URL exists in EDD post meta.', 'amazon-s3-and-cloudfront' ); } /** diff --git a/classes/upgrades/as3cf-filter-post-content.php b/classes/upgrades/as3cf-filter-post-content.php new file mode 100644 index 00000000..aa3546bc --- /dev/null +++ b/classes/upgrades/as3cf-filter-post-content.php @@ -0,0 +1,93 @@ +Running Content Upgrade%1$s
    A find & replace is running in the background to update URLs in your post content. %2$s', 'amazon-s3-and-cloudfront' ), $this->get_progress_text(), $this->get_generic_message() ); + } + + /** + * Process blog. + * + * @param array $blog + */ + protected function process_blog( $blog ) { + $this->upgrade_theme_mods( $blog['prefix'] ); + } + + /** + * Upgrade theme mods. Ensures background and header images have local URLs saved to the database. + * + * @param string $prefix + */ + protected function upgrade_theme_mods( $prefix ) { + global $wpdb; + + $mods = $wpdb->get_results( "SELECT * FROM `{$prefix}options` WHERE option_name LIKE 'theme_mods_%'" ); + + foreach ( $mods as $mod ) { + $value = maybe_unserialize( $mod->option_value ); + + if ( isset( $value['background_image'] ) ) { + $value['background_image'] = $this->as3cf->filter_s3->filter_customizer_image( $value['background_image'] ); + } + + if ( isset( $value['header_image'] ) ) { + $value['header_image'] = $this->as3cf->filter_s3->filter_customizer_image( $value['header_image'] ); + } + + if ( isset( $value['header_image_data'] ) ) { + $value['header_image_data'] = $this->as3cf->filter_s3->filter_header_image_data( $value['header_image_data'] ); + } + + $value = maybe_serialize( $value ); + + if ( $value !== $mod->option_value ) { + $wpdb->query( "UPDATE `{$prefix}options` SET option_value = '{$value}' WHERE option_id = '{$mod->option_id}'" ); + } + } + } + +} \ No newline at end of file diff --git a/classes/upgrades/as3cf-filter-post-excerpt.php b/classes/upgrades/as3cf-filter-post-excerpt.php new file mode 100644 index 00000000..07dce7a2 --- /dev/null +++ b/classes/upgrades/as3cf-filter-post-excerpt.php @@ -0,0 +1,50 @@ +Running Excerpts Upgrade%1$s
    A find & replace is running in the background to update URLs in your post excerpts. %2$s', 'amazon-s3-and-cloudfront' ), $this->get_progress_text(), $this->get_generic_message() ); + } +} \ No newline at end of file diff --git a/classes/upgrades/as3cf-meta-wp-error.php b/classes/upgrades/as3cf-meta-wp-error.php index 1adeebcd..99e8a299 100644 --- a/classes/upgrades/as3cf-meta-wp-error.php +++ b/classes/upgrades/as3cf-meta-wp-error.php @@ -26,18 +26,27 @@ class AS3CF_Upgrade_Meta_WP_Error extends AS3CF_Upgrade { /** - * Initiate the upgrade - * - * @param object $as3cf Instance of calling class + * @var int */ - public function __construct( $as3cf ) { - $this->upgrade_id = 3; - $this->upgrade_name = 'meta_error'; - $this->upgrade_type = 'attachments'; + protected $upgrade_id = 3; - $this->running_update_text = __( 'and rebuilding the metadata for attachments that may have been corrupted.', 'amazon-s3-and-cloudfront' ); + /** + * @var string + */ + protected $upgrade_name = 'meta_error'; - parent::__construct( $as3cf ); + /** + * @var string 'metadata', 'attachment' + */ + protected $upgrade_type = 'attachments'; + + /** + * Get running update text. + * + * @return string + */ + protected function get_running_update_text() { + return __( 'and rebuilding the metadata for attachments that may have been corrupted.', 'amazon-s3-and-cloudfront' ); } /** diff --git a/classes/upgrades/as3cf-region-meta.php b/classes/upgrades/as3cf-region-meta.php index 66b5199b..048ed2e7 100644 --- a/classes/upgrades/as3cf-region-meta.php +++ b/classes/upgrades/as3cf-region-meta.php @@ -24,18 +24,27 @@ class AS3CF_Upgrade_Region_Meta extends AS3CF_Upgrade { /** - * Initiate the upgrade - * - * @param object $as3cf Instance of calling class + * @var int */ - public function __construct( $as3cf ) { - $this->upgrade_id = 1; - $this->upgrade_name = 'meta_with_region'; - $this->upgrade_type = 'metadata'; + protected $upgrade_id = 1; - $this->running_update_text = __( 'and updating the metadata with the bucket region it is served from. This will allow us to serve your files from the proper S3 region subdomain (e.g. s3-us-west-2.amazonaws.com).', 'amazon-s3-and-cloudfront' ); + /** + * @var string + */ + protected $upgrade_name = 'meta_with_region'; - parent::__construct( $as3cf ); + /** + * @var string 'metadata', 'attachment' + */ + protected $upgrade_type = 'metadata'; + + /** + * Get running update text. + * + * @return string + */ + protected function get_running_update_text() { + return __( 'and updating the metadata with the bucket region it is served from. This will allow us to serve your files from the proper S3 region subdomain (e.g. s3-us-west-2.amazonaws.com).', 'amazon-s3-and-cloudfront' ); } /** diff --git a/classes/wp-aws-compatibility-check.php b/classes/wp-aws-compatibility-check.php index cf2cb5f1..f8435862 100644 --- a/classes/wp-aws-compatibility-check.php +++ b/classes/wp-aws-compatibility-check.php @@ -332,7 +332,7 @@ function get_error_msg() { } else { $msg .= ' ' . __( 'It appears to be installed already.', 'amazon-s3-and-cloudfront' ); $activate_url = $this->get_plugin_action_url( 'activate', $parent_basename ); - $msg .= ' ' . _x( 'Activate it now.', 'Activate plugin', 'amazon-s3-and-cloudfront' ) . ''; + $msg .= ' ' . _x( 'Activate it now.', 'Activate plugin', 'amazon-s3-and-cloudfront' ) . ''; } } else { $install_url = 'https://deliciousbrains.com/my-account/'; @@ -479,7 +479,7 @@ function get_admin_notice() { * @param string $message */ function render_notice( $message ) { - printf( '

    %s

    ', $message ); + printf( '

    %s

    ', $message ); } /** diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index 4993ba15..4bb88f81 100644 --- a/languages/amazon-s3-and-cloudfront-en.pot +++ b/languages/amazon-s3-and-cloudfront-en.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: amazon-s3-and-cloudfront\n" "Report-Msgid-Bugs-To: nom@deliciousbrains.com\n" -"POT-Creation-Date: 2016-11-28 11:11+0000\n" +"POT-Creation-Date: 2016-12-13 11:56+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,127 +25,127 @@ msgstr "" msgid "S3 and CloudFront" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:214 +#: classes/amazon-s3-and-cloudfront.php:215 #: view/bucket-setting.php:18 msgid "defined in wp-config.php" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:851 +#: classes/amazon-s3-and-cloudfront.php:874 msgid "Upload aborted by filter 'as3cf_pre_upload_attachment'" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:862 +#: classes/amazon-s3-and-cloudfront.php:885 #, php-format msgid "File %s does not exist" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:873 +#: classes/amazon-s3-and-cloudfront.php:896 #, php-format msgid "Mime type %s is not allowed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:958 +#: classes/amazon-s3-and-cloudfront.php:981 #, php-format msgid "Error uploading %s to S3: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2134 +#: classes/amazon-s3-and-cloudfront.php:2170 msgid "Cheatin’ eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2138 +#: classes/amazon-s3-and-cloudfront.php:2174 msgid "You do not have sufficient permissions to access this page." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2144 +#: classes/amazon-s3-and-cloudfront.php:2180 msgid "No bucket name provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2429 +#: classes/amazon-s3-and-cloudfront.php:2439 msgid "Error Getting Bucket Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2430 +#: classes/amazon-s3-and-cloudfront.php:2440 #, php-format msgid "There was an error attempting to get the region of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2550 +#: classes/amazon-s3-and-cloudfront.php:2560 msgid "" "This is a test file to check if the user has write permission to S3. Delete " "me if found." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2582 +#: classes/amazon-s3-and-cloudfront.php:2592 #, php-format msgid "" "There was an error attempting to check the permissions of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2639 +#: classes/amazon-s3-and-cloudfront.php:2649 msgid "Error creating bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2640 +#: classes/amazon-s3-and-cloudfront.php:2650 msgid "Bucket name too short." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2641 +#: classes/amazon-s3-and-cloudfront.php:2651 msgid "Bucket name too long." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2642 +#: classes/amazon-s3-and-cloudfront.php:2652 msgid "" "Invalid character. Bucket names can contain lowercase letters, numbers, " "periods and hyphens." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2643 +#: classes/amazon-s3-and-cloudfront.php:2653 msgid "Error saving bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2644 +#: classes/amazon-s3-and-cloudfront.php:2654 msgid "Error fetching buckets" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2645 +#: classes/amazon-s3-and-cloudfront.php:2655 msgid "Error getting URL preview: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2646 +#: classes/amazon-s3-and-cloudfront.php:2656 msgid "The changes you made will be lost if you navigate away from this page" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2647 +#: classes/amazon-s3-and-cloudfront.php:2657 msgid "Getting diagnostic info..." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2648 +#: classes/amazon-s3-and-cloudfront.php:2658 msgid "Error getting diagnostic info: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2716 +#: classes/amazon-s3-and-cloudfront.php:2726 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2824 +#: classes/amazon-s3-and-cloudfront.php:2834 msgctxt "Show the media library tab" msgid "Media Library" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2825 +#: classes/amazon-s3-and-cloudfront.php:2835 msgctxt "Show the support tab" msgid "Support" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3041 +#: classes/amazon-s3-and-cloudfront.php:3052 #, php-format msgid "" "WP Offload S3 — The file %s has been given %s " "permissions on Amazon S3." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3060 +#: classes/amazon-s3-and-cloudfront.php:3071 msgid "" "WP Offload S3 Requirement Missing — Looks like you " "don't have an image manipulation library installed on this server and " @@ -153,11 +153,11 @@ msgid "" "Please setup GD or ImageMagick." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3723 +#: classes/amazon-s3-and-cloudfront.php:3748 msgid "Quick Start Guide" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3725 +#: classes/amazon-s3-and-cloudfront.php:3750 #, php-format msgid "" "Looks like we don't have write access to this bucket. It's likely that the " @@ -166,7 +166,7 @@ msgid "" "correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3727 +#: classes/amazon-s3-and-cloudfront.php:3752 #, php-format msgid "" "Looks like we don't have access to the buckets. It's likely that the user " @@ -174,39 +174,39 @@ msgid "" "Please see our %s for instructions on setting up permissions correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3878 +#: classes/amazon-s3-and-cloudfront.php:3903 msgid "WP Offload S3 Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3879 +#: classes/amazon-s3-and-cloudfront.php:3904 msgid "" "WP Offload S3 Lite and WP Offload S3 cannot both be active. We've " "automatically deactivated WP Offload S3 Lite." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3881 +#: classes/amazon-s3-and-cloudfront.php:3906 msgid "WP Offload S3 Lite Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3882 +#: classes/amazon-s3-and-cloudfront.php:3907 msgid "" "WP Offload S3 Lite and WP Offload S3 cannot both be active. We've " "automatically deactivated WP Offload S3." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3956 +#: classes/amazon-s3-and-cloudfront.php:3981 msgid "More info" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4047 +#: classes/amazon-s3-and-cloudfront.php:4072 msgid "this doc" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4049 +#: classes/amazon-s3-and-cloudfront.php:4074 msgid "WP Offload S3 Feature Removed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4050 +#: classes/amazon-s3-and-cloudfront.php:4075 #, php-format msgid "" "You had the \"Always non-SSL\" option selected in your settings, but we've " @@ -217,32 +217,32 @@ msgid "" "to the old behavior." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4078 -#: classes/amazon-s3-and-cloudfront.php:4171 +#: classes/amazon-s3-and-cloudfront.php:4103 +#: classes/amazon-s3-and-cloudfront.php:4196 msgid "Amazon S3" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4172 +#: classes/amazon-s3-and-cloudfront.php:4197 msgctxt "Amazon S3 bucket" msgid "Bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4173 +#: classes/amazon-s3-and-cloudfront.php:4198 msgctxt "Path to file on Amazon S3" msgid "Path" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4174 +#: classes/amazon-s3-and-cloudfront.php:4199 msgctxt "Location of Amazon S3 bucket" msgid "Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4175 +#: classes/amazon-s3-and-cloudfront.php:4200 msgctxt "Access control list of the file on Amazon S3" msgid "Access" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4176 +#: classes/amazon-s3-and-cloudfront.php:4201 msgid "URL" msgstr "" @@ -290,24 +290,42 @@ msgstr "" #: classes/as3cf-plugin-compatibility.php:665 #: classes/as3cf-plugin-compatibility.php:677 -#: classes/upgrades/as3cf-meta-wp-error.php:72 +#: classes/upgrades/as3cf-meta-wp-error.php:81 #, php-format msgid "There was an error attempting to download the file %s from S3: %s" msgstr "" -#: classes/as3cf-upgrade.php:298 +#: classes/as3cf-upgrade-filter-post.php:544 +#, php-format +msgid "" +"Paused Upgrade
    The find & replace to update URLs has " +"been paused. %s" +msgstr "" + +#: classes/as3cf-upgrade-filter-post.php:553 +msgid "See our documentation" +msgstr "" + +#: classes/as3cf-upgrade-filter-post.php:556 +#, php-format +msgid "" +"%s for details on why we’re doing this, why it runs slowly, and how to " +"make it run faster." +msgstr "" + +#: classes/as3cf-upgrade.php:318 msgid "Pause Update" msgstr "" -#: classes/as3cf-upgrade.php:306 +#: classes/as3cf-upgrade.php:326 msgid "Restart Update" msgstr "" -#: classes/as3cf-upgrade.php:310 +#: classes/as3cf-upgrade.php:330 msgid "Try Run It Again" msgstr "" -#: classes/as3cf-upgrade.php:333 +#: classes/as3cf-upgrade.php:353 #, php-format msgid "" "Running %1$s Update%2$s — We’re going through " @@ -317,14 +335,14 @@ msgid "" "performance." msgstr "" -#: classes/as3cf-upgrade.php:347 +#: classes/as3cf-upgrade.php:367 #, php-format msgid "" "%1$s Update Paused%2$s — Updating Media Library %3$s " "has been paused." msgstr "" -#: classes/as3cf-upgrade.php:360 +#: classes/as3cf-upgrade.php:380 #, php-format msgid "" "Error Updating %1$s — We ran into some errors " @@ -332,62 +350,55 @@ msgid "" "been uploaded to S3. Please check your error log for details. (#%3$d)" msgstr "" -#: classes/as3cf-upgrade.php:384 +#: classes/as3cf-upgrade.php:404 #, php-format msgid " (%s%% Complete)" msgstr "" -#: classes/as3cf-upgrade.php:495 +#: classes/as3cf-upgrade.php:515 #, php-format msgid "Every %d Minutes" msgstr "" -#: classes/upgrades/as3cf-content-replace-urls.php:43 -msgid "and ensuring that only the local URL exists in post content." -msgstr "" - -#: classes/upgrades/as3cf-content-replace-urls.php:566 -#, php-format +#: classes/upgrades/as3cf-file-sizes.php:48 msgid "" -"Running 1.2 Upgrade%1$s
    A find & replace is running " -"in the background to update URLs in your content. %2$s" +"and updating the metadata with the sizes of files that have been removed " +"from the server. This will allow us to serve the correct size for media " +"items and the total space used in Multisite subsites." msgstr "" -#: classes/upgrades/as3cf-content-replace-urls.php:575 -#, php-format -msgid "" -"Paused 1.2 Upgrade
    The find & replace to update URLs " -"in your content has been paused. %s" +#: classes/upgrades/as3cf-filter-edd.php:39 +msgid "and ensuring that only the local URL exists in EDD post meta." msgstr "" -#: classes/upgrades/as3cf-content-replace-urls.php:584 -msgid "See our documentation" +#: classes/upgrades/as3cf-filter-post-content.php:39 +msgid "and ensuring that only the local URL exists in post content." msgstr "" -#: classes/upgrades/as3cf-content-replace-urls.php:587 +#: classes/upgrades/as3cf-filter-post-content.php:48 #, php-format msgid "" -"%s for details on why we’re doing this, why it runs slowly, and how to " -"make it run faster." +"Running Content Upgrade%1$s
    A find & replace is " +"running in the background to update URLs in your post content. %2$s" msgstr "" -#: classes/upgrades/as3cf-edd-replace-urls.php:28 -msgid "and ensuring that only the local URL exists in EDD post meta." +#: classes/upgrades/as3cf-filter-post-excerpt.php:39 +msgid "and ensuring that only the local URL exists in post excerpts." msgstr "" -#: classes/upgrades/as3cf-file-sizes.php:37 +#: classes/upgrades/as3cf-filter-post-excerpt.php:48 +#, php-format msgid "" -"and updating the metadata with the sizes of files that have been removed " -"from the server. This will allow us to serve the correct size for media " -"items and the total space used in Multisite subsites." +"Running Excerpts Upgrade%1$s
    A find & replace is " +"running in the background to update URLs in your post excerpts. %2$s" msgstr "" -#: classes/upgrades/as3cf-meta-wp-error.php:38 +#: classes/upgrades/as3cf-meta-wp-error.php:49 msgid "" "and rebuilding the metadata for attachments that may have been corrupted." msgstr "" -#: classes/upgrades/as3cf-region-meta.php:36 +#: classes/upgrades/as3cf-region-meta.php:47 msgid "" "and updating the metadata with the bucket region it is served from. This " "will allow us to serve your files from the proper S3 region subdomain

    - +

    - - - + + +

    - +

    @@ -22,8 +22,8 @@

    - - + +

    @@ -37,7 +37,7 @@ - +

    @@ -49,7 +49,7 @@ get_aws_regions(); if ( ! defined( 'AS3CF_REGION' ) ) { ?> - $label ) : ?> @@ -63,7 +63,7 @@

    - +

    diff --git a/view/bucket-setting.php b/view/bucket-setting.php index 3e6b6dea..4a2f821a 100644 --- a/view/bucket-setting.php +++ b/view/bucket-setting.php @@ -13,7 +13,7 @@ get_defined_setting( 'bucket', false ) ) { ?> - + ' . __( 'defined in wp-config.php', 'amazon-s3-and-cloudfront' ) . '
    '; } ?> diff --git a/view/checkbox.php b/view/checkbox.php index 1bca9cb7..738a41e6 100644 --- a/view/checkbox.php +++ b/view/checkbox.php @@ -3,10 +3,11 @@ $class = ( isset( $class ) ) ? 'class="' . $class . '"' : ''; $disabled = ( isset( $disabled ) && $disabled ) ? ' disabled' : ''; $values = ( isset( $values ) && is_array( $values ) && 2 === count( $values ) ) ? $values : array( 0, 1 ); +$prefix = $this->get_plugin_prefix_slug(); ?> -
    +
    ON OFF - /> -
    \ No newline at end of file + /> +
    diff --git a/view/cloudfront-setting.php b/view/cloudfront-setting.php index 4b002a8f..648362cd 100644 --- a/view/cloudfront-setting.php +++ b/view/cloudfront-setting.php @@ -1,6 +1,9 @@ -

    +get_plugin_prefix_slug(); +?> +

    /> -

    \ No newline at end of file +

    diff --git a/view/settings.php b/view/settings.php index 9e57c221..95edf1fe 100644 --- a/view/settings.php +++ b/view/settings.php @@ -39,7 +39,7 @@ 'prefix' => $prefix, 'selected_bucket' => $selected_bucket, 'selected_bucket_prefix' => $selected_bucket_prefix, - 'tr_class' => 'as3cf-border-bottom as3cf-bucket-setting', + 'tr_class' => "as3cf-border-bottom {$prefix}-bucket-setting", ) ); ?> @@ -103,7 +103,7 @@ settings_more_info_link( 'object-prefix' ); ?>

    -

    +

    get_setting_args( 'object-prefix' ); ?> />

    @@ -214,4 +214,4 @@ if ( ! $this->is_pro() ) { $this->render_view( 'sidebar' ); } -?> \ No newline at end of file +?> diff --git a/wordpress-s3.php b/wordpress-s3.php index 126a6bdf..60606547 100644 --- a/wordpress-s3.php +++ b/wordpress-s3.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/ Description: Automatically copies media uploads to Amazon S3 for storage and delivery. Optionally configure Amazon CloudFront for even faster delivery. Author: Delicious Brains -Version: 1.1.3 +Version: 1.1.4 Author URI: http://deliciousbrains.com/ Network: True Text Domain: amazon-s3-and-cloudfront @@ -26,9 +26,9 @@ // Then completely rewritten. */ -$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.1.3'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.1.4'; -$aws_plugin_version_required = '1.0'; +$aws_plugin_version_required = '1.0.1'; require_once dirname( __FILE__ ) . '/classes/wp-aws-compatibility-check.php'; require_once dirname( __FILE__ ) . '/classes/as3cf-utils.php'; @@ -62,11 +62,13 @@ function as3cf_init( $aws ) { require_once $abspath . '/include/functions.php'; require_once $abspath . '/classes/as3cf-error.php'; require_once $abspath . '/classes/as3cf-upgrade.php'; + require_once $abspath . '/classes/as3cf-upgrade-filter-post.php'; require_once $abspath . '/classes/upgrades/as3cf-region-meta.php'; require_once $abspath . '/classes/upgrades/as3cf-file-sizes.php'; require_once $abspath . '/classes/upgrades/as3cf-meta-wp-error.php'; - require_once $abspath . '/classes/upgrades/as3cf-content-replace-urls.php'; - require_once $abspath . '/classes/upgrades/as3cf-edd-replace-urls.php'; + require_once $abspath . '/classes/upgrades/as3cf-filter-edd.php'; + require_once $abspath . '/classes/upgrades/as3cf-filter-post-content.php'; + require_once $abspath . '/classes/upgrades/as3cf-filter-post-excerpt.php'; require_once $abspath . '/classes/as3cf-filter.php'; require_once $abspath . '/classes/filters/as3cf-local-to-s3.php'; require_once $abspath . '/classes/filters/as3cf-s3-to-local.php';