WP Offload S3 Lite - Version 0.8.1

Version Description

  • 2015-01-19 =
  • Bug Fix: Permission problems on installs running on EC2s
  • Bug Fix: Blank settings page due to WP_Error on S3 permission check
  • Bug Fix: Warning: strtolower() expects parameter 1 to be string, object given
  • Bug Fix: Region post meta update running on subsites of Multisite installs
Download this release

Release Info

Developer bradt
Plugin Icon 128x128 WP Offload S3 Lite
Version 0.8.1
Comparing to
See all releases

Code changes from version 0.8 to 0.8.1

assets/css/styles.css CHANGED
@@ -1 +1 @@
1
- .aws-main .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.aws-main .error pre code{padding:0;background:none}.aws-main .as3cf-notice,.aws-main .error{max-width:935px}.aws-main .updated{display:none}.aws-main .updated.show{display:block}.as3cf-settings{position:relative;width:650px;min-height:800px}.as3cf-settings .as3cf-main-settings{display:none}.as3cf-settings .as3cf-main-settings p{font-size:13px}.as3cf-settings .as3cf-main-settings p a{color:#444}.as3cf-settings.as3cf-has-bucket .as3cf-bucket-select{display:none}.as3cf-settings.as3cf-has-bucket .as3cf-main-settings{display:block}.as3cf-settings tr.configure-url,.as3cf-settings tr.advanced-options{display:none}.as3cf-settings .object-prefix-desc em{white-space:nowrap}.as3cf-settings .as3cf-url-preview-wrap{background:#ffffff;text-align:center;padding:20px 20px 10px;max-width:610px;width:100%}.as3cf-settings .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:5px;overflow-x:scroll;padding-bottom:15px}.as3cf-settings .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-settings .as3cf-ssl p.info{margin-top:10px;padding:0}.as3cf-settings .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-settings .as3cf-radio-group label.disabled,.as3cf-settings .as3cf-radio-group label.disabled p{color:#bbbbbb;cursor:default}.as3cf-settings .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-settings .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-settings .as3cf-switch{position:relative}.as3cf-settings .as3cf-switch.disabled span{cursor:default;margin:1px 0 0 0}.as3cf-settings .as3cf-switch.disabled span.checked{background:#F1F1F1;border:1px solid #dddddd;color:#a3a3a3}.as3cf-settings .as3cf-switch span{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;-webkit-border-radius:2px;font-weight:bold;padding:4px 8px;background:#F1F1F1;border:1px solid #dddddd;color:#CCCCCC;margin:1px -1px 0;z-index:1}.as3cf-settings .as3cf-switch span.checked{background:#ffffff;border-color:#E4E4E4;color:#373737;padding:5px 10px;margin:0;z-index:2}.as3cf-settings .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-settings .as3cf-setting.hide{display:none}.as3cf-settings .as3cf-bucket-actions{position:absolute;right:0;top:2px}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap{display:none}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap:after{content:" | "}.as3cf-settings .as3cf-bucket-list-wrapper{background:#fff;padding:15px 20px;margin-bottom:2em}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list{max-height:300px;overflow:auto;margin:0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list li{font-size:14px;padding:10px 0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a:hover,.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{color:#0074A2}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{font-weight:bold}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket{float:left;clear:both}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket .dashicons{margin-right:5px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .spinner{float:left;background-size:15px 15px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list.saving{opacity:0.5}.as3cf-settings .as3cf-create-bucket-form input[type="text"]{width:80%}.as3cf-settings select.bucket{margin-bottom:5px;width:380px}.as3cf-settings .form-table td{padding-left:0;padding-right:0}.as3cf-settings .form-table td:first-child{vertical-align:top;min-width:120px}.as3cf-settings .form-table h3{font-weight:normal;text-transform:uppercase;margin:0}.as3cf-settings .form-table h4{margin:0}.as3cf-settings .form-table .as3cf-border-bottom td{border-bottom:1px solid #ddd}.as3cf-settings .as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-settings .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-settings .tooltip:before,.as3cf-settings .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-settings .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-settings .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-settings .tooltip:hover:before,.as3cf-settings .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}.as3cf-banner img{display:block}.as3cf-sidebar{position:absolute;top:17px;right:-312px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe ul{margin-left:20px;list-style-type:disc}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.as3cf-sidebar .as3cf-banner{background-image:url(../img/snail@2x.jpg);background-size:292px 165px;width:292px;height:165px;display:block}.as3cf-sidebar .as3cf-banner img{display:none}}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto;margin-top:50px}}
1
+ .aws-main .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.aws-main .error pre code{padding:0;background:none}.aws-main .as3cf-notice,.aws-main .error{max-width:935px}.aws-main .updated{display:none}.aws-main .updated.as3cf-notice,.aws-main .updated.show{display:block}.as3cf-settings{position:relative;width:650px;min-height:800px}.as3cf-settings .as3cf-main-settings{display:none}.as3cf-settings .as3cf-main-settings p{font-size:13px}.as3cf-settings .as3cf-main-settings p a{color:#444}.as3cf-settings.as3cf-has-bucket .as3cf-bucket-select{display:none}.as3cf-settings.as3cf-has-bucket .as3cf-main-settings{display:block}.as3cf-settings tr.configure-url,.as3cf-settings tr.advanced-options{display:none}.as3cf-settings .object-prefix-desc em{white-space:nowrap}.as3cf-settings .as3cf-url-preview-wrap{background:#ffffff;text-align:center;padding:20px 20px 10px;max-width:610px;width:100%}.as3cf-settings .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:5px;overflow-x:scroll;padding-bottom:15px}.as3cf-settings .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-settings .as3cf-ssl p.info{margin-top:10px;padding:0}.as3cf-settings .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-settings .as3cf-radio-group label.disabled,.as3cf-settings .as3cf-radio-group label.disabled p{color:#bbbbbb;cursor:default}.as3cf-settings .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-settings .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-settings .as3cf-switch{position:relative}.as3cf-settings .as3cf-switch.disabled span{cursor:default;margin:1px 0 0 0}.as3cf-settings .as3cf-switch.disabled span.checked{background:#F1F1F1;border:1px solid #dddddd;color:#a3a3a3}.as3cf-settings .as3cf-switch span{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;-webkit-border-radius:2px;font-weight:bold;padding:4px 8px;background:#F1F1F1;border:1px solid #dddddd;color:#CCCCCC;margin:1px -1px 0;z-index:1}.as3cf-settings .as3cf-switch span.checked{background:#ffffff;border-color:#E4E4E4;color:#373737;padding:5px 10px;margin:0;z-index:2}.as3cf-settings .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-settings .as3cf-setting.hide{display:none}.as3cf-settings .as3cf-bucket-actions{position:absolute;right:0;top:2px}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap{display:none}.as3cf-settings .as3cf-bucket-actions .as3cf-cancel-bucket-select-wrap:after{content:" | "}.as3cf-settings .as3cf-bucket-list-wrapper{background:#fff;padding:15px 20px;margin-bottom:2em}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list{max-height:300px;overflow:auto;margin:0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list li{font-size:14px;padding:10px 0}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a:hover,.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{color:#0074A2}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a.selected{font-weight:bold}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket{float:left;clear:both}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .bucket .dashicons{margin-right:5px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list a .spinner{float:left;background-size:15px 15px}.as3cf-settings .as3cf-bucket-list-wrapper .as3cf-bucket-list.saving{opacity:0.5}.as3cf-settings .as3cf-create-bucket-form input[type="text"]{width:80%}.as3cf-settings select.bucket{margin-bottom:5px;width:380px}.as3cf-settings .form-table td{padding-left:0;padding-right:0}.as3cf-settings .form-table td:first-child{vertical-align:top;min-width:120px}.as3cf-settings .form-table h3{font-weight:normal;text-transform:uppercase;margin:0}.as3cf-settings .form-table h4{margin:0}.as3cf-settings .form-table .as3cf-border-bottom td{border-bottom:1px solid #ddd}.as3cf-settings .as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-settings .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-settings .tooltip:before,.as3cf-settings .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-settings .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-settings .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-settings .tooltip:hover:before,.as3cf-settings .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}.as3cf-banner img{display:block}.as3cf-sidebar{position:absolute;top:17px;right:-312px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe ul{margin-left:20px;list-style-type:disc}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.as3cf-sidebar .as3cf-banner{background-image:url(../img/snail@2x.jpg);background-size:292px 165px;width:292px;height:165px;display:block}.as3cf-sidebar .as3cf-banner img{display:none}}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto;margin-top:50px}}
assets/js/script.js CHANGED
@@ -57,7 +57,7 @@
57
  if($changeBucket.length){
58
  $changeBucket.on('click', function(e){
59
  e.preventDefault();
60
- $( '.updated' ).hide();
61
  $('.as3cf-can-write-error').hide();
62
  $('.as3cf-settings').removeClass('as3cf-has-bucket');
63
  loadBuckets();
@@ -131,6 +131,8 @@
131
  }
132
 
133
  var bucket = this;
 
 
134
  $('.as3cf-bucket-list a' ).removeClass('selected');
135
  $(bucket).addClass('selected');
136
 
@@ -152,6 +154,8 @@
152
  error: function(jqXHR, textStatus, errorThrown) {
153
  $bucketList.removeClass('saving');
154
  show_bucket_error( as3cf_i18n.save_bucket_error, errorThrown );
 
 
155
  },
156
  success: function(data, textStatus, jqXHR) {
157
  $(bucket).find('.spinner').hide();
@@ -160,6 +164,8 @@
160
  bucket_select( bucketName, data['region'], data['can_write'] );
161
  } else {
162
  show_bucket_error( as3cf_i18n.save_bucket_error, data['error'] );
 
 
163
  }
164
  }
165
  });
@@ -180,7 +186,7 @@
180
  $( '.as3cf-active-bucket' ).text( bucket );
181
  $( '#as3cf-bucket' ).val( bucket );
182
  $( '#as3cf-region' ).val( region );
183
- $( '.updated' ).show();
184
  // check permission on bucket
185
  if( can_write === false){
186
  $('.as3cf-can-write-error').show();
57
  if($changeBucket.length){
58
  $changeBucket.on('click', function(e){
59
  e.preventDefault();
60
+ $( '.updated' ).not('.as3cf-notice').hide();
61
  $('.as3cf-can-write-error').hide();
62
  $('.as3cf-settings').removeClass('as3cf-has-bucket');
63
  loadBuckets();
131
  }
132
 
133
  var bucket = this;
134
+ var previous_bucket = $('.as3cf-bucket-list a.selected' ).attr('data-bucket');
135
+
136
  $('.as3cf-bucket-list a' ).removeClass('selected');
137
  $(bucket).addClass('selected');
138
 
154
  error: function(jqXHR, textStatus, errorThrown) {
155
  $bucketList.removeClass('saving');
156
  show_bucket_error( as3cf_i18n.save_bucket_error, errorThrown );
157
+ $('.as3cf-bucket-list a' ).removeClass('selected');
158
+ $( '.as3cf-bucket-list a[data-bucket="' + previous_bucket + '"]' ).addClass( 'selected' );
159
  },
160
  success: function(data, textStatus, jqXHR) {
161
  $(bucket).find('.spinner').hide();
164
  bucket_select( bucketName, data['region'], data['can_write'] );
165
  } else {
166
  show_bucket_error( as3cf_i18n.save_bucket_error, data['error'] );
167
+ $('.as3cf-bucket-list a' ).removeClass('selected');
168
+ $( '.as3cf-bucket-list a[data-bucket="' + previous_bucket + '"]' ).addClass( 'selected' );
169
  }
170
  }
171
  });
186
  $( '.as3cf-active-bucket' ).text( bucket );
187
  $( '#as3cf-bucket' ).val( bucket );
188
  $( '#as3cf-region' ).val( region );
189
+ $( '.updated' ).not('.as3cf-notice' ).show();
190
  // check permission on bucket
191
  if( can_write === false){
192
  $('.as3cf-can-write-error').show();
assets/js/script.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){var b;a(document).ready(function(){function c(){a(".as3cf-bucket-error").hide(),h.html('<li class="loading">'+h.attr("data-working")+"</li>");var b={action:"as3cf-get-buckets",_nonce:as3cf_i18n.get_buckets_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){h.html(""),d(as3cf_i18n.get_buckets_error,c)},success:function(b){h.html(""),"undefined"!=typeof b.success?a(b.buckets).each(function(a,c){var d=c.Name==b.selected?"selected":"";h.append('<li><a class="'+d+'" href="#" data-bucket="'+c.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+c.Name+'</span><span class="spinner"></span></span></a></li>')}):d(as3cf_i18n.get_buckets_error,b.error)}})}function d(b,c){a(".as3cf-bucket-error span.title").html(b),a(".as3cf-bucket-error span.message").html(c),a(".as3cf-bucket-error").show()}function e(b,c,d){""==a(".as3cf-active-bucket").text()&&(f("copy-to-s3-wrap"),f("serve-from-s3-wrap")),a(".as3cf-active-bucket").text(b),a("#as3cf-bucket").val(b),a("#as3cf-region").val(c),a(".updated").show(),d===!1&&a(".as3cf-can-write-error").show(),a(".as3cf-settings").addClass("as3cf-has-bucket"),g()}function f(b){a("#"+b+" span").toggleClass("checked");var c=a("#"+b+" span.on").hasClass("checked"),d=a("#"+b).data("checkbox"),e=a("input#"+d);e.attr("checked",c),e.trigger("change")}function g(){a(".as3cf-url-preview").html("Generating...");var b={_nonce:as3cf_i18n.get_url_preview_nonce};a.each(a(".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_i18n.get_url_preview_error+c)},success:function(b){"undefined"!=typeof b.success?a(".as3cf-url-preview").html(b.url):alert(as3cf_i18n.get_url_preview_error+b.error)}})}a(".as3cf-settings").each(function(){var b=a(this),f=a(".as3cf-bucket-list"),g=b.find(".as3cf-create-bucket-form");if(g.length){var h=g.find("button"),i=h.text();g.on("submit",function(b){b.preventDefault(),a(".as3cf-bucket-error").hide(),f.addClass("saving"),h.text(h.attr("data-working")),h.prop("disabled",!0);var j=g.find('input[name="bucket_name"]').val(),k={action:"as3cf-create-bucket",bucket_name:j,_nonce:as3cf_i18n.create_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:k,error:function(a,b,c){h.text(i),d(as3cf_i18n.create_bucket_error,c)},success:function(b){h.text(i),h.prop("disabled",!1),"undefined"!=typeof b.success?(e(j,b.region,b.can_write),g.find('input[name="bucket_name"]').val(""),a(".as3cf-bucket-list a").removeClass("selected"),c(),f.removeClass("saving")):d(as3cf_i18n.create_bucket_error,b.error)}})})}var j=b.find(".as3cf-change-bucket");j.length&&j.on("click",function(b){b.preventDefault(),a(".updated").hide(),a(".as3cf-can-write-error").hide(),a(".as3cf-settings").removeClass("as3cf-has-bucket"),c(),a(".as3cf-active-bucket").html&&a(".as3cf-cancel-bucket-select-wrap").show(),a(".as3cf-bucket-list a.selected").length&&a(".as3cf-bucket-list").scrollTop(a(".as3cf-bucket-list a.selected").position().top-50)});var k=b.find(".as3cf-refresh-buckets");k.length&&k.on("click",function(a){a.preventDefault(),c()});var l=b.find(".as3cf-cancel-bucket-select");l.length&&l.on("click",function(b){b.preventDefault(),a(".as3cf-bucket-error").hide(),a(".as3cf-settings").addClass("as3cf-has-bucket")})});var h=a(".as3cf-bucket-list");h.on("click","a",function(b){if(b.preventDefault(),a(this).hasClass("selected"))return void a(".as3cf-settings").addClass("as3cf-has-bucket");var c=this;a(".as3cf-bucket-list a").removeClass("selected"),a(c).addClass("selected"),h.addClass("saving"),a(c).find(".spinner").show();var f=a(c).attr("data-bucket"),g={action:"as3cf-save-bucket",bucket_name:f,_nonce:as3cf_i18n.save_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:g,error:function(a,b,c){h.removeClass("saving"),d(as3cf_i18n.save_bucket_error,c)},success:function(b){a(c).find(".spinner").hide(),h.removeClass("saving"),"undefined"!=typeof b.success?e(f,b.region,b.can_write):d(as3cf_i18n.save_bucket_error,b.error)}})}),a(".as3cf-switch").on("click","span",function(){if(!a(this).parent().hasClass("disabled")){var b=a(this).parent().attr("id");f(b)}}),a(".as3cf-settings").length&&!a(".as3cf-settings").hasClass("as3cf-has-bucket")&&c(),a("#copy-to-s3").is(":checked")&&a("tr.advanced-options").show(),a(".as3cf-settings").on("change","#copy-to-s3",function(){a("tr.advanced-options").toggle()}),a("#serve-from-s3").is(":checked")&&a("tr.configure-url").show(),a(".as3cf-settings").on("change","#serve-from-s3",function(){a("tr.configure-url").toggle()}),a(".as3cf-settings").on("change",".sub-toggle",function(){var b=a(this).attr("id");a(".as3cf-setting."+b).toggleClass("hide")}),a(".as3cf-domain").on("change",'input[type="radio"]',function(){var b=a('input:radio[name="domain"]:checked').val();"cloudfront"==b&&a(".as3cf-setting.cloudfront").hasClass("hide")?a(".as3cf-setting.cloudfront").removeClass("hide"):a(".as3cf-setting.cloudfront").addClass("hide")}),a(".as3cf-ssl").on("change",'input[type="radio"]',function(){var b=a('input:radio[name="ssl"]:checked').val();if("https"==b){var c=a('input:radio[name="domain"]:checked').val();"subdomain"==c&&a('input[name="domain"][value="path"]').attr("checked",!0),a(".subdomain-wrap input").attr("disabled",!0),a(".subdomain-wrap").addClass("disabled")}else a(".subdomain-wrap input").removeAttr("disabled"),a(".subdomain-wrap").removeClass("disabled")}),a(".url-preview").on("change","input",function(){g()}),b=a(".as3cf-main-settings form").serialize(),a(document).on("submit",".as3cf-main-settings form",function(){a(window).off("beforeunload.as3cf-settings")}),a(window).on("beforeunload.as3cf-settings",function(){return a(".as3cf-main-settings form").serialize()!=b?as3cf_i18n.save_alert:void 0})})}(jQuery);
1
+ !function(a){var b;a(document).ready(function(){function c(){a(".as3cf-bucket-error").hide(),h.html('<li class="loading">'+h.attr("data-working")+"</li>");var b={action:"as3cf-get-buckets",_nonce:as3cf_i18n.get_buckets_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){h.html(""),d(as3cf_i18n.get_buckets_error,c)},success:function(b){h.html(""),"undefined"!=typeof b.success?a(b.buckets).each(function(a,c){var d=c.Name==b.selected?"selected":"";h.append('<li><a class="'+d+'" href="#" data-bucket="'+c.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+c.Name+'</span><span class="spinner"></span></span></a></li>')}):d(as3cf_i18n.get_buckets_error,b.error)}})}function d(b,c){a(".as3cf-bucket-error span.title").html(b),a(".as3cf-bucket-error span.message").html(c),a(".as3cf-bucket-error").show()}function e(b,c,d){""==a(".as3cf-active-bucket").text()&&(f("copy-to-s3-wrap"),f("serve-from-s3-wrap")),a(".as3cf-active-bucket").text(b),a("#as3cf-bucket").val(b),a("#as3cf-region").val(c),a(".updated").not(".as3cf-notice").show(),d===!1&&a(".as3cf-can-write-error").show(),a(".as3cf-settings").addClass("as3cf-has-bucket"),g()}function f(b){a("#"+b+" span").toggleClass("checked");var c=a("#"+b+" span.on").hasClass("checked"),d=a("#"+b).data("checkbox"),e=a("input#"+d);e.attr("checked",c),e.trigger("change")}function g(){a(".as3cf-url-preview").html("Generating...");var b={_nonce:as3cf_i18n.get_url_preview_nonce};a.each(a(".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_i18n.get_url_preview_error+c)},success:function(b){"undefined"!=typeof b.success?a(".as3cf-url-preview").html(b.url):alert(as3cf_i18n.get_url_preview_error+b.error)}})}a(".as3cf-settings").each(function(){var b=a(this),f=a(".as3cf-bucket-list"),g=b.find(".as3cf-create-bucket-form");if(g.length){var h=g.find("button"),i=h.text();g.on("submit",function(b){b.preventDefault(),a(".as3cf-bucket-error").hide(),f.addClass("saving"),h.text(h.attr("data-working")),h.prop("disabled",!0);var j=g.find('input[name="bucket_name"]').val(),k={action:"as3cf-create-bucket",bucket_name:j,_nonce:as3cf_i18n.create_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:k,error:function(a,b,c){h.text(i),d(as3cf_i18n.create_bucket_error,c)},success:function(b){h.text(i),h.prop("disabled",!1),"undefined"!=typeof b.success?(e(j,b.region,b.can_write),g.find('input[name="bucket_name"]').val(""),a(".as3cf-bucket-list a").removeClass("selected"),c(),f.removeClass("saving")):d(as3cf_i18n.create_bucket_error,b.error)}})})}var j=b.find(".as3cf-change-bucket");j.length&&j.on("click",function(b){b.preventDefault(),a(".updated").not(".as3cf-notice").hide(),a(".as3cf-can-write-error").hide(),a(".as3cf-settings").removeClass("as3cf-has-bucket"),c(),a(".as3cf-active-bucket").html&&a(".as3cf-cancel-bucket-select-wrap").show(),a(".as3cf-bucket-list a.selected").length&&a(".as3cf-bucket-list").scrollTop(a(".as3cf-bucket-list a.selected").position().top-50)});var k=b.find(".as3cf-refresh-buckets");k.length&&k.on("click",function(a){a.preventDefault(),c()});var l=b.find(".as3cf-cancel-bucket-select");l.length&&l.on("click",function(b){b.preventDefault(),a(".as3cf-bucket-error").hide(),a(".as3cf-settings").addClass("as3cf-has-bucket")})});var h=a(".as3cf-bucket-list");h.on("click","a",function(b){if(b.preventDefault(),a(this).hasClass("selected"))return void a(".as3cf-settings").addClass("as3cf-has-bucket");var c=this,f=a(".as3cf-bucket-list a.selected").attr("data-bucket");a(".as3cf-bucket-list a").removeClass("selected"),a(c).addClass("selected"),h.addClass("saving"),a(c).find(".spinner").show();var g=a(c).attr("data-bucket"),i={action:"as3cf-save-bucket",bucket_name:g,_nonce:as3cf_i18n.save_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:i,error:function(b,c,e){h.removeClass("saving"),d(as3cf_i18n.save_bucket_error,e),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+f+'"]').addClass("selected")},success:function(b){a(c).find(".spinner").hide(),h.removeClass("saving"),"undefined"!=typeof b.success?e(g,b.region,b.can_write):(d(as3cf_i18n.save_bucket_error,b.error),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+f+'"]').addClass("selected"))}})}),a(".as3cf-switch").on("click","span",function(){if(!a(this).parent().hasClass("disabled")){var b=a(this).parent().attr("id");f(b)}}),a(".as3cf-settings").length&&!a(".as3cf-settings").hasClass("as3cf-has-bucket")&&c(),a("#copy-to-s3").is(":checked")&&a("tr.advanced-options").show(),a(".as3cf-settings").on("change","#copy-to-s3",function(){a("tr.advanced-options").toggle()}),a("#serve-from-s3").is(":checked")&&a("tr.configure-url").show(),a(".as3cf-settings").on("change","#serve-from-s3",function(){a("tr.configure-url").toggle()}),a(".as3cf-settings").on("change",".sub-toggle",function(){var b=a(this).attr("id");a(".as3cf-setting."+b).toggleClass("hide")}),a(".as3cf-domain").on("change",'input[type="radio"]',function(){var b=a('input:radio[name="domain"]:checked').val();"cloudfront"==b&&a(".as3cf-setting.cloudfront").hasClass("hide")?a(".as3cf-setting.cloudfront").removeClass("hide"):a(".as3cf-setting.cloudfront").addClass("hide")}),a(".as3cf-ssl").on("change",'input[type="radio"]',function(){var b=a('input:radio[name="ssl"]:checked').val();if("https"==b){var c=a('input:radio[name="domain"]:checked').val();"subdomain"==c&&a('input[name="domain"][value="path"]').attr("checked",!0),a(".subdomain-wrap input").attr("disabled",!0),a(".subdomain-wrap").addClass("disabled")}else a(".subdomain-wrap input").removeAttr("disabled"),a(".subdomain-wrap").removeClass("disabled")}),a(".url-preview").on("change","input",function(){g()}),b=a(".as3cf-main-settings form").serialize(),a(document).on("submit",".as3cf-main-settings form",function(){a(window).off("beforeunload.as3cf-settings")}),a(window).on("beforeunload.as3cf-settings",function(){return a(".as3cf-main-settings form").serialize()!=b?as3cf_i18n.save_alert:void 0})})}(jQuery);
assets/sass/styles.scss CHANGED
@@ -19,7 +19,7 @@
19
 
20
  .updated {
21
  display: none;
22
- &.show {
23
  display: block;
24
  }
25
  }
19
 
20
  .updated {
21
  display: none;
22
+ &.as3cf-notice, &.show {
23
  display: block;
24
  }
25
  }
classes/amazon-s3-and-cloudfront.php CHANGED
@@ -98,6 +98,9 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
98
  if ( 'region' == $key && ! isset( $settings['region'] ) ) {
99
  $bucket = $this->get_setting( 'bucket' );
100
  $region = $this->get_bucket_region( $bucket );
 
 
 
101
 
102
  return $region;
103
  }
@@ -244,14 +247,15 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
244
  /**
245
  * Delete bulk objects from an S3 bucket
246
  *
 
247
  * @param string $bucket
248
  * @param array $objects
249
  * @param bool $log_error
250
  * @param bool $return_on_error
251
  */
252
- function delete_s3_objects( $bucket, $objects, $log_error = false, $return_on_error = false ) {
253
  try {
254
- $this->get_s3client()->deleteObjects( array(
255
  'Bucket' => $bucket,
256
  'Objects' => $objects,
257
  ) );
@@ -275,8 +279,11 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
275
  }
276
 
277
  $bucket = $s3object['bucket'];
278
-
279
- $this->set_s3client_region( $s3object );
 
 
 
280
 
281
  $amazon_path = dirname( $s3object['key'] );
282
  $objects = array();
@@ -295,7 +302,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
295
  );
296
  }
297
 
298
- $this->delete_s3_objects( $bucket, $hidpi_images );
299
  }
300
 
301
  // add main file to be deleted
@@ -303,7 +310,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
303
  'Key' => $s3object['key'],
304
  );
305
 
306
- $this->delete_s3_objects( $bucket, $objects, true, true );
307
 
308
  delete_post_meta( $post_id, 'amazonS3_info' );
309
  }
@@ -356,6 +363,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
356
 
357
  // use bucket from settings
358
  $bucket = $this->get_setting( 'bucket' );
 
359
  }
360
 
361
  $file_path = get_attached_file( $post_id, true );
@@ -364,11 +372,10 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
364
  $acl = apply_filters( 'wps3_upload_acl', $acl, $type, $data, $post_id, $this ); // Old naming convention, will be deprecated soon
365
  $acl = apply_filters( 'as3cf_upload_acl', $acl, $data, $post_id );
366
 
367
- $s3client = $this->get_s3client();
368
-
369
  $s3object = array(
370
  'bucket' => $bucket,
371
  'key' => $prefix . $file_name,
 
372
  );
373
 
374
  // store acl if not default
@@ -376,13 +383,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
376
  $s3object['acl'] = $acl;
377
  }
378
 
379
- // use existing region
380
- if ( isset( $region ) ) {
381
- $s3object['region'] = $region;
382
- }
383
-
384
- // retrieve region when necessary and set the region of the s3client
385
- $s3object['region'] = $this->set_s3client_region( $s3object );
386
 
387
  $args = array(
388
  'Bucket' => $bucket,
@@ -407,7 +408,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
407
  );
408
  // edited resized image files
409
  $this->prepare_intermediate_images_to_remove( $post_id, $objects_to_remove, $prefix );
410
- $this->delete_s3_objects( $bucket, $objects_to_remove, true );
411
  }
412
 
413
  $files_to_remove = array();
@@ -581,11 +582,13 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
581
  $time = current_time( 'timestamp' );
582
  $time = date( 'Y/m', $time );
583
 
584
- $prefix = ltrim( trailingslashit( $this->get_setting( 'object-prefix' ) ), '/' );
585
  $prefix .= ltrim( trailingslashit( $this->get_dynamic_prefix( $time ) ), '/' );
586
- $s3client = $this->get_s3client();
587
 
588
  $bucket = $this->get_setting( 'bucket' );
 
 
 
589
 
590
  $number = '';
591
  while ( $s3client->doesObjectExist( $bucket, $prefix . $filename ) !== false ) {
@@ -802,7 +805,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
802
  if ( ! is_null( $expires ) ) {
803
  try {
804
  $expires = time() + $expires;
805
- $secure_url = $this->get_s3client()->getObjectUrl( $s3object['bucket'], $s3object['key'], $expires );
806
  }
807
  catch ( Exception $e ) {
808
  return new WP_Error( 'exception', $e->getMessage() );
@@ -1050,6 +1053,9 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1050
  }
1051
  $this->set_setting( 'bucket', $bucket_name );
1052
  $region = $this->get_bucket_region( $bucket_name );
 
 
 
1053
  $this->set_setting( 'region', $region );
1054
  $this->save_settings();
1055
 
@@ -1064,9 +1070,19 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1064
  add_action( 'load-' . $hook_suffix , array( $this, 'plugin_load' ) );
1065
  }
1066
 
1067
- function get_s3client() {
1068
  if ( is_null( $this->s3client ) ) {
1069
- $this->s3client = $this->aws->get_client()->get( 's3' );
 
 
 
 
 
 
 
 
 
 
1070
  }
1071
 
1072
  return $this->s3client;
@@ -1084,6 +1100,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1084
  $region = $this->get_s3client()->getBucketLocation( array( 'Bucket' => $bucket ) );
1085
  }
1086
  catch ( Exception $e ) {
 
 
1087
  return new WP_Error( 'exception', $e->getMessage() );
1088
  }
1089
 
@@ -1140,31 +1158,6 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1140
  return $region;
1141
  }
1142
 
1143
- /**
1144
- * Set the region of the AWS client based on the bucket.
1145
- *
1146
- * This is needed for non US standard buckets to add and delete files.
1147
- *
1148
- * @param array $s3object
1149
- * @param int $post_id
1150
- *
1151
- * @return string - region name
1152
- */
1153
- function set_s3client_region( $s3object, $post_id = null ) {
1154
- $region = $this->get_s3object_region( $s3object, $post_id );
1155
-
1156
- if ( is_wp_error( $region ) ) {
1157
- return '';
1158
- }
1159
-
1160
- if ( $region ) {
1161
- $region = $this->translate_region( $region );
1162
- $this->get_s3client()->setRegion( $region );
1163
- }
1164
-
1165
- return $region;
1166
- }
1167
-
1168
  /**
1169
  * AJAX handler for get_buckets()
1170
  */
@@ -1221,7 +1214,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1221
  $file_name = 'as3cf-permission-check.txt';
1222
  $file_contents = __( 'This is a test file to check if the user has write permission to S3. Delete me if found.', 'as3cf' );
1223
 
1224
- $path = $this->get_setting( 'object-prefix' );
1225
  $key = $path . $file_name;
1226
 
1227
  $args = array(
@@ -1236,11 +1229,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
1236
  if ( is_null( $region ) ) {
1237
  $region = $this->get_setting( 'region' );
1238
  }
1239
- if ( $region ) {
1240
- $this->get_s3client()->setRegion( $region );
1241
- }
1242
  // attempt to create the test file
1243
- $this->get_s3client()->putObject( $args );
1244
  // delete it straight away if created
1245
  $this->get_s3client()->deleteObject( array(
1246
  'Bucket' => $bucket,
98
  if ( 'region' == $key && ! isset( $settings['region'] ) ) {
99
  $bucket = $this->get_setting( 'bucket' );
100
  $region = $this->get_bucket_region( $bucket );
101
+ if ( is_wp_error( $region ) ) {
102
+ $region = '';
103
+ }
104
 
105
  return $region;
106
  }
247
  /**
248
  * Delete bulk objects from an S3 bucket
249
  *
250
+ * @param string $region
251
  * @param string $bucket
252
  * @param array $objects
253
  * @param bool $log_error
254
  * @param bool $return_on_error
255
  */
256
+ function delete_s3_objects( $region, $bucket, $objects, $log_error = false, $return_on_error = false ) {
257
  try {
258
+ $this->get_s3client( $region )->deleteObjects( array(
259
  'Bucket' => $bucket,
260
  'Objects' => $objects,
261
  ) );
279
  }
280
 
281
  $bucket = $s3object['bucket'];
282
+ $region = $this->get_s3object_region( $s3object );
283
+ if ( is_wp_error( $region ) ) {
284
+ error_log( 'Error retrieving region: ' . $region->get_error_message() );
285
+ $region = '';
286
+ }
287
 
288
  $amazon_path = dirname( $s3object['key'] );
289
  $objects = array();
302
  );
303
  }
304
 
305
+ $this->delete_s3_objects( $region, $bucket, $hidpi_images );
306
  }
307
 
308
  // add main file to be deleted
310
  'Key' => $s3object['key'],
311
  );
312
 
313
+ $this->delete_s3_objects( $region, $bucket, $objects, true, true );
314
 
315
  delete_post_meta( $post_id, 'amazonS3_info' );
316
  }
