From 340ad2ccda16ccd8169b35d397ef63ef1c3b3f9b Mon Sep 17 00:00:00 2001 From: "Ian M. Jones" Date: Mon, 20 Nov 2017 15:15:25 +0000 Subject: [PATCH] Deploying version 1.2.1 --- README.md | 15 ++- assets/css/notice.css | 2 +- assets/js/media.js | 6 +- assets/js/media.min.js | 2 +- assets/js/script.js | 61 ++++++----- assets/js/script.min.js | 2 +- assets/sass/notice.scss | 7 ++ classes/amazon-s3-and-cloudfront.php | 97 +++++++++++------ classes/as3cf-filter.php | 24 +++++ classes/as3cf-plugin-compatibility.php | 45 ++++++++ classes/as3cf-utils.php | 87 ++++++++++++++-- classes/null-s3-client.php | 34 ++++++ classes/upgrades/upgrade-filter-post.php | 4 +- classes/wp-aws-compatibility-check.php | 4 +- languages/amazon-s3-and-cloudfront-en.pot | 121 +++++++++++----------- readme.txt | 15 ++- view/attachment-metabox.php | 21 +++- wordpress-s3.php | 6 +- 18 files changed, 408 insertions(+), 145 deletions(-) create mode 100644 classes/null-s3-client.php diff --git a/README.md b/README.md index ec285e83..f816e739 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.6 -**Tested up to:** 4.8 -**Stable tag:** 1.2 +**Tested up to:** 4.9 +**Stable tag:** 1.2.1 **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,17 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog ## +### WP Offload S3 Lite 1.2.1 - 2017-11-20 ### +* New: Compatibility with HTML Widget +* New: Dismissible admin notice that WP Offload S3 Lite will soon require PHP 5.5+ +* Improvement: Compatibility with WordPress 4.9 +* Bug fix: Incorrect region used when changing bucket by defining it in WPOS3_SETTINGS +* Bug fix: Media library notices render inside the upload tool +* Bug fix: Save notices disappear on settings page +* Bug fix: Improper use of jQuery.attr logged to browser console +* Bug fix: "Content Filtering Upgrade" URL in notice incorrect +* Bug fix: "More info" links can be broken across two lines + ### WP Offload S3 Lite 1.2 - 2017-06-19 ### * New: Compatibility with WordPress 4.8 * New: Support for WP CLI `wp media regenerate` diff --git a/assets/css/notice.css b/assets/css/notice.css index 0c584a31..a7c1c7a6 100644 --- a/assets/css/notice.css +++ b/assets/css/notice.css @@ -1 +1 @@ -.as3cf-notice p,.aws-compatibility-notice p{max-width:800px} +.as3cf-notice p,.aws-compatibility-notice p{max-width:800px}.as3cf-license-notice p:not(.as3cf-before):before{display:none} diff --git a/assets/js/media.js b/assets/js/media.js index c9912484..69f9e835 100644 --- a/assets/js/media.js +++ b/assets/js/media.js @@ -112,7 +112,7 @@ var test = {}; event.preventDefault(); var toggle = $( '#as3cfpro-toggle-acl' ); - var currentACL = toggle.attr( 'data-currentACL' ); + var currentACL = toggle.data( 'currentacl' ); var newACL = as3cfpro_media.settings.private_acl; toggle.hide(); @@ -124,7 +124,7 @@ var test = {}; wp.ajax.send( 'as3cfpro_update_acl', { data: { - _nonce: as3cfpro_media.nonces.update_acl, + _ajax_nonce: as3cfpro_media.nonces.singular_update_acl, id: this.model.get( 'id' ), acl: newACL } @@ -155,7 +155,7 @@ var test = {}; toggle.text( response.acl_display ); toggle.attr( 'title', response.title ); - toggle.attr( 'data-currentACL', response.acl ); + toggle.data( 'currentacl', response.acl ); toggle.show(); } } ); diff --git a/assets/js/media.min.js b/assets/js/media.min.js index 286bc5ba..b1b4e568 100644 --- a/assets/js/media.min.js +++ b/assets/js/media.min.js @@ -1 +1 @@ -var test={};!function(a,b){var c=wp.media,d=c.view.Attachment.Details.TwoColumn;c.view.Attachment.Details.TwoColumn=d.extend({events:function(){return b.extend({},d.prototype.events,{"click .local-warning":"confirmS3Removal","click #as3cfpro-toggle-acl":"toggleACL"})},render:function(){this.fetchS3Details(this.model.get("id"))},fetchS3Details:function(a){wp.ajax.send("as3cf_get_attachment_s3_details",{data:{_nonce:as3cf_media.nonces.get_attachment_s3_details,id:a}}).done(b.bind(this.renderView,this))},renderView:function(a){d.prototype.render.apply(this),this.renderActionLinks(a),this.renderS3Details(a)},renderActionLinks:function(c){var d=c&&c.links||[],e=this.$el.find(".actions"),f=a("
",{"class":"s3-actions"}),g=[];b(d).each(function(a){g.push(a)}),f.append(g.join(" | ")),e.append(f)},renderS3Details:function(a){if(a&&a.s3object){var b=this.$el.find(".attachment-info .details"),c=this.generateDetails(a,["bucket","key","region","acl"]);b.append(c)}},generateDetails:function(a,c){var d="",e=b.template('
<%= label %>: <%= value %>
');return b(c).each(function(c){if(a.s3object[c]){var f=a.s3object[c];if("acl"===c&&(f=a.s3object[c].name,a.acl_toggle)){var g=b.template('<%= value %>');f=g({title:a.s3object[c].title,acl:a.s3object[c].acl,value:f})}d+=e({key:c,label:as3cf_media.strings[c],value:f})}}),d},confirmS3Removal:function(a){if(!confirm(as3cfpro_media.strings.local_warning))return a.preventDefault(),a.stopImmediatePropagation(),!1},toggleACL:function(c){c.preventDefault();var d=a("#as3cfpro-toggle-acl"),e=d.attr("data-currentACL"),f=as3cfpro_media.settings.private_acl;d.hide(),d.after(''+as3cfpro_media.strings.updating_acl+""),e===as3cfpro_media.settings.private_acl&&(f=as3cfpro_media.settings.default_acl),wp.ajax.send("as3cfpro_update_acl",{data:{_nonce:as3cfpro_media.nonces.update_acl,id:this.model.get("id"),acl:f}}).done(b.bind(this.updateACL,this)).fail(b.bind(this.renderACLError,this))},renderACLError:function(){a("#as3cfpro-updating").remove(),a("#as3cfpro-toggle-acl").show(),alert(as3cfpro_media.strings.change_acl_error)},updateACL:function(b){if(null==b.acl_display||null==b.title||null==b.acl||null==b.url)return void this.renderACLError();this.model.set("url",b.url),this.render();var c=a("#as3cfpro-toggle-acl");a("#as3cfpro-updating").remove(),c.text(b.acl_display),c.attr("title",b.title),c.attr("data-currentACL",b.acl),c.show()}})}(jQuery,_); \ No newline at end of file +var test={};!function(a,b){var c=wp.media,d=c.view.Attachment.Details.TwoColumn;c.view.Attachment.Details.TwoColumn=d.extend({events:function(){return b.extend({},d.prototype.events,{"click .local-warning":"confirmS3Removal","click #as3cfpro-toggle-acl":"toggleACL"})},render:function(){this.fetchS3Details(this.model.get("id"))},fetchS3Details:function(a){wp.ajax.send("as3cf_get_attachment_s3_details",{data:{_nonce:as3cf_media.nonces.get_attachment_s3_details,id:a}}).done(b.bind(this.renderView,this))},renderView:function(a){d.prototype.render.apply(this),this.renderActionLinks(a),this.renderS3Details(a)},renderActionLinks:function(c){var d=c&&c.links||[],e=this.$el.find(".actions"),f=a("
",{"class":"s3-actions"}),g=[];b(d).each(function(a){g.push(a)}),f.append(g.join(" | ")),e.append(f)},renderS3Details:function(a){if(a&&a.s3object){var b=this.$el.find(".attachment-info .details"),c=this.generateDetails(a,["bucket","key","region","acl"]);b.append(c)}},generateDetails:function(a,c){var d="",e=b.template('
<%= label %>: <%= value %>
');return b(c).each(function(c){if(a.s3object[c]){var f=a.s3object[c];if("acl"===c&&(f=a.s3object[c].name,a.acl_toggle)){var g=b.template('<%= value %>');f=g({title:a.s3object[c].title,acl:a.s3object[c].acl,value:f})}d+=e({key:c,label:as3cf_media.strings[c],value:f})}}),d},confirmS3Removal:function(a){if(!confirm(as3cfpro_media.strings.local_warning))return a.preventDefault(),a.stopImmediatePropagation(),!1},toggleACL:function(c){c.preventDefault();var d=a("#as3cfpro-toggle-acl"),e=d.data("currentacl"),f=as3cfpro_media.settings.private_acl;d.hide(),d.after(''+as3cfpro_media.strings.updating_acl+""),e===as3cfpro_media.settings.private_acl&&(f=as3cfpro_media.settings.default_acl),wp.ajax.send("as3cfpro_update_acl",{data:{_ajax_nonce:as3cfpro_media.nonces.singular_update_acl,id:this.model.get("id"),acl:f}}).done(b.bind(this.updateACL,this)).fail(b.bind(this.renderACLError,this))},renderACLError:function(){a("#as3cfpro-updating").remove(),a("#as3cfpro-toggle-acl").show(),alert(as3cfpro_media.strings.change_acl_error)},updateACL:function(b){if(null==b.acl_display||null==b.title||null==b.acl||null==b.url)return void this.renderACLError();this.model.set("url",b.url),this.render();var c=a("#as3cfpro-toggle-acl");a("#as3cfpro-updating").remove(),c.text(b.acl_display),c.attr("title",b.title),c.data("currentacl",b.acl),c.show()}})}(jQuery,_); \ No newline at end of file diff --git a/assets/js/script.js b/assets/js/script.js index 1179e041..19f2de7a 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -30,7 +30,7 @@ $switch.toggleClass( 'on' ).find( 'span' ).toggleClass( 'checked' ); var switchOn = $switch.find( 'span.on' ).hasClass( 'checked' ); - $checkbox.attr( 'checked', switchOn ).trigger( 'change' ); + $checkbox.prop( 'checked', switchOn ).trigger( 'change' ); } /** @@ -45,10 +45,10 @@ if ( pattern.test( $input.val() ) ) { $error.show(); - $submit.attr( 'disabled', true ); + $submit.prop( 'disabled', true ); } else { $error.hide(); - $submit.attr( 'disabled', false ); + $submit.prop( 'disabled', false ); } } @@ -68,9 +68,9 @@ $activeTab.show(); $( '.nav-tab' ).removeClass( 'nav-tab-active' ); $( 'a.nav-tab[data-tab="' + hash + '"]' ).addClass( 'nav-tab-active' ); - $( '.aws-main' ).attr( 'data-tab', hash ); - if ( $activeTab.attr( 'data-prefix' ) ) { - as3cfModal.prefix = $activeTab.attr( 'data-prefix' ); + $( '.aws-main' ).data( 'tab', hash ); + if ( $activeTab.data( 'prefix' ) ) { + as3cfModal.prefix = $activeTab.data( 'prefix' ); } if ( ! persist_updated_notice ) { $( '.as3cf-updated' ).removeClass( 'show' ); @@ -167,7 +167,7 @@ return; } - $bucketList.html( '
  • ' + $bucketList.attr( 'data-working' ) + '
  • ' ); + $bucketList.html( '
  • ' + $bucketList.data( 'working' ) + '
  • ' ); var data = { action: as3cfModal.prefix + '-get-buckets', @@ -264,7 +264,7 @@ return; } $( '.as3cf-bucket-error' ).hide(); - $manualBucketButton.text( $manualBucketButton.attr( 'data-working' ) ); + $manualBucketButton.text( $manualBucketButton.data( 'working' ) ); $manualBucketButton.prop( 'disabled', true ); var data = { @@ -324,14 +324,14 @@ return; } - var previousBucket = $( '.as3cf-bucket-list a.selected' ).attr( 'data-bucket' ); + var previousBucket = $( '.as3cf-bucket-list a.selected' ).data( 'bucket' ); $( '.as3cf-bucket-list a' ).removeClass( 'selected' ); $link.addClass( 'selected' ); $bucketList.addClass( 'saving' ); $link.find( '.spinner' ).show().css( 'visibility', 'visible' ); - var bucketName = $link.attr( 'data-bucket' ); + var bucketName = $link.data( 'bucket' ); var data = { action: as3cfModal.prefix + '-save-bucket', @@ -379,15 +379,15 @@ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' ); if ( $createBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) { - $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true ); + $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true ); } else { - $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', false ); + $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false ); } if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) { - $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true ); + $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true ); } else { - $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', false ); + $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false ); } }, @@ -480,7 +480,7 @@ var origButtonText = $createBucketButton.text(); $( '.as3cf-bucket-error' ).hide(); - $createBucketButton.text( $createBucketButton.attr( 'data-working' ) ); + $createBucketButton.text( $createBucketButton.data( 'working' ) ); $createBucketButton.prop( 'disabled', true ); var data = { @@ -512,9 +512,9 @@ // Tidy up create bucket form $( '.as3cf-bucket-select-region' ).hide(); - $( '.as3cf-bucket-select-region' ).removeAttr( 'selected' ); + $( '.as3cf-bucket-select-region' ).prop( 'selected', false ); $createBucketInput.val( '' ); - $createBucketButton.attr( 'disabled', true ); + $createBucketButton.prop( 'disabled', true ); // Make sure the bucket list will refresh the next time the modal loads refreshBucketListOnLoad = true; @@ -662,12 +662,9 @@ return; } - // Strip the # if still on the end of the URL - if ( 'function' === typeof history.replaceState && '#' === location.href.slice( -1 ) ) { - history.replaceState( {}, '', location.href.slice( 0, -1 ) ); - } - as3cf.tabs.toggle( location.hash.replace( '#', '' ), true ); + + $( document ).trigger( 'as3cf.tabRendered', [ location.hash.replace( '#', '' ) ] ); } $( document ).ready( function() { @@ -679,7 +676,15 @@ /** * Set the hashchange callback to update the rendered active tab. */ - window.onhashchange = renderCurrentTab; + window.onhashchange = function( event ) { + + // Strip the # if still on the end of the URL + if ( 'function' === typeof history.replaceState && '#' === location.href.slice( -1 ) ) { + history.replaceState( {}, '', location.href.slice( 0, -1 ) ); + } + + renderCurrentTab(); + }; // Move any compatibility errors below the nav tabs var $navTabs = $( '.wrap.aws-main .nav-tab-wrapper' ); @@ -768,7 +773,7 @@ var $submit = $( '#' + $activeTab.attr( 'id' ) + ' form button[type="submit"]' ); if ( 'cloudfront' !== $input.val() ) { - $submit.attr( 'disabled', false ); + $submit.prop( 'disabled', false ); } else { validateCustomDomain( $input.next( '.as3cf-setting' ).find( 'input[name="cloudfront"]' ) ); } @@ -862,9 +867,9 @@ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' ); if ( as3cf.buckets.isValidName( bucketName ) ) { - $createBucketForm.find( 'button[type=submit]' ).removeAttr( 'disabled' ); + $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false ); } else { - $createBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true ); + $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true ); } as3cf.buckets.updateNameNotice( bucketName ); } ); @@ -874,9 +879,9 @@ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' ); if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < as3cf.buckets.validLength ) { - $manualBucketForm.find( 'button[type=submit]' ).attr( 'disabled', true ); + $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true ); } else { - $manualBucketForm.find( 'button[type=submit]' ).removeAttr( 'disabled' ); + $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false ); } } ); diff --git a/assets/js/script.min.js b/assets/js/script.min.js index 457c04ca..6a72cfa0 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-remove-local-file").is(":checked")&&a("#as3cf-serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function i(){a("#as3cf-remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}function j(){return"#"+as3cf.tabs.defaultTab===location.hash?void(location.hash=""):("function"==typeof history.replaceState&&"#"===location.href.slice(-1)&&history.replaceState({},"",location.href.slice(0,-1)),void as3cf.tabs.toggle(location.hash.replace("#",""),!0))}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,h,i){var j=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),m=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===m.text().trim().length){d("as3cf-copy-to-s3-wrap"),d("as3cf-serve-from-s3-wrap");var n=k.attr("id");l[n]=c(n)}a(".as3cf-error.fatal").hide(),m.text(e),j.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(h),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!i),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(function(){k.trigger("bucket-change",[i]),as3cf.buckets.bucketSelectLock=!1})},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(){j(),window.onhashchange=j;var m=a(".wrap.aws-main .nav-tab-wrapper");a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(m),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()}),h(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){h()}),i(),a("#as3cf-remove-local-file").on("change",function(a){i()}),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.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.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").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.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]").prop("disabled",!0):c.find("button[type=submit]").prop("disabled",!1),d.find(".as3cf-bucket-name").val().length<3?d.find("button[type=submit]").prop("disabled",!0):d.find("button[type=submit]").prop("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,h,i){var j=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),m=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===m.text().trim().length){d("as3cf-copy-to-s3-wrap"),d("as3cf-serve-from-s3-wrap");var n=k.attr("id");l[n]=c(n)}a(".as3cf-error.fatal").hide(),m.text(e),j.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(h),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!i),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(function(){k.trigger("bucket-change",[i]),as3cf.buckets.bucketSelectLock=!1})},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.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").prop("selected",!1),d.val(""),f.prop("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(){j(),window.onhashchange=function(a){"function"==typeof history.replaceState&&"#"===location.href.slice(-1)&&history.replaceState({},"",location.href.slice(0,-1)),j()};var m=a(".wrap.aws-main .nav-tab-wrapper");a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(m),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()}),h(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){h()}),i(),a("#as3cf-remove-local-file").on("change",function(a){i()}),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.prop("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]").prop("disabled",!1):e.find("button[type=submit]").prop("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().lengthfilter_local = new AS3CF_Local_To_S3( $this ); $this->filter_s3 = new AS3CF_S3_To_Local( $this ); @@ -223,9 +227,11 @@ function get_setting_args( $key ) { 'disabled_attr' => '', 'tr_class' => str_replace( '_', '-', $this->plugin_prefix . '-' . $key . '-container' ), 'setting_msg' => '', + 'is_defined' => false, ); if ( false !== $is_defined ) { + $args['is_defined'] = true; $args['disabled'] = true; $args['disabled_attr'] = 'disabled="disabled"'; $args['tr_class'] .= ' as3cf-defined-setting'; @@ -452,12 +458,18 @@ private function remove_region_on_constant_change( $bucket, $constant ) { } if ( false !== $value && $bucket !== $value ) { - // Clear region - $this->remove_setting( 'region' ); - $this->save_settings(); + $this->bucket_changed(); } } + /** + * Perform necessary actions when the chosen bucket is changed. + */ + public function bucket_changed() { + $this->remove_setting( 'region' ); + $this->save_settings(); + } + /** * Filter in defined settings with sensible defaults. * @@ -890,16 +902,14 @@ public function upload_attachment_to_s3( $post_id, $data = null, $file_path = nu } // Allow S3 upload to be hijacked / cancelled for any reason - $pre = apply_filters( 'as3cf_pre_upload_attachment', false, $post_id, $data ); - if ( false !== $pre ) { - if ( ! is_null( $return_metadata ) ) { - // If the attachment metadata is supplied, return it - return $data; - } - - $error_msg = is_string( $pre ) ? $pre : __( 'Upload aborted by filter \'as3cf_pre_upload_attachment\'', 'amazon-s3-and-cloudfront' ); + try { + $pre = apply_filters( 'as3cf_pre_upload_attachment', false, $post_id, $data ); + } catch ( \Exception $e ) { + return $this->return_upload_error( $e->getMessage() ); + } - return $this->return_upload_error( $error_msg ); + if ( false !== $pre ) { + return $data; } if ( is_null( $file_path ) ) { @@ -1507,7 +1517,7 @@ public function get_attachment_s3_info( $post_id ) { * @return bool */ function is_plugin_setup() { - if ( is_wp_error( $this->aws->get_client() ) ) { + if ( $this->aws->needs_access_keys() ) { // AWS not configured return false; } @@ -2467,8 +2477,13 @@ public function get_s3client( $region = false, $force = false ) { $args['signature'] = self::AWS_SIGNATURE; } - $client = $this->aws->get_client()->get( 's3', $args ); - $this->set_client( $client ); + try { + $aws_client = $this->aws->get_client(); + $this->set_client( $aws_client->get( 's3', $args ) ); + } catch ( \Exception $e ) { + AS3CF_Error::log( $e->getMessage() ); + $this->set_client( new Null_S3_Client ); + } } return $this->s3client; @@ -2477,7 +2492,7 @@ public function get_s3client( $region = false, $force = false ) { /** * Setter for S3 client * - * @param Aws\S3\S3Client $client + * @param Aws\S3\S3Client|Null_S3_Client $client */ public function set_client( $client ) { $this->s3client = $client; @@ -2486,11 +2501,22 @@ public function set_client( $client ) { /** * Get the region of a bucket * - * @param string $bucket + * @param string $bucket + * @param boolean $use_cache * * @return string|WP_Error */ - function get_bucket_region( $bucket ) { + public function get_bucket_region( $bucket, $use_cache = false ) { + $regions = get_site_transient( 'as3cf_regions_cache' ); + + if ( ! is_array( $regions ) ) { + $regions = array(); + } + + if ( $use_cache && isset( $regions[ $bucket ] ) ) { + return $regions[ $bucket ]; + } + try { $region = $this->get_s3client()->getBucketLocation( array( 'Bucket' => $bucket ) ); } catch ( Exception $e ) { @@ -2503,6 +2529,11 @@ function get_bucket_region( $bucket ) { $region = $this->translate_region( $region['Location'] ); + if ( is_string( $region ) ) { + $regions[ $bucket ] = $region; + set_site_transient( 'as3cf_regions_cache', $regions, 5 * MINUTE_IN_SECONDS ); + } + return $region; } @@ -2859,15 +2890,14 @@ function get_plugin_page_url( $args = array(), $url_method = 'network', $escape function render_page() { $this->aws->render_view( 'header', array( 'page_title' => $this->get_plugin_page_title(), 'page' => 'as3cf' ) ); - $aws_client = $this->aws->get_client(); - - if ( is_wp_error( $aws_client ) ) { - $this->render_view( 'error-fatal', array( 'message' => $aws_client->get_error_message() ) ); - } else { + try { + $this->aws->get_client(); $this->render_view( 'settings-tabs' ); do_action( 'as3cf_pre_settings_render' ); $this->render_view( 'settings' ); do_action( 'as3cf_post_settings_render' ); + } catch ( \Exception $e ) { + $this->render_view( 'error-fatal', array( 'message' => $e->getMessage() ) ); } $this->aws->render_view( 'footer' ); @@ -3405,10 +3435,6 @@ function output_diagnostic_info( $escape = true ) { $output .= esc_html( ( defined( 'AS3CF_BUCKET' ) ) ? AS3CF_BUCKET : 'Not defined' ); $output .= "\r\n"; - $output .= 'AS3CF_ASSETS_BUCKET: '; - $output .= esc_html( ( defined( 'AS3CF_ASSETS_BUCKET' ) ) ? AS3CF_ASSETS_BUCKET : 'Not defined' ); - $output .= "\r\n"; - $output .= 'AS3CF_REGION: '; $output .= esc_html( ( defined( 'AS3CF_REGION' ) ) ? AS3CF_REGION : 'Not defined' ); $output .= "\r\n\r\n"; @@ -3936,10 +3962,10 @@ public function more_info_link( $path, $utm_content = '', $hash = '' ) { } $url = $this->dbrains_url( $path, $args, $hash ); - $text = __( 'More info', 'amazon-s3-and-cloudfront' ); + $text = __( 'More info', 'amazon-s3-and-cloudfront' ); $link = AS3CF_Utils::dbrains_link( $url, $text ); - return sprintf( '%s »', $link ); + return sprintf( '%s »', $link ); } /** @@ -4081,6 +4107,17 @@ public function verify_media_actions() { return false; } + /** + * Get a list of available media actions which can be performed according to plugin and user capability requirements. + * + * @param string|null $scope + * + * @return array + */ + public function get_available_media_actions( $scope = '' ) { + return array(); + } + /** * Render the S3 attachment meta box */ @@ -4092,7 +4129,7 @@ public function attachment_s3_actions_meta_box() { 's3object' => $this->get_formatted_s3_info( $post->ID ), 'post' => $post, 'local_file_exists' => file_exists( $file ), - 'user_can_perform_actions' => $this->verify_media_actions(), + 'available_actions' => $this->get_available_media_actions( 'singular' ), 'sendback' => 'post.php?post=' . $post->ID . '&action=edit', ); diff --git a/classes/as3cf-filter.php b/classes/as3cf-filter.php index 506e12cc..3c42ec38 100644 --- a/classes/as3cf-filter.php +++ b/classes/as3cf-filter.php @@ -174,6 +174,10 @@ protected function handle_widget( $instance, $class ) { return $this->filter_text_widget( $instance, $update_cache ); } + if ( $class instanceof WP_Widget_Custom_HTML ) { + return $this->filter_custom_html_widget( $instance, $update_cache ); + } + return $instance; } @@ -226,6 +230,26 @@ protected function filter_text_widget( $instance, $update_cache ) { return $instance; } + /** + * Filter custom html widget. + * + * @param array $instance + * @param bool $update_cache + * + * @return array + */ + protected function filter_custom_html_widget( $instance, $update_cache ) { + $cache = $this->get_option_cache(); + $to_cache = array(); + $instance['content'] = $this->process_content( $instance['content'], $cache, $to_cache ); + + if ( $update_cache ) { + $this->maybe_update_option_cache( $to_cache ); + } + + return $instance; + } + /** * Process content. * diff --git a/classes/as3cf-plugin-compatibility.php b/classes/as3cf-plugin-compatibility.php index 8ba2d27e..5b395efa 100644 --- a/classes/as3cf-plugin-compatibility.php +++ b/classes/as3cf-plugin-compatibility.php @@ -63,6 +63,9 @@ function compatibility_init() { add_filter( 'wp_calculate_image_srcset', array( $this, 'wp_calculate_image_srcset' ), 10, 5 ); add_filter( 'wp_calculate_image_srcset_meta', array( $this, 'wp_calculate_image_srcset_meta' ), 10, 4 ); + // Maybe warn about PHP version if in admin screens. + add_action( 'admin_init', array( $this, 'maybe_warn_about_php_version' ) ); + if ( $this->as3cf->is_plugin_setup() ) { $this->compatibility_init_if_setup(); } @@ -818,4 +821,46 @@ public function customizer_crop_unique_filename( $filename, $ext, $dir ) { return $filename; } + + /** + * Display an admin message if PHP version is soon to be unsupported by plugin. + * + * NOTE: This is not added to AWS SDK compatibility checks as it is remaining compatible with earlier PHP versions. + * This function should be removed or reworked once PHP 5.5 is required. + */ + public function maybe_warn_about_php_version() { + $key_base = 'php-version-55'; + + if ( version_compare( PHP_VERSION, '5.5', '<' ) ) { + $message = sprintf( + __( 'Warning: This site is using PHP %1$s, in a future update WP Offload S3 will require PHP %2$s or later. %3$s', 'amazon-s3-and-cloudfront' ), + PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, + '5.5', + $this->as3cf->more_info_link( '/wp-offload-s3/doc/php-version-requirements/', 'upgrade-php-version' ) + ); + + // Show notice to user if not already dismissed. + $args = array( + 'custom_id' => $key_base . '-site', + 'type' => 'notice-warning', + 'flash' => false, + 'only_show_to_user' => false, + ); + + if ( ! in_array( $args['custom_id'], $this->as3cf->notices->get_dismissed_notices() ) ) { + $this->as3cf->notices->add_notice( $message, $args ); + } else { + // If user has dismissed site-wide notice but we're in settings pages, show notice. + $args['custom_id'] = $key_base . '-settings'; + $args['dismissible'] = false; + $args['only_show_in_settings'] = true; + + $this->as3cf->notices->add_notice( $message, $args ); + } + } else { + // If PHP version (now) OK, make sure notices not shown. + $this->as3cf->notices->remove_notice_by_id( $key_base . '-site' ); + $this->as3cf->notices->remove_notice_by_id( $key_base . '-settings' ); + } + } } diff --git a/classes/as3cf-utils.php b/classes/as3cf-utils.php index 5c536bc5..340e5406 100644 --- a/classes/as3cf-utils.php +++ b/classes/as3cf-utils.php @@ -168,11 +168,13 @@ public static function reduce_url( $url ) { /** * Parses a URL into its components. Compatible with PHP < 5.4.7. * - * @param $url string The URL to parse. + * @param $url string The URL to parse. * - * @return array|false The parsed components or false on error. + * @param int $component PHP_URL_ constant for URL component to return. + * + * @return mixed An array of the parsed components, mixed for a requested component, or false on error. */ - public static function parse_url( $url ) { + public static function parse_url( $url, $component = -1 ) { $url = trim( $url ); $no_scheme = 0 === strpos( $url, '//' ); @@ -180,9 +182,13 @@ public static function parse_url( $url ) { $url = 'http:' . $url; } - $parts = parse_url( $url ); + $parts = parse_url( $url, $component ); - if ( $no_scheme ) { + if ( 0 < $component ) { + return $parts; + } + + if ( $no_scheme && is_array( $parts ) ) { unset( $parts['scheme'] ); } @@ -197,13 +203,30 @@ public static function parse_url( $url ) { * @return bool */ public static function is_url( $string ) { - if ( preg_match( '@^(?:https?:)?\/\/[a-zA-Z0-9\-]{3,}@', $string ) ) { + if ( preg_match( '@^(?:https?:)?//[a-zA-Z0-9\-]+@', $string ) ) { return true; } return false; } + /** + * Is the string a relative URL? + * + * @param $string + * + * @return bool + */ + public static function is_relative_url( $string ) { + if ( empty( $string ) || ! is_string( $string ) ) { + return false; + } + + $url = static::parse_url( $string ); + + return ( empty( $url['scheme'] ) && empty( $url['host'] ) ); + } + /** * Get file paths for all attachment versions. * @@ -357,5 +380,57 @@ public static function strip_image_edit_suffix_and_extension( $path ) { public static function dbrains_link( $url, $text ) { return sprintf( '%s', esc_url( $url ), esc_html( $text ) ); } + + /** + * Check whether two URLs share the same domain. + * + * @param string $url_a + * @param string $url_b + * + * @return bool + */ + public static function url_domains_match( $url_a, $url_b ) { + if ( ! static::is_url( $url_a ) || ! static::is_url( $url_b ) ) { + return false; + } + + return static::parse_url( $url_a, PHP_URL_HOST ) === static::parse_url( $url_b, PHP_URL_HOST ); + } + + /** + * Get the current domain. + * + * @return string|false + */ + public static function current_domain() { + return parse_url( home_url(), PHP_URL_HOST ); + } + + /** + * Get the base domain of the current domain. + * + * @return string + */ + public static function current_base_domain() { + $domain = static::current_domain(); + $parts = explode( '.', $domain, 2 ); + + if ( isset( $parts[1] ) && in_array( $parts[0], array( 'www' ) ) ) { + return $parts[1]; + } + + return $domain; + } + + /** + * A safe wrapper for deactivate_plugins() + */ + public static function deactivate_plugins() { + if ( ! function_exists( 'deactivate_plugins' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + call_user_func_array( 'deactivate_plugins', func_get_args() ); + } } } diff --git a/classes/null-s3-client.php b/classes/null-s3-client.php new file mode 100644 index 00000000..080e1ff8 --- /dev/null +++ b/classes/null-s3-client.php @@ -0,0 +1,34 @@ +$name()" ); + throw new \Exception( 'Failed to instantiate the AWS S3 client. Check your error log.' ); + } + + /** + * Log and fail calls to static methods. + * + * @param $name + * @param $arguments + * + * @throws \Exception + */ + public static function __callStatic( $name, $arguments ) { + AS3CF_Error::log( $arguments, __CLASS__ . "::$name()" ); + throw new \Exception( 'Failed to instantiate the AWS S3 client. Check your error log.' ); + } +} diff --git a/classes/upgrades/upgrade-filter-post.php b/classes/upgrades/upgrade-filter-post.php index aeb456c8..7c219f64 100644 --- a/classes/upgrades/upgrade-filter-post.php +++ b/classes/upgrades/upgrade-filter-post.php @@ -395,7 +395,7 @@ protected function get_paused_message() { */ protected function get_generic_message() { $link_text = __( 'See our documentation', 'amazon-s3-and-cloudfront' ); - $url = $this->as3cf->dbrains_url( '/wp-offload-s3/doc/version-1-2-upgrade', array( + $url = $this->as3cf->dbrains_url( '/wp-offload-s3/doc/content-filtering-upgrade', array( 'utm_campaign' => 'support+docs', ) ); $link = AS3CF_Utils::dbrains_link( $url, $link_text ); @@ -453,4 +453,4 @@ protected function load_last_post_id() { return $this->get_highest_post_id(); } -} \ No newline at end of file +} diff --git a/classes/wp-aws-compatibility-check.php b/classes/wp-aws-compatibility-check.php index f8435862..66da850b 100644 --- a/classes/wp-aws-compatibility-check.php +++ b/classes/wp-aws-compatibility-check.php @@ -304,7 +304,7 @@ function is_parent_plugin_at_version( $version ) { /** * Get the compatibility error message * - * @return string|void + * @return string|bool */ function get_error_msg() { if ( is_null( $this->parent_plugin_slug ) ) { @@ -521,4 +521,4 @@ public static function is_installing_or_updating_plugins() { return self::$is_installing_or_updating_plugins; } } -} \ No newline at end of file +} diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index aa804d6f..b898dd1f 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: 2017-06-19 15:09+0100\n" +"POT-Creation-Date: 2017-11-20 15:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,137 +17,133 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: classes/amazon-s3-and-cloudfront.php:122 +#: classes/amazon-s3-and-cloudfront.php:123 msgid "Offload S3 Lite" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:123 +#: classes/amazon-s3-and-cloudfront.php:124 msgid "S3 and CloudFront" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:232 +#: classes/amazon-s3-and-cloudfront.php:238 #: view/bucket-setting.php:18 msgid "defined in wp-config.php" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:900 -msgid "Upload aborted by filter 'as3cf_pre_upload_attachment'" -msgstr "" - -#: classes/amazon-s3-and-cloudfront.php:911 -#: classes/amazon-s3-and-cloudfront.php:1071 +#: classes/amazon-s3-and-cloudfront.php:921 +#: classes/amazon-s3-and-cloudfront.php:1081 #, php-format msgid "File %s does not exist" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:922 +#: classes/amazon-s3-and-cloudfront.php:932 #, php-format msgid "Mime type %s is not allowed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1007 -#: classes/amazon-s3-and-cloudfront.php:1079 +#: classes/amazon-s3-and-cloudfront.php:1017 +#: classes/amazon-s3-and-cloudfront.php:1089 #, php-format msgid "Error uploading %s to S3: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2223 +#: classes/amazon-s3-and-cloudfront.php:2233 msgid "Cheatin’ eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2227 +#: classes/amazon-s3-and-cloudfront.php:2237 msgid "You do not have sufficient permissions to access this page." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2233 +#: classes/amazon-s3-and-cloudfront.php:2243 msgid "No bucket name provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2497 +#: classes/amazon-s3-and-cloudfront.php:2523 msgid "Error Getting Bucket Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2498 +#: classes/amazon-s3-and-cloudfront.php:2524 #, php-format msgid "There was an error attempting to get the region of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2626 +#: classes/amazon-s3-and-cloudfront.php:2657 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:2645 +#: classes/amazon-s3-and-cloudfront.php:2676 #, php-format msgid "" "There was an error attempting to check the permissions of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2699 +#: classes/amazon-s3-and-cloudfront.php:2730 msgid "Error creating bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2700 +#: classes/amazon-s3-and-cloudfront.php:2731 msgid "Bucket name too short." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2701 +#: classes/amazon-s3-and-cloudfront.php:2732 msgid "Bucket name too long." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2702 +#: classes/amazon-s3-and-cloudfront.php:2733 msgid "" "Invalid character. Bucket names can contain lowercase letters, numbers, " "periods and hyphens." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2703 +#: classes/amazon-s3-and-cloudfront.php:2734 msgid "Error saving bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2704 +#: classes/amazon-s3-and-cloudfront.php:2735 msgid "Error fetching buckets" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2705 +#: classes/amazon-s3-and-cloudfront.php:2736 msgid "Error getting URL preview: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2706 +#: classes/amazon-s3-and-cloudfront.php:2737 msgid "The changes you made will be lost if you navigate away from this page" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2707 +#: classes/amazon-s3-and-cloudfront.php:2738 msgid "Getting diagnostic info..." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2708 +#: classes/amazon-s3-and-cloudfront.php:2739 msgid "Error getting diagnostic info: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2776 +#: classes/amazon-s3-and-cloudfront.php:2807 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2883 +#: classes/amazon-s3-and-cloudfront.php:2913 msgctxt "Show the media library tab" msgid "Media Library" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2884 +#: classes/amazon-s3-and-cloudfront.php:2914 msgctxt "Show the support tab" msgid "Support" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3101 +#: classes/amazon-s3-and-cloudfront.php:3131 #, php-format msgid "" "WP Offload S3 — The file %s has been given %s " "permissions on Amazon S3." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3120 +#: classes/amazon-s3-and-cloudfront.php:3150 msgid "" "WP Offload S3 Requirement Missing — Looks like you " "don't have an image manipulation library installed on this server and " @@ -155,11 +151,11 @@ msgid "" "Please setup GD or ImageMagick." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3729 +#: classes/amazon-s3-and-cloudfront.php:3755 msgid "Quick Start Guide" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3731 +#: classes/amazon-s3-and-cloudfront.php:3757 #, php-format msgid "" "Looks like we don't have write access to this bucket. It's likely that the " @@ -168,7 +164,7 @@ msgid "" "correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3733 +#: classes/amazon-s3-and-cloudfront.php:3759 #, php-format msgid "" "Looks like we don't have access to the buckets. It's likely that the user " @@ -176,39 +172,39 @@ msgid "" "Please see our %s for instructions on setting up permissions correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3883 +#: classes/amazon-s3-and-cloudfront.php:3909 msgid "WP Offload S3 Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3884 +#: classes/amazon-s3-and-cloudfront.php:3910 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:3886 +#: classes/amazon-s3-and-cloudfront.php:3912 msgid "WP Offload S3 Lite Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3887 +#: classes/amazon-s3-and-cloudfront.php:3913 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:3939 -msgid "More info" +#: classes/amazon-s3-and-cloudfront.php:3965 +msgid "More info" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4034 +#: classes/amazon-s3-and-cloudfront.php:4060 msgid "this doc" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4036 +#: classes/amazon-s3-and-cloudfront.php:4062 msgid "WP Offload S3 Feature Removed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4037 +#: classes/amazon-s3-and-cloudfront.php:4063 #, php-format msgid "" "You had the \"Always non-SSL\" option selected in your settings, but we've " @@ -219,32 +215,32 @@ msgid "" "to the old behavior." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4067 -#: classes/amazon-s3-and-cloudfront.php:4165 +#: classes/amazon-s3-and-cloudfront.php:4093 +#: classes/amazon-s3-and-cloudfront.php:4202 msgid "Amazon S3" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4166 +#: classes/amazon-s3-and-cloudfront.php:4203 msgctxt "Amazon S3 bucket" msgid "Bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4167 +#: classes/amazon-s3-and-cloudfront.php:4204 msgctxt "Path to file on Amazon S3" msgid "Path" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4168 +#: classes/amazon-s3-and-cloudfront.php:4205 msgctxt "Location of Amazon S3 bucket" msgid "Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4169 +#: classes/amazon-s3-and-cloudfront.php:4206 msgctxt "Access control list of the file on Amazon S3" msgid "Access" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4170 +#: classes/amazon-s3-and-cloudfront.php:4207 msgid "URL" msgstr "" @@ -256,18 +252,25 @@ msgstr "" msgid "Invalid notice ID." msgstr "" -#: classes/as3cf-plugin-compatibility.php:512 +#: classes/as3cf-plugin-compatibility.php:515 #, php-format msgid "The local directory %s does not exist and could not be created." msgstr "" -#: classes/as3cf-plugin-compatibility.php:513 -#: classes/as3cf-plugin-compatibility.php:525 +#: classes/as3cf-plugin-compatibility.php:516 +#: classes/as3cf-plugin-compatibility.php:528 #: classes/upgrades/upgrade-meta-wp-error.php:81 #, php-format msgid "There was an error attempting to download the file %s from S3: %s" msgstr "" +#: classes/as3cf-plugin-compatibility.php:836 +#, php-format +msgid "" +"Warning: This site is using PHP %1$s, in a future update WP " +"Offload S3 will require PHP %2$s or later. %3$s" +msgstr "" + #: classes/upgrades/upgrade-content-replace-urls.php:36 msgid "and ensuring that only the local URL exists in post content." msgstr "" @@ -455,11 +458,11 @@ msgstr "" msgid "The %s plugin has been deactivated." msgstr "" -#: view/attachment-metabox.php:4 +#: view/attachment-metabox.php:14 msgid "This item has not been copied to S3 yet." msgstr "" -#: view/attachment-metabox.php:29 +#: view/attachment-metabox.php:39 msgid "File does not exist on server" msgstr "" diff --git a/readme.txt b/readme.txt index 7e363d80..385f6f14 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: bradt, deliciousbrains Tags: uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront Requires at least: 4.6 -Tested up to: 4.8 -Stable tag: 1.2 +Tested up to: 4.9 +Stable tag: 1.2.1 License: GPLv3 Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery. @@ -65,6 +65,17 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin == Changelog == += WP Offload S3 Lite 1.2.1 - 2017-11-20 = +* New: Compatibility with HTML Widget +* New: Dismissible admin notice that WP Offload S3 Lite will soon require PHP 5.5+ +* Improvement: Compatibility with WordPress 4.9 +* Bug fix: Incorrect region used when changing bucket by defining it in WPOS3_SETTINGS +* Bug fix: Media library notices render inside the upload tool +* Bug fix: Save notices disappear on settings page +* Bug fix: Improper use of jQuery.attr logged to browser console +* Bug fix: "Content Filtering Upgrade" URL in notice incorrect +* Bug fix: "More info" links can be broken across two lines + = WP Offload S3 Lite 1.2 - 2017-06-19 = * New: Compatibility with WordPress 4.8 * New: Support for WP CLI `wp media regenerate` diff --git a/view/attachment-metabox.php b/view/attachment-metabox.php index 3f11f49e..cb0276eb 100644 --- a/view/attachment-metabox.php +++ b/view/attachment-metabox.php @@ -1,3 +1,13 @@ +
    @@ -24,7 +34,7 @@ get_acl_value_string( $s3object['acl'] ); ?>
    - + - + +