WP Offload S3 Lite - Version 2.0.1

Version Description

= 2.0 = This is a major upgrade that introduces support for DigitalOcean Spaces, renames the plugin to WP Offload Media Lite, and coincidentally upgrades some of its database settings. You may not be able to downgrade to WP Offload S3 Lite 1.x after upgrading to WP Offload Media Lite 2.0+.

= 1.1 = This is a major change, which ensures S3 URLs are no longer saved in post content. Instead, local URLs are filtered on page generation and replaced with the S3 version. If you depend on the S3 URLs being stored in post content you will need to make modifications to support this version.

= 0.6 = This version requires PHP 5.3.3+ and the Amazon Web Services plugin

Download this release

Release Info

Developer deliciousbrains
Plugin Icon 128x128 WP Offload S3 Lite
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

README.md CHANGED
@@ -2,9 +2,9 @@
2
  **Contributors:** bradt, deliciousbrains, ianmjones
3
  **Tags:** uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, mirror, admin, media, cdn, cloudfront
4
  **Requires at least:** 4.7
5
- **Tested up to:** 4.9
6
  **Requires PHP:** 5.5
7
- **Stable tag:** 2.0
8
  **License:** GPLv3
9
 
10
  Copies files to Amazon S3 or DigitalOcean Spaces as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery.
@@ -21,6 +21,10 @@ Uploading files *directly* to your Amazon S3 or DigitalOcean Spaces account is n
21
 
22
  If you're adding this plugin to a site that's been around for a while, your existing media files will not be copied to or served from Amazon S3 or DigitalOcean Spaces. Only newly uploaded files will be copied to and served from the bucket. The pro upgrade has an upload tool to handle existing media files.
23
 
 
 
 
 
24
  **PRO Upgrade with Email Support and More Features**
25
 
26
  * Upload existing Media Library to Amazon S3 or DigitalOcean Spaces
@@ -36,8 +40,6 @@ The video below runs through the pro upgrade features...
36
 
37
  https://www.youtube.com/watch?v=55xNGnbJ_CY
38
 
39
- *This plugin has been completely rewritten, but was originally a fork of [Amazon S3 for WordPress with CloudFront](http://wordpress.org/extend/plugins/tantan-s3-cloudfront/) which is a fork of [Amazon S3 for WordPress](http://wordpress.org/extend/plugins/tantan-s3/), also known as tantan-s3.*
40
-
41
  ## Installation ##
42
 
43
  1. Install this plugin using WordPress' built-in installer
@@ -84,8 +86,16 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
84
 
85
  ## Changelog ##
86
 
 
 
 
 
 
 
 
 
87
  ### WP Offload Media Lite 2.0 - 2018-09-24 ###
88
- * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-supports-digitalocean-spaces/)
89
  * New: DigitalOcean Spaces is now supported
90
  * New: Plugin name updated from WP Offload S3 Lite to WP Offload Media Lite
91
  * Improvement: More logical UI layout and better description of each setting
2
  **Contributors:** bradt, deliciousbrains, ianmjones
3
  **Tags:** uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, mirror, admin, media, cdn, cloudfront
4
  **Requires at least:** 4.7
5
+ **Tested up to:** 5.0
6
  **Requires PHP:** 5.5
7
+ **Stable tag:** 2.0.1
8
  **License:** GPLv3
9
 
10
  Copies files to Amazon S3 or DigitalOcean Spaces as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery.
21
 
22
  If you're adding this plugin to a site that's been around for a while, your existing media files will not be copied to or served from Amazon S3 or DigitalOcean Spaces. Only newly uploaded files will be copied to and served from the bucket. The pro upgrade has an upload tool to handle existing media files.
23
 
24
+ **Image Optimization**
25
+
26
+ Although WP Offload Media doesn't include image optimization features, we work closely with the author of [EWWW Image Optimizer](https://wordpress.org/plugins/ewww-image-optimizer/) to ensure they always work well together. Not only do we recommend EWWW Image Optimizer but we officially support its integration with WP Offload Media.
27
+
28
  **PRO Upgrade with Email Support and More Features**
29
 
30
  * Upload existing Media Library to Amazon S3 or DigitalOcean Spaces
40
 
41
  https://www.youtube.com/watch?v=55xNGnbJ_CY
42
 
 
 
43
  ## Installation ##
44
 
45
  1. Install this plugin using WordPress' built-in installer
86
 
87
  ## Changelog ##
88
 
89
+ ### WP Offload Media Lite 2.0.1 - 2018-12-17 ###
90
+ * Improvement: Streamlined UI for setting Storage Provider and Bucket
91
+ * Bug fix: On/Off switches in settings look reversed
92
+ * Bug fix: Latest upgrade routine runs on fresh install
93
+ * Bug fix: Defined settings still found in database
94
+ * Bug fix: More Info links in Storage Provider settings incorrect
95
+ * Tested: WordPress 5.0
96
+
97
  ### WP Offload Media Lite 2.0 - 2018-09-24 ###
98
+ * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-s3-is-now-wp-offload-media-and-adds-support-for-digitalocean-spaces/)
99
  * New: DigitalOcean Spaces is now supported
100
  * New: Plugin name updated from WP Offload S3 Lite to WP Offload Media Lite
101
  * Improvement: More logical UI layout and better description of each setting
