WP Offload S3 Lite - Version 0.7.1

Version Description

  • 2014-12-05 =
  • Bug: Read-only error on settings page sometimes false positive
Download this release

Release Info

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

Code changes from version 0.7 to 0.7.1

classes/amazon-s3-and-cloudfront.php CHANGED
@@ -781,11 +781,13 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
781
/**
782
* Checks the user has write permission for S3
783
*
784
- * @param string $bucket
785
- *
786
* @return bool
787
*/
788
- function check_write_permission( $bucket ) {
789
// fire up the filesystem API
790
$filesystem = WP_Filesystem();
791
global $wp_filesystem;
@@ -803,20 +805,28 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
803
return new WP_Error( 'exception', __( 'It looks like we cannot create a file locally to test the S3 permissions', 'as3cf' ) );
804
}
805
806
$args = array(
807
'Bucket' => $bucket,
808
- 'Key' => $file_name,
809
'SourceFile' => $file,
810
'ACL' => 'public-read'
811
);
812
813
try {
814
// attempt to create the test file
815
$this->get_s3client()->putObject( $args );
816
// delete it straight away if created
817
$this->get_s3client()->deleteObject( array(
818
'Bucket' => $bucket,
819
- 'Key' => $file_name
820
) );
821
$can_write = true;
822
} catch ( Exception $e ) {
781
/**
782
* Checks the user has write permission for S3
783
*
784
* @return bool
785
*/
786
+ function check_write_permission( ) {
787
+ if ( ! ( $bucket = $this->get_setting('bucket') ) ) {
788
+ // if no bucket set then no need check
789
+ return true;
790
+ }
791
// fire up the filesystem API
792
$filesystem = WP_Filesystem();
793
global $wp_filesystem;
805
return new WP_Error( 'exception', __( 'It looks like we cannot create a file locally to test the S3 permissions', 'as3cf' ) );
806
}
807
808
+ $path = $this->get_setting( 'object-prefix' );
809
+ $key = $path . $file_name;
810
+
811
$args = array(
812
'Bucket' => $bucket,
813
+ 'Key' => $key,
814
'SourceFile' => $file,
815
'ACL' => 'public-read'
816
);
817
818
try {
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 );
826
// delete it straight away if created
827
$this->get_s3client()->deleteObject( array(
828
'Bucket' => $bucket,
829
+ 'Key' => $key
830
) );
831
$can_write = true;
832
} catch ( Exception $e ) {
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: 3.9
7
- Stable tag: 0.7
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,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
58
59
== Changelog ==
60
61
= 0.7 - 2014-12-04 =
62
* New: Proper S3 region subdomain in URLs for buckets not in the US Standard region (e.g. https://s3-us-west-2.amazonaws.com/...)
63
* New: Update all existing attachment meta with bucket region (automatically runs in the background)
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
59
== Changelog ==
60
61
+ = 0.7.1 - 2014-12-05 =
62
+ * Bug: Read-only error on settings page sometimes false positive
63
+
64
= 0.7 - 2014-12-04 =
65
* New: Proper S3 region subdomain in URLs for buckets not in the US Standard region (e.g. https://s3-us-west-2.amazonaws.com/...)
66
* New: Update all existing attachment meta with bucket region (automatically runs in the background)
view/settings.php CHANGED
@@ -26,7 +26,7 @@ if ( isset( $_GET['updated'] ) ) {
26
27
$can_write = true;
28
if ( ! is_wp_error( $buckets ) && is_array( $buckets ) ) {
29
- $can_write = $this->check_write_permission( $buckets[0]['Name'] );
30
// catch any file system issues
31
if ( is_wp_error( $can_write ) ) {
32
$this->render_view( 'error', array( 'error' => $can_write ) );
@@ -54,8 +54,6 @@ if ( ! $can_write ) : ?>
54
}</code></pre>
55
</div>
56
<?php
57
- // don't show the rest of the settings if cannot write
58
- return;
59
endif;
60
?>
61
26
27
$can_write = true;
28
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 ) );
54
}</code></pre>
55
</div>
56
<?php
57
endif;
58
?>
59
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
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';
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.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.7.1';
30
31
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
32
'amazon-s3-and-cloudfront-edd' => '1.0',