363
 
364
  // use bucket from settings
365
  $bucket = $this->get_setting( 'bucket' );
366
+ $region = $this->get_setting( 'region' );
367
  }
368
 
369
  $file_path = get_attached_file( $post_id, true );
372
  $acl = apply_filters( 'wps3_upload_acl', $acl, $type, $data, $post_id, $this ); // Old naming convention, will be deprecated soon
373
  $acl = apply_filters( 'as3cf_upload_acl', $acl, $data, $post_id );
374
 
 
 
375
  $s3object = array(
376
  'bucket' => $bucket,
377
  'key' => $prefix . $file_name,
378
+ 'region' => $region,
379
  );
380
 
381
  // store acl if not default
383
  $s3object['acl'] = $acl;
384
  }
385
 
386
+ $s3client = $this->get_s3client( $region );
 
 
 
 
 
 
387
 
388
  $args = array(
389
  'Bucket' => $bucket,
408
  );
409
  // edited resized image files
410
  $this->prepare_intermediate_images_to_remove( $post_id, $objects_to_remove, $prefix );
411
+ $this->delete_s3_objects( $region, $bucket, $objects_to_remove, true );
412
  }
413
 
414
  $files_to_remove = array();
582
  $time = current_time( 'timestamp' );
583
  $time = date( 'Y/m', $time );