assets/css/styles.css CHANGED
@@ -1 +1 @@
1
- .as3cf-content,.as3cf-updated,.as3cf-compatibility-notice{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.settings_page_amazon-s3-and-cloudfront .error,.settings_page_amazon-s3-and-cloudfront .notice,.settings_page_amazon-s3-and-cloudfront .updated{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.as3cf-main.wrap{position:relative}.as3cf-main.wrap>h1{float:left}.as3cf-main.wrap .as3cf-notice,.as3cf-main.wrap .as3cf-updated,.as3cf-main.wrap .as3cf-error{-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-main.wrap .as3cf-error.fatal{clear:both}.as3cf-main.wrap h2.nav-tab-wrapper{float:none;margin-bottom:15px;width:650px;margin-top:10px;padding:9px 0 0 5px}.as3cf-main.wrap h2.nav-tab-wrapper .nav-tab-container{float:right}.as3cf-main.wrap h2.nav-tab-wrapper .nav-tab-container :last-child{margin-right:5px}.as3cf-main.wrap h2.nav-tab-wrapper a.nav-tab-active{color:#464646;cursor:default}.as3cf-main.wrap h2.nav-tab-wrapper a:focus{-webkit-box-shadow:none;box-shadow:none}.as3cf-main.wrap .more-info{white-space:nowrap}.as3cf-main.wrap .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.as3cf-main.wrap .error pre code{padding:0;background:none}.as3cf-main.wrap[data-tab="support"] .as3cf-notice,.as3cf-main.wrap[data-tab="support"] .error,.as3cf-main.wrap[data-tab="support"] .updated,.as3cf-main.wrap[data-tab="support"] .updated.show{display:none}.as3cf-main.wrap[data-tab="support"] .fatal .error,.as3cf-main.wrap[data-tab="support"] .as3cf-notice.important,.as3cf-main.wrap[data-tab="support"] .dbrains-api-down{display:block}.as3cf-main.wrap .as3cf-notice,.as3cf-main.wrap .error,.as3cf-main.wrap .updated{max-width:650px;margin-top:15px;-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-main.wrap .as3cf-updated{display:none}.as3cf-main.wrap .as3cf-updated.as3cf-notice,.as3cf-main.wrap .as3cf-updated.show{display:block}.as3cf-main.wrap .alignleft{margin-right:20px;margin-bottom:20px}.as3cf-main.wrap .spinner{min-width:20px}.as3cf-tab .as3cf-main-settings{display:none}.as3cf-tab .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab .as3cf-bucket-container{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-can-write-error,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-can-write-error{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings{display:block}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings .as3cf-provider-select,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings .as3cf-provider-select{display:block}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings .as3cf-media-settings,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-bucket-container,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-bucket-container{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-bucket-container{display:block}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider) .as3cf-main-settings{display:block}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-media-settings{display:block}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider) .as3cf-bucket-container{display:none}.as3cf-content>section{margin-bottom:20px}.as3cf-content>section+section.as3cf-access-keys{padding-top:20px;border-top:1px solid #d3d3d3}.as3cf-content>section+section.as3cf-access-keys .as3cf-section-heading{margin-top:0}.as3cf-tab{display:none;position:relative;width:650px}.as3cf-tab .as3cf-main-settings p{font-size:13px}.as3cf-tab .as3cf-main-settings p a{color:#444}.as3cf-tab .object-prefix-desc em{white-space:nowrap}.as3cf-tab .as3cf-url-preview-wrap{background:#fff;text-align:center;padding:20px 0 0;max-width:650px;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-tab .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:10px;padding:0 20px 10px;overflow-x:scroll}.as3cf-tab .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-tab .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-tab .as3cf-radio-group label.disabled,.as3cf-tab .as3cf-radio-group label.disabled p{color:#bbb;cursor:default}.as3cf-tab .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-tab .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-tab .as3cf-switch{position:relative;display:inline-block;padding:2px;overflow:hidden;border-radius:2px;background-color:#d4d3d3;cursor:pointer}.as3cf-tab .as3cf-switch.on{background-color:#ade7b5}.as3cf-tab .as3cf-switch span{visibility:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;font-weight:bold;padding:4px 8px;background:#fff;color:#8d8d8d;z-index:1}.as3cf-tab .as3cf-switch span.on{color:#82d78b}.as3cf-tab .as3cf-switch span.checked{visibility:visible}.as3cf-tab .as3cf-switch.disabled{cursor:default;background:#e6e6e6}.as3cf-tab .as3cf-switch.disabled span{background:#f1f1f1;color:#d6d6d6}.as3cf-tab .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-tab .as3cf-setting.hide{display:none}.as3cf-tab div.as3cf-setting{margin-top:4px}.as3cf-tab h3{font-weight:normal;text-transform:uppercase}.as3cf-tab .form-table{margin:0}.as3cf-tab .form-table tr.as3cf-border-bottom td{border-bottom:1px solid #ddd;padding:20px 0px}.as3cf-tab .form-table tr.as3cf-setting-title td{padding-bottom:0}.as3cf-tab .form-table tr.as3cf-setting-title:first-child td{padding-top:20px}.as3cf-tab .form-table tr.configure-url:first-child td{padding-top:5px;padding-bottom:0}.as3cf-tab .form-table tr td{padding:15px 0}.as3cf-tab .form-table tr td:first-child{vertical-align:top;min-width:120px;padding-top:20px}.as3cf-tab .form-table tr td .as3cf-notice:last-child{margin-bottom:0}.as3cf-tab .form-table tr td>p:first-child{margin-top:0}.as3cf-tab .form-table h3{padding:0;margin:0}.as3cf-tab .form-table h4{margin:0}.as3cf-tab .as3cf-active-region{font-style:italic}.as3cf-tab .as3cf-view-bucket{color:#444;text-decoration:none;margin-right:10px}.as3cf-tab .as3cf-view-bucket:hover,.as3cf-tab .as3cf-view-bucket:active{color:#00a0d2}.as3cf-tab .as3cf-view-bucket:focus{-webkit-box-shadow:none;box-shadow:none}.as3cf-tab .as3cf-view-bucket .dashicons-external{margin-top:-2px}.as3cf-tab .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-tab .tooltip:before,.as3cf-tab .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-tab .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-tab .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-tab .tooltip:hover:before,.as3cf-tab .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}.as3cf-tab .as3cf-defined-in-config{background:#ccc;color:#fff;padding:2px 5px;margin:0 0 5px 5px;float:right;white-space:nowrap}.as3cf-tab .as3cf-defined-setting{color:#bbb}.as3cf-tab .as3cf-defined-setting label{cursor:default}.as3cf-tab .as3cf-defined-setting p .more-info a{color:#bbb}.as3cf-tab .as3cf-defined-setting .as3cf-radio-group p{color:#bbb}.as3cf-tab .as3cf-defined-setting .as3cf-notice{display:none !important}#tab-media{display:block}#tab-media .as3cf-provider-setting td{padding-top:20px;padding-bottom:5px}#tab-media .as3cf-bucket-setting td{padding:5px 0}.as3cf-bucket-container h3{line-height:1.3;text-transform:none}.as3cf-bucket-container a:focus{-webkit-box-shadow:none;box-shadow:none;outline:none}.as3cf-bucket-container input[type=text]{-webkit-box-sizing:border-box;box-sizing:border-box;width:100%}.as3cf-bucket-container select{-webkit-box-sizing:border-box;box-sizing:border-box;width:50%}.as3cf-bucket-container .form-table .as3cf-provider-setting h4{font-weight:inherit;margin:0}.as3cf-bucket-container .form-table .as3cf-bucket-list{margin:5px 0 0 0}.as3cf-bucket-container .form-table td{padding:5px 0}.as3cf-bucket-container .form-table td:first-child{width:100px;line-height:30px;vertical-align:top}.as3cf-bucket-container .bucket-actions{margin:15px 0;border-top:1px solid #ccc;padding-top:15px;overflow:hidden}.as3cf-bucket-container .bucket-actions button,.as3cf-bucket-container .bucket-actions .right{float:right;margin-right:0}.as3cf-bucket-container .bucket-actions span{display:inline-block;margin-right:20px;line-height:28px}.as3cf-bucket-container .bucket-actions .bucket-action-cancel{color:#a00;text-decoration:none}.as3cf-bucket-container .bucket-actions .bucket-action-cancel:hover{color:red}.as3cf-bucket-container .as3cf-bucket-list{padding:15px;max-height:200px;overflow-x:hidden;overflow-y:auto;background-color:#fff;font-size:14px}.as3cf-bucket-container .as3cf-bucket-list li:last-of-type{margin-bottom:0}.as3cf-bucket-container .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-bucket-container .as3cf-bucket-list a:hover{color:#0074a2}.as3cf-bucket-container .as3cf-bucket-list a.selected{font-weight:bold;color:#0074a2}.as3cf-bucket-container .as3cf-bucket-list a .dashicons{margin-right:5px}.as3cf-bucket-container .as3cf-bucket-select,.as3cf-bucket-container .as3cf-bucket-create{display:none}.as3cf-bucket-container .bucket-actions.select{display:none}#tab-media{display:block}#tab-support{min-height:900px}#tab-support .as3cf-sidebar{top:11px}#tab-support .support-section{border-bottom:1px solid #ccc;padding-bottom:20px;margin-bottom:20px}#tab-support .support-section h3{font-size:20px}#tab-support .debug textarea{width:100%;min-height:200px;font-family:Consolas, Monaco, monospace;margin-bottom:5px}.as3cf-sidebar{position:absolute;top:9px;left:670px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field input[type=text],.as3cf-sidebar .subscribe .field input[type=email]{width:100%}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto}}.as3cf-active-provider,.as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-banner{margin-top:35px;width:292px;height:200px;display:block;background:#f8cfae url(../img/os3-banner.svg) left bottom/220px 220px no-repeat}.as3cf-banner:focus{-webkit-box-shadow:none;box-shadow:none}.wrap .as3cf-upgrade-details{background-color:#4e0d33;padding:10px 20px 20px 20px;color:#eee;font-size:13px;margin:0;display:block;text-decoration:none}.wrap .as3cf-upgrade-details h1{font-size:28px;color:#eee;margin:0 0 15px 0;padding:0;text-decoration:none;font-weight:200;line-height:1}.wrap .as3cf-upgrade-details p{margin:0}.wrap .as3cf-upgrade-details a{color:#eee;font-weight:bold;text-decoration:none;font-size:16px;-webkit-box-shadow:none;box-shadow:none}.wrap .as3cf-upgrade-details a:hover{color:#fff}.wrap .as3cf-upgrade-details ul{margin-top:0;margin-left:16px;list-style-type:disc}.as3cf-compatibility-notice.error{clear:both;margin:5px 20px 5px 0}.as3cf-bucket-error span.title{font-weight:bold}.as3cf-invalid-bucket-name,.as3cf-validation-error{display:block;margin-top:2px;font-size:12px;color:#a00}.as3cf-notice-toggle-content{max-height:100px;overflow-y:scroll}.as3cf-notice-toggle-content .as3cf-notice-toggle-list{margin-top:0;margin-left:0;padding-left:40px;color:#dc3232}.as3cf-need-help{background-color:white;font-size:16px;font-weight:bold;padding:1em}.as3cf-need-help a{text-decoration:none}.as3cf-settings h3{font-size:20px}.as3cf-settings p{font-size:14px}.as3cf-addons,.as3cf-tab .as3cf-compatibility-notice{max-width:cover}textarea.as3cf-access-key-constants-snippet.code{width:100%;white-space:pre;overflow:hidden;font-size:12px;padding:10px;height:53px}.as3cf-addons .as3cf-addons-list{margin:20px 0 200px;padding-top:5px}.as3cf-addons .as3cf-addon{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:20px;font-size:14px}.as3cf-addons .as3cf-addon-info{min-height:100px}.as3cf-addons .as3cf-addon-links{float:right}.as3cf-addons .as3cf-addon-links span{padding:4px 6px}.as3cf-addons .as3cf-addon-icon{float:left;margin-right:20px}.as3cf-addons .as3cf-addon-details{white-space:nowrap}.as3cf-addons .as3cf-addon-title,.as3cf-addons .as3cf-addon-description{font-weight:100}.as3cf-addons .as3cf-addon+.as3cf-addon{margin-top:20px}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull{background-color:#0769ad;color:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .as3cf-addon-title,.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .as3cf-addon-description,.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull a{color:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .extra{background:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .extra a{color:#0769ad;text-decoration:none}
1
+ .as3cf-content,.as3cf-updated,.as3cf-compatibility-notice{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.settings_page_amazon-s3-and-cloudfront .error,.settings_page_amazon-s3-and-cloudfront .notice,.settings_page_amazon-s3-and-cloudfront .updated{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.as3cf-main.wrap{position:relative}.as3cf-main.wrap>h1{float:left}.as3cf-main.wrap .as3cf-notice,.as3cf-main.wrap .as3cf-updated,.as3cf-main.wrap .as3cf-error{-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-main.wrap .as3cf-error.fatal{clear:both}.as3cf-main.wrap h2.nav-tab-wrapper{float:none;margin-bottom:15px;width:650px;margin-top:10px;padding:9px 0 0 5px}.as3cf-main.wrap h2.nav-tab-wrapper .nav-tab-container{float:right}.as3cf-main.wrap h2.nav-tab-wrapper .nav-tab-container :last-child{margin-right:5px}.as3cf-main.wrap h2.nav-tab-wrapper a.nav-tab-active{color:#464646;cursor:default}.as3cf-main.wrap h2.nav-tab-wrapper a:focus{-webkit-box-shadow:none;box-shadow:none}.as3cf-main.wrap .more-info{white-space:nowrap}.as3cf-main.wrap .error pre{background:#eaeaea;background:rgba(0,0,0,0.07);display:block;padding:10px 15px}.as3cf-main.wrap .error pre code{padding:0;background:none}.as3cf-main.wrap[data-tab="support"] .as3cf-notice,.as3cf-main.wrap[data-tab="support"] .error,.as3cf-main.wrap[data-tab="support"] .updated,.as3cf-main.wrap[data-tab="support"] .updated.show{display:none}.as3cf-main.wrap[data-tab="support"] .fatal .error,.as3cf-main.wrap[data-tab="support"] .as3cf-notice.important,.as3cf-main.wrap[data-tab="support"] .dbrains-api-down{display:block}.as3cf-main.wrap .as3cf-notice,.as3cf-main.wrap .error,.as3cf-main.wrap .updated{max-width:650px;margin-top:15px;-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-main.wrap .as3cf-updated{display:none}.as3cf-main.wrap .as3cf-updated.as3cf-notice,.as3cf-main.wrap .as3cf-updated.show{display:block}.as3cf-main.wrap .alignleft{margin-right:20px;margin-bottom:20px}.as3cf-main.wrap .spinner{min-width:20px}.as3cf-tab .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab .as3cf-main-settings .as3cf-bucket-container{display:none}.as3cf-tab .as3cf-main-settings .as3cf-bucket-container a.as3cf-change-provider{display:none}.as3cf-tab .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-can-write-error,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-can-write-error{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings .as3cf-provider-select,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings .as3cf-provider-select{display:block}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings .as3cf-bucket-container,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings .as3cf-bucket-container{display:none}.as3cf-tab.as3cf-needs-access-keys .as3cf-main-settings .as3cf-media-settings,.as3cf-tab.as3cf-has-access-keys.as3cf-change-provider .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-can-write-error,.as3cf-tab.as3cf-has-access-keys.as3cf-change-bucket:not(.as3cf-change-provider) .as3cf-can-write-error{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-provider-select,.as3cf-tab.as3cf-has-access-keys.as3cf-change-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-bucket-container,.as3cf-tab.as3cf-has-access-keys.as3cf-change-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-bucket-container{display:block}.as3cf-tab.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-media-settings,.as3cf-tab.as3cf-has-access-keys.as3cf-change-bucket:not(.as3cf-change-provider) .as3cf-main-settings .as3cf-media-settings{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider):not(.as3cf-change-bucket) .as3cf-main-settings .as3cf-provider-select{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider):not(.as3cf-change-bucket) .as3cf-main-settings .as3cf-bucket-container{display:none}.as3cf-tab.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider):not(.as3cf-change-bucket) .as3cf-main-settings .as3cf-media-settings{display:block}.as3cf-content>section{margin-bottom:20px}.as3cf-content>section+section.as3cf-access-keys{padding-top:20px;border-top:1px solid #d3d3d3}.as3cf-content>section+section.as3cf-access-keys .as3cf-section-heading{margin-top:0}.as3cf-tab{display:none;position:relative;width:650px}.as3cf-tab .as3cf-main-settings p{font-size:13px}.as3cf-tab .as3cf-main-settings p a{color:#444}.as3cf-tab .object-prefix-desc em{white-space:nowrap}.as3cf-tab .as3cf-url-preview-wrap{background:#fff;text-align:center;padding:20px 0 0;max-width:650px;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.as3cf-tab .as3cf-url-preview-wrap .as3cf-url-preview{margin-top:10px;padding:0 20px 10px;overflow-x:scroll}.as3cf-tab .as3cf-url-preview-wrap span{color:#aaa;text-transform:uppercase;font-weight:bold}.as3cf-tab .as3cf-radio-group label{display:block;margin-bottom:10px}.as3cf-tab .as3cf-radio-group label.disabled,.as3cf-tab .as3cf-radio-group label.disabled p{color:#bbb;cursor:default}.as3cf-tab .as3cf-radio-group p{padding-left:25px;color:#6b6b6b;margin:0;font-size:12px}.as3cf-tab .as3cf-radio-group p.as3cf-setting{margin-top:5px}.as3cf-tab .as3cf-switch{position:relative;display:inline-block;padding:2px;overflow:hidden;border-radius:2px;background-color:#d4d3d3;cursor:pointer}.as3cf-tab .as3cf-switch.on{background-color:#ade7b5}.as3cf-tab .as3cf-switch span{visibility:hidden;-webkit-box-sizing:border-box;box-sizing:border-box;float:left;display:inline-block;height:100%;font-size:12px;line-height:20px;border-radius:2px;font-weight:bold;padding:4px 8px;background:#fff;color:#8d8d8d;z-index:1}.as3cf-tab .as3cf-switch span.on{color:#82d78b}.as3cf-tab .as3cf-switch span.checked{visibility:visible}.as3cf-tab .as3cf-switch.disabled{cursor:default;background:#e6e6e6}.as3cf-tab .as3cf-switch.disabled span{background:#f1f1f1;color:#d6d6d6}.as3cf-tab .as3cf-switch input[type="checkbox"]{position:absolute !important;top:0;left:0;opacity:0;filter:alpha(opacity=0);z-index:-1}.as3cf-tab .as3cf-setting.hide{display:none}.as3cf-tab div.as3cf-setting{margin-top:4px}.as3cf-tab h3{font-weight:normal;text-transform:uppercase}.as3cf-tab .form-table{margin:0}.as3cf-tab .form-table tr.as3cf-border-bottom td{border-bottom:1px solid #ddd;padding:20px 0px}.as3cf-tab .form-table tr.as3cf-setting-title td{padding-bottom:0}.as3cf-tab .form-table tr.as3cf-setting-title:first-child td{padding-top:20px}.as3cf-tab .form-table tr.configure-url:first-child td{padding-top:5px;padding-bottom:0}.as3cf-tab .form-table tr td{padding:15px 0}.as3cf-tab .form-table tr td:first-child{vertical-align:top;min-width:120px;padding-top:20px}.as3cf-tab .form-table tr td .as3cf-notice:last-child{margin-bottom:0}.as3cf-tab .form-table tr td>p:first-child{margin-top:0}.as3cf-tab .form-table h3{padding:0;margin:0}.as3cf-tab .form-table h4{margin:0}.as3cf-tab .as3cf-active-region{font-style:italic}.as3cf-tab .as3cf-view-bucket{color:#444;text-decoration:none;margin-right:10px}.as3cf-tab .as3cf-view-bucket:hover,.as3cf-tab .as3cf-view-bucket:active{color:#00a0d2}.as3cf-tab .as3cf-view-bucket:focus{-webkit-box-shadow:none;box-shadow:none}.as3cf-tab .as3cf-view-bucket .dashicons-external{margin-top:-2px}.as3cf-tab .tooltip{position:relative;z-index:2;cursor:pointer}.as3cf-tab .tooltip:before,.as3cf-tab .tooltip:after{visibility:hidden;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);opacity:0;pointer-events:none}.as3cf-tab .tooltip:before{position:absolute;bottom:150%;left:50%;margin-bottom:5px;margin-left:-250px;padding:10px;width:500px;border-radius:3px;background-color:#000;background-color:rgba(51,51,51,0.9);color:#fff;content:attr(data-tooltip);text-align:center;font-size:14px;line-height:1.3}.as3cf-tab .tooltip:after{position:absolute;bottom:150%;left:50%;margin-left:-5px;width:0;border-top:5px solid #000;border-top:5px solid rgba(51,51,51,0.9);border-right:5px solid transparent;border-left:5px solid transparent;content:" ";font-size:0;line-height:0}.as3cf-tab .tooltip:hover:before,.as3cf-tab .tooltip:hover:after{visibility:visible;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);opacity:1}.as3cf-tab .as3cf-defined-in-config{background:#ccc;color:#fff;padding:2px 5px;margin:0 0 5px 5px;float:right;white-space:nowrap}.as3cf-tab .as3cf-defined-setting{color:#bbb}.as3cf-tab .as3cf-defined-setting label{cursor:default}.as3cf-tab .as3cf-defined-setting p .more-info a{color:#bbb}.as3cf-tab .as3cf-defined-setting .as3cf-radio-group p{color:#bbb}.as3cf-tab .as3cf-defined-setting .as3cf-notice{display:none !important}.as3cf-tab p.actions{margin:20px -30px -30px;padding:20px 30px;border-top:none;overflow:hidden}.as3cf-tab p.actions .right{margin-left:15px}.as3cf-tab p.actions .right:last-of-type{margin-left:0}.as3cf-tab p.actions button{min-width:90px}#tab-media{display:block}#tab-media .as3cf-provider-setting td{padding-top:20px;padding-bottom:5px}#tab-media .as3cf-bucket-setting td{padding:5px 0}.as3cf-bucket-container h3{line-height:1.3;text-transform:none}.as3cf-bucket-container a:focus{-webkit-box-shadow:none;box-shadow:none;outline:none}.as3cf-bucket-container input[type=text]{-webkit-box-sizing:border-box;box-sizing:border-box;width:100%}.as3cf-bucket-container select{-webkit-box-sizing:border-box;box-sizing:border-box;width:50%}.as3cf-bucket-container .form-table .as3cf-provider-setting h4{font-weight:inherit;margin:0}.as3cf-bucket-container .form-table .as3cf-bucket-list{margin:5px 0 0 0}.as3cf-bucket-container .form-table td{padding:5px 0}.as3cf-bucket-container .form-table td:first-child{width:100px;line-height:30px;vertical-align:top}.as3cf-bucket-container .bucket-actions{margin:15px 0;border-top:1px solid #ccc;padding-top:15px;overflow:hidden}.as3cf-bucket-container .bucket-actions button,.as3cf-bucket-container .bucket-actions .right{float:right;margin-right:0}.as3cf-bucket-container .bucket-actions span{display:inline-block;margin-right:20px;line-height:28px}.as3cf-bucket-container .as3cf-bucket-list{padding:15px;max-height:200px;overflow-x:hidden;overflow-y:auto;background-color:#fff;font-size:14px}.as3cf-bucket-container .as3cf-bucket-list li:last-of-type{margin-bottom:0}.as3cf-bucket-container .as3cf-bucket-list a{color:#444;text-decoration:none}.as3cf-bucket-container .as3cf-bucket-list a:hover{color:#0074a2}.as3cf-bucket-container .as3cf-bucket-list a.selected{font-weight:bold;color:#0074a2}.as3cf-bucket-container .as3cf-bucket-list a .dashicons{margin-right:5px}#tab-media{display:block}#tab-support{min-height:900px}#tab-support .as3cf-sidebar{top:11px}#tab-support .support-section{border-bottom:1px solid #ccc;padding-bottom:20px;margin-bottom:20px}#tab-support .support-section h3{font-size:20px}#tab-support .debug textarea{width:100%;min-height:200px;font-family:Consolas, Monaco, monospace;margin-bottom:5px}.as3cf-sidebar{position:absolute;top:9px;left:670px;width:292px}.as3cf-sidebar .block{padding:20px;border:1px solid #ccc}.as3cf-sidebar .subscribe{border-top:none}.as3cf-sidebar .subscribe h2{padding:0;margin:0;margin-bottom:0.5em;color:#666;font-size:20px;line-height:1.2em;float:none}.as3cf-sidebar .subscribe h3{font-size:16px;margin:0}.as3cf-sidebar .subscribe p{margin:0}.as3cf-sidebar .subscribe .intro{margin-bottom:1em;line-height:1.4}.as3cf-sidebar .subscribe li{line-height:1.4}.as3cf-sidebar .subscribe .links{margin-bottom:2em}.as3cf-sidebar .subscribe .links a{text-decoration:none}.as3cf-sidebar .subscribe .promise{color:#999;font-size:12px;line-height:1.4em}.as3cf-sidebar .subscribe .field{margin-bottom:0.5em}.as3cf-sidebar .subscribe .field p{margin-bottom:0.3em}.as3cf-sidebar .subscribe .field input[type=text],.as3cf-sidebar .subscribe .field input[type=email]{width:100%}.as3cf-sidebar .subscribe .field.submit-button{margin-bottom:1em}.as3cf-sidebar .credits{border-top:0}.as3cf-sidebar .credits h4{font-size:16px;margin-top:0;margin-bottom:10px}.as3cf-sidebar .credits ul{margin:0}.as3cf-sidebar .credits li{overflow:hidden}.as3cf-sidebar .credits li:last-child{margin-bottom:0}.as3cf-sidebar .credits img{float:left;margin-right:10px}.as3cf-sidebar .credits span{float:left;display:block;line-height:32px}.as3cf-sidebar .credits a{display:block;text-decoration:none;color:#444;font-size:16px;text-align:center}.as3cf-sidebar .credits a:hover{color:#888}@media screen and (max-width: 1052px){.as3cf-sidebar{position:relative;top:auto;right:auto}}.as3cf-active-provider,.as3cf-active-bucket{font-weight:bold;margin-right:10px}.as3cf-banner{margin-top:35px;width:292px;height:200px;display:block;background:#f8cfae url(../img/os3-banner.svg) left bottom/220px 220px no-repeat}.as3cf-banner:focus{-webkit-box-shadow:none;box-shadow:none}.wrap .as3cf-upgrade-details{background-color:#4e0d33;padding:10px 20px 20px 20px;color:#eee;font-size:13px;margin:0;display:block;text-decoration:none}.wrap .as3cf-upgrade-details h1{font-size:28px;color:#eee;margin:0 0 15px 0;padding:0;text-decoration:none;font-weight:200;line-height:1}.wrap .as3cf-upgrade-details p{margin:0}.wrap .as3cf-upgrade-details a{color:#eee;font-weight:bold;text-decoration:none;font-size:16px;-webkit-box-shadow:none;box-shadow:none}.wrap .as3cf-upgrade-details a:hover{color:#fff}.wrap .as3cf-upgrade-details ul{margin-top:0;margin-left:16px;list-style-type:disc}.as3cf-compatibility-notice.error{clear:both;margin:5px 20px 5px 0}.as3cf-bucket-error span.title{font-weight:bold}.as3cf-invalid-bucket-name,.as3cf-validation-error{display:block;margin-top:2px;font-size:12px;color:#a00}.as3cf-notice-toggle-content{max-height:100px;overflow-y:scroll}.as3cf-notice-toggle-content .as3cf-notice-toggle-list{margin-top:0;margin-left:0;padding-left:40px;color:#dc3232}.as3cf-need-help{background-color:white;font-size:16px;font-weight:bold;padding:1em}.as3cf-need-help a{text-decoration:none}.as3cf-settings h3{font-size:20px}.as3cf-settings p{font-size:14px}.as3cf-addons,.as3cf-tab .as3cf-compatibility-notice{max-width:cover}textarea.as3cf-access-key-constants-snippet.code{width:100%;white-space:pre;overflow:hidden;font-size:12px;padding:10px;height:53px}.as3cf-addons .as3cf-addons-list{margin:20px 0 200px;padding-top:5px}.as3cf-addons .as3cf-addon{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:20px;font-size:14px}.as3cf-addons .as3cf-addon-info{min-height:100px}.as3cf-addons .as3cf-addon-links{float:right}.as3cf-addons .as3cf-addon-links span{padding:4px 6px}.as3cf-addons .as3cf-addon-icon{float:left;margin-right:20px}.as3cf-addons .as3cf-addon-details{white-space:nowrap}.as3cf-addons .as3cf-addon-title,.as3cf-addons .as3cf-addon-description{font-weight:100}.as3cf-addons .as3cf-addon+.as3cf-addon{margin-top:20px}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull{background-color:#0769ad;color:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .as3cf-addon-title,.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .as3cf-addon-description,.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull a{color:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .extra{background:white}.as3cf-addons .as3cf-addon.amazon-s3-and-cloudfront-assets-pull .extra a{color:#0769ad;text-decoration:none}
assets/js/script.js CHANGED
@@ -2,7 +2,6 @@
2
 
3
  var savedSettings = {};
4
  var bucketNamePattern = /[^a-z0-9.-]/;
5
- var refreshBucketListOnLoad = false;
6
 
7
  var $body = $( 'body' );
8
  var $tabs = $( '.as3cf-tab' );
@@ -173,6 +172,9 @@
173
 
174
  $bucketList.html( '<li class="loading">' + $bucketList.data( 'working' ) + '</li>' );
175
 
 
 
 
176
  var data = {
177
  action: as3cfModal.prefix + '-get-buckets',
178
  _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.get_buckets
@@ -199,7 +201,7 @@
199
  if ( 'undefined' !== typeof data[ 'success' ] ) {
200
  $( '.as3cf-bucket-error' ).hide();
201
 
202
- if ( 0 === data['buckets'].length ) {
203
  $bucketList.html( '<li class="loading">' + $bucketList.data( 'nothing-found' ) + '</li>' );
204
  } else {
205
  $( data[ 'buckets' ] ).each( function( idx, bucket ) {
@@ -208,6 +210,7 @@
208
  } );
209
 
210
  that.scrollToSelected();
 
211
  }
212
  } else {
213
  that.showError( as3cf.strings.get_buckets_error, data[ 'error' ], 'as3cf-bucket-select' );
@@ -232,189 +235,44 @@
232
  },
233
 
234
  /**
235
- * Reset bucket modal
236
- */
237
- resetModal: function() {
238
- var $bucketContainer = $( '.as3cf-bucket-container.' + as3cfModal.prefix );
239
-
240
- if ( false === $activeTab.hasClass( 'as3cf-has-bucket' ) || 'manual' === $( '#' + as3cfModal.prefix + '-bucket-select' ).val() ) {
241
- $bucketContainer.find( '.as3cf-bucket-manual' ).show().siblings().hide();
242
- $bucketContainer.find( '.bucket-actions.manual' ).show().siblings( '.bucket-actions' ).hide();
243
- } else {
244
- $bucketContainer.find( '.as3cf-bucket-select' ).show().siblings().hide();
245
- $bucketContainer.find( '.bucket-actions.select' ).show().siblings( '.bucket-actions' ).hide();
246
-
247
- this.loadList( refreshBucketListOnLoad );
248
-
249
- refreshBucketListOnLoad = false;
250
- }
251
-
252
- $bucketContainer.find( '.as3cf-bucket-error' ).hide();
253
-
254
- // Reset manual select value
255
- var bucket = $( '#' + as3cfModal.prefix + '-bucket' ).val();
256
- $bucketContainer.find( '.as3cf-bucket-manual .as3cf-bucket-name' ).val( bucket );
257
-
258
- // Unlock setting the bucket
259
- this.bucketSelectLock = false;
260
- },
261
-
262
- /**
263
- * Save manual bucket
264
- */
265
- saveManual: function() {
266
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
267
- var $manualBucketRegion = $manualBucketForm.find( '.bucket-manual-region' );
268
- var $manualBucketInput = $manualBucketForm.find( '.as3cf-bucket-name' );
269
- var $manualBucketButton = $manualBucketForm.find( 'button[type=submit]' );
270
- var bucketName = $manualBucketInput.val();
271
- var originalBucketText = $manualBucketButton.first().text();
272
-
273
- if ( bucketName === $( '#' + as3cfModal.prefix + '-active-bucket' ).text() ) {
274
- $( '.as3cf-bucket-error' ).hide();
275
- $activeTab.addClass( 'as3cf-has-bucket' );
276
- as3cfModal.close();
277
- return;
278
- }
279
- $( '.as3cf-bucket-error' ).hide();
280
- $manualBucketButton.text( $manualBucketButton.data( 'working' ) );
281
- $manualBucketButton.prop( 'disabled', true );
282
-
283
- var data = {
284
- action: as3cfModal.prefix + '-manual-save-bucket',
285
- bucket_name: bucketName,
286
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.manual_bucket
287
- };
288
-
289
- if ( $manualBucketRegion.val() ) {
290
- data[ 'region' ] = $manualBucketRegion.val();
291
- }
292
-
293
- var that = this;
294
-
295
- $.ajax( {
296
- url: ajaxurl,
297
- type: 'POST',
298
- dataType: 'JSON',
299
- data: data,
300
- error: function( jqXHR, textStatus, errorThrown ) {
301
- $manualBucketButton.text( originalBucketText );
302
- that.showError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-manual' );
303
- },
304
- success: function( data, textStatus, jqXHR ) {
305
- $manualBucketButton.text( originalBucketText );
306
- $manualBucketButton.prop( 'disabled', false );
307
- if ( 'undefined' !== typeof data[ 'success' ] ) {
308
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
309
- $( '#' + as3cfModal.prefix + '-bucket-select' ).val( 'manual' );
310
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' ).filter( '[data-bucket="' + bucketName + '"]' ).addClass( 'selected' );
311
-
312
- // Make sure the bucket list will refresh the next time the modal loads
313
- refreshBucketListOnLoad = true;
314
-
315
- as3cf.showSettingsSavedNotice();
316
- } else {
317
- that.showError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-manual' );
318
- }
319
- }
320
- } );
321
- },
322
-
323
- /**
324
- * Save select bucket
325
  *
326
  * @param {object} $link
327
  */
328
- saveSelected: function( $link ) {
329
- if ( this.bucketSelectLock ) {
330
-
331
- // Bail if a bucket has already been clicked
332
- return;
333
- }
334
-
335
- // Lock the bucket selection
336
- this.bucketSelectLock = true;
337
-
338
- var $selectBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
339
- var $selectBucketRegion = $selectBucketForm.find( '.bucket-select-region' );
340
- var $bucketList = $selectBucketForm.find( '.as3cf-bucket-list' );
341
-
342
- if ( $link.hasClass( 'selected' ) ) {
343
- $activeTab.addClass( 'as3cf-has-bucket' );
344
- as3cfModal.close();
345
- return;
346
- }
347
-
348
- var previousBucket = $selectBucketForm.find( '.as3cf-bucket-list a.selected' ).data( 'bucket' );
349
-
350
  $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
351
  $link.addClass( 'selected' );
352
-
353
- $bucketList.addClass( 'saving' );
354
- $link.find( '.spinner' ).show().css( 'visibility', 'visible' );
355
- var bucketName = $link.data( 'bucket' );
356
-
357
- var data = {
358
- action: as3cfModal.prefix + '-save-bucket',
359
- bucket_name: bucketName,
360
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.save_bucket
361
- };
362
-
363
- if ( $selectBucketRegion.val() ) {
364
- data[ 'region' ] = $selectBucketRegion.val();
365
- }
366
-
367
- var that = this;
368
-
369
- $.ajax( {
370
- url: ajaxurl,
371
- type: 'POST',
372
- dataType: 'JSON',
373
- data: data,
374
- error: function( jqXHR, textStatus, errorThrown ) {
375
- $bucketList.removeClass( 'saving' );
376
- that.showError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-select' );
377
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
378
- $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
379
- },
380
- success: function( data, textStatus, jqXHR ) {
381
- $link.find( '.spinner' ).hide().css( 'visibility', 'hidden' );
382
- $bucketList.removeClass( 'saving' );
383
- if ( 'undefined' !== typeof data[ 'success' ] ) {
384
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
385
- $( '#' + as3cfModal.prefix + '-bucket-select' ).val( '' );
386
-
387
- as3cf.showSettingsSavedNotice();
388
- } else {
389
- that.showError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-select' );
390
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
391
- $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
392
- }
393
- }
394
- } );
395
  },
396
 
397
  /**
398
  * Disable bucket buttons
399
  */
400
  disabledButtons: function() {
401
- if ( 0 === $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' ).length ) {
 
 
 
 
402
  return;
403
  }
404
 
405
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
406
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
407
-
408
- if ( $createBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
409
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
410
- } else {
411
  $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
 
 
412
  }
413
 
414
- if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
 
 
415
  $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
 
 
 
 
416
  } else {
417
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
418
  }
419
  },
420
 
@@ -443,127 +301,6 @@
443
  this.bucketSelectLock = false;
444
  },
445
 
446
- /**
447
- * Set the selected bucket in the UI
448
- *
449
- * @param {string} bucket
450
- * @param {string} region
451
- * @param {string} region_name
452
- * @param {boolean} canWrite
453
- */
454
- set: function( bucket, region, region_name, canWrite ) {
455
- var $manualBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' );
456
- var $selectBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
457
- var $createBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' );
458
- var $activeRegion = $( '#' + as3cfModal.prefix + '-active-region' );
459
- var $activeBucket = $( '#' + as3cfModal.prefix + '-active-bucket' );
460
-
461
- if ( 'as3cf' === as3cfModal.prefix && 0 === $activeBucket.text().trim().length ) {
462
-
463
- // First time bucket select - enable main options by default
464
- setCheckbox( 'as3cf-copy-to-s3-wrap' );
465
- setCheckbox( 'as3cf-serve-from-s3-wrap' );
466
-
467
- // Update the saved settings string so we don't trigger the navigation alert
468
- var id = $activeTab.attr( 'id' );
469
- savedSettings[ id ] = serializedForm( id );
470
- }
471
-
472
- // Remove previous permission errors
473
- $( '.as3cf-error.fatal' ).hide();
474
-
475
- $activeBucket.text( bucket );
476
- $manualBucket.find( '.as3cf-bucket-name' ).val( bucket );
477
- $( '#' + as3cfModal.prefix + '-bucket' ).val( bucket );
478
-
479
- $activeRegion.text( region_name );
480
- $manualBucket.find( '.bucket-manual-region' ).val( region );
481
- $selectBucket.find( '.bucket-select-region' ).val( region );
482
- $createBucket.find( '.bucket-create-region' ).val( region );
483
- $( '#' + as3cfModal.prefix + '-region' ).val( region );
484
-
485
- $( '.updated' ).not( '.as3cf-notice' ).show();
486
-
487
- $activeTab.addClass( 'as3cf-has-bucket' );
488
-
489
- // Check permission on bucket
490
- $activeTab.find( '.as3cf-can-write-error' ).toggle( ! canWrite );
491
- $activeTab.find( '.as3cf-bucket-error' ).hide();
492
-
493
- if ( 'as3cf' === as3cfModal.prefix ) {
494
- generateUrlPreview();
495
- }
496
-
497
- setBucketLink();
498
-
499
- as3cfModal.close( function() {
500
- $activeTab.trigger( 'bucket-change', [ canWrite ] );
501
-
502
- // Unlock setting the bucket
503
- as3cf.buckets.bucketSelectLock = false;
504
- } );
505
- },
506
-
507
- /**
508
- * Save create bucket
509
- */
510
- create: function() {
511
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
512
- var $createBucketInput = $createBucketForm.find( '.as3cf-bucket-name' );
513
- var $createBucketRegion = $createBucketForm.find( '.bucket-create-region' );
514
- var $createBucketButton = $createBucketForm.find( 'button[type=submit]' );
515
-
516
- var bucketName = $createBucketInput.val();
517
- var origButtonText = $createBucketButton.text();
518
-
519
- $( '.as3cf-bucket-error' ).hide();
520
- $createBucketButton.text( $createBucketButton.data( 'working' ) );
521
- $createBucketButton.prop( 'disabled', true );
522
-
523
- var data = {
524
- action: as3cfModal.prefix + '-create-bucket',
525
- bucket_name: bucketName,
526
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.create_bucket
527
- };
528
-
529
- if ( $createBucketRegion.val() ) {
530
- data[ 'region' ] = $createBucketRegion.val();
531
- }
532
-
533
- var that = this;
534
-
535
- $.ajax( {
536
- url: ajaxurl,
537
- type: 'POST',
538
- dataType: 'JSON',
539
- data: data,
540
- error: function( jqXHR, textStatus, errorThrown ) {
541
- $createBucketButton.text( origButtonText );
542
- that.showError( as3cf.strings.create_bucket_error, errorThrown, 'as3cf-bucket-create' );
543
- },
544
- success: function( data, textStatus, jqXHR ) {
545
- $createBucketButton.text( origButtonText );
546
- $createBucketButton.prop( 'disabled', false );
547
- if ( 'undefined' !== typeof data[ 'success' ] ) {
548
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
549
-
550
- // Tidy up create bucket form
551
- $( '.as3cf-bucket-select-region' ).hide();
552
- $( '.as3cf-bucket-select-region' ).prop( 'selected', false );
553
- $createBucketInput.val( '' );
554
- $createBucketButton.prop( 'disabled', true );
555
-
556
- // Make sure the bucket list will refresh the next time the modal loads
557
- refreshBucketListOnLoad = true;
558
-
559
- as3cf.showSettingsSavedNotice();
560
- } else {
561
- that.showError( as3cf.strings.create_bucket_error, data[ 'error' ], 'as3cf-bucket-create' );
562
- }
563
- }
564
- } );
565
- },
566
-
567
  /**
568
  * Check for a valid bucket name
569
  *
@@ -658,6 +395,39 @@
658
  $( '#' + as3cfModal.prefix + '-view-bucket' ).attr( 'href', url );
659
  }
660
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  /**
662
  * Generate URL preview
663
  */
@@ -697,39 +467,6 @@
697
  } );
698
  }
699
 
700
- /*
701
- * Toggle the lost files notice
702
- */
703
- function toggleLostFilesNotice() {
704
- if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) && $( '#as3cf-serve-from-s3' ).is( ':not(:checked)' ) ) {
705
- $( '#as3cf-lost-files-notice' ).show();
706
- } else {
707
- $( '#as3cf-lost-files-notice' ).hide();
708
- }
709
- }
710
-
711
- /*
712
- * Toggle the remove local files notice
713
- */
714
- function toggleRemoveLocalNotice() {
715
- if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) ) {
716
- $( '#as3cf-remove-local-notice' ).show();
717
- } else {
718
- $( '#as3cf-remove-local-notice' ).hide();
719
- }
720
- }
721
-
722
- /*
723
- * Toggle the seo friendly url notice.
724
- */
725
- function toggleSEOFriendlyURLNotice( seo_friendly ) {
726
- if ( true !== seo_friendly ) {
727
- $( '#as3cf-seo-friendly-url-notice' ).show();
728
- } else {
729
- $( '#as3cf-seo-friendly-url-notice' ).hide();
730
- }
731
- }
732
-
733
  /**
734
  * Update the UI with the current active tab set in the URL hash.
735
  */
