WP Offload S3 Lite - Version 0.7.2

Version Description

  • 2014-12-11 =
  • Bug: Some buckets in the EU region causing permission and HTTP errors
  • Bug: Undefined variable: message in view/error.php also causing white screens
Download this release

Release Info

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

Code changes from version 0.7.1 to 0.7.2

assets/js/script.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){e(document).ready(function(){e(".as3cf-settings").each(function(){var t=e(this);e("select.bucket",t).change(function(){var t=e(this);if(t.val()!=="new"){return}var n=function(e,n,r){alert(as3cf_i18n.create_bucket_error+r);t[0].selectedIndex=0;console.log(e);console.log(n);console.log(r)};var r=function(n,r,s){if(typeof n["success"]!=="undefined"){var o=document.createElement("option");o.value=o.innerHTML=i;var u=0;e("option",t).each(function(){if(e(this).val()==i){return false}if(e(this).val()>i||"new"==e(this).val()){e(o).insertBefore(e(this));return false}u=u+1});t[0].selectedIndex=u;as3cf_i18n.create_bucket_nonce=n["_nonce"]}else{alert(as3cf_i18n.create_bucket_error+n["error"]);t[0].selectedIndex=0}};var i=window.prompt(as3cf_i18n.create_bucket_prompt);if(!i){t[0].selectedIndex=0;return}var s={action:"as3cf-create-bucket",bucket_name:i,_nonce:as3cf_i18n.create_bucket_nonce};e.ajax({url:ajaxurl,type:"POST",dataType:"JSON",success:r,error:n,data:s})})})})})(jQuery)
1
+ !function(a){a(document).ready(function(){a(".as3cf-settings").each(function(){var b=a(this);a("select.bucket",b).change(function(){var b=a(this);if("new"===b.val()){var c=function(a,c,d){alert(as3cf_i18n.create_bucket_error+d),b[0].selectedIndex=0,console.log(a),console.log(c),console.log(d)},d=function(c){if("undefined"!=typeof c.success){var d=document.createElement("option");d.value=d.innerHTML=e;var f=0;a("option",b).each(function(){return a(this).val()==e?!1:a(this).val()>e||"new"==a(this).val()?(a(d).insertBefore(a(this)),!1):void(f+=1)}),b[0].selectedIndex=f,as3cf_i18n.create_bucket_nonce=c._nonce}else alert(as3cf_i18n.create_bucket_error+c.error),b[0].selectedIndex=0},e=window.prompt(as3cf_i18n.create_bucket_prompt);if(!e)return void(b[0].selectedIndex=0);var f={action:"as3cf-create-bucket",bucket_name:e,_nonce:as3cf_i18n.create_bucket_nonce};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",success:d,error:c,data:f})}})})})}(jQuery);
classes/amazon-s3-and-cloudfront.php CHANGED
@@ -542,7 +542,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
542
  // We don't use $this->get_s3object_region() here because we don't want
543
  // to make an AWS API call and slow down page loading
544
  if ( isset( $s3object['region'] ) ) {
545
- $region = $s3object['region'];
546
  }
547
  else {
548
  $region = '';
@@ -743,6 +743,26 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
743
  return $s3object['region'];
744
  }
745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  /**
747
  * Set the region of the AWS client based on the bucket.
748
  *
@@ -761,6 +781,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
761
  }
762
 
763
  if ( $region ) {
 
764
  $this->get_s3client()->setRegion( $region );
765
  }
766
 
@@ -792,7 +813,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
792
  $filesystem = WP_Filesystem();
793
  global $wp_filesystem;
794
  if ( false === $filesystem || is_null( $wp_filesystem ) ) {
795
- return new WP_Error( 'exception', __( 'There was an error attempting to access the file system', 'as3cf' ) );
796
  }
797
 
798
  $uploads = wp_upload_dir();
@@ -819,7 +840,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
819
  // need to set region for buckets in non default region
820
  $region = $this->get_s3client()->getBucketLocation( array( 'Bucket' => $bucket ) );
821
  if ( $region['Location'] ) {
822
- $this->get_s3client()->setRegion( $region['Location'] );
 
823
  }
824
  // attempt to create the test file
825
  $this->get_s3client()->putObject( $args );
542
  // We don't use $this->get_s3object_region() here because we don't want
543
  // to make an AWS API call and slow down page loading
544
  if ( isset( $s3object['region'] ) ) {
545
+ $region = $this->translate_region( $s3object['region'] );
546
  }
547
  else {
548
  $region = '';
743
  return $s3object['region'];
744
  }
745
 
746
+ /**
747
+ * Translate older bucket locations to newer S3 region names
748
+ * http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
749
+ *
750
+ * @param $region
751
+ *
752
+ * @return string
753
+ */
754
+ function translate_region( $region ) {
755
+ $region = strtolower( $region );
756
+
757
+ switch ( $region ) {
758
+ case 'eu' :
759
+ $region = 'eu-west-1';
760
+ break;
761
+ }
762
+
763
+ return $region;
764
+ }
765
+
766
  /**
767
  * Set the region of the AWS client based on the bucket.
768
  *
781
  }
782
 
783
  if ( $region ) {
784
+ $region = $this->translate_region( $region );
785
  $this->get_s3client()->setRegion( $region );
786
  }
787
 
813
  $filesystem = WP_Filesystem();
814
  global $wp_filesystem;
815
  if ( false === $filesystem || is_null( $wp_filesystem ) ) {
816
+ return new WP_Error( 'exception', __( 'There was an error attempting to access the local file system whilst checking the bucket permissions', 'as3cf' ) );
817
  }
818
 
819
  $uploads = wp_upload_dir();
840
  // need to set region for buckets in non default region
841
  $region = $this->get_s3client()->getBucketLocation( array( 'Bucket' => $bucket ) );
842
  if ( $region['Location'] ) {
843
+ $region = $this->translate_region( $region['Location'] );
844
+ $this->get_s3client()->setRegion( $region );
845
  }
846
  // attempt to create the test file
847
  $this->get_s3client()->putObject( $args );
languages/amazon-s3-and-cloudfront.pot CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Amazon S3 and CloudFront\n"
4
- "POT-Creation-Date: 2014-12-02 16:41-0000\n"
5
- "PO-Revision-Date: 2014-12-02 16:44-0000\n"
6
  "Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
7
  "Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
8
  "Language: en\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.10\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-SourceCharset: UTF-8\n"
15
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
@@ -17,6 +17,8 @@ msgstr ""
17
  "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "X-Poedit-SearchPath-0: .\n"
 
 
20
 
21
  #: classes/amazon-s3-and-cloudfront.php:25
22
  msgid "Amazon S3 and CloudFront"
@@ -38,30 +40,32 @@ msgstr ""
38
  msgid "No bucket name provided."
39
  msgstr ""
40
 
41
- #: classes/amazon-s3-and-cloudfront.php:793
42
- msgid "There was an error attempting to access the file system"
 
 
43
  msgstr ""
44
 
45
- #: classes/amazon-s3-and-cloudfront.php:799
46
  msgid ""
47
  "This is a test file to check if the user has write permission to S3. Delete "
48
  "me if found."
49
  msgstr ""
50
 
51
- #: classes/amazon-s3-and-cloudfront.php:803
52
  msgid ""
53
  "It looks like we cannot create a file locally to test the S3 permissions"
54
  msgstr ""
55
 
56
- #: classes/amazon-s3-and-cloudfront.php:845
57
  msgid "Bucket Name:"
58
  msgstr ""
59
 
60
- #: classes/amazon-s3-and-cloudfront.php:846
61
  msgid "Error creating bucket: "
62
  msgstr ""
63
 
64
- #: classes/amazon-s3-and-cloudfront.php:859
65
  msgid "Cheatin' eh?"
66
  msgstr ""
67
 
@@ -172,11 +176,11 @@ msgstr ""
172
  msgid "Settings saved."
173
  msgstr ""
174
 
175
- #: view/settings.php:41
176
  msgid "S3 Policy is Read-Only"
177
  msgstr ""
178
 
179
- #: view/settings.php:43
180
  #, php-format
181
  msgid ""
182
  "You need to go to <a href=\"%s\">Identity and Access Management</a> in your "
@@ -184,89 +188,89 @@ msgid ""
184
  "Your policy should look something like the following:"
185
  msgstr ""
186
 
187
- #: view/settings.php:69
188
  msgid "S3 Settings"
189
  msgstr ""
190
 
191
- #: view/settings.php:72
192
  msgid "Select an S3 Bucket"
193
  msgstr ""
194
 
195
- #: view/settings.php:76
196
  msgid "Create a new bucket..."
197
  msgstr ""
198
 
199
- #: view/settings.php:80
200
  msgid "Bucket is setup for virtual hosting"
201
  msgstr ""
202
 
203
- #: view/settings.php:80
204
  msgid "more info"
205
  msgstr ""
206
 
207
- #: view/settings.php:84
208
  #, php-format
209
  msgid ""
210
  "Set a <a href=\"%s\" target=\"_blank\">far future HTTP expiration header</a> "
211
  "for uploaded files <em>(recommended)</em>"
212
  msgstr ""
213
 
214
- #: view/settings.php:90
215
  msgid "Object Path:"
216
  msgstr ""
217
 
218
- #: view/settings.php:98
219
  msgid "CloudFront Settings"
220
  msgstr ""
221
 
222
- #: view/settings.php:100
223
  msgid "Domain Name"
224
  msgstr ""
225
 
226
- #: view/settings.php:102
227
  msgid "Leave blank if you aren&#8217;t using CloudFront."
228
  msgstr ""
229
 
230
- #: view/settings.php:109
231
  msgid "Plugin Settings"
232
  msgstr ""
233
 
234
- #: view/settings.php:112
235
  msgid "Copy files to S3 as they are uploaded to the Media Library"
236
  msgstr ""
237
 
238
- #: view/settings.php:116
239
  msgid "Point file URLs to S3/CloudFront for files that have been copied to S3"
240
  msgstr ""
241
 
242
- #: view/settings.php:117
243
  msgid ""
244
  "When this is option unchecked, your Media Library images and other files "
245
  "will be served from your server instead of S3/CloudFront. If any images were "
246
  "removed from your server, they will be broken."
247
  msgstr ""
248
 
249
- #: view/settings.php:124
250
  msgid ""
251
  "Remove uploaded file from local filesystem once it has been copied to S3"
252
  msgstr ""
253
 
254
- #: view/settings.php:128
255
  msgid "Always serve files over https (SSL)"
256
  msgstr ""
257
 
258
- #: view/settings.php:132
259
  #, php-format
260
  msgid ""
261
  "Implement <a href=\"%s\">object versioning</a> by appending a timestamp to "
262
  "the S3 file path"
263
  msgstr ""
264
 
265
- #: view/settings.php:136
266
  msgid "Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)"
267
  msgstr ""
268
 
269
- #: view/settings.php:142
270
  msgid "Save Changes"
271
  msgstr ""
272
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Amazon S3 and CloudFront\n"
4
+ "POT-Creation-Date: 2014-12-11 15:33-0000\n"
5
+ "PO-Revision-Date: 2014-12-11 15:33-0000\n"
6
  "Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
7
  "Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
8
  "Language: en\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.7\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-SourceCharset: UTF-8\n"
15
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
17
  "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
+ "X-Poedit-SearchPathExcluded-0: vendor\n"
21
+ "X-Poedit-SearchPathExcluded-1: assets\n"
22
 
23
  #: classes/amazon-s3-and-cloudfront.php:25
24
  msgid "Amazon S3 and CloudFront"
40
  msgid "No bucket name provided."
41
  msgstr ""
42
 
43
+ #: classes/amazon-s3-and-cloudfront.php:816
44
+ msgid ""
45
+ "There was an error attempting to access the local file system whilst "
46
+ "checking the bucket permissions"
47
  msgstr ""
48
 
49
+ #: classes/amazon-s3-and-cloudfront.php:822
50
  msgid ""
51
  "This is a test file to check if the user has write permission to S3. Delete "
52
  "me if found."
53
  msgstr ""
54
 
55
+ #: classes/amazon-s3-and-cloudfront.php:826
56
  msgid ""
57
  "It looks like we cannot create a file locally to test the S3 permissions"
58
  msgstr ""
59
 
60
+ #: classes/amazon-s3-and-cloudfront.php:877
61
  msgid "Bucket Name:"
62
  msgstr ""
63
 
64
+ #: classes/amazon-s3-and-cloudfront.php:878
65
  msgid "Error creating bucket: "
66
  msgstr ""
67
 
68
+ #: classes/amazon-s3-and-cloudfront.php:891
69
  msgid "Cheatin' eh?"
70
  msgstr ""
71
 
176
  msgid "Settings saved."
177
  msgstr ""
178
 
179
+ #: view/settings.php:40
180
  msgid "S3 Policy is Read-Only"
181
  msgstr ""
182
 
183
+ #: view/settings.php:42
184
  #, php-format
185
  msgid ""
186
  "You need to go to <a href=\"%s\">Identity and Access Management</a> in your "
188
  "Your policy should look something like the following:"
189
  msgstr ""
190
 
191
+ #: view/settings.php:66
192
  msgid "S3 Settings"
193
  msgstr ""
194
 
195
+ #: view/settings.php:69
196
  msgid "Select an S3 Bucket"
197
  msgstr ""
198
 
199
+ #: view/settings.php:73
200
  msgid "Create a new bucket..."
201
  msgstr ""
202
 
203
+ #: view/settings.php:77
204
  msgid "Bucket is setup for virtual hosting"
205
  msgstr ""
206
 
207
+ #: view/settings.php:77
208
  msgid "more info"
209
  msgstr ""
210
 
211
+ #: view/settings.php:81
212
  #, php-format
213
  msgid ""
214
  "Set a <a href=\"%s\" target=\"_blank\">far future HTTP expiration header</a> "
215
  "for uploaded files <em>(recommended)</em>"
216
  msgstr ""
217
 
218
+ #: view/settings.php:87
219
  msgid "Object Path:"
220
  msgstr ""
221
 
222
+ #: view/settings.php:95
223
  msgid "CloudFront Settings"
224
  msgstr ""
225
 
226
+ #: view/settings.php:97
227
  msgid "Domain Name"
228
  msgstr ""
229
 
230
+ #: view/settings.php:99
231
  msgid "Leave blank if you aren&#8217;t using CloudFront."
232
  msgstr ""
233
 
234
+ #: view/settings.php:106
235
  msgid "Plugin Settings"
236
  msgstr ""
237
 
238
+ #: view/settings.php:109
239
  msgid "Copy files to S3 as they are uploaded to the Media Library"
240
  msgstr ""
241
 
242
+ #: view/settings.php:113
243
  msgid "Point file URLs to S3/CloudFront for files that have been copied to S3"
244
  msgstr ""
245
 
246
+ #: view/settings.php:114
247
  msgid ""
248
  "When this is option unchecked, your Media Library images and other files "
249
  "will be served from your server instead of S3/CloudFront. If any images were "
250
  "removed from your server, they will be broken."
251
  msgstr ""
252
 
253
+ #: view/settings.php:121
254
  msgid ""
255
  "Remove uploaded file from local filesystem once it has been copied to S3"
256
  msgstr ""
257
 
258
+ #: view/settings.php:125
259
  msgid "Always serve files over https (SSL)"
260
  msgstr ""
261
 
262
+ #: view/settings.php:129
263
  #, php-format
264
  msgid ""
265
  "Implement <a href=\"%s\">object versioning</a> by appending a timestamp to "
266
  "the S3 file path"
267
  msgstr ""
268
 
269
+ #: view/settings.php:133
270
  msgid "Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)"
271
  msgstr ""
272
 
273
+ #: view/settings.php:139
274
  msgid "Save Changes"
275
  msgstr ""
276
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: bradt
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5VPMGLLK94XJC
4
  Tags: uploads, amazon, s3, mirror, admin, media, cdn, cloudfront
5
  Requires at least: 3.5
6
- Tested up to: 4.0.1
7
- Stable tag: 0.7.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.
@@ -58,6 +58,10 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 0.7.1 - 2014-12-05 =
62
  * Bug: Read-only error on settings page sometimes false positive
63
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5VPMGLLK94XJC
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.7.2
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.
58
 
59
  == Changelog ==
60
 
61
+ = 0.7.2 - 2014-12-11 =
62
+ * Bug: Some buckets in the EU region causing permission and HTTP errors
63
+ * Bug: Undefined variable: message in view/error.php also causing white screens
64
+
65
  = 0.7.1 - 2014-12-05 =
66
  * Bug: Read-only error on settings page sometimes false positive
67
 
view/settings.php CHANGED
@@ -29,8 +29,7 @@ if ( ! is_wp_error( $buckets ) && is_array( $buckets ) ) {
29
  $can_write = $this->check_write_permission();
30
  // catch any file system issues
31
  if ( is_wp_error( $can_write ) ) {
32
- $this->render_view( 'error', array( 'error' => $can_write ) );
33
- return;
34
  }
35
  }
36
  // display a error message if the user does not have write permission to S3
29
  $can_write = $this->check_write_permission();
30
  // catch any file system issues
31
  if ( is_wp_error( $can_write ) ) {
32
+ $this->render_view( 'error', array( 'message' => $can_write->get_error_message() ) );
 
33
  }
34
  }
35
  // display a error message if the user does not have write permission to S3
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.7.1
8
  Author URI: http://bradt.ca
9
  Network: True
10
  Text Domain: as3cf
@@ -26,7 +26,7 @@ Domain Path: /languages/
26
  // Then completely rewritten.
27
  */
28
 
29
- $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '0.7.1';
30
 
31
  $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
32
  'amazon-s3-and-cloudfront-edd' => '1.0',
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.7.2
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.7.2';
30
 
31
  $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
32
  'amazon-s3-and-cloudfront-edd' => '1.0',