584
 
585
+ $prefix = ltrim( trailingslashit( $this->get_object_prefix() ), '/' );
586
  $prefix .= ltrim( trailingslashit( $this->get_dynamic_prefix( $time ) ), '/' );
 
587
 
588
  $bucket = $this->get_setting( 'bucket' );
589
+ $region = $this->get_setting( 'region' );
590
+
591
+ $s3client = $this->get_s3client( $region );
592
 
593
  $number = '';
594
  while ( $s3client->doesObjectExist( $bucket, $prefix . $filename ) !== false ) {
805
  if ( ! is_null( $expires ) ) {
806
  try {
807
  $expires = time() + $expires;
808
+ $secure_url = $this->get_s3client( $region )->getObjectUrl( $s3object['bucket'], $s3object['key'], $expires );
809
  }
810
  catch ( Exception $e ) {
811
  return new WP_Error( 'exception', $e->getMessage() );
1053
  }
1054
  $this->set_setting( 'bucket', $bucket_name );
1055
  $region = $this->get_bucket_region( $bucket_name );
1056
+ if ( is_wp_error( $region ) ) {
1057
+ return false;
1058
+ }
1059
  $this->set_setting( 'region', $region );
1060
  $this->save_settings();
1061
 
1070
  add_action( 'load-' . $hook_suffix , array( $this, 'plugin_load' ) );
1071
  }
1072
 
1073
+ function get_s3client( $region = false ) {
1074
  if ( is_null( $this->s3client ) ) {
1075
+
1076
+ if ( $region ) {
1077
+ $args = array(
1078
+ 'region' => $this->translate_region( $region ),
1079
+ 'signature' => 'v4',
1080
+ );
1081
+ } else {
1082
+ $args = array();
1083
+ }
1084
+
1085
+ $this->s3client = $this->aws->get_client()->get( 's3', $args );
1086
  }
1087
 
1088
  return $this->s3client;
1100
  $region = $this->get_s3client()->getBucketLocation( array( 'Bucket' => $bucket ) );
1101
  }
1102
  catch ( Exception $e ) {
1103
+ error_log( sprintf( __( 'There was an error attempting to get the region of the bucket %s: %s', 'as3cf' ), $bucket, $e->getMessage() ) );
1104
+
1105
  return new WP_Error( 'exception', $e->getMessage() );
1106
  }
1107
 
1158
  return $region;
1159
  }