@@ -870,38 +607,8 @@
870
  // Move bucket errors
871
  $( '#tab-media > .as3cf-bucket-error' ).detach().insertAfter( '.as3cf-bucket-container h3' );
872
 
873
- // Action click handlers
874
- $body.on( 'click', '.bucket-action-manual', function( e ) {
875
- e.preventDefault();
876
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' ).show().siblings().hide();
877
- } );
878
- $body.on( 'click', '.bucket-action-browse', function( e ) {
879
- e.preventDefault();
880
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' ).show().siblings().hide();
881
- as3cf.buckets.loadList( refreshBucketListOnLoad );
882
- refreshBucketListOnLoad = false;
883
- } );
884
- $body.on( 'click', '.bucket-action-create', function( e ) {
885
- e.preventDefault();
886
-
887
- // Reset create bucket modal
888
- $( '.as3cf-bucket-name' ).val( '' );
889
- $( '.as3cf-invalid-bucket-name' ).html( '' );
890
-
891
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' ).show().siblings().hide();
892
- } );
893
- $body.on( 'click', '.bucket-action-cancel', function( e ) {
894
- e.preventDefault();
895
- as3cf.buckets.resetModal();
896
- } );
897
- $body.on( 'click', '.bucket-action-save', function( e ) {
898
- e.preventDefault();
899
- as3cf.buckets.saveManual();
900
- } );
901
- $body.on( 'click', '.as3cf-create-bucket-form button[type="submit"]', function( e ) {
902
- e.preventDefault();
903
- as3cf.buckets.create();
904
- } );
905
 
