Version Description
= 0.6 = This version requires PHP 5.3.3+ and the Amazon Web Services plugin
= 0.6.1 = This version requires PHP 5.3.3+ and the Amazon Web Services plugin
= 0.6.2 = This version requires PHP 5.3.3+ and the Amazon Web Services plugin
Download this release
Release Info
Developer | deliciousbrains |
Plugin | WP Offload S3 Lite |
Version | 0.9.10 |
Comparing to | |
See all releases |
Code changes from version 0.9.9 to 0.9.10
- README.md +39 -28
- assets/js/notice.min.js +1 -1
- assets/js/script.min.js +1 -1
- classes/amazon-s3-and-cloudfront.php +84 -37
- classes/as3cf-plugin-compatibility.php +59 -0
- languages/amazon-s3-and-cloudfront-en.pot +34 -34
- readme.txt +7 -2
- wordpress-s3.php +2 -2
README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
# WP Offload S3 #
|
2 |
**Contributors:** bradt, deliciousbrains
|
3 |
-
**Tags:** uploads, amazon, s3, mirror, admin, media, cdn, cloudfront
|
4 |
**Requires at least:** 3.7
|
5 |
-
**Tested up to:** 4.
|
6 |
-
**Stable tag:** 0.9.
|
7 |
**License:** GPLv3
|
8 |
|
9 |
Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
|
@@ -12,18 +12,18 @@ Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally
|
|
12 |
|
13 |
https://www.youtube.com/watch?v=_PVybEGaRXc
|
14 |
|
15 |
-
This plugin automatically copies images, videos, documents, and any other media added through WordPress' media uploader to [Amazon
|
16 |
|
17 |
-
Uploading files *directly* to your S3 account is not currently supported by this plugin. They are uploaded to your server first, then copied to S3. There is an option to automatically remove the files from your server once they are copied to S3 however.
|
18 |
|
19 |
-
If you're adding this plugin to a site that's been around for a while, your existing media files will not be copied or served from S3. Only newly uploaded files will be copied and served from S3. The pro upgrade has an upload tool to handle existing media files.
|
20 |
|
21 |
**PRO Upgrade with Email Support and More Features**
|
22 |
|
23 |
-
* Upload existing Media Library to S3
|
24 |
* Find & replace file URLs in content
|
25 |
-
* Control S3 files from the Media Library
|
26 |
-
* [Assets addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#assets-addon) - Serve your CSS & JS from S3/CloudFront
|
27 |
* [WooCommerce addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#woocommerce-addon)
|
28 |
* [Easy Digital Downloads addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#edd-addon)
|
29 |
* PriorityExpert™ email support
|
@@ -45,6 +45,12 @@ which is a fork of [Amazon S3 for WordPress](http://wordpress.org/extend/plugins
|
|
45 |
3. Install this plugin using WordPress' built-in installer
|
46 |
4. Access the *S3 and CloudFront* option under *AWS* and configure
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
## Screenshots ##
|
49 |
|
50 |
### 1. Choosing/creating a bucket ###
|
@@ -67,7 +73,12 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
67 |
|
68 |
## Changelog ##
|
69 |
|
70 |
-
### 0.9.
|
|
|
|
|
|
|
|
|
|
|
71 |
* Improvement: Improve wording of compatibility notices
|
72 |
* Improvement: Compatibility with Easy Digital Downloads 1.0.1 and WooCommerce 1.0.3 addons
|
73 |
* Improvement: Better determine available memory for background processes
|
@@ -75,10 +86,10 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
75 |
* Bug fix: PHP Warning: stream_wrapper_register(): Protocol s3:// is already defined
|
76 |
* Bug fix: PHP Fatal error: Call to undefined method WP_Error::get()
|
77 |
|
78 |
-
### 0.9.8 - 2015-11-02 ###
|
79 |
* Bug fix: Attachment URLs containing query string parameters incorrectly encoded
|
80 |
|
81 |
-
### 0.9.7 - 2015-10-26 ###
|
82 |
* Improvement: Improve compatibility with third party plugins when the _Remove Files From Server_ option is enabled
|
83 |
* Improvement: Fix inconsistent spacing on the WP Offload S3 settings screen
|
84 |
* Improvement: Validate _CloudFront or custom domain_ input field
|
@@ -96,13 +107,13 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
96 |
* Bug fix: Cron tasks incorrectly scheduled due to passing the wrong time to `wp_schedule_event`
|
97 |
* Bug fix: Default options not shown in the UI after first install
|
98 |
|
99 |
-
### 0.9.6 - 2015-10-01 ###
|
100 |
* Improvement: Update text domains for translate.wordpress.org integration
|
101 |
|
102 |
-
### 0.9.5 - 2015-09-01 ###
|
103 |
* Bug fix: Fatal error: Cannot use object of type WP_Error as array
|
104 |
|
105 |
-
### 0.9.4 - 2015-08-27 ###
|
106 |
* New: Update all existing attachments with missing file sizes when the 'Remove Files From Server' option is enabled (automatically runs in the background)
|
107 |
* Improvement: Show when constants are used to set bucket and region options
|
108 |
* Improvement: Don't show compatibility notices on plugin update screen
|
@@ -113,14 +124,14 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
113 |
* Bug fix: Upload attempted to non existent bucket when defined by constant
|
114 |
* Bug fix: 'SignatureDoesNotMatch' error shown when using signed URLs with bucket names containing '.' characters
|
115 |
|
116 |
-
### 0.9.3 - 2015-08-17 ###
|
117 |
* New: Pro upgrade sidebar
|
118 |
* Bug fix: Create buckets in US standard region causing S3 URLs to 404 errors
|
119 |
|
120 |
-
### 0.9.2 - 2015-07-29 ###
|
121 |
* Bug fix: Accidentally released the sidebar for after we launch the pro version
|
122 |
|
123 |
-
### 0.9.1 - 2015-07-29 ###
|
124 |
* Improvement: Access denied sample IAM policy replaced with link to [Quick Start Guide](https://deliciousbrains.com/wp-offload-s3/doc/quick-start-guide/)
|
125 |
* Improvement: Access denied messages on bucket selection or bucket creation now link to [Quick Start Guide](https://deliciousbrains.com/wp-offload-s3/doc/quick-start-guide/)
|
126 |
* Improvement: Object expires time can now be filtered using the `as3cf_object_meta` filter
|
@@ -134,7 +145,7 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
134 |
* Bug fix: WordPress footer overlaps WP Offload S3 sidebar
|
135 |
* Bug fix: Upon initial setup the settings changed alert shows when no settings have changed
|
136 |
|
137 |
-
### 0.9 - 2015-07-08 ###
|
138 |
* New: Plugin rebranded to WP Offload S3
|
139 |
* New: Support tab added to _Offload S3_ screen containing diagnostic information
|
140 |
* New: Compatibility with the [Media Replace](https://wordpress.org/plugins/enable-media-replace/) plugin
|
@@ -164,19 +175,19 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
164 |
* Bug fix: Subsite upload paths repeated on multisite installs
|
165 |
* Bug fix: Handle multisite installs where `BLOG_ID_CURRENT_SITE` is not 1
|
166 |
|
167 |
-
### 0.8.2 - 2015-01-31 ###
|
168 |
* New: Input bucket in settings to avoid listing all buckets
|
169 |
* New: Specify bucket with 'AS3CF_BUCKET' constant
|
170 |
* Improvement: Compatibility with beta release of Pro plugin
|
171 |
* Bug Fix: Incorrect file prefix in S3 permission check
|
172 |
|
173 |
-
### 0.8.1 - 2015-01-19 ###
|
174 |
* Bug Fix: Permission problems on installs running on EC2s
|
175 |
* Bug Fix: Blank settings page due to WP_Error on S3 permission check
|
176 |
* Bug Fix: Warning: strtolower() expects parameter 1 to be string, object given
|
177 |
* Bug Fix: Region post meta update running on subsites of Multisite installs
|
178 |
|
179 |
-
### 0.8 - 2015-01-10 ###
|
180 |
* New: Redesigned settings UI
|
181 |
* Improvement: SSL setting can be fully controlled, HTTPS for urls always, based on request or never
|
182 |
* Improvement: Download files from S3 that are not found on server when running Regenerate Thumbnails plugin
|
@@ -185,14 +196,14 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
185 |
* Bug Fix: Files for all subsites going into the same S3 folder on multisite installs setup prior to WP 3.5
|
186 |
* Bug Fix: 'attempting to access local file system' error for some installs
|
187 |
|
188 |
-
### 0.7.2 - 2014-12-11 ###
|
189 |
* Bug: Some buckets in the EU region causing permission and HTTP errors
|
190 |
* Bug: Undefined variable: message in view/error.php also causing white screens
|
191 |
|
192 |
-
### 0.7.1 - 2014-12-05 ###
|
193 |
* Bug: Read-only error on settings page sometimes false positive
|
194 |
|
195 |
-
### 0.7 - 2014-12-04 ###
|
196 |
* New: Proper S3 region subdomain in URLs for buckets not in the US Standard region (e.g. https://s3-us-west-2.amazonaws.com/...)
|
197 |
* New: Update all existing attachment meta with bucket region (automatically runs in the background)
|
198 |
* New: Get secure URL for different image sizes (iamzozo)
|
@@ -215,10 +226,10 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
215 |
* Bug Fix: S3 file overwritten when file with same name uploaded and local file removed (dataferret)
|
216 |
* Bug Fix: Manually resized images not uploaded (gmauricio)
|
217 |
|
218 |
-
### 0.6.1 - 2013-09-21 ###
|
219 |
* WP.org download of Amazon Web Services plugin is giving a 404 Not Found, so directing people to download from Github instead
|
220 |
|
221 |
-
### 0.6 - 2013-09-20 ###
|
222 |
* Complete rewrite
|
223 |
* Now requires PHP 5.3.3+
|
224 |
* Now requires the [Amazon Web Services plugin](http://wordpress.org/extend/plugins/amazon-web-services/) which contains the latest PHP libraries from Amazon
|
@@ -229,7 +240,7 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
229 |
* New Option: Remove uploaded file from local filesystem once it has been copied to S3
|
230 |
* New Option: Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)
|
231 |
|
232 |
-
### 0.5 - 2013-01-29 ###
|
233 |
* Forked [Amazon S3 for WordPress with CloudFront](http://wordpress.org/extend/plugins/tantan-s3-cloudfront/)
|
234 |
* Cleaned up the UI to fit with today's WP UI
|
235 |
* Fixed issues causing error messages when WP_DEBUG is on
|
1 |
# WP Offload S3 #
|
2 |
**Contributors:** bradt, deliciousbrains
|
3 |
+
**Tags:** uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront
|
4 |
**Requires at least:** 3.7
|
5 |
+
**Tested up to:** 4.4
|
6 |
+
**Stable tag:** 0.9.10
|
7 |
**License:** GPLv3
|
8 |
|
9 |
Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
|
12 |
|
13 |
https://www.youtube.com/watch?v=_PVybEGaRXc
|
14 |
|
15 |
+
This plugin automatically copies images, videos, documents, and any other media added through WordPress' media uploader to [Amazon S3](http://aws.amazon.com/s3/). It then automatically replaces the URL to each media file with their respective Amazon S3 URL or, if you have configured [Amazon CloudFront](http://aws.amazon.com/cloudfront/), the respective CloudFront URL. Image thumbnails are also copied to Amazon S3 and delivered through S3/CloudFront.
|
16 |
|
17 |
+
Uploading files *directly* to your Amazon S3 account is not currently supported by this plugin. They are uploaded to your server first, then copied to Amazon S3. There is an option to automatically remove the files from your server once they are copied to Amazon S3 however.
|
18 |
|
19 |
+
If you're adding this plugin to a site that's been around for a while, your existing media files will not be copied or served from Amazon S3. Only newly uploaded files will be copied and served from Amazon S3. The pro upgrade has an upload tool to handle existing media files.
|
20 |
|
21 |
**PRO Upgrade with Email Support and More Features**
|
22 |
|
23 |
+
* Upload existing Media Library to Amazon S3
|
24 |
* Find & replace file URLs in content
|
25 |
+
* Control Amazon S3 files from the Media Library
|
26 |
+
* [Assets addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#assets-addon) - Serve your CSS & JS from Amazon S3/CloudFront
|
27 |
* [WooCommerce addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#woocommerce-addon)
|
28 |
* [Easy Digital Downloads addon](https://deliciousbrains.com/wp-offload-s3/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#edd-addon)
|
29 |
* PriorityExpert™ email support
|
45 |
3. Install this plugin using WordPress' built-in installer
|
46 |
4. Access the *S3 and CloudFront* option under *AWS* and configure
|
47 |
|
48 |
+
## Frequently Asked Questions ##
|
49 |
+
|
50 |
+
### What are the minimum requirements? ###
|
51 |
+
|
52 |
+
You can see the minimum requirements [here](https://deliciousbrains.com/wp-offload-s3/pricing/?utm_source=wordpress.org&utm_medium=web&utm_content=desc&utm_campaign=os3-free-plugin#requirements).
|
53 |
+
|
54 |
## Screenshots ##
|
55 |
|
56 |
### 1. Choosing/creating a bucket ###
|
73 |
|
74 |
## Changelog ##
|
75 |
|
76 |
+
### WP Offload S3 0.9.10 - 2015-11-26 ###
|
77 |
+
* Improvement: Support for responsive images in WP 4.4
|
78 |
+
* Bug fix: Incorrect file path for intermediate image size files uploaded to S3 with no prefix
|
79 |
+
* Bug fix: Thumbnail previews return 404 error during image edit screen due to character encoding
|
80 |
+
|
81 |
+
### WP Offload S3 0.9.9 - 2015-11-12 ###
|
82 |
* Improvement: Improve wording of compatibility notices
|
83 |
* Improvement: Compatibility with Easy Digital Downloads 1.0.1 and WooCommerce 1.0.3 addons
|
84 |
* Improvement: Better determine available memory for background processes
|
86 |
* Bug fix: PHP Warning: stream_wrapper_register(): Protocol s3:// is already defined
|
87 |
* Bug fix: PHP Fatal error: Call to undefined method WP_Error::get()
|
88 |
|
89 |
+
### WP Offload S3 0.9.8 - 2015-11-02 ###
|
90 |
* Bug fix: Attachment URLs containing query string parameters incorrectly encoded
|
91 |
|
92 |
+
### WP Offload S3 0.9.7 - 2015-10-26 ###
|
93 |
* Improvement: Improve compatibility with third party plugins when the _Remove Files From Server_ option is enabled
|
94 |
* Improvement: Fix inconsistent spacing on the WP Offload S3 settings screen
|
95 |
* Improvement: Validate _CloudFront or custom domain_ input field
|
107 |
* Bug fix: Cron tasks incorrectly scheduled due to passing the wrong time to `wp_schedule_event`
|
108 |
* Bug fix: Default options not shown in the UI after first install
|
109 |
|
110 |
+
### WP Offload S3 0.9.6 - 2015-10-01 ###
|
111 |
* Improvement: Update text domains for translate.wordpress.org integration
|
112 |
|
113 |
+
### WP Offload S3 0.9.5 - 2015-09-01 ###
|
114 |
* Bug fix: Fatal error: Cannot use object of type WP_Error as array
|
115 |
|
116 |
+
### WP Offload S3 0.9.4 - 2015-08-27 ###
|
117 |
* New: Update all existing attachments with missing file sizes when the 'Remove Files From Server' option is enabled (automatically runs in the background)
|
118 |
* Improvement: Show when constants are used to set bucket and region options
|
119 |
* Improvement: Don't show compatibility notices on plugin update screen
|
124 |
* Bug fix: Upload attempted to non existent bucket when defined by constant
|
125 |
* Bug fix: 'SignatureDoesNotMatch' error shown when using signed URLs with bucket names containing '.' characters
|
126 |
|
127 |
+
### WP Offload S3 0.9.3 - 2015-08-17 ###
|
128 |
* New: Pro upgrade sidebar
|
129 |
* Bug fix: Create buckets in US standard region causing S3 URLs to 404 errors
|
130 |
|
131 |
+
### WP Offload S3 0.9.2 - 2015-07-29 ###
|
132 |
* Bug fix: Accidentally released the sidebar for after we launch the pro version
|
133 |
|
134 |
+
### WP Offload S3 0.9.1 - 2015-07-29 ###
|
135 |
* Improvement: Access denied sample IAM policy replaced with link to [Quick Start Guide](https://deliciousbrains.com/wp-offload-s3/doc/quick-start-guide/)
|
136 |
* Improvement: Access denied messages on bucket selection or bucket creation now link to [Quick Start Guide](https://deliciousbrains.com/wp-offload-s3/doc/quick-start-guide/)
|
137 |
* Improvement: Object expires time can now be filtered using the `as3cf_object_meta` filter
|
145 |
* Bug fix: WordPress footer overlaps WP Offload S3 sidebar
|
146 |
* Bug fix: Upon initial setup the settings changed alert shows when no settings have changed
|
147 |
|
148 |
+
### WP Offload S3 0.9 - 2015-07-08 ###
|
149 |
* New: Plugin rebranded to WP Offload S3
|
150 |
* New: Support tab added to _Offload S3_ screen containing diagnostic information
|
151 |
* New: Compatibility with the [Media Replace](https://wordpress.org/plugins/enable-media-replace/) plugin
|
175 |
* Bug fix: Subsite upload paths repeated on multisite installs
|
176 |
* Bug fix: Handle multisite installs where `BLOG_ID_CURRENT_SITE` is not 1
|
177 |
|
178 |
+
### WP Offload S3 0.8.2 - 2015-01-31 ###
|
179 |
* New: Input bucket in settings to avoid listing all buckets
|
180 |
* New: Specify bucket with 'AS3CF_BUCKET' constant
|
181 |
* Improvement: Compatibility with beta release of Pro plugin
|
182 |
* Bug Fix: Incorrect file prefix in S3 permission check
|
183 |
|
184 |
+
### WP Offload S3 0.8.1 - 2015-01-19 ###
|
185 |
* Bug Fix: Permission problems on installs running on EC2s
|
186 |
* Bug Fix: Blank settings page due to WP_Error on S3 permission check
|
187 |
* Bug Fix: Warning: strtolower() expects parameter 1 to be string, object given
|
188 |
* Bug Fix: Region post meta update running on subsites of Multisite installs
|
189 |
|
190 |
+
### WP Offload S3 0.8 - 2015-01-10 ###
|
191 |
* New: Redesigned settings UI
|
192 |
* Improvement: SSL setting can be fully controlled, HTTPS for urls always, based on request or never
|
193 |
* Improvement: Download files from S3 that are not found on server when running Regenerate Thumbnails plugin
|
196 |
* Bug Fix: Files for all subsites going into the same S3 folder on multisite installs setup prior to WP 3.5
|
197 |
* Bug Fix: 'attempting to access local file system' error for some installs
|
198 |
|
199 |
+
### WP Offload S3 0.7.2 - 2014-12-11 ###
|
200 |
* Bug: Some buckets in the EU region causing permission and HTTP errors
|
201 |
* Bug: Undefined variable: message in view/error.php also causing white screens
|
202 |
|
203 |
+
### WP Offload S3 0.7.1 - 2014-12-05 ###
|
204 |
* Bug: Read-only error on settings page sometimes false positive
|
205 |
|
206 |
+
### WP Offload S3 0.7 - 2014-12-04 ###
|
207 |
* New: Proper S3 region subdomain in URLs for buckets not in the US Standard region (e.g. https://s3-us-west-2.amazonaws.com/...)
|
208 |
* New: Update all existing attachment meta with bucket region (automatically runs in the background)
|
209 |
* New: Get secure URL for different image sizes (iamzozo)
|
226 |
* Bug Fix: S3 file overwritten when file with same name uploaded and local file removed (dataferret)
|
227 |
* Bug Fix: Manually resized images not uploaded (gmauricio)
|
228 |
|
229 |
+
### WP Offload S3 0.6.1 - 2013-09-21 ###
|
230 |
* WP.org download of Amazon Web Services plugin is giving a 404 Not Found, so directing people to download from Github instead
|
231 |
|
232 |
+
### WP Offload S3 0.6 - 2013-09-20 ###
|
233 |
* Complete rewrite
|
234 |
* Now requires PHP 5.3.3+
|
235 |
* Now requires the [Amazon Web Services plugin](http://wordpress.org/extend/plugins/amazon-web-services/) which contains the latest PHP libraries from Amazon
|
240 |
* New Option: Remove uploaded file from local filesystem once it has been copied to S3
|
241 |
* New Option: Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)
|
242 |
|
243 |
+
### WP Offload S3 0.5 - 2013-01-29 ###
|
244 |
* Forked [Amazon S3 for WordPress with CloudFront](http://wordpress.org/extend/plugins/tantan-s3-cloudfront/)
|
245 |
* Cleaned up the UI to fit with today's WP UI
|
246 |
* Fixed issues causing error messages when WP_DEBUG is on
|
assets/js/notice.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a){a("body").on("click",".as3cf-notice .notice-dismiss",function(
|
1 |
+
!function(a){a("body").on("click",".as3cf-notice .notice-dismiss",function(){var b=a(this).parents(".as3cf-notice").attr("id");if(b){var c={action:"as3cf-dismiss-notice",notice_id:b,_nonce:as3cf_notice.nonces.dismiss_notice};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:c,error:function(a,b,c){alert(as3cf_notice.strings.dismiss_notice_error+c)}})}})}(jQuery);
|
assets/js/script.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a,b){function c(b){return a("#"+b+" .as3cf-main-settings form").find("input:not(.no-compare)").serialize()}function d(b){var c=a("#"+b),d=c.find("input[type=checkbox]");c.toggleClass("on").find("span").toggleClass("checked");var e=c.find("span.on").hasClass("checked");d.attr("checked",e).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.buckets.bucketSelectLock=!1}function i(){a("#remove-local-file").is(":checked")&&a("#serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function j(){a("#remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}var k,l={},m=/[^a-z0-9.-]/,n=a(".as3cf-tab");as3cf.tabs={defaultTab:"media",toggle:function(c,d){n.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")}},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('<li class="loading">'+d.attr("data-working")+"</li>");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('<li><a class="'+c+'" href="#" data-bucket="'+b.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+b.Name+'</span><span class="spinner"></span></span></a></li>')}),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()),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")):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,i,j){var m=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),n=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===n.text().trim().length){d("copy-to-s3-wrap"),d("serve-from-s3-wrap");var o=k.attr("id");l[o]=c(o)}a(".as3cf-error.fatal").hide(),n.text(e),m.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(i),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!j),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(h)},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)):j.showError(as3cf.strings.create_bucket_error,b.error,"as3cf-bucket-create")}})},isValidName:function(a){return a.length<3||a.length>63?!1:!0===m.test(a)?!1:!0},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(){var h=a(".wrap.aws-main .nav-tab-wrapper");if(a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(h),window.location.hash){var m=window.location.hash.substring(1);as3cf.tabs.toggle(m,!0)}else k=a("#tab-"+as3cf.tabs.defaultTab),a(".aws-main").attr("data-tab",as3cf.tabs.defaultTab);a(".aws-main").on("click",".nav-tab",function(b){if(b.preventDefault(),!a(this).hasClass("nav-tab-active")){var c=a(this).attr("data-tab");as3cf.tabs.toggle(c),"media"===c?(window.location.hash="","function"==typeof window.history.replaceState&&"#"===window.location.href.slice(-1)&&history.replaceState({},"",window.location.href.slice(0,-1))):window.location.hash=c}}),n.length&&n.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"))}),n.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(".as3cf-ssl").on("change",'input[type="radio"]',function(b){var c=a('input:radio[name="ssl"]:checked').val();if("https"===c){var d=a('input:radio[name="domain"]:checked').val();"subdomain"===d&&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(a){g()}),i(),a("#serve-from-s3,#remove-local-file").on("change",function(a){i()}),j(),a("#remove-local-file").on("change",function(a){j()}),a('.as3cf-setting input[type="text"]').keypress(function(a){return 13===a.which?(a.preventDefault(),!1):void 0}),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()}),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().length<as3cf.buckets.validLength?d.find("button[type=submit]").attr("disabled",!0):d.find("button[type=submit]").removeAttr("disabled")})})}(jQuery,as3cfModal);
|
1 |
+
!function(a,b){function c(b){return a("#"+b+" .as3cf-main-settings form").find("input:not(.no-compare)").serialize()}function d(b){var c=a("#"+b),d=c.find("input[type=checkbox]");c.toggleClass("on").find("span").toggleClass("checked");var e=c.find("span.on").hasClass("checked");d.attr("checked",e).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){"undefined"!=typeof b.success?a(".as3cf-url-preview").html(b.url):alert(as3cf.strings.get_url_preview_error+b.error)}})}function h(){as3cf.buckets.bucketSelectLock=!1}function i(){a("#remove-local-file").is(":checked")&&a("#serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function j(){a("#remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}var k,l={},m=/[^a-z0-9.-]/,n=a(".as3cf-tab");as3cf.tabs={defaultTab:"media",toggle:function(c,d){n.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")}},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('<li class="loading">'+d.attr("data-working")+"</li>");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){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('<li><a class="'+c+'" href="#" data-bucket="'+b.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+b.Name+'</span><span class="spinner"></span></span></a></li>')}),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()),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){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")):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){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,i,j){var m=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form"),n=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===n.text().trim().length){d("copy-to-s3-wrap"),d("serve-from-s3-wrap");var o=k.attr("id");l[o]=c(o)}a(".as3cf-error.fatal").hide(),n.text(e),m.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),a("#"+b.prefix+"-region").val(i),a(".updated").not(".as3cf-notice").show(),k.addClass("as3cf-has-bucket"),k.find(".as3cf-can-write-error").toggle(!j),k.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(h)},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){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)):j.showError(as3cf.strings.create_bucket_error,b.error,"as3cf-bucket-create")}})},isValidName:function(a){return a.length<3||a.length>63?!1:!0===m.test(a)?!1:!0},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),a(".as3cf-invalid-bucket-name").html(c&&b.length>0?c:"")}},a(document).ready(function(){var h=a(".wrap.aws-main .nav-tab-wrapper");if(a(".aws-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(h),window.location.hash){var m=window.location.hash.substring(1);as3cf.tabs.toggle(m,!0)}else k=a("#tab-"+as3cf.tabs.defaultTab),a(".aws-main").attr("data-tab",as3cf.tabs.defaultTab);a(".aws-main").on("click",".nav-tab",function(b){if(b.preventDefault(),!a(this).hasClass("nav-tab-active")){var c=a(this).attr("data-tab");as3cf.tabs.toggle(c),"media"===c?(window.location.hash="","function"==typeof window.history.replaceState&&"#"===window.location.href.slice(-1)&&history.replaceState({},"",window.location.href.slice(0,-1))):window.location.hash=c}}),n.length&&n.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(){a(window).off("beforeunload.as3cf-settings")}),a(".as3cf-switch").on("click",function(){a(this).hasClass("disabled")||d(a(this).attr("id"))}),n.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(this).closest('input:radio[name="domain"]:checked'),c=b.val(),d=a(this).parents(".as3cf-domain").find(".as3cf-setting.cloudfront"),e="cloudfront"===c;d.toggleClass("hide",!e)}),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()}),i(),a("#serve-from-s3,#remove-local-file").on("change",function(){i()}),j(),a("#remove-local-file").on("change",function(){j()}),a('.as3cf-setting input[type="text"]').keypress(function(a){return 13===a.which?(a.preventDefault(),!1):void 0}),a('input[name="cloudfront"]').on("keyup",function(){e(a(this))}),a('input[name="domain"]').on("change",function(){var b=a(this),c=a("#"+k.attr("id")+' form button[type="submit"]');"cloudfront"!==b.val()?c.attr("disabled",!1):e(b.next(".as3cf-setting").find('input[name="cloudfront"]'))}),a('input[name="object-prefix"]').on("change",function(){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()}),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(){var c=a(this).val(),d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-create-bucket-form");as3cf.buckets.isValidName(c)?d.find("button[type=submit]").removeAttr("disabled"):d.find("button[type=submit]").attr("disabled",!0),as3cf.buckets.updateNameNotice(c)}),a("body").on("input keyup",".as3cf-manual-save-bucket-form .as3cf-bucket-name",function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-manual-save-bucket-form");c.find(".as3cf-bucket-name").val().length<as3cf.buckets.validLength?c.find("button[type=submit]").attr("disabled",!0):c.find("button[type=submit]").removeAttr("disabled")})})}(jQuery,as3cfModal);
|
classes/amazon-s3-and-cloudfront.php
CHANGED
@@ -121,6 +121,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
121 |
add_filter( 'get_image_tag', array( $this, 'maybe_encode_get_image_tag' ), 99, 6 );
|
122 |
add_filter( 'wp_get_attachment_image_src', array( $this, 'maybe_encode_wp_get_attachment_image_src' ), 99, 4 );
|
123 |
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'maybe_encode_wp_prepare_attachment_for_js' ), 99, 3 );
|
|
|
124 |
add_filter( 'get_attached_file', array( $this, 'get_attached_file' ), 10, 2 );
|
125 |
|
126 |
// Communication with S3, plugin needs to be setup
|
@@ -599,7 +600,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
599 |
$acl = $old_s3object['acl'];
|
600 |
}
|
601 |
// use existing prefix
|
602 |
-
$prefix =
|
|
|
603 |
// use existing bucket
|
604 |
$bucket = $old_s3object['bucket'];
|
605 |
// get existing region
|
@@ -1299,15 +1301,26 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1299 |
* @return bool|mixed|void|WP_Error
|
1300 |
*/
|
1301 |
function get_attachment_url( $post_id, $expires = null, $size = null, $meta = null, $headers = array(), $skip_rewrite_check = false ) {
|
1302 |
-
if ( ! $
|
1303 |
return false;
|
1304 |
}
|
1305 |
|
1306 |
-
|
1307 |
-
|
1308 |
-
return false;
|
1309 |
-
}
|
1310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1311 |
$scheme = $this->get_s3_url_scheme();
|
1312 |
|
1313 |
// We don't use $this->get_s3object_region() here because we don't want
|
@@ -1330,7 +1343,10 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1330 |
$meta = get_post_meta( $post_id, '_wp_attachment_metadata', true );
|
1331 |
}
|
1332 |
if ( isset( $meta['sizes'][ $size ]['file'] ) ) {
|
1333 |
-
$
|
|
|
|
|
|
|
1334 |
}
|
1335 |
}
|
1336 |
|
@@ -1364,14 +1380,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1364 |
*
|
1365 |
* @return string
|
1366 |
*/
|
1367 |
-
function maybe_encode_get_image_tag( $html, $id, $alt, $title, $align, $size ) {
|
1368 |
-
if ( ! $this->
|
1369 |
-
// Not serving S3 URLs
|
1370 |
-
return $html;
|
1371 |
-
}
|
1372 |
-
|
1373 |
-
if ( ! $this->get_attachment_s3_info( $id ) ) {
|
1374 |
-
// File not uploaded to S3
|
1375 |
return $html;
|
1376 |
}
|
1377 |
|
@@ -1398,14 +1408,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1398 |
*
|
1399 |
* @return array
|
1400 |
*/
|
1401 |
-
function maybe_encode_wp_get_attachment_image_src( $image, $attachment_id, $size, $icon ) {
|
1402 |
-
if ( ! $this->
|
1403 |
-
// Not serving S3 URLs
|
1404 |
-
return $image;
|
1405 |
-
}
|
1406 |
-
|
1407 |
-
if ( ! $this->get_attachment_s3_info( $attachment_id ) ) {
|
1408 |
-
// File not uploaded to S3
|
1409 |
return $image;
|
1410 |
}
|
1411 |
|
@@ -1425,14 +1429,8 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1425 |
*
|
1426 |
* @return array
|
1427 |
*/
|
1428 |
-
function maybe_encode_wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
|
1429 |
-
if ( ! $this->
|
1430 |
-
// Not serving S3 URLs
|
1431 |
-
return $response;
|
1432 |
-
}
|
1433 |
-
|
1434 |
-
if ( ! $this->get_attachment_s3_info( $attachment->ID ) ) {
|
1435 |
-
// File not uploaded to S3
|
1436 |
return $response;
|
1437 |
}
|
1438 |
|
@@ -1449,6 +1447,49 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1449 |
return $response;
|
1450 |
}
|
1451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1452 |
/**
|
1453 |
* Encode file names according to RFC 3986 when generating urls
|
1454 |
* As per Amazon https://forums.aws.amazon.com/thread.jspa?threadID=55746#jive-message-244233
|
@@ -1540,11 +1581,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1540 |
* @return string
|
1541 |
*/
|
1542 |
function get_attached_file( $file, $attachment_id ) {
|
1543 |
-
if ( file_exists( $file ) || ! $this->
|
1544 |
-
return $file;
|
1545 |
-
}
|
1546 |
-
|
1547 |
-
if ( ! ( $s3object = $this->get_attachment_s3_info( $attachment_id ) ) ) {
|
1548 |
return $file;
|
1549 |
}
|
1550 |
|
@@ -1836,12 +1873,22 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
|
|
1836 |
$args = array();
|
1837 |
}
|
1838 |
|
1839 |
-
$
|
|
|
1840 |
}
|
1841 |
|
1842 |
return $this->s3client;
|
1843 |
}
|
1844 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1845 |
/**
|
1846 |
* Get the region of a bucket
|
1847 |
*
|
121 |
add_filter( 'get_image_tag', array( $this, 'maybe_encode_get_image_tag' ), 99, 6 );
|
122 |
add_filter( 'wp_get_attachment_image_src', array( $this, 'maybe_encode_wp_get_attachment_image_src' ), 99, 4 );
|
123 |
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'maybe_encode_wp_prepare_attachment_for_js' ), 99, 3 );
|
124 |
+
add_filter( 'image_get_intermediate_size', array( $this, 'maybe_encode_image_get_intermediate_size' ), 99, 3 );
|
125 |
add_filter( 'get_attached_file', array( $this, 'get_attached_file' ), 10, 2 );
|
126 |
|
127 |
// Communication with S3, plugin needs to be setup
|
600 |
$acl = $old_s3object['acl'];
|
601 |
}
|
602 |
// use existing prefix
|
603 |
+
$prefix = dirname( $old_s3object['key'] );
|
604 |
+
$prefix = ( '.' === $prefix ) ? '' : $prefix . '/';
|
605 |
// use existing bucket
|
606 |
$bucket = $old_s3object['bucket'];
|
607 |
// get existing region
|
1301 |
* @return bool|mixed|void|WP_Error
|
1302 |
*/
|
1303 |
function get_attachment_url( $post_id, $expires = null, $size = null, $meta = null, $headers = array(), $skip_rewrite_check = false ) {
|
1304 |
+
if ( ! ( $s3object = $this->is_attachment_served_by_s3( $post_id, $skip_rewrite_check ) ) ) {
|
1305 |
return false;
|
1306 |
}
|
1307 |
|
1308 |
+
return $this->get_attachment_s3_url( $post_id, $s3object, $expires, $size, $meta, $headers );
|
1309 |
+
}
|
|
|
|
|
1310 |
|
1311 |
+
/**
|
1312 |
+
* Get the S3 URL for an attachment
|
1313 |
+
*
|
1314 |
+
* @param int $post_id
|
1315 |
+
* @param array $s3object
|
1316 |
+
* @param null|int $expires
|
1317 |
+
* @param null|string $size
|
1318 |
+
* @param null|array $meta
|
1319 |
+
* @param array $headers
|
1320 |
+
*
|
1321 |
+
* @return mixed|void|WP_Error
|
1322 |
+
*/
|
1323 |
+
public function get_attachment_s3_url( $post_id, $s3object, $expires = null, $size = null, $meta = null, $headers = array() ) {
|
1324 |
$scheme = $this->get_s3_url_scheme();
|
1325 |
|
1326 |
// We don't use $this->get_s3object_region() here because we don't want
|
1343 |
$meta = get_post_meta( $post_id, '_wp_attachment_metadata', true );
|
1344 |
}
|
1345 |
if ( isset( $meta['sizes'][ $size ]['file'] ) ) {
|
1346 |
+
$size_prefix = dirname( $s3object['key'] );
|
1347 |
+
$size_file_prefix = ( '.' === $size_prefix ) ? '' : $size_prefix . '/';
|
1348 |
+
|
1349 |
+
$s3object['key'] = $size_file_prefix . $meta['sizes'][ $size ]['file'];
|
1350 |
}
|
1351 |
}
|
1352 |
|
1380 |
*
|
1381 |
* @return string
|
1382 |
*/
|
1383 |
+
public function maybe_encode_get_image_tag( $html, $id, $alt, $title, $align, $size ) {
|
1384 |
+
if ( ! $this->is_attachment_served_by_s3( $id ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
1385 |
return $html;
|
1386 |
}
|
1387 |
|
1408 |
*
|
1409 |
* @return array
|
1410 |
*/
|
1411 |
+
public function maybe_encode_wp_get_attachment_image_src( $image, $attachment_id, $size, $icon ) {
|
1412 |
+
if ( ! $this->is_attachment_served_by_s3( $attachment_id ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
1413 |
return $image;
|
1414 |
}
|
1415 |
|
1429 |
*
|
1430 |
* @return array
|
1431 |
*/
|
1432 |
+
public function maybe_encode_wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
|
1433 |
+
if ( ! $this->is_attachment_served_by_s3( $attachment->ID ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
1434 |
return $response;
|
1435 |
}
|
1436 |
|
1447 |
return $response;
|
1448 |
}
|
1449 |
|
1450 |
+
/**
|
1451 |
+
* Maybe encode URLs when retrieving intermediate sizes.
|
1452 |
+
*
|
1453 |
+
* @param array $data
|
1454 |
+
* @param int $post_id
|
1455 |
+
* @param string|array $size
|
1456 |
+
*
|
1457 |
+
* @return array
|
1458 |
+
*/
|
1459 |
+
public function maybe_encode_image_get_intermediate_size( $data, $post_id, $size ) {
|
1460 |
+
if ( ! $this->is_attachment_served_by_s3( $post_id ) ) {
|
1461 |
+
return $data;
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
if ( isset( $data['url'] ) ) {
|
1465 |
+
$data['url'] = $this->encode_filename_in_path( $data['url'] );
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
return $data;
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
/**
|
1472 |
+
* Is attachment served by S3.
|
1473 |
+
*
|
1474 |
+
* @param int $attachment_id
|
1475 |
+
* @param bool $skip_rewrite_check
|
1476 |
+
*
|
1477 |
+
* @return bool|array
|
1478 |
+
*/
|
1479 |
+
public function is_attachment_served_by_s3( $attachment_id, $skip_rewrite_check = false ) {
|
1480 |
+
if ( ! $skip_rewrite_check && ! $this->get_setting( 'serve-from-s3' ) ) {
|
1481 |
+
// Not serving S3 URLs
|
1482 |
+
return false;
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
if ( ! ( $s3object = $this->get_attachment_s3_info( $attachment_id ) ) ) {
|
1486 |
+
// File not uploaded to S3
|
1487 |
+
return false;
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
return $s3object;
|
1491 |
+
}
|
1492 |
+
|
1493 |
/**
|
1494 |
* Encode file names according to RFC 3986 when generating urls
|
1495 |
* As per Amazon https://forums.aws.amazon.com/thread.jspa?threadID=55746#jive-message-244233
|
1581 |
* @return string
|
1582 |
*/
|
1583 |
function get_attached_file( $file, $attachment_id ) {
|
1584 |
+
if ( file_exists( $file ) || ! ( $s3object = $this->is_attachment_served_by_s3( $attachment_id ) ) ) {
|
|
|
|
|
|
|
|
|
1585 |
return $file;
|
1586 |
}
|
1587 |
|
1873 |
$args = array();
|
1874 |
}
|
1875 |
|
1876 |
+
$client = $this->aws->get_client()->get( 's3', $args );
|
1877 |
+
$this->set_client( $client );
|
1878 |
}
|
1879 |
|
1880 |
return $this->s3client;
|
1881 |
}
|
1882 |
|
1883 |
+
/**
|
1884 |
+
* Setter for S3 client
|
1885 |
+
*
|
1886 |
+
* @param Aws\S3\S3Client $client
|
1887 |
+
*/
|
1888 |
+
public function set_client( $client ) {
|
1889 |
+
$this->s3client = $client;
|
1890 |
+
}
|
1891 |
+
|
1892 |
/**
|
1893 |
* Get the region of a bucket
|
1894 |
*
|
classes/as3cf-plugin-compatibility.php
CHANGED
@@ -52,6 +52,11 @@ class AS3CF_Plugin_Compatibility {
|
|
52 |
*/
|
53 |
add_filter( 'attachment_url_to_postid', array( $this, 'customizer_background_image' ), 10, 2 );
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
if ( $this->as3cf->is_plugin_setup() ) {
|
56 |
$this->compatibility_init_if_setup();
|
57 |
}
|
@@ -703,4 +708,58 @@ class AS3CF_Plugin_Compatibility {
|
|
703 |
|
704 |
return $this->prepare_stream_wrapper_file( $s3_object['bucket'], $s3_object['region'], $s3_object['key'] );
|
705 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
}
|
52 |
*/
|
53 |
add_filter( 'attachment_url_to_postid', array( $this, 'customizer_background_image' ), 10, 2 );
|
54 |
|
55 |
+
/*
|
56 |
+
* Responsive Images WP 4.4+
|
57 |
+
*/
|
58 |
+
add_filter( 'wp_calculate_image_srcset', array( $this, 'wp_calculate_image_srcset' ), 10, 5 );
|
59 |
+
|
60 |
if ( $this->as3cf->is_plugin_setup() ) {
|
61 |
$this->compatibility_init_if_setup();
|
62 |
}
|
708 |
|
709 |
return $this->prepare_stream_wrapper_file( $s3_object['bucket'], $s3_object['region'], $s3_object['key'] );
|
710 |
}
|
711 |
+
|
712 |
+
/**
|
713 |
+
* Replace local URLs with S3 ones for srcset image sources
|
714 |
+
*
|
715 |
+
* @param array $sources
|
716 |
+
* @param array $size_array
|
717 |
+
* @param string $image_src
|
718 |
+
* @param array $image_meta
|
719 |
+
* @param int $attachment_id
|
720 |
+
*
|
721 |
+
* @return array
|
722 |
+
*/
|
723 |
+
public function wp_calculate_image_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {
|
724 |
+
if ( ! $this->as3cf->get_setting( 'serve-from-s3' ) ) {
|
725 |
+
// S3 URLs disabled, abort
|
726 |
+
return $sources;
|
727 |
+
}
|
728 |
+
|
729 |
+
if ( ! ( $s3object = $this->as3cf->get_attachment_s3_info( $attachment_id ) ) ) {
|
730 |
+
// Attachment not uploaded to S3, abort
|
731 |
+
return $sources;
|
732 |
+
}
|
733 |
+
|
734 |
+
foreach ( $sources as $width => $source ) {
|
735 |
+
$size = $this->find_image_size_from_width( $image_meta['sizes'], $width );
|
736 |
+
$s3_url = $this->as3cf->get_attachment_s3_url( $attachment_id, $s3object, null, $size, $image_meta );
|
737 |
+
|
738 |
+
if ( false === $s3_url || is_wp_error( $s3_url ) ) {
|
739 |
+
continue;
|
740 |
+
}
|
741 |
+
|
742 |
+
$sources[ $width ]['url'] = $s3_url;
|
743 |
+
}
|
744 |
+
|
745 |
+
return $sources;
|
746 |
+
}
|
747 |
+
|
748 |
+
/**
|
749 |
+
* Helper function to find size name from width
|
750 |
+
*
|
751 |
+
* @param array $sizes
|
752 |
+
* @param string $width
|
753 |
+
*
|
754 |
+
* @return null|string
|
755 |
+
*/
|
756 |
+
protected function find_image_size_from_width( $sizes, $width ) {
|
757 |
+
foreach ( $sizes as $name => $size ) {
|
758 |
+
if ( $width === $size['width'] ) {
|
759 |
+
return $name;
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
return null;
|
764 |
+
}
|
765 |
}
|
languages/amazon-s3-and-cloudfront-en.pot
CHANGED
@@ -8,7 +8,7 @@ msgid ""
|
|
8 |
msgstr ""
|
9 |
"Project-Id-Version: amazon-s3-and-cloudfront\n"
|
10 |
"Report-Msgid-Bugs-To: nom@deliciousbrains.com\n"
|
11 |
-
"POT-Creation-Date: 2015-11-
|
12 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
@@ -25,112 +25,112 @@ msgstr ""
|
|
25 |
msgid "S3 and CloudFront"
|
26 |
msgstr ""
|
27 |
|
28 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
29 |
msgid "Upload aborted by filter 'as3cf_pre_upload_attachment'"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
33 |
#, php-format
|
34 |
msgid "File %s does not exist"
|
35 |
msgstr ""
|
36 |
|
37 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
38 |
#, php-format
|
39 |
msgid "Mime type %s is not allowed"
|
40 |
msgstr ""
|
41 |
|
42 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
43 |
#, php-format
|
44 |
msgid "Error uploading %s to S3: %s"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
48 |
msgid "Cheatin’ eh?"
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
52 |
msgid "You do not have sufficient permissions to access this page."
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
56 |
msgid "No bucket name provided."
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
60 |
msgid "Error Getting Bucket Region"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
64 |
#, php-format
|
65 |
msgid "There was an error attempting to get the region of the bucket %s: %s"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
69 |
msgid ""
|
70 |
"This is a test file to check if the user has write permission to S3. Delete "
|
71 |
"me if found."
|
72 |
msgstr ""
|
73 |
|
74 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
75 |
#, php-format
|
76 |
msgid ""
|
77 |
"There was an error attempting to check the permissions of the bucket %s: %s"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
81 |
msgid "Error creating bucket"
|
82 |
msgstr ""
|
83 |
|
84 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
85 |
msgid "Bucket name too short."
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
89 |
msgid "Bucket name too long."
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
93 |
msgid ""
|
94 |
"Invalid character. Bucket names can contain lowercase letters, numbers, "
|
95 |
"periods and hyphens."
|
96 |
msgstr ""
|
97 |
|
98 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
99 |
msgid "Error saving bucket"
|
100 |
msgstr ""
|
101 |
|
102 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
103 |
msgid "Error fetching buckets"
|
104 |
msgstr ""
|
105 |
|
106 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
107 |
msgid "Error getting URL preview: "
|
108 |
msgstr ""
|
109 |
|
110 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
111 |
msgid "The changes you made will be lost if you navigate away from this page"
|
112 |
msgstr ""
|
113 |
|
114 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
115 |
msgid "Cheatin' eh?"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
119 |
msgctxt "Show the media library tab"
|
120 |
msgid "Media Library"
|
121 |
msgstr ""
|
122 |
|
123 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
124 |
msgctxt "Show the support tab"
|
125 |
msgid "Support"
|
126 |
msgstr ""
|
127 |
|
128 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
129 |
#, php-format
|
130 |
msgid "The file %s has been given %s permissions on Amazon S3."
|
131 |
msgstr ""
|
132 |
|
133 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
134 |
msgid ""
|
135 |
"<strong>Image Manipulation Library Missing</strong> — Looks like you "
|
136 |
"don't have an image manipulation library installed on this server and "
|
@@ -138,11 +138,11 @@ msgid ""
|
|
138 |
"Please setup GD or ImageMagick."
|
139 |
msgstr ""
|
140 |
|
141 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
142 |
msgid "Quick Start Guide"
|
143 |
msgstr ""
|
144 |
|
145 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
146 |
#, php-format
|
147 |
msgid ""
|
148 |
"Looks like we don't have write access to this bucket. It's likely that the "
|
@@ -151,7 +151,7 @@ msgid ""
|
|
151 |
"correctly."
|
152 |
msgstr ""
|
153 |
|
154 |
-
#: classes/amazon-s3-and-cloudfront.php:
|
155 |
#, php-format
|
156 |
msgid ""
|
157 |
"Looks like we don't have access to the buckets. It's likely that the user "
|
@@ -167,15 +167,15 @@ msgstr ""
|
|
167 |
msgid "Invalid notice ID."
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: classes/as3cf-plugin-compatibility.php:
|
171 |
msgid "WP Offload S3 Compatibility Addons"
|
172 |
msgstr ""
|
173 |
|
174 |
-
#: classes/as3cf-plugin-compatibility.php:
|
175 |
msgid "compatibility addons"
|
176 |
msgstr ""
|
177 |
|
178 |
-
#: classes/as3cf-plugin-compatibility.php:
|
179 |
#, php-format
|
180 |
msgid ""
|
181 |
"To get WP Offload S3 to work with certain 3rd party plugins, you might need "
|
@@ -184,7 +184,7 @@ msgid ""
|
|
184 |
"about each addon to determine if you need it or not."
|
185 |
msgstr ""
|
186 |
|
187 |
-
#: classes/as3cf-plugin-compatibility.php:
|
188 |
#, php-format
|
189 |
msgid ""
|
190 |
"You will need to purchase a license to get access to these addons. If you're "
|
@@ -192,11 +192,11 @@ msgid ""
|
|
192 |
"to %s."
|
193 |
msgstr ""
|
194 |
|
195 |
-
#: classes/as3cf-plugin-compatibility.php:
|
196 |
msgid "View Licenses"
|
197 |
msgstr ""
|
198 |
|
199 |
-
#: classes/as3cf-plugin-compatibility.php:
|
200 |
#: classes/upgrades/as3cf-meta-wp-error.php:72
|
201 |
#, php-format
|
202 |
msgid "There was an error attempting to download the file %s from S3: %s"
|
8 |
msgstr ""
|
9 |
"Project-Id-Version: amazon-s3-and-cloudfront\n"
|
10 |
"Report-Msgid-Bugs-To: nom@deliciousbrains.com\n"
|
11 |
+
"POT-Creation-Date: 2015-11-26 14:06+0000\n"
|
12 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
25 |
msgid "S3 and CloudFront"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: classes/amazon-s3-and-cloudfront.php:567
|
29 |
msgid "Upload aborted by filter 'as3cf_pre_upload_attachment'"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: classes/amazon-s3-and-cloudfront.php:578
|
33 |
#, php-format
|
34 |
msgid "File %s does not exist"
|
35 |
msgstr ""
|
36 |
|
37 |
+
#: classes/amazon-s3-and-cloudfront.php:589
|
38 |
#, php-format
|
39 |
msgid "Mime type %s is not allowed"
|
40 |
msgstr ""
|
41 |
|
42 |
+
#: classes/amazon-s3-and-cloudfront.php:670
|
43 |
#, php-format
|
44 |
msgid "Error uploading %s to S3: %s"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: classes/amazon-s3-and-cloudfront.php:1608
|
48 |
msgid "Cheatin’ eh?"
|
49 |
msgstr ""
|
50 |
|
51 |
+
#: classes/amazon-s3-and-cloudfront.php:1612
|
52 |
msgid "You do not have sufficient permissions to access this page."
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: classes/amazon-s3-and-cloudfront.php:1618
|
56 |
msgid "No bucket name provided."
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: classes/amazon-s3-and-cloudfront.php:1903
|
60 |
msgid "Error Getting Bucket Region"
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: classes/amazon-s3-and-cloudfront.php:1904
|
64 |
#, php-format
|
65 |
msgid "There was an error attempting to get the region of the bucket %s: %s"
|
66 |
msgstr ""
|
67 |
|
68 |
+
#: classes/amazon-s3-and-cloudfront.php:2024
|
69 |
msgid ""
|
70 |
"This is a test file to check if the user has write permission to S3. Delete "
|
71 |
"me if found."
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: classes/amazon-s3-and-cloudfront.php:2056
|
75 |
#, php-format
|
76 |
msgid ""
|
77 |
"There was an error attempting to check the permissions of the bucket %s: %s"
|
78 |
msgstr ""
|
79 |
|
80 |
+
#: classes/amazon-s3-and-cloudfront.php:2113
|
81 |
msgid "Error creating bucket"
|
82 |
msgstr ""
|
83 |
|
84 |
+
#: classes/amazon-s3-and-cloudfront.php:2114
|
85 |
msgid "Bucket name too short."
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: classes/amazon-s3-and-cloudfront.php:2115
|
89 |
msgid "Bucket name too long."
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: classes/amazon-s3-and-cloudfront.php:2116
|
93 |
msgid ""
|
94 |
"Invalid character. Bucket names can contain lowercase letters, numbers, "
|
95 |
"periods and hyphens."
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: classes/amazon-s3-and-cloudfront.php:2117
|
99 |
msgid "Error saving bucket"
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: classes/amazon-s3-and-cloudfront.php:2118
|
103 |
msgid "Error fetching buckets"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: classes/amazon-s3-and-cloudfront.php:2119
|
107 |
msgid "Error getting URL preview: "
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: classes/amazon-s3-and-cloudfront.php:2120
|
111 |
msgid "The changes you made will be lost if you navigate away from this page"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: classes/amazon-s3-and-cloudfront.php:2180
|
115 |
msgid "Cheatin' eh?"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: classes/amazon-s3-and-cloudfront.php:2283
|
119 |
msgctxt "Show the media library tab"
|
120 |
msgid "Media Library"
|
121 |
msgstr ""
|
122 |
|
123 |
+
#: classes/amazon-s3-and-cloudfront.php:2284
|
124 |
msgctxt "Show the support tab"
|
125 |
msgid "Support"
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: classes/amazon-s3-and-cloudfront.php:2436
|
129 |
#, php-format
|
130 |
msgid "The file %s has been given %s permissions on Amazon S3."
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: classes/amazon-s3-and-cloudfront.php:2448
|
134 |
msgid ""
|
135 |
"<strong>Image Manipulation Library Missing</strong> — Looks like you "
|
136 |
"don't have an image manipulation library installed on this server and "
|
138 |
"Please setup GD or ImageMagick."
|
139 |
msgstr ""
|
140 |
|
141 |
+
#: classes/amazon-s3-and-cloudfront.php:2978
|
142 |
msgid "Quick Start Guide"
|
143 |
msgstr ""
|
144 |
|
145 |
+
#: classes/amazon-s3-and-cloudfront.php:2980
|
146 |
#, php-format
|
147 |
msgid ""
|
148 |
"Looks like we don't have write access to this bucket. It's likely that the "
|
151 |
"correctly."
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: classes/amazon-s3-and-cloudfront.php:2982
|
155 |
#, php-format
|
156 |
msgid ""
|
157 |
"Looks like we don't have access to the buckets. It's likely that the user "
|
167 |
msgid "Invalid notice ID."
|
168 |
msgstr ""
|
169 |
|
170 |
+
#: classes/as3cf-plugin-compatibility.php:180
|
171 |
msgid "WP Offload S3 Compatibility Addons"
|
172 |
msgstr ""
|
173 |
|
174 |
+
#: classes/as3cf-plugin-compatibility.php:182
|
175 |
msgid "compatibility addons"
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: classes/as3cf-plugin-compatibility.php:183
|
179 |
#, php-format
|
180 |
msgid ""
|
181 |
"To get WP Offload S3 to work with certain 3rd party plugins, you might need "
|
184 |
"about each addon to determine if you need it or not."
|
185 |
msgstr ""
|
186 |
|
187 |
+
#: classes/as3cf-plugin-compatibility.php:189
|
188 |
#, php-format
|
189 |
msgid ""
|
190 |
"You will need to purchase a license to get access to these addons. If you're "
|
192 |
"to %s."
|
193 |
msgstr ""
|
194 |
|
195 |
+
#: classes/as3cf-plugin-compatibility.php:190
|
196 |
msgid "View Licenses"
|
197 |
msgstr ""
|
198 |
|
199 |
+
#: classes/as3cf-plugin-compatibility.php:629
|
200 |
#: classes/upgrades/as3cf-meta-wp-error.php:72
|
201 |
#, php-format
|
202 |
msgid "There was an error attempting to download the file %s from S3: %s"
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: bradt, deliciousbrains
|
3 |
Tags: uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront
|
4 |
Requires at least: 3.7
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 0.9.
|
7 |
License: GPLv3
|
8 |
|
9 |
Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
|
@@ -69,6 +69,11 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
|
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
|
|
72 |
= WP Offload S3 0.9.9 - 2015-11-12 =
|
73 |
* Improvement: Improve wording of compatibility notices
|
74 |
* Improvement: Compatibility with Easy Digital Downloads 1.0.1 and WooCommerce 1.0.3 addons
|
2 |
Contributors: bradt, deliciousbrains
|
3 |
Tags: uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront
|
4 |
Requires at least: 3.7
|
5 |
+
Tested up to: 4.4
|
6 |
+
Stable tag: 0.9.10
|
7 |
License: GPLv3
|
8 |
|
9 |
Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery.
|
69 |
|
70 |
== Changelog ==
|
71 |
|
72 |
+
= WP Offload S3 0.9.10 - 2015-11-26 =
|
73 |
+
* Improvement: Support for responsive images in WP 4.4
|
74 |
+
* Bug fix: Incorrect file path for intermediate image size files uploaded to S3 with no prefix
|
75 |
+
* Bug fix: Thumbnail previews return 404 error during image edit screen due to character encoding
|
76 |
+
|
77 |
= WP Offload S3 0.9.9 - 2015-11-12 =
|
78 |
* Improvement: Improve wording of compatibility notices
|
79 |
* Improvement: Compatibility with Easy Digital Downloads 1.0.1 and WooCommerce 1.0.3 addons
|
wordpress-s3.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Offload S3
|
|
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: Delicious Brains
|
7 |
-
Version: 0.9.
|
8 |
Author URI: http://deliciousbrains.com/
|
9 |
Network: True
|
10 |
Text Domain: amazon-s3-and-cloudfront
|
@@ -26,7 +26,7 @@ Domain Path: /languages/
|
|
26 |
// Then completely rewritten.
|
27 |
*/
|
28 |
|
29 |
-
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '0.9.
|
30 |
|
31 |
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
|
32 |
'amazon-s3-and-cloudfront-pro' => '1.0b1',
|
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: Delicious Brains
|
7 |
+
Version: 0.9.10
|
8 |
Author URI: http://deliciousbrains.com/
|
9 |
Network: True
|
10 |
Text Domain: amazon-s3-and-cloudfront
|
26 |
// Then completely rewritten.
|
27 |
*/
|
28 |
|
29 |
+
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '0.9.10';
|
30 |
|
31 |
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['supported_addon_versions'] = array(
|
32 |
'amazon-s3-and-cloudfront-pro' => '1.0b1',
|