diff --git a/README.md b/README.md index 21236021..80c020d2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **Contributors:** bradt, deliciousbrains **Tags:** uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront **Requires at least:** 4.4 -**Tested up to:** 4.7.1 -**Stable tag:** 1.1.5 +**Tested up to:** 4.7.3 +**Stable tag:** 1.1.6 **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.1.6 - 2017-03-13 ### +* New: Compatibility with [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) +* New: `as3cf_filter_post_local_to_s3` and `as3cf_filter_post_s3_to_local` filters added for filtering S3 URLs in custom content +* Improvement: Ensure files uploaded using `media_handle_sideload` have unique filename on S3 when 'Remove Files From Server' enabled +* Bug fix: Files uploaded to S3 with empty filenames when the filename started with non-latin characters +* Bug fix: Audio files with private ACL not working with WordPress's default media player +* Bug fix: S3 API version not passed to S3 client +* Bug fix: Content added to text widgets via the Customizer not saved +* Bug fix: Original file not removed locally when cropped via the Customizer and 'Remove Files From Server' enabled +* Bug fix: Incorrect Media Library URLs saved to the database when WordPress installed in a subdirectory + ### WP Offload S3 Lite 1.1.5 - 2017-01-12 ### * Improvement: Filter custom CSS - S3 URLs will no longer be saved to the database * Bug fix: PDF previews have incorrect MIME type diff --git a/assets/js/media.js b/assets/js/media.js index c087b93b..c9912484 100644 --- a/assets/js/media.js +++ b/assets/js/media.js @@ -140,12 +140,15 @@ var test = {}; }, updateACL: function( response ) { - if ( 'undefined' === typeof response.acl_display || 'undefined' === typeof response.title || 'undefined' === typeof response.acl ) { + if ( null == response.acl_display || null == response.title || null == response.acl || null == response.url ) { this.renderACLError(); return; } + this.model.set( 'url', response.url ); + this.render(); + var toggle = $( '#as3cfpro-toggle-acl' ); $( '#as3cfpro-updating' ).remove(); diff --git a/assets/js/media.min.js b/assets/js/media.min.js index 9d9e2176..286bc5ba 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('WordPress.org support forum. Response time can range from a few days to a few weeks and will likely be from a non-developer.', 'amazon-s3-and-cloudfront'), 'https://wordpress.org/plugins/amazon-s3-and-cloudfront/' ); ?>
-timely response via email from a developer who works on this plugin, upgrade and send us an email.', 'amazon-s3-and-cloudfront' ), 'https://deliciousbrains.com/wp-offload-s3/?utm_source=insideplugin&utm_medium=web&utm_content=support-tab&utm_campaign=freeplugin-as3cf' ); ?>
+timely response via email from a developer who works on this plugin, upgrade and send us an email.', 'amazon-s3-and-cloudfront' ), 'https://deliciousbrains.com/wp-offload-s3/?utm_source=insideplugin&utm_medium=web&utm_content=support-tab&utm_campaign=os3-free-plugin' ); ?>
submit an issue on GitHub.', 'amazon-s3-and-cloudfront' ), 'https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/issues' ); ?>
diff --git a/wordpress-s3.php b/wordpress-s3.php index 1de9631c..b1044e5e 100644 --- a/wordpress-s3.php +++ b/wordpress-s3.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/ Description: Automatically copies media uploads to Amazon S3 for storage and delivery. Optionally configure Amazon CloudFront for even faster delivery. Author: Delicious Brains -Version: 1.1.5 +Version: 1.1.6 Author URI: http://deliciousbrains.com/ Network: True Text Domain: amazon-s3-and-cloudfront @@ -26,7 +26,7 @@ // Then completely rewritten. */ -$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.1.5'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.1.6'; $aws_plugin_version_required = '1.0.1'; @@ -76,6 +76,11 @@ function as3cf_init( $aws ) { require_once $abspath . '/classes/as3cf-stream-wrapper.php'; require_once $abspath . '/classes/as3cf-plugin-compatibility.php'; require_once $abspath . '/classes/amazon-s3-and-cloudfront.php'; + + // Autoloader + require_once $abspath . '/wp-offload-s3-autoloader.php'; + new WP_Offload_S3_Autoloader( 'WP_Offload_S3', $abspath ); + $as3cf = new Amazon_S3_And_CloudFront( __FILE__, $aws ); } diff --git a/wp-offload-s3-autoloader.php b/wp-offload-s3-autoloader.php new file mode 100644 index 00000000..7a280c5a --- /dev/null +++ b/wp-offload-s3-autoloader.php @@ -0,0 +1,94 @@ +prefix = $prefix; + $this->abspath = $abspath; + + spl_autoload_register( array( $this, 'autoloader' ) ); + } + + /** + * Autoloader. + * + * @param string $class_name + */ + public function autoloader( $class_name ) { + if ( ! $this->class_belongs_to_plugin( $class_name ) ) { + return; + } + + $path = $this->get_classes_directory() . $this->get_class_path( $class_name ); + + if ( file_exists( $path ) ) { + require_once $path; + } + } + + /** + * Class belong to plugin. + * + * @param string $class_name + * + * @return bool + */ + protected function class_belongs_to_plugin( $class_name ) { + if ( 0 !== strpos( $class_name, $this->vendor . '\\' . $this->prefix . '\\' ) ) { + return false; + } + + return true; + } + + /** + * Get class path. + * + * @param string $class_name + * + * @return string + */ + protected function get_class_path( $class_name ) { + $parts = explode( '\\', strtolower( $class_name ) ); + $parts = array_slice( $parts, 2 ); + + $filename = implode( DIRECTORY_SEPARATOR, $parts ) . '.php'; + + return str_replace( '_', '-', strtolower( $filename ) ); + } + + /** + * Get classes directory. + * + * @return string + */ + protected function get_classes_directory() { + return $this->abspath . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR; + } + + } +}