906
  // Bucket list refresh handler
907
  $body.on( 'click', '.bucket-action-refresh', function( e ) {
@@ -915,10 +622,16 @@
915
  as3cf.buckets.loadList( true );
916
  } );
917
 
 
 
 
 
 
918
  // Bucket list click handler
919
  $body.on( 'click', '.as3cf-bucket-list a', function( e ) {
920
  e.preventDefault();
921
- as3cf.buckets.saveSelected( $( this ) );
 
922
  } );
923
 
924
  // External links click handler
@@ -929,45 +642,25 @@
929
  return false;
930
  } );
931
 
932
- // Modal open
933
- $body.on( 'as3cf-modal-open', function( e, target ) {
934
- if ( '.as3cf-bucket-container.' + as3cfModal.prefix === target ) {
935
-
936
- // Reset modal
937
- as3cf.buckets.resetModal();
938
-
939
- // Change manual title text
940
- var title = $( '.as3cf-bucket-manual h3' ).data( 'modal-title' );
941
- $( '.as3cf-bucket-manual h3' ).text( title );
942
-
943
- // Hide buttons
944
- as3cf.buckets.disabledButtons();
945
- }
946
- } );
947
-
948
- as3cf.buckets.disabledButtons();
949
-
950
  // Validate bucket name on create
951
- $body.on( 'input keyup', '.as3cf-create-bucket-form .as3cf-bucket-name', function( e ) {
952
  var bucketName = $( this ).val();
953
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
 
 
954
 
955
- if ( as3cf.buckets.isValidName( bucketName ) ) {
956
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
957
- } else {
958
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
959
- }
960
  as3cf.buckets.updateNameNotice( bucketName );
 
961
  } );
962
 
963
- // Check bucket name length on manual
964
- $body.on( 'input keyup', '.as3cf-manual-save-bucket-form .as3cf-bucket-name', function( e ) {
965
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
 
966
 
967
- if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < as3cf.buckets.validLength ) {
968
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
969
- } else {
970
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
971
  }
972
  } );
973
  } );
2
 
3
  var savedSettings = {};
4
  var bucketNamePattern = /[^a-z0-9.-]/;
 
5
 
6
  var $body = $( 'body' );
7
  var $tabs = $( '.as3cf-tab' );
172
 
173
  $bucketList.html( '<li class="loading">' + $bucketList.data( 'working' ) + '</li>' );
174
 
175
+ // Stop accidental submit while reloading list.
176
+ this.disabledButtons();
177
+
178
  var data = {
179
  action: as3cfModal.prefix + '-get-buckets',
180
  _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.get_buckets
201
  if ( 'undefined' !== typeof data[ 'success' ] ) {
202
  $( '.as3cf-bucket-error' ).hide();
203
 
204
+ if ( 0 === data[ 'buckets' ].length ) {
205
  $bucketList.html( '<li class="loading">' + $bucketList.data( 'nothing-found' ) + '</li>' );
206
  } else {
207
  $( data[ 'buckets' ] ).each( function( idx, bucket ) {
210
  } );
211
 
212
  that.scrollToSelected();
213
+ that.disabledButtons();
214
  }
215
  } else {
216
  that.showError( as3cf.strings.get_buckets_error, data[ 'error' ], 'as3cf-bucket-select' );
235
  },
236
 
237
  /**
238
+ * Set the selected bucket in list.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  *
240
  * @param {object} $link
241
  */
242
+ setSelected: function( $link ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
244
  $link.addClass( 'selected' );
245
+ $( '#' + as3cfModal.prefix + '-bucket-select-name' ).val( $link.data( 'bucket' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  },
247
 
248
  /**
249
  * Disable bucket buttons
250
  */
251
  disabledButtons: function() {
252
+ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' );
253
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' );
254
+ var $selectBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
255
+
256
+ if ( 0 === $createBucketForm.length && 0 === $manualBucketForm.length && 0 === $selectBucketForm.length ) {
257
  return;
258
  }
259
 
260
+ if ( 0 < $createBucketForm.length && this.isValidName( $createBucketForm.find( '.as3cf-bucket-name' ).val() ) ) {
 
 
 
 
 
261
  $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
262
+ } else {
263
+ $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
264
  }
265
 
266
+ if ( 0 < $manualBucketForm.length && this.isValidName( $manualBucketForm.find( '.as3cf-bucket-name' ).val() ) ) {
267
+ $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
268
+ } else {
269
  $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
270
+ }
271
+
272
+ if ( 0 < $selectBucketForm.length && 1 === $selectBucketForm.find( '.as3cf-bucket-list a.selected' ).length ) {
273
+ $selectBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
274
  } else {
275
+ $selectBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
276
  }
277
  },
278
 
301
  this.bucketSelectLock = false;
302
  },
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  /**
305
  * Check for a valid bucket name
306
  *
395
  $( '#' + as3cfModal.prefix + '-view-bucket' ).attr( 'href', url );
396
  }
397
 
398
+ /*
399
+ * Toggle the lost files notice
400
+ */
401
+ function toggleLostFilesNotice() {
402
+ if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) && $( '#as3cf-serve-from-s3' ).is( ':not(:checked)' ) ) {
403
+ $( '#as3cf-lost-files-notice' ).show();
404
+ } else {
405
+ $( '#as3cf-lost-files-notice' ).hide();
406
+ }
407
+ }
408
+
409
+ /*
410
+ * Toggle the remove local files notice
411
+ */
412
+ function toggleRemoveLocalNotice() {
413
+ if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) ) {
414
+ $( '#as3cf-remove-local-notice' ).show();
415
+ } else {
416
+ $( '#as3cf-remove-local-notice' ).hide();
417
+ }
418
+ }
419
+
420
+ /*
421
+ * Toggle the seo friendly url notice.
422
+ */
423
+ function toggleSEOFriendlyURLNotice( seo_friendly ) {
424
+ if ( true !== seo_friendly ) {
425
+ $( '#as3cf-seo-friendly-url-notice' ).show();
426
+ } else {
427
+ $( '#as3cf-seo-friendly-url-notice' ).hide();
428
+ }
429
+ }
430
+
431
  /**
432
  * Generate URL preview
433
  */
467
  } );
468
  }
469
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  /**
471
  * Update the UI with the current active tab set in the URL hash.
472
  */
607
  // Move bucket errors
608
  $( '#tab-media > .as3cf-bucket-error' ).detach().insertAfter( '.as3cf-bucket-container h3' );
609
 
610
+ // Enable/disable change bucket's save buttons.
611
+ as3cf.buckets.disabledButtons();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
 
613
  // Bucket list refresh handler
614
  $body.on( 'click', '.bucket-action-refresh', function( e ) {
622
  as3cf.buckets.loadList( true );
623
  } );
624
 
625
+ // If select bucket form is available on load, populate its list.
626
+ if ( 0 < $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' ).length ) {
627
+ as3cf.buckets.loadList( true );
628
+ }
629
+
630
  // Bucket list click handler
631
  $body.on( 'click', '.as3cf-bucket-list a', function( e ) {
632
  e.preventDefault();
633
+ as3cf.buckets.setSelected( $( this ) );
634
+ as3cf.buckets.disabledButtons();
635
  } );
636
 
637
  // External links click handler
642
  return false;
643
  } );
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  // Validate bucket name on create
646
+ $body.on( 'input keyup', '.as3cf-bucket-create .as3cf-bucket-name', function( e ) {
647
  var bucketName = $( this ).val();
648
+ as3cf.buckets.updateNameNotice( bucketName );
649
+ as3cf.buckets.disabledButtons();
650
+ } );
651
 
652
+ $body.on( 'input keyup', '.as3cf-bucket-manual .as3cf-bucket-name', function( e ) {
653
+ var bucketName = $( this ).val();
 
 
 
654
  as3cf.buckets.updateNameNotice( bucketName );
655
+ as3cf.buckets.disabledButtons();
656
  } );
657
 
658
+ // Don't allow 'enter' key to submit form on text input settings
659
+ $( '.as3cf-bucket-container input[type="text"]' ).keypress( function( event ) {
660
+ if ( 13 === event.which ) {
661
+ event.preventDefault();
662
 
663
+ return false;
 
 
 
664
  }
665
  } );
666
  } );
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(a){var b=l.find("#"+a),c=b.find("input[type=checkbox]");b.toggleClass("on").find("span").toggleClass("checked");var d=b.find("span.on").hasClass("checked");c.prop("checked",d).trigger("change")}function e(b){var c=b.next(".as3cf-validation-error"),d=a("#"+l.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\.\-]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function f(){var c=a("#"+b.prefix+"-bucket").val(),d=l.find('input[name="object-prefix"]'),e=d.val();""!==e&&(e=as3cf.provider_console_url_param+encodeURIComponent(e));var f=as3cf.provider_console_url+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),j(b.seo_friendly)):alert(as3cf.strings.get_url_preview_error+b.error)}})}function h(){a("#as3cf-remove-local-file").is(":checked")&&a("#as3cf-serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function i(){a("#as3cf-remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}function j(b){!0!==b?a("#as3cf-seo-friendly-url-notice").show():a("#as3cf-seo-friendly-url-notice").hide()}function k(){return"#"+as3cf.tabs.defaultTab===location.hash?void(location.hash=""):(as3cf.tabs.toggle(location.hash.replace("#",""),!0),void a(document).trigger("as3cf.tabRendered",[location.hash.replace("#","")]))}var l,m={},n=/[^a-z0-9.-]/,o=!1,p=a("body"),q=a(".as3cf-tab");a(".as3cf-settings");as3cf.tabs={defaultTab:"media",toggle:function(c,d){c=as3cf.tabs.sanitizeHash(c),q.hide(),l=a("#tab-"+c),l.show(),a(".nav-tab").removeClass("nav-tab-active"),a('a.nav-tab[data-tab="'+c+'"]').addClass("nav-tab-active"),a(".as3cf-main").data("tab",c),l.data("prefix")&&(b.prefix=l.data("prefix")),d||a(".as3cf-updated").removeClass("show"),"support"===c&&as3cf.tabs.getDiagnosticInfo()},getDiagnosticInfo:function(){var b=a(".debug-log-textarea");b.html(as3cf.strings.get_diagnostic_info);var c={action:"as3cf-get-diagnostic-info",_nonce:as3cf.nonces.get_diagnostic_info};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:c,error:function(a,c,d){b.html(d)},success:function(a,c,d){"undefined"!=typeof a.success?b.html(a.diagnostic_info):(b.html(as3cf.strings.get_diagnostic_info_error),b.append(a.error))}})},sanitizeHash:function(b){var c=a("#tab-"+b);return 0===c.length&&(b=as3cf.tabs.defaultTab),b}},as3cf.buckets={validLength:3,bucketSelectLock:!1,loadList:function(c){"undefined"==typeof c&&(c=!1);var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select"),e=d.find(".bucket-select-region"),f=d.find(".as3cf-bucket-list"),g=a("#"+b.prefix+"-bucket").val();if(!1===c&&f.find("li").length>1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').addClass("selected"),void this.scrollToSelected();f.html('<li class="loading">'+f.data("working")+"</li>");var h={action:b.prefix+"-get-buckets",_nonce:window[b.prefix.replace(/-/g,"_")].nonces.get_buckets};e.val()&&(h.region=e.val());var i=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:h,error:function(a,b,c){f.html(""),i.showError(as3cf.strings.get_buckets_error,c,"as3cf-bucket-select")},success:function(b,c,d){f.html(""),"undefined"!=typeof b.success?(a(".as3cf-bucket-error").hide(),0===b.buckets.length?f.html('<li class="loading">'+f.data("nothing-found")+"</li>"):(a(b.buckets).each(function(a,b){var c=b.Name===g?"selected":"";f.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>')}),i.scrollToSelected())):i.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===l.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(o),o=!1),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(".bucket-manual-region"),e=c.find(".as3cf-bucket-name"),f=c.find("button[type=submit]"),g=e.val(),h=f.first().text();if(g===a("#"+b.prefix+"-active-bucket").text())return a(".as3cf-bucket-error").hide(),l.addClass("as3cf-has-bucket"),void b.close();a(".as3cf-bucket-error").hide(),f.text(f.data("working")),f.prop("disabled",!0);var i={action:b.prefix+"-manual-save-bucket",bucket_name:g,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.manual_bucket};d.val()&&(i.region=d.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.save_bucket_error,c,"as3cf-bucket-manual")},success:function(c,d,e){f.text(h),f.prop("disabled",!1),"undefined"!=typeof c.success?(j.set(g,c.region,c.region_name,c.can_write),a("#"+b.prefix+"-bucket-select").val("manual"),a(".as3cf-bucket-list a").removeClass("selected").filter('[data-bucket="'+g+'"]').addClass("selected"),o=!0,as3cf.showSettingsSavedNotice()):j.showError(as3cf.strings.save_bucket_error,c.error,"as3cf-bucket-manual")}})},saveSelected:function(c){if(!this.bucketSelectLock){this.bucketSelectLock=!0;var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select"),e=d.find(".bucket-select-region"),f=d.find(".as3cf-bucket-list");if(c.hasClass("selected"))return l.addClass("as3cf-has-bucket"),void b.close();var g=d.find(".as3cf-bucket-list a.selected").data("bucket");a(".as3cf-bucket-list a").removeClass("selected"),c.addClass("selected"),f.addClass("saving"),c.find(".spinner").show().css("visibility","visible");var h=c.data("bucket"),i={action:b.prefix+"-save-bucket",bucket_name:h,_nonce:window[b.prefix.replace(/-/g,"_")].nonces.save_bucket};e.val()&&(i.region=e.val());var j=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:i,error:function(b,c,d){f.removeClass("saving"),j.showError(as3cf.strings.save_bucket_error,d,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').addClass("selected")},success:function(d,e,i){c.find(".spinner").hide().css("visibility","hidden"),f.removeClass("saving"),"undefined"!=typeof d.success?(j.set(h,d.region,d.region_name,d.can_write),a("#"+b.prefix+"-bucket-select").val(""),as3cf.showSettingsSavedNotice()):(j.showError(as3cf.strings.save_bucket_error,d.error,"as3cf-bucket-select"),a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').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]").prop("disabled",!0):c.find("button[type=submit]").prop("disabled",!1),d.find(".as3cf-bucket-name").val().length<3?d.find("button[type=submit]").prop("disabled",!0):d.find("button[type=submit]").prop("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+" &mdash;"),f.find("span.message").html(c),f.show(),this.bucketSelectLock=!1)},set:function(e,h,i,j){var k=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual"),n=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select"),o=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-create"),p=a("#"+b.prefix+"-active-region"),q=a("#"+b.prefix+"-active-bucket");if("as3cf"===b.prefix&&0===q.text().trim().length){d("as3cf-copy-to-s3-wrap"),d("as3cf-serve-from-s3-wrap");var r=l.attr("id");m[r]=c(r)}a(".as3cf-error.fatal").hide(),q.text(e),k.find(".as3cf-bucket-name").val(e),a("#"+b.prefix+"-bucket").val(e),p.text(i),k.find(".bucket-manual-region").val(h),n.find(".bucket-select-region").val(h),o.find(".bucket-create-region").val(h),a("#"+b.prefix+"-region").val(h),a(".updated").not(".as3cf-notice").show(),l.addClass("as3cf-has-bucket"),l.find(".as3cf-can-write-error").toggle(!j),l.find(".as3cf-bucket-error").hide(),"as3cf"===b.prefix&&g(),f(),b.close(function(){l.trigger("bucket-change",[j]),as3cf.buckets.bucketSelectLock=!1})},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.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.region_name,b.can_write),a(".as3cf-bucket-select-region").hide(),a(".as3cf-bucket-select-region").prop("selected",!1),d.val(""),f.prop("disabled",!0),o=!0,as3cf.showSettingsSavedNotice()):j.showError(as3cf.strings.create_bucket_error,b.error,"as3cf-bucket-create")}})},isValidName:function(a){return!(a.length<3||a.length>63)&&!0!==n.test(a)},updateNameNotice:function(b){var c=null;!0===n.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("")}},as3cf.reloadUpdated=function(){var a=location.pathname+location.search;location.search.match(/[?&]updated=/)||(a+="&updated=1"),a+=location.hash,location.assign(a)},as3cf.showSettingsSavedNotice=function(){if(!(0<a("#setting-error-settings_updated:visible").length||0<a("#as3cf-settings_updated:visible").length)){var b='<div id="as3cf-settings_updated" class="updated settings-error notice is-dismissible"><p><strong>'+as3cf.strings.settings_saved+"</strong></p></div>";a("h2.nav-tab-wrapper").after(b),a(document).trigger("wp-updates-notice-added")}},a(document).ready(function(){k(),window.onhashchange=function(a){"function"==typeof history.replaceState&&"#"===location.href.slice(-1)&&history.replaceState({},"",location.href.slice(0,-1)),k()};var j=a(".as3cf-main .nav-tab-wrapper");a(".as3cf-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(j),q.length&&q.each(function(a,b){m[b.id]=c(b.id)}),a(window).on("beforeunload.as3cf-settings",function(){if(!a.isEmptyObject(m)){var b=l.attr("id");return c(b)!==m[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"))}),q.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(".url-preview").on("change","input",function(a){g()}),h(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){h()}),i(),a("#as3cf-remove-local-file").on("change",function(a){i()}),a('.as3cf-setting input[type="text"]').keypress(function(a){if(13===a.which)return a.preventDefault(),!1}),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("#"+l.attr("id")+' form button[type="submit"]');"cloudfront"!==c.val()?d.prop("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"),p.on("click",".bucket-action-manual",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual").show().siblings().hide()}),p.on("click",".bucket-action-browse",function(c){c.preventDefault(),a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select").show().siblings().hide(),as3cf.buckets.loadList(o),o=!1}),p.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()}),p.on("click",".bucket-action-cancel",function(a){a.preventDefault(),as3cf.buckets.resetModal()}),p.on("click",".bucket-action-save",function(a){a.preventDefault(),as3cf.buckets.saveManual()}),p.on("click",'.as3cf-create-bucket-form button[type="submit"]',function(a){a.preventDefault(),as3cf.buckets.create()}),p.on("click",".bucket-action-refresh",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),p.on("change",".bucket-select-region",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),p.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}),p.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(),p.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]").prop("disabled",!1):e.find("button[type=submit]").prop("disabled",!0),as3cf.buckets.updateNameNotice(d)}),p.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]").prop("disabled",!0):d.find("button[type=submit]").prop("disabled",!1)})})}(jQuery,as3cfModal);
1
+ !function(a,b){function c(b){return a("#"+b+" .as3cf-main-settings form").find("input:not(.no-compare)").serialize()}function d(a){var b=l.find("#"+a),c=b.find("input[type=checkbox]");b.toggleClass("on").find("span").toggleClass("checked");var d=b.find("span.on").hasClass("checked");c.prop("checked",d).trigger("change")}function e(b){var c=b.next(".as3cf-validation-error"),d=a("#"+l.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\.\-]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function f(){var c=a("#"+b.prefix+"-bucket").val(),d=l.find('input[name="object-prefix"]'),e=d.val();""!==e&&(e=as3cf.provider_console_url_param+encodeURIComponent(e));var f=as3cf.provider_console_url+c+e;a("#"+b.prefix+"-view-bucket").attr("href",f)}function g(){a("#as3cf-remove-local-file").is(":checked")&&a("#as3cf-serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function h(){a("#as3cf-remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}function i(b){!0!==b?a("#as3cf-seo-friendly-url-notice").show():a("#as3cf-seo-friendly-url-notice").hide()}function j(){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),i(b.seo_friendly)):alert(as3cf.strings.get_url_preview_error+b.error)}})}function k(){return"#"+as3cf.tabs.defaultTab===location.hash?void(location.hash=""):(as3cf.tabs.toggle(location.hash.replace("#",""),!0),void a(document).trigger("as3cf.tabRendered",[location.hash.replace("#","")]))}var l,m={},n=/[^a-z0-9.-]/,o=a("body"),p=a(".as3cf-tab");a(".as3cf-settings");as3cf.tabs={defaultTab:"media",toggle:function(c,d){c=as3cf.tabs.sanitizeHash(c),p.hide(),l=a("#tab-"+c),l.show(),a(".nav-tab").removeClass("nav-tab-active"),a('a.nav-tab[data-tab="'+c+'"]').addClass("nav-tab-active"),a(".as3cf-main").data("tab",c),l.data("prefix")&&(b.prefix=l.data("prefix")),d||a(".as3cf-updated").removeClass("show"),"support"===c&&as3cf.tabs.getDiagnosticInfo()},getDiagnosticInfo:function(){var b=a(".debug-log-textarea");b.html(as3cf.strings.get_diagnostic_info);var c={action:"as3cf-get-diagnostic-info",_nonce:as3cf.nonces.get_diagnostic_info};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:c,error:function(a,c,d){b.html(d)},success:function(a,c,d){"undefined"!=typeof a.success?b.html(a.diagnostic_info):(b.html(as3cf.strings.get_diagnostic_info_error),b.append(a.error))}})},sanitizeHash:function(b){var c=a("#tab-"+b);return 0===c.length&&(b=as3cf.tabs.defaultTab),b}},as3cf.buckets={validLength:3,bucketSelectLock:!1,loadList:function(c){"undefined"==typeof c&&(c=!1);var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select"),e=d.find(".bucket-select-region"),f=d.find(".as3cf-bucket-list"),g=a("#"+b.prefix+"-bucket").val();if(!1===c&&f.find("li").length>1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').addClass("selected"),void this.scrollToSelected();f.html('<li class="loading">'+f.data("working")+"</li>"),this.disabledButtons();var h={action:b.prefix+"-get-buckets",_nonce:window[b.prefix.replace(/-/g,"_")].nonces.get_buckets};e.val()&&(h.region=e.val());var i=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:h,error:function(a,b,c){f.html(""),i.showError(as3cf.strings.get_buckets_error,c,"as3cf-bucket-select")},success:function(b,c,d){f.html(""),"undefined"!=typeof b.success?(a(".as3cf-bucket-error").hide(),0===b.buckets.length?f.html('<li class="loading">'+f.data("nothing-found")+"</li>"):(a(b.buckets).each(function(a,b){var c=b.Name===g?"selected":"";f.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>')}),i.scrollToSelected(),i.disabledButtons())):i.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})}},setSelected:function(c){a(".as3cf-bucket-list a").removeClass("selected"),c.addClass("selected"),a("#"+b.prefix+"-bucket-select-name").val(c.data("bucket"))},disabledButtons:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-create"),d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual"),e=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select");0===c.length&&0===d.length&&0===e.length||(0<c.length&&this.isValidName(c.find(".as3cf-bucket-name").val())?c.find("button[type=submit]").prop("disabled",!1):c.find("button[type=submit]").prop("disabled",!0),0<d.length&&this.isValidName(d.find(".as3cf-bucket-name").val())?d.find("button[type=submit]").prop("disabled",!1):d.find("button[type=submit]").prop("disabled",!0),0<e.length&&1===e.find(".as3cf-bucket-list a.selected").length?e.find("button[type=submit]").prop("disabled",!1):e.find("button[type=submit]").prop("disabled",!0))},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+" &mdash;"),f.find("span.message").html(c),f.show(),this.bucketSelectLock=!1)},isValidName:function(a){return!(a.length<3||a.length>63)&&!0!==n.test(a)},updateNameNotice:function(b){var c=null;!0===n.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("")}},as3cf.reloadUpdated=function(){var a=location.pathname+location.search;location.search.match(/[?&]updated=/)||(a+="&updated=1"),a+=location.hash,location.assign(a)},as3cf.showSettingsSavedNotice=function(){if(!(0<a("#setting-error-settings_updated:visible").length||0<a("#as3cf-settings_updated:visible").length)){var b='<div id="as3cf-settings_updated" class="updated settings-error notice is-dismissible"><p><strong>'+as3cf.strings.settings_saved+"</strong></p></div>";a("h2.nav-tab-wrapper").after(b),a(document).trigger("wp-updates-notice-added")}},a(document).ready(function(){k(),window.onhashchange=function(a){"function"==typeof history.replaceState&&"#"===location.href.slice(-1)&&history.replaceState({},"",location.href.slice(0,-1)),k()};var i=a(".as3cf-main .nav-tab-wrapper");a(".as3cf-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(i),p.length&&p.each(function(a,b){m[b.id]=c(b.id)}),a(window).on("beforeunload.as3cf-settings",function(){if(!a.isEmptyObject(m)){var b=l.attr("id");return c(b)!==m[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"))}),p.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(".url-preview").on("change","input",function(a){j()}),g(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){g()}),h(),a("#as3cf-remove-local-file").on("change",function(a){h()}),a('.as3cf-setting input[type="text"]').keypress(function(a){if(13===a.which)return a.preventDefault(),!1}),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("#"+l.attr("id")+' form button[type="submit"]');"cloudfront"!==c.val()?d.prop("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"),as3cf.buckets.disabledButtons(),o.on("click",".bucket-action-refresh",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),o.on("change",".bucket-select-region",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),0<a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select").length&&as3cf.buckets.loadList(!0),o.on("click",".as3cf-bucket-list a",function(b){b.preventDefault(),as3cf.buckets.setSelected(a(this)),as3cf.buckets.disabledButtons()}),a(".as3cf-bucket-container").on("click","a.js-link",function(b){return b.preventDefault(),window.open(a(this).attr("href")),!1}),o.on("input keyup",".as3cf-bucket-create .as3cf-bucket-name",function(b){var c=a(this).val();as3cf.buckets.updateNameNotice(c),as3cf.buckets.disabledButtons()}),o.on("input keyup",".as3cf-bucket-manual .as3cf-bucket-name",function(b){var c=a(this).val();as3cf.buckets.updateNameNotice(c),as3cf.buckets.disabledButtons()}),a('.as3cf-bucket-container input[type="text"]').keypress(function(a){if(13===a.which)return a.preventDefault(),!1})})}(jQuery,as3cfModal);
assets/sass/styles.scss CHANGED
@@ -110,19 +110,21 @@ $as3cf_assets: #0769ad;
110
  */
111
  .as3cf-tab {
112
  .as3cf-main-settings {
113
- display: none;
114
-
115
  .as3cf-provider-select {
116
  display: none;
117
  }
118
 
119
- .as3cf-media-settings {
120
  display: none;
 
 
 
 
121
  }
122
- }
123
 
124
- .as3cf-bucket-container {
125
- display: none;
 
126
  }
127
 
128
  &.as3cf-needs-access-keys, &.as3cf-has-access-keys.as3cf-change-provider {
@@ -131,56 +133,54 @@ $as3cf_assets: #0769ad;
131
  }
132
 
133
  .as3cf-main-settings {
134
- display: block;
135
-
136
  .as3cf-provider-select {
137
  display: block;
138
  }
139
 
 
 
 
 
140
  .as3cf-media-settings {
141
  display: none;
142
  }
143
  }
 
144
 
145
- .as3cf-bucket-container {
 
146
  display: none;
147
  }
148
- }
149
 
150
- &.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider) {
151
  .as3cf-main-settings {
152
- display: none;
153
-
154
  .as3cf-provider-select {
155
  display: none;
156
  }
157
 
 
 
 
 
158
  .as3cf-media-settings {
159
  display: none;
160
  }
161
  }
162
-
163
- .as3cf-bucket-container {
164
- display: block;
165
- }
166
  }
167
 
168
- &.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider) {
169
  .as3cf-main-settings {
170
- display: block;
171
-
172
  .as3cf-provider-select {
173
  display: none;
174
  }
175
 
 
 
 
 
176
  .as3cf-media-settings {
177
  display: block;
178
  }
179
  }
180
-
181
- .as3cf-bucket-container {
182
- display: none;
183
- }
184
  }
185
  }
186
 
@@ -487,6 +487,25 @@ $as3cf_assets: #0769ad;
487
  display: none !important;
488
  }
489
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  }
491
 
492
  /**
@@ -567,15 +586,6 @@ $as3cf_assets: #0769ad;
567
  margin-right: 20px;
568
  line-height: 28px;
569
  }
570
-
571
- .bucket-action-cancel {
572
- color: #a00;
573
- text-decoration: none;
574
-
575
- &:hover {
576
- color: red;
577
- }
578
- }
579
  }
580
 
581
  .as3cf-bucket-list {
@@ -608,15 +618,6 @@ $as3cf_assets: #0769ad;
608
  }
609
  }
610
  }
611
-
612
- .as3cf-bucket-select,
613
- .as3cf-bucket-create {
614
- display: none;
615
- }
616
-
617
- .bucket-actions.select {
618
- display: none;
619
- }
620
  }
621
 
622
  #tab-media {
110
  */
111
  .as3cf-tab {
112
  .as3cf-main-settings {
 
 
113
  .as3cf-provider-select {
114
  display: none;
115
  }
116
 
117
+ .as3cf-bucket-container {
118
  display: none;
119
+
120
+ a.as3cf-change-provider {
121
+ display: none;
122
+ }
123
  }
 
124
 
125
+ .as3cf-media-settings {
126
+ display: none;
127
+ }
128
  }
129
 
130
  &.as3cf-needs-access-keys, &.as3cf-has-access-keys.as3cf-change-provider {
133
  }
134
 
135
  .as3cf-main-settings {
 
 
136
  .as3cf-provider-select {
137
  display: block;
138
  }
139
 
140
+ .as3cf-bucket-container {
141
+ display: none;
142
+ }
143
+
144
  .as3cf-media-settings {
145
  display: none;
146
  }
147
  }
148
+ }
149
 
150
+ &.as3cf-has-access-keys.as3cf-needs-bucket:not(.as3cf-change-provider), &.as3cf-has-access-keys.as3cf-change-bucket:not(.as3cf-change-provider) {
151
+ .as3cf-can-write-error {
152
  display: none;
153
  }
 
154
 
 
155
  .as3cf-main-settings {
 
 
156
  .as3cf-provider-select {
157
  display: none;
158
  }
159
 
160
+ .as3cf-bucket-container {
161
+ display: block;
162
+ }
163
+
164
  .as3cf-media-settings {
165
  display: none;
166
  }
167
  }
 
 
 
 
168
  }
169
 
170
+ &.as3cf-has-access-keys.as3cf-has-bucket:not(.as3cf-change-provider):not(.as3cf-change-bucket) {
171
  .as3cf-main-settings {
 
 
172
  .as3cf-provider-select {
173
  display: none;
174
  }
175
 
176
+ .as3cf-bucket-container {
177
+ display: none;
178
+ }
179
+
180
  .as3cf-media-settings {
181
  display: block;
182
  }
183
  }
 
 
 
 
184
  }
185
  }
186
 
487
  display: none !important;
488
  }
489
  }
490
+
491
+ p.actions {
492
+ margin: 20px -30px -30px;
493
+ padding: 20px 30px;
494
+ border-top: none;
495
+ overflow: hidden;
496
+
497
+ .right {
498
+ margin-left: 15px;
499
+
500
+ &:last-of-type {
501
+ margin-left: 0;
502
+ }
503
+ }
504
+
505
+ button {
506
+ min-width: 90px;
507
+ }
508
+ }
509
  }
510
 
511
  /**
586
  margin-right: 20px;
587
  line-height: 28px;
588
  }
 
 
 
 
 
 
 
 
 
589
  }
590
 
591
  .as3cf-bucket-list {
618
  }
619
  }
620
  }
 
 
 
 
 
 
 
 
 
621
  }
622
 
623
  #tab-media {
classes/amazon-s3-and-cloudfront.php CHANGED
@@ -106,7 +106,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
106
  'WPOS3_SETTINGS',
107
  );
108
 
109
- const LATEST_UPGRADE_ROUTINE = 6;
110
 
111
  /**
112
  * @param string $plugin_file_path
@@ -171,9 +171,6 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
171
 
172
  // UI AJAX
173
  add_action( 'wp_ajax_as3cf-get-buckets', array( $this, 'ajax_get_buckets' ) );
174
- add_action( 'wp_ajax_as3cf-save-bucket', array( $this, 'ajax_save_bucket' ) );
175
- add_action( 'wp_ajax_as3cf-create-bucket', array( $this, 'ajax_create_bucket' ) );
176
- add_action( 'wp_ajax_as3cf-manual-save-bucket', array( $this, 'ajax_save_bucket' ) );
177
  add_action( 'wp_ajax_as3cf-get-url-preview', array( $this, 'ajax_get_url_preview' ) );
178
  add_action( 'wp_ajax_as3cf_get_attachment_provider_details', array( $this, 'ajax_get_attachment_provider_details' ) );
179
  add_action( 'wp_ajax_as3cf-get-diagnostic-info', array( $this, 'ajax_get_diagnostic_info' ) );
@@ -2382,74 +2379,46 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2382
  }
2383
 
2384
  /**
2385
- * Returns cleaned up region name or kills ajax request if missing.
2386
  *
2387
- * @param bool $region_required
 
2388
  *
2389
- * @return string
2390
  */
2391
- function ajax_check_region( $region_required = false ) {
2392
- $region = '';
2393
-
2394
- // Are we defining the region or specifying via the form?
2395
  if ( defined( 'AS3CF_REGION' ) ) {
2396
- $region = AS3CF_REGION;
2397
- } elseif ( false !== $this->get_defined_setting( 'region', false ) ) {
2398
- $region = $this->get_defined_setting( 'region' );
2399
- } elseif (
2400
- ( ! isset( $_POST['region'] ) || ! ( $region = sanitize_text_field( $_POST['region'] ) ) ) &&
2401
- $region_required // It's very important that this test is after the above inline assign!
2402
- ) { // input var okay
2403
- $out = array( 'error' => __( 'No region provided.', 'amazon-s3-and-cloudfront' ) );
2404
-
2405
- $this->end_ajax( $out );
2406
  }
2407
 
2408
- return $region;
2409
- }
 
 
2410
 
2411
- /**
2412
- * Returns cleaned up bucket name or kills ajax request if missing.
2413
- *
2414
- * @return string
2415
- */
2416
- function ajax_check_bucket() {
2417
- if ( ! isset( $_POST['bucket_name'] ) || ! ( $bucket = sanitize_text_field( $_POST['bucket_name'] ) ) ) { // input var okay
2418
- $out = array( 'error' => __( 'No bucket name provided.', 'amazon-s3-and-cloudfront' ) );
2419
 
2420
- $this->end_ajax( $out );
 
2421
  }
2422
 
2423
- return strtolower( $bucket );
2424
  }
2425
 
2426
  /**
2427
- * Handler for AJAX callback to create a bucket in provider
2428
  *
2429
- * @throws Exception
 
 
2430
  */
2431
- function ajax_create_bucket() {
2432
- $this->verify_ajax_request();
2433
-
2434
- $region = $this->ajax_check_region( true );
2435
- $bucket = $this->ajax_check_bucket();
2436
-
2437
- $result = $this->create_bucket( $bucket, $region );
2438
-
2439
- if ( is_wp_error( $result ) ) {
2440
- $out = $this->prepare_bucket_error( $result, false );
2441
 
2442
- $this->end_ajax( $out );
2443
- }
2444
-
2445
- // check if we were previously selecting a bucket manually via the input
2446
- $previous_manual_bucket_select = $this->get_setting( 'manual_bucket', false );
2447
-
2448
- $args = array(
2449
- '_nonce' => wp_create_nonce( 'as3cf-create-bucket' ),
2450
- );
2451
-
2452
- $this->save_bucket_for_ajax( $bucket, $previous_manual_bucket_select, $region, $args );
2453
  }
2454
 
2455
  /**
@@ -2481,76 +2450,20 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2481
  return true;
2482
  }
2483
 
2484
- /**
2485
- * Handler for AJAX callback to save the selection of a bucket
2486
- *
2487
- * @throws Exception
2488
- */
2489
- function ajax_save_bucket() {
2490
- $this->verify_ajax_request();
2491
-
2492
- $region = $this->ajax_check_region( $this->get_provider()->region_required() );
2493
- $bucket = $this->ajax_check_bucket();
2494
-
2495
- $manual = false;
2496
- // are we inputting the bucket manually?
2497
- if ( isset( $_POST['action'] ) && false !== strpos( $_POST['action'], 'manual-save-bucket' ) ) {
2498
- $manual = true;
2499
- }
2500
-
2501
- $this->save_bucket_for_ajax( $bucket, $manual, $region );
2502
- }
2503
-
2504
- /**
2505
- * Wrapper method for saving a bucket when creating or selecting
2506
- *
2507
- * @param string $bucket
2508
- * @param bool|false $manual_select
2509
- * @param null|string $region
2510
- * @param array $defaults
2511
- *
2512
- * @throws Exception
2513
- */
2514
- function save_bucket_for_ajax( $bucket, $manual_select = false, $region = null, $defaults = array() ) {
2515
- $region = $this->save_bucket( $bucket, $manual_select, $region );
2516
-
2517
- if ( ! is_wp_error( $region ) ) {
2518
- $out = array(
2519
- 'success' => '1',
2520
- 'region' => $region,
2521
- 'region_name' => $this->get_provider()->get_region_name( $region ),
2522
- );
2523
-
2524
- $out = wp_parse_args( $out, $defaults );
2525
-
2526
- $can_write = $this->check_write_permission( $bucket, $region );
2527
-
2528
- if ( is_wp_error( $can_write ) ) {
2529
- $out = $this->prepare_bucket_error( $can_write );
2530
- } else {
2531
- $out['can_write'] = $can_write;
2532
- }
2533
- } else {
2534
- $out = $this->prepare_bucket_error( $region );
2535
- }
2536
-
2537
- $this->end_ajax( $out );
2538
- }
2539
-
2540
  /**
2541
  * Prepare the bucket error before returning to JS
2542
  *
2543
  * @param WP_Error $object
2544
  * @param bool $single Are we dealing with a single bucket?
2545
  *
2546
- * @return array
2547
  */