1160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1161
  /**
1162
  * AJAX handler for get_buckets()
1163
  */
1214
  $file_name = 'as3cf-permission-check.txt';
1215
  $file_contents = __( 'This is a test file to check if the user has write permission to S3. Delete me if found.', 'as3cf' );
1216
 
1217
+ $path = $this->get_object_prefix();
1218
  $key = $path . $file_name;
1219
 
1220
  $args = array(
1229
  if ( is_null( $region ) ) {
1230
  $region = $this->get_setting( 'region' );
1231
  }
 
 
 
1232
  // attempt to create the test file
1233
+ $this->get_s3client( $region )->putObject( $args );
1234
  // delete it straight away if created
1235
  $this->get_s3client()->deleteObject( array(
1236
  'Bucket' => $bucket,
classes/as3cf-upgrade.php CHANGED
@@ -62,6 +62,11 @@ class AS3CF_Upgrade {
62
  return;
63
  }
64
 
 
 
 
 
 
65
  // Have we completed the upgrade yet?
66
  if ( $this->as3cf->get_setting( 'post_meta_version', 0 ) > 0 ) {
67
  return;
62
  return;
63
  }
64
 
65
+ // make sure this only fires inside the network admin for multisites
66
+ if ( is_multisite() && ! is_network_admin() ) {
67
+ return;
68
+ }
69
+
70
  // Have we completed the upgrade yet?
71
  if ( $this->as3cf->get_setting( 'post_meta_version', 0 ) > 0 ) {
72
  return;
languages/amazon-s3-and-cloudfront.pot CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Amazon S3 and CloudFront\n"
4
- "POT-Creation-Date: 2015-01-09 16:19-0000\n"
5
- "PO-Revision-Date: 2015-01-09 16:19-0000\n"
6
  "Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
7
  "Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
8
  "Language: en\n"
@@ -28,58 +28,63 @@ msgstr ""
28
  msgid "S3 and CloudFront"
29
  msgstr ""
30
 
31
- #: classes/amazon-s3-and-cloudfront.php:920
32
  msgid "There was an error attempting to access the file system"
33
  msgstr ""
34
 
35
- #: classes/amazon-s3-and-cloudfront.php:960
36
  msgid "Cheatin&#8217; eh?"
37
  msgstr ""
38
 
39
- #: classes/amazon-s3-and-cloudfront.php:964
40
  msgid "You do not have sufficient permissions to access this page."
41
  msgstr ""
42
 
43
- #: classes/amazon-s3-and-cloudfront.php:970
44
  msgid "No bucket name provided."
45
  msgstr ""
46
 
47
- #: classes/amazon-s3-and-cloudfront.php:996
48
- #: classes/amazon-s3-and-cloudfront.php:1029
49
  msgid "Failed to retrieve bucket region."
50
  msgstr ""
51
 
52
- #: classes/amazon-s3-and-cloudfront.php:1222
 
 
 
 
 
53
  msgid ""
54
  "This is a test file to check if the user has write permission to S3. Delete "
55
  "me if found."
56
  msgstr ""
57
 
58
- #: classes/amazon-s3-and-cloudfront.php:1270
59
  msgid "Bucket Name:"
60
  msgstr ""
61
 
62
- #: classes/amazon-s3-and-cloudfront.php:1271
63
  msgid "Error creating bucket: "
64
  msgstr ""
65
 
66
- #: classes/amazon-s3-and-cloudfront.php:1273
67
  msgid "Error fetching buckets: "
68
  msgstr ""
69
 
70
- #: classes/amazon-s3-and-cloudfront.php:1275
71
  msgid "Error saving bucket: "
72
  msgstr ""
73
 
74
- #: classes/amazon-s3-and-cloudfront.php:1278
75
  msgid "Error getting URL preview: "
76
  msgstr ""
77
 
78
- #: classes/amazon-s3-and-cloudfront.php:1279
79
  msgid "The changes you made will be lost if you navigate away from this page"
80
  msgstr ""
81
 
82
- #: classes/amazon-s3-and-cloudfront.php:1291
83
  msgid "Cheatin' eh?"
84
  msgstr ""
85
 
@@ -140,7 +145,7 @@ msgstr ""
140
  msgid "Update Amazon S3 and CloudFront to the latest version"
141
  msgstr ""
142
 
143
- #: classes/as3cf-upgrade.php:90
144
  #, php-format
145
  msgid ""
146
  "<strong>Running Metadata Update</strong> &mdash; We&#8217;re going through "
@@ -153,32 +158,32 @@ msgid ""
153
  "performance."
154
  msgstr ""
155
 
156
- #: classes/as3cf-upgrade.php:91
157
  msgid "Pause Update"
158
  msgstr ""
159
 
160
- #: classes/as3cf-upgrade.php:95
161
  msgid ""
162
  "<strong>Metadata Update Paused</strong> &mdash; Updating Media Library "
163
  "metadata has been paused."
164
  msgstr ""
165
 
166
- #: classes/as3cf-upgrade.php:96
167
  msgid "Restart Update"
168
  msgstr ""
169
 
170
- #: classes/as3cf-upgrade.php:99
171
  msgid ""
172
  "<strong>Error Updating Metadata</strong> &mdash; We ran into some errors "
173
  "attempting to update the metadata for all your Media Library items that have "
174
  "been uploaded to S3. Please check your error log for details."
175
  msgstr ""
176
 
177
- #: classes/as3cf-upgrade.php:100
178
  msgid "Try Run It Again"
179
  msgstr ""
180
 
181
- #: classes/as3cf-upgrade.php:163
182
  #, php-format
183
  msgid "Every %d Minutes"
184
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Amazon S3 and CloudFront\n"
4
+ "POT-Creation-Date: 2015-01-19 16:02-0000\n"
5
+ "PO-Revision-Date: 2015-01-19 16:02-0000\n"
6
  "Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
7
  "Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
8
  "Language: en\n"
28
  msgid "S3 and CloudFront"
29
  msgstr ""
30
 
31
+ #: classes/amazon-s3-and-cloudfront.php:923
32
  msgid "There was an error attempting to access the file system"
33
  msgstr ""
34
 
35
+ #: classes/amazon-s3-and-cloudfront.php:963
36
  msgid "Cheatin&#8217; eh?"
37
  msgstr ""
38
 
39
+ #: classes/amazon-s3-and-cloudfront.php:967
40
  msgid "You do not have sufficient permissions to access this page."
41
  msgstr ""
42
 
43
+ #: classes/amazon-s3-and-cloudfront.php:973
44
  msgid "No bucket name provided."
45
  msgstr ""
46
 
47
+ #: classes/amazon-s3-and-cloudfront.php:999
48
+ #: classes/amazon-s3-and-cloudfront.php:1032
49
  msgid "Failed to retrieve bucket region."
50
  msgstr ""
51
 
52
+ #: classes/amazon-s3-and-cloudfront.php:1103
53
+ #, php-format
54
+ msgid "There was an error attempting to get the region of the bucket %s: %s"
55
+ msgstr ""
56
+
57
+ #: classes/amazon-s3-and-cloudfront.php:1215
58
  msgid ""
59
  "This is a test file to check if the user has write permission to S3. Delete "
60
  "me if found."
61
  msgstr ""
62
 
63
+ #: classes/amazon-s3-and-cloudfront.php:1260
64
  msgid "Bucket Name:"
65
  msgstr ""
66
 
67
+ #: classes/amazon-s3-and-cloudfront.php:1261
68
  msgid "Error creating bucket: "
69
  msgstr ""
70
 
71
+ #: classes/amazon-s3-and-cloudfront.php:1263
72
  msgid "Error fetching buckets: "
73
  msgstr ""
74
 
75
+ #: classes/amazon-s3-and-cloudfront.php:1265
76
  msgid "Error saving bucket: "
77
  msgstr ""
78
 
79
+ #: classes/amazon-s3-and-cloudfront.php:1268
80
  msgid "Error getting URL preview: "
81
  msgstr ""
82
 
83
+ #: classes/amazon-s3-and-cloudfront.php:1269
84
  msgid "The changes you made will be lost if you navigate away from this page"
85
  msgstr ""
86
 
87
+ #: classes/amazon-s3-and-cloudfront.php:1281
88
  msgid "Cheatin' eh?"
89
  msgstr ""
90
 
145
  msgid "Update Amazon S3 and CloudFront to the latest version"
146
  msgstr ""
147
 
148
+ #: classes/as3cf-upgrade.php:95
149
  #, php-format
150
  msgid ""
151
  "<strong>Running Metadata Update</strong> &mdash; We&#8217;re going through "
158
  "performance."
159
  msgstr ""
160
 
161
+ #: classes/as3cf-upgrade.php:96
162
  msgid "Pause Update"
163
  msgstr ""
164
 
165
+ #: classes/as3cf-upgrade.php:100
166
  msgid ""
167
  "<strong>Metadata Update Paused</strong> &mdash; Updating Media Library "
168
  "metadata has been paused."
169
  msgstr ""
170
 
171
+ #: classes/as3cf-upgrade.php:101
172
  msgid "Restart Update"
173
  msgstr ""
174
 
175
+ #: classes/as3cf-upgrade.php:104
176
  msgid ""
177
  "<strong>Error Updating Metadata</strong> &mdash; We ran into some errors "
178
  "attempting to update the metadata for all your Media Library items that have "
179
  "been uploaded to S3. Please check your error log for details."
180
  msgstr ""
181
 
182
+ #: classes/as3cf-upgrade.php:105
183
  msgid "Try Run It Again"
184
  msgstr ""
185
 
186
+ #: classes/as3cf-upgrade.php:168
187
  #, php-format
188
  msgid "Every %d Minutes"
189
  msgstr ""
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: uploads, amazon, s3, mirror, admin, media, cdn, cloudfront
5
  Requires at least: 3.5
6
  Tested up to: 4.1
7
- Stable tag: 0.8
8
  License: GPLv3
9
 
10
  Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
@@ -59,6 +59,12 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
 
62
  = 0.8 - 2015-01-10 =
63
  * New: Redesigned settings UI
64
  * Improvement: SSL setting can be fully controlled, HTTPS for urls always, based on request or never
4
  Tags: uploads, amazon, s3, mirror, admin, media, cdn, cloudfront
5
  Requires at least: 3.5
6
  Tested up to: 4.1
7
+ Stable tag: 0.8.1
8
  License: GPLv3
9
 
10
  Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
59
 
60
  == Changelog ==
61
 
62
+ = 0.8.1 - 2015-01-19 =
63
+ * Bug Fix: Permission problems on installs running on EC2s
64
+ * Bug Fix: Blank settings page due to WP_Error on S3 permission check
65
+ * Bug Fix: Warning: strtolower() expects parameter 1 to be string, object given
66
+ * Bug Fix: Region post meta update running on subsites of Multisite installs
67
+
68
  = 0.8 - 2015-01-10 =
69
  * New: Redesigned settings UI
70
  * Improvement: SSL setting can be fully controlled, HTTPS for urls always, based on request or never
wordpress-s3.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Amazon S3 and CloudFront
4
  Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/
5
  Description: Automatically copies media uploads to Amazon S3 for storage and delivery. Optionally configure Amazon CloudFront for even faster delivery.
6
  Author: Brad Touesnard
7
- Version: 0.8
8
  Author URI: http://bradt.ca
9
  Network: True
10
  Text Domain: as3cf
@@ -26,13 +26,13 @@ Domain Path: /languages/
26
  // Then completely rewritten.
27
  */
28
 
29
- $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '0.8';
30
 
31
  $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
32
  'amazon-s3-and-cloudfront-edd' => '1.0',
33
  );
34
 
35
- $aws_plugin_version_required = '0.2.1';
36
 
37
  require dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';
38
  global $as3cf_compat_check;
4
  Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/
5
  Description: Automatically copies media uploads to Amazon S3 for storage and delivery. Optionally configure Amazon CloudFront for even faster delivery.
6
  Author: Brad Touesnard
7
+ Version: 0.8.1
8
  Author URI: http://bradt.ca
9
  Network: True
10
  Text Domain: as3cf
26
  // Then completely rewritten.
27
  */
28
 
29
+ $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '0.8.1';
30
 
31
  $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
32
  'amazon-s3-and-cloudfront-edd' => '1.0',
33
  );
34
 
35
+ $aws_plugin_version_required = '0.2.2';
36
 
37
  require dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';
38
  global $as3cf_compat_check;