2548
  function prepare_bucket_error( $object, $single = true ) {
2549
  if ( 'Access Denied' === $object->get_error_message() ) {
2550
  // If the bucket error is access denied, show our notice message
2551
- $out = array( 'error' => $this->get_access_denied_notice_message( $single ) );
2552
  } else {
2553
- $out = array( 'error' => $object->get_error_message() );
2554
  }
2555
 
2556
  return $out;
@@ -2577,7 +2490,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2577
  * @param bool $manual if we are entering the bucket via the manual input form
2578
  * @param null|string $region
2579
  *
2580
- * @return string|bool region on success
2581
  */
2582
  function save_bucket( $bucket_name, $manual = false, $region = null ) {
2583
  if ( $bucket_name ) {
@@ -2780,12 +2693,15 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2780
  function ajax_get_buckets() {
2781
  $this->verify_ajax_request();
2782
 
2783
- $region = $this->ajax_check_region( $this->get_provider()->region_required() );
 
2784
 
2785
  $result = $this->get_buckets( $region );
2786
 
2787
  if ( is_wp_error( $result ) ) {
2788
- $out = $this->prepare_bucket_error( $result, false );
 
 
2789
  } else {
2790
  $out = array(
2791
  'success' => '1',
@@ -2829,6 +2745,11 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2829
  }
2830
 
2831
  if ( is_null( $bucket ) ) {
 
 
 
 
 
2832
  if ( ! ( $bucket = $this->get_setting( 'bucket' ) ) ) {
2833
  // if no bucket set then no need check
2834
  return true;
@@ -2868,16 +2789,22 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2868
 
2869
  /**
2870
  * Render error messages in a view for bucket permission and access issues
 
 
 
2871
  */
2872
  function render_bucket_permission_errors() {
2873
  $can_write = $this->check_write_permission();
2874
  // catch any checking issues
2875
  if ( is_wp_error( $can_write ) ) {
2876
  $this->render_view( 'error-fatal', array( 'message' => $can_write->get_error_message() ) );
2877
- $can_write = true;
 
 
 
2878
  }
2879
- // display a error message if the user does not have write permission to S3 bucket
2880
- $this->render_view( 'error-access', array( 'can_write' => $can_write ) );
2881
  }
2882
 
2883
  /**
@@ -2995,6 +2922,19 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
2995
  );
2996
  }
2997
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2998
  /**
2999
  * List of settings that should skip full sanitize.
3000
  *
@@ -3007,7 +2947,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
3007
  /**
3008
  * Handle the saving of the settings page
3009
  */
3010
- function handle_post_request() {
3011
  if ( empty( $_POST['plugin'] ) || $this->get_plugin_slug() != sanitize_key( $_POST['plugin'] ) ) { // input var okay
3012
  return;
3013
  }
@@ -3020,9 +2960,176 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
3020
  die( __( "Cheatin' eh?", 'amazon-s3-and-cloudfront' ) );
3021
  }
3022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3023
  do_action( 'as3cf_pre_save_settings' );
3024
 
3025
- $post_vars = $this->get_settings_whitelist();
 
3026
 
3027
  foreach ( $post_vars as $var ) {
3028
  // Special case for when Secret Access Key is not changed.
@@ -3039,13 +3146,16 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
3039
  $value = $this->sanitize_setting( $var, $_POST[ $var ] );
3040
 
3041
  $this->set_setting( $var, $value );
 
 
 
 
 
3042
  }
3043
 
3044
  $this->save_settings();
3045
 
3046
- $url = $this->get_plugin_page_url( array( 'updated' => '1' ) );
3047
- wp_redirect( $url );
3048
- exit;
3049
  }
3050
 
3051
  /**
@@ -3340,7 +3450,6 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
3340
  } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
3341
  $size_details .= $size . ' (' . $_wp_additional_image_sizes[ $size ]['width'] . 'x' . $_wp_additional_image_sizes[ $size ]['height'] . ')' . "\r\n";
3342
  }
3343
-
3344
  }
3345
 
3346
  return $size_details;
@@ -4429,7 +4538,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
4429
  }
4430
 
4431
  /**
4432
- * Handle retieving the S3 details for attachment modals.
4433
  */
4434
  public function ajax_get_attachment_provider_details() {
4435
  if ( ! isset( $_POST['id'] ) ) {
@@ -4724,7 +4833,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
4724
  * @return array Attachment's cleaned up metadata.
4725
  */
4726
  public function maybe_cleanup_filesize_metadata( $post_id, $data, $update_metadata = true ) {
4727
- if ( ! is_int( $post_id ) || empty( $post_id ) || empty( $data ) ) {
4728
  return $data;
4729
  }
4730
 
106
  'WPOS3_SETTINGS',
107
  );
108
 
109
+ const LATEST_UPGRADE_ROUTINE = 7;
110
 
111
  /**
112
  * @param string $plugin_file_path
171
 
172
  // UI AJAX
173
  add_action( 'wp_ajax_as3cf-get-buckets', array( $this, 'ajax_get_buckets' ) );
 
 
 
174
  add_action( 'wp_ajax_as3cf-get-url-preview', array( $this, 'ajax_get_url_preview' ) );
175
  add_action( 'wp_ajax_as3cf_get_attachment_provider_details', array( $this, 'ajax_get_attachment_provider_details' ) );
176
  add_action( 'wp_ajax_as3cf-get-diagnostic-info', array( $this, 'ajax_get_diagnostic_info' ) );
2379
  }
2380
 
2381
  /**
2382
+ * Returns cleaned up region name to be used while setting bucket or returns false if missing.
2383
  *
2384
+ * @param string $region
2385
+ * @param bool $region_required
2386
  *
2387
+ * @return string|bool
2388
  */
2389
+ function check_region( $region = '', $region_required = false ) {
2390
+ // If defined, just use.
 
 
2391
  if ( defined( 'AS3CF_REGION' ) ) {
2392
+ return AS3CF_REGION;
 
 
 
 
 
 
 
 
 
2393
  }
2394
 
2395
+ // If defined in settings define, just use.
2396
+ if ( false !== $this->get_defined_setting( 'region', false ) ) {
2397
+ return $this->get_defined_setting( 'region' );
2398
+ }
2399
 
2400
+ if ( ! empty( $region ) ) {
2401
+ $region = sanitize_text_field( $region );
2402
+ }
 
 
 
 
 
2403
 
2404
+ if ( $region_required && empty( $region ) ) {
2405
+ return false;
2406
  }
2407
 
2408
+ return $region;
2409
  }
2410
 
2411
  /**
2412
+ * Returns cleaned up bucket name or returns false if missing.
2413
  *
2414
+ * @param string $bucket
2415
+ *
2416
+ * @return string|bool
2417
  */
2418
+ function check_bucket( $bucket ) {
2419
+ $bucket = sanitize_text_field( $bucket );
 
 
 
 
 
 
 
 
2420
 
2421
+ return empty( $bucket ) ? false : strtolower( $bucket );
 
 
 
 
 
 
 
 
 
 
2422
  }
2423
 
2424
  /**
2450
  return true;
2451
  }
2452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2453
  /**
2454
  * Prepare the bucket error before returning to JS
2455
  *
2456
  * @param WP_Error $object
2457
  * @param bool $single Are we dealing with a single bucket?
2458
  *
2459
+ * @return string
2460
  */
2461
  function prepare_bucket_error( $object, $single = true ) {
2462
  if ( 'Access Denied' === $object->get_error_message() ) {
2463
  // If the bucket error is access denied, show our notice message
2464
+ $out = $this->get_access_denied_notice_message( $single );
2465
  } else {
2466
+ $out = $object->get_error_message();
2467
  }
2468
 
2469
  return $out;
2490
  * @param bool $manual if we are entering the bucket via the manual input form
2491
  * @param null|string $region
2492
  *
2493
+ * @return string|bool|WP_Error region on success
2494
  */
2495
  function save_bucket( $bucket_name, $manual = false, $region = null ) {
2496
  if ( $bucket_name ) {
2693
  function ajax_get_buckets() {
2694
  $this->verify_ajax_request();
2695
 
2696
+ $region = empty( $_POST['region'] ) ? '' : $_POST['region'];
2697
+ $region = $this->check_region( $region, $this->get_provider()->region_required() );
2698
 
2699
  $result = $this->get_buckets( $region );
2700
 
2701
  if ( is_wp_error( $result ) ) {
2702
+ $out = array(
2703
+ 'error' => $this->prepare_bucket_error( $result, false ),
2704
+ );
2705
  } else {
2706
  $out = array(
2707
  'success' => '1',
2745
  }
2746
 
2747
  if ( is_null( $bucket ) ) {
2748
+ // If changing provider or bucket don't bother to test saved bucket permissions.
2749
+ if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'change-provider', 'change-bucket' ) ) ) {
2750
+ return false;
2751
+ }
2752
+
2753
  if ( ! ( $bucket = $this->get_setting( 'bucket' ) ) ) {
2754
  // if no bucket set then no need check
2755
  return true;
2789
 
2790
  /**
2791
  * Render error messages in a view for bucket permission and access issues
2792
+ *
2793
+ * @return bool
2794
+ * @throws Exception
2795
  */
2796
  function render_bucket_permission_errors() {
2797
  $can_write = $this->check_write_permission();
2798
  // catch any checking issues
2799
  if ( is_wp_error( $can_write ) ) {
2800
  $this->render_view( 'error-fatal', array( 'message' => $can_write->get_error_message() ) );
2801
+ $can_write = false;
2802
+ } else {
2803
+ // display a error message if the user does not have write permission to S3 bucket
2804
+ $this->render_view( 'error-access', array( 'can_write' => $can_write ) );
2805
  }
2806
+
2807
+ return $can_write;
2808
  }
2809
 
2810
  /**
2922
  );
2923
  }
2924
 
2925
+ /**
2926
+ * Get the blacklisted settings for monitoring changes in defines.
2927
+ * These settings will not be saved in the database.
2928
+ *
2929
+ * @return array
2930
+ */
2931
+ function get_monitored_settings_blacklist() {
2932
+ return array(
2933
+ 'access-key-id',
2934
+ 'secret-access-key',
2935
+ );
2936
+ }
2937
+
2938
  /**
2939
  * List of settings that should skip full sanitize.
2940
  *
2947
  /**
2948
  * Handle the saving of the settings page
2949
  */
2950
+ public function handle_post_request() {
2951
  if ( empty( $_POST['plugin'] ) || $this->get_plugin_slug() != sanitize_key( $_POST['plugin'] ) ) { // input var okay
2952
  return;
2953
  }
2960
  die( __( "Cheatin' eh?", 'amazon-s3-and-cloudfront' ) );
2961
  }
2962
 
2963
+ if ( $this->get_provider()->needs_access_keys() || ( ! empty( $_GET['action'] ) && 'change-provider' === $_GET['action'] ) ) {
2964
+ // Changing Provider currently doesn't need anything special over saving settings,
2965
+ // but if not already set needs to be handled rather than change-bucket raising its hand.
2966
+ $changed_keys = $this->handle_save_settings();
2967
+ } elseif ( empty( $this->get_setting( 'bucket' ) ) || ( ! empty( $_GET['action'] ) && 'change-bucket' === $_GET['action'] ) ) {
2968
+ $changed_keys = $this->handle_change_bucket();
2969
+ } elseif ( ! empty( $_GET['action'] ) ) {
2970
+ $changed_keys = apply_filters( 'as3cf_handle_post_request', array() );
2971
+ } else {
2972
+ $changed_keys = $this->handle_save_settings();
2973
+ }
2974
+
2975
+ // If the changes can't be saved, stay on same page.
2976
+ // An admin notice should be created with the error message.
2977
+ if ( false === $changed_keys ) {
2978
+ return;
2979
+ }
2980
+
2981
+ // No failures, so let's make things super green.
2982
+ $url_args = array( 'updated' => '1' );
2983
+
2984
+ if ( ! empty( $changed_keys ) ) {
2985
+ $action = null;
2986
+
2987
+ foreach ( $changed_keys as $key ) {
2988
+ // If anything about the Provider has changed then we need to verify the bucket selection.
2989
+ // Otherwise we can let the filter decide whether there is an action to take.
2990
+ // Last implementer will win, but the above handlers take care of grouping things appropriately.
2991
+ if ( in_array( $key, array( 'provider', 'access-key-id', 'secret-access-key' ) ) && ! $this->get_defined_setting( 'bucket', false ) ) {
2992
+ $action = 'change-bucket';
2993
+ break;
2994
+ } else {
2995
+ $action = apply_filters( 'as3cf_action_for_changed_settings_key', $action, $key );
2996
+ }
2997
+ }
2998
+ }
2999
+
3000
+ // Stash which step we're on in possibly multi-step config.
3001
+ $prev_action = ! empty( $_GET['action'] ) ? $_GET['action'] : null;
3002
+
3003
+ // Depending on the step we're on, we may need another step if not already determined by newly saved settings.
3004
+ if ( empty( $action ) && ! empty( $prev_action ) ) {
3005
+ // After change-provider we always want the user to confirm the bucket is still ok.
3006
+ // This gets round the change-provider => change-bucket => "back" problem.
3007
+ // but then no change in provider settings problem.
3008
+ if ( 'change-provider' === $prev_action && ! $this->get_defined_setting( 'bucket', false ) ) {
3009
+ $action = 'change-bucket';
3010
+ }
3011
+ }
3012
+
3013
+ if ( ! empty( $action ) ) {
3014
+ $url_args['action'] = $action;
3015
+ }
3016
+
3017
+ if ( ! empty( $prev_action ) ) {
3018
+ $url_args['prev_action'] = $prev_action;
3019
+ }
3020
+
3021
+ $url = $this->get_plugin_page_url( $url_args );
3022
+ wp_redirect( $url );
3023
+ exit;
3024
+ }
3025
+
3026
+ /**
3027
+ * Handle saving change in bucket as submitted by user, whether create, enter or select.
3028
+ *
3029
+ * @return array|bool
3030
+ * @throws Exception
3031
+ */
3032
+ private function handle_change_bucket() {
3033
+ // Quick check that bucket name actually given.
3034
+ $bucket = empty( $_POST['bucket_name'] ) ? false : $_POST['bucket_name'];
3035
+
3036
+ if ( false === $bucket ) {
3037
+ $this->notices->add_notice( __( 'No bucket name provided.', 'amazon-s3-and-cloudfront' ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3038
+
3039
+ return false;
3040
+ }
3041
+
3042
+ // Check and set bucket.
3043
+ $bucket = $this->check_bucket( $bucket );
3044
+
3045
+ if ( false === $bucket ) {
3046
+ $this->notices->add_notice( __( 'No bucket name not valid.', 'amazon-s3-and-cloudfront' ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3047
+
3048
+ return false;
3049
+ }
3050
+
3051
+ $bucket_mode = empty( $_GET['bucket_mode'] ) ? 'manual' : $_GET['bucket_mode'];
3052
+
3053
+ // Check and set region.
3054
+ $region = empty( $_POST['region_name'] ) ? '' : $_POST['region_name'];
3055
+ $region_required = 'create' === $bucket_mode ? true : $this->get_provider()->region_required();
3056
+ $region = $this->check_region( $region, $region_required );
3057
+
3058
+ if ( false === $region ) {
3059
+ $this->notices->add_notice( __( 'No region provided.', 'amazon-s3-and-cloudfront' ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3060
+
3061
+ return false;
3062
+ }
3063
+
3064
+ // Are we creating a bucket?
3065
+ if ( 'create' === $bucket_mode ) {
3066
+ $result = $this->create_bucket( $bucket, $region );
3067
+
3068
+ if ( is_wp_error( $result ) ) {
3069
+ $this->notices->add_notice( $this->prepare_bucket_error( $result, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3070
+
3071
+ return false;
3072
+ }
3073
+
3074
+ // Check if we were previously selecting a bucket manually via the input.
3075
+ $manual_select = $this->get_setting( 'manual_bucket', false );
3076
+
3077
+ $args = array(
3078
+ '_nonce' => wp_create_nonce( 'as3cf-create-bucket' ),
3079
+ );
3080
+ } elseif ( 'manual' === $bucket_mode ) {
3081
+ $manual_select = true;
3082
+ } else {
3083
+ $manual_select = false;
3084
+ }
3085
+
3086
+ // Stash the current bucket and region before they change.
3087
+ $old_bucket = $this->get_setting( 'bucket', false );
3088
+ $old_region = $this->get_setting( 'region', '' );
3089
+
3090
+ // Set bucket.
3091
+ $region = $this->save_bucket( $bucket, $manual_select, $region );
3092
+
3093
+ if ( is_wp_error( $region ) ) {
3094
+ $this->notices->add_notice( $this->prepare_bucket_error( $region, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3095
+
3096
+ return false;
3097
+ }
3098
+
3099
+ $can_write = $this->check_write_permission( $bucket, $region );
3100
+
3101
+ if ( is_wp_error( $can_write ) ) {
3102
+ $this->notices->add_notice( $this->prepare_bucket_error( $can_write, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
3103
+
3104
+ return false;
3105
+ }
3106
+
3107
+ // Tell the parent handler whether the bucket or region have changed.
3108
+ $changed_keys = array();
3109
+
3110
+ if ( ! $old_bucket || $bucket !== $old_bucket ) {
3111
+ $changed_keys[] = 'bucket';
3112
+ }
3113
+
3114
+ if ( $region !== $old_region ) {
3115
+ $changed_keys[] = 'region';
3116
+ }
3117
+
3118
+ return $changed_keys;
3119
+ }
3120
+
3121
+ /**
3122
+ * Handle saving settings submitted by user.
3123
+ *
3124
+ * @return array
3125
+ */
3126
+ private function handle_save_settings() {
3127
+ $changed_keys = array();
3128
+
3129
  do_action( 'as3cf_pre_save_settings' );
3130
 
3131
+ $post_vars = $this->get_settings_whitelist();
3132
+ $old_settings = $this->get_settings();
3133
 
3134
  foreach ( $post_vars as $var ) {
3135
  // Special case for when Secret Access Key is not changed.
3146
  $value = $this->sanitize_setting( $var, $_POST[ $var ] );
3147
 
3148
  $this->set_setting( $var, $value );
3149
+
3150
+ // Some setting changes might have knock-on effects that require confirmation of secondary settings.
3151
+ if ( isset( $old_settings[ $var ] ) && $old_settings[ $var ] !== $value ) {
3152
+ $changed_keys[] = $var;
3153
+ }
3154
  }
3155
 
3156
  $this->save_settings();
3157
 
3158
+ return $changed_keys;
 
 
3159
  }
3160
 
3161
  /**
3450
  } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
3451
  $size_details .= $size . ' (' . $_wp_additional_image_sizes[ $size ]['width'] . 'x' . $_wp_additional_image_sizes[ $size ]['height'] . ')' . "\r\n";
3452
  }
 
3453
  }
3454
 
3455
  return $size_details;
4538
  }
4539
 
4540
  /**
4541
+ * Handle retrieving the provider details for attachment modals.
4542
  */
4543
  public function ajax_get_attachment_provider_details() {
4544
  if ( ! isset( $_POST['id'] ) ) {
4833
  * @return array Attachment's cleaned up metadata.
4834
  */
4835
  public function maybe_cleanup_filesize_metadata( $post_id, $data, $update_metadata = true ) {
4836
+ if ( ! is_int( $post_id ) || empty( $post_id ) || empty( $data ) || ! is_array( $data ) ) {
4837
  return $data;
4838
  }
4839
 
classes/as3cf-compatibility-check.php CHANGED
@@ -369,7 +369,7 @@ if ( ! class_exists( 'AS3CF_Compatibility_Check' ) ) {
369
  global $as3cfpro;
370
  if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
371
  // Don't show update link for addons of a licensed plugin where the license is invalid
372
- if ( ! $as3cfpro->is_valid_licence() ) {
373
  $msg .= ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
374
  $msg .= $hide_notice_msg;
375
 
@@ -407,7 +407,7 @@ if ( ! class_exists( 'AS3CF_Compatibility_Check' ) ) {
407
  global $as3cfpro;
408
  if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
409
  // Don't show update link for addons of a licensed plugin where the license is invalid
410
- if ( ! $as3cfpro->is_valid_licence() ) {
411
  $upgrade_msg = ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
412
  }
413
  }
369
  global $as3cfpro;
370
  if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
371
  // Don't show update link for addons of a licensed plugin where the license is invalid
372
+ if ( ! $as3cfpro->is_valid_licence( false, true ) ) {
373
  $msg .= ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
374
  $msg .= $hide_notice_msg;
375
 
407
  global $as3cfpro;
408
  if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
409
  // Don't show update link for addons of a licensed plugin where the license is invalid
410
+ if ( ! $as3cfpro->is_valid_licence( false, true ) ) {
411
  $upgrade_msg = ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
412
  }
413
  }
classes/as3cf-plugin-base.php CHANGED
@@ -114,7 +114,13 @@ abstract class AS3CF_Plugin_Base {
114
  */
115
  function get_settings( $force = false ) {
116
  if ( is_null( $this->settings ) || $force ) {
117
- $this->settings = $this->filter_settings( get_site_option( static::SETTINGS_KEY ) );
 
 
 
 
 
 
118
  }
119
 
120
  return $this->settings;
@@ -170,7 +176,7 @@ abstract class AS3CF_Plugin_Base {
170
 
171
  // Normalize the defined settings before saving, so we can detect when a real change happens.
172
  ksort( $this->defined_settings );
173
- update_site_option( 'as3cf_constant_' . static::settings_constant(), $this->defined_settings );
174
  }
175
 
176
  return $this->defined_settings;
@@ -280,6 +286,17 @@ abstract class AS3CF_Plugin_Base {
280
  return array();
281
  }
282
 
 
 
 
 
 
 
 
 
 
 
 
283
  /**
284
  * List of settings that should skip full sanitize.
285
  *
@@ -424,7 +441,7 @@ abstract class AS3CF_Plugin_Base {
424
  ksort( $this->settings );
425
  }
426
 
427
- $this->update_site_option( static::SETTINGS_KEY, $this->settings );
428
  }
429
 
430
  /**
114
  */
115
  function get_settings( $force = false ) {
116
  if ( is_null( $this->settings ) || $force ) {
117
+ $saved_settings = get_site_option( static::SETTINGS_KEY );
118
+ $this->settings = $this->filter_settings( $saved_settings );
119
+
120
+ // If defined settings keys have changed since last time settings were saved to database, re-save to remove the new keys.
121
+ if ( ! empty( $saved_settings ) && ! empty( $this->defined_settings ) && ! empty( array_intersect_key( $saved_settings, $this->defined_settings ) ) ) {
122
+ $this->save_settings();
123
+ }
124
  }
125
 
126
  return $this->settings;
176
 
177
  // Normalize the defined settings before saving, so we can detect when a real change happens.
178
  ksort( $this->defined_settings );
179
+ update_site_option( 'as3cf_constant_' . static::settings_constant(), array_diff_key( $this->defined_settings, array_flip( $this->get_monitored_settings_blacklist() ) ) );
180
  }
181
 
182
  return $this->defined_settings;
286
  return array();
287
  }
288
 
289
+ /**
290
+ * Get the blacklisted settings for monitoring changes in defines.
291
+ * These settings will not be saved in the database.
292
+ * Meant to be overridden in child classes.
293
+ *
294
+ * @return array
295
+ */
296
+ function get_monitored_settings_blacklist() {
297
+ return array();
298
+ }
299
+
300
  /**
301
  * List of settings that should skip full sanitize.
302
  *
441
  ksort( $this->settings );
442
  }
443
 
444
+ $this->update_site_option( static::SETTINGS_KEY, array_diff_key( $this->settings, $this->defined_settings ) );
445
  }
446
 
447
  /**
classes/providers/aws-provider.php CHANGED
@@ -63,6 +63,13 @@ class AWS_Provider extends Provider {
63
  */
64
  protected static $provider_service_name = 'Amazon S3';
65
 
 
 
 
 
 
 
 
66
  /**
67
  * @var array
68
  */
63
  */
64
  protected static $provider_service_name = 'Amazon S3';
65
 
66
+ /**
67
+ * The slug for the service's quick start guide doc.
68
+ *
69
+ * @var string
70
+ */
71
+ protected static $provider_service_quick_start_slug = 'amazon-s3-quick-start-guide';
72
+
73
  /**
74
  * @var array
75
  */
classes/providers/digitalocean-provider.php CHANGED
@@ -45,6 +45,13 @@ class DigitalOcean_Provider extends AWS_Provider {
45
  */
46
  protected static $provider_service_name = '';
47
 
 
 
 
 
 
 
 
48
  /**
49
  * @var array
50
  */
45
  */
46
  protected static $provider_service_name = '';
47
 
48
+ /**
49
+ * The slug for the service's quick start guide doc.
50
+ *
51
+ * @var string
52
+ */
53
+ protected static $provider_service_quick_start_slug = 'digitalocean-spaces-quick-start-guide';
54
+
55
  /**
56
  * @var array
57
  */
classes/providers/provider.php CHANGED
@@ -60,6 +60,13 @@ abstract class Provider {
60
  */
61
  protected static $provider_service_name = '';
62
 
 
 
 
 
 
 
 
63
  /**
64
  * @var string
65
  */
@@ -166,6 +173,15 @@ abstract class Provider {
166
  return static::$provider_name . ' ' . static::$service_name;
167
  }
168