From 9a12cc0709b06782f73b774fbe91417a616bf2d2 Mon Sep 17 00:00:00 2001
From: "Ian M. Jones"
Date: Mon, 17 Dec 2018 10:44:39 +0000
Subject: [PATCH] Deploying version 2.0.1
---
README.md | 47 +-
assets/css/styles.css | 2 +-
assets/js/script.js | 463 ++++----------------
assets/js/script.min.js | 2 +-
assets/sass/styles.scss | 85 ++--
classes/amazon-s3-and-cloudfront.php | 367 ++++++++++------
classes/as3cf-compatibility-check.php | 4 +-
classes/as3cf-plugin-base.php | 23 +-
classes/providers/aws-provider.php | 7 +
classes/providers/digitalocean-provider.php | 7 +
classes/providers/provider.php | 16 +
languages/amazon-s3-and-cloudfront-en.pot | 317 +++++++-------
readme.txt | 39 +-
view/bucket-select.php | 172 ++++----
view/bucket-setting.php | 2 +-
view/checkbox.php | 4 +-
view/provider-select.php | 31 +-
view/settings/media.php | 49 ++-
wordpress-s3.php | 4 +-
19 files changed, 790 insertions(+), 851 deletions(-)
diff --git a/README.md b/README.md
index 36ec2738..ee75b7f2 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,18 @@
-# WP Offload Media Lite #
+# WP Offload Media Lite for Amazon S3 and DigitalOcean Spaces #
**Contributors:** bradt, deliciousbrains, ianmjones
**Tags:** uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, mirror, admin, media, cdn, cloudfront
**Requires at least:** 4.7
-**Tested up to:** 4.9
+**Tested up to:** 5.0
**Requires PHP:** 5.5
-**Stable tag:** 2.0
+**Stable tag:** 2.0.1
**License:** GPLv3
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.
## Description ##
+FORMERLY WP OFFLOAD S3 LITE
+
https://www.youtube.com/watch?v=_PVybEGaRXc
This plugin automatically copies images, videos, documents, and any other media added through WordPress' media uploader to [Amazon S3](http://aws.amazon.com/s3/) or [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/). It then automatically replaces the URL to each media file with their respective Amazon S3 or DigitalOcean Spaces URL or, if you have configured [Amazon CloudFront](http://aws.amazon.com/cloudfront/) or another CDN with or without a custom domain, that URL instead. Image thumbnails are also copied to the bucket and delivered through the correct remote URL.
@@ -19,6 +21,10 @@ Uploading files *directly* to your Amazon S3 or DigitalOcean Spaces account is n
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.
+**Image Optimization**
+
+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.
+
**PRO Upgrade with Email Support and More Features**
* Upload existing Media Library to Amazon S3 or DigitalOcean Spaces
@@ -34,10 +40,6 @@ The video below runs through the pro upgrade features...
https://www.youtube.com/watch?v=55xNGnbJ_CY
-*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.*
-
## Installation ##
1. Install this plugin using WordPress' built-in installer
@@ -52,13 +54,23 @@ Check out the [Quick Start Guide](https://deliciousbrains.com/wp-offload-media/d
You can see the minimum requirements [here](https://deliciousbrains.com/wp-offload-media/pricing/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting&utm_content=requirements#requirements).
+### Do you offer email support? ###
+
+If you upgrade to the pro version of [WP Offload Media](https://deliciousbrains.com/wp-offload-media/upgrade/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting), we will gladly provide you with email support. We take pride in delivering exceptional customer support. We do not provide email support for the free version.
+
## Screenshots ##
-### 1. Choosing/creating a bucket ###
-![Choosing/creating a bucket](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite/assets/screenshot-1.png)
+### 1. Select Cloud Storage Provider ###
+![Select Cloud Storage Provider](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite-for-amazon-s3-and-digitalocean-spaces/assets/screenshot-1.png)
+
+### 2. Select or Create Bucket ###
+![Select or Create Bucket](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite-for-amazon-s3-and-digitalocean-spaces/assets/screenshot-2.png)
-### 2. Settings screen ###
-![Settings screen](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite/assets/screenshot-2.png)
+### 3. Settings Screen ###
+![Settings Screen](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite-for-amazon-s3-and-digitalocean-spaces/assets/screenshot-3.png)
+
+### 4. Custom Domain Used With CDN ###
+![Custom Domain Used With CDN](https://raw.githubusercontent.com/deliciousbrains/wp-wp-offload-media-lite-for-amazon-s3-and-digitalocean-spaces/assets/screenshot-4.png)
## Upgrade Notice ##
@@ -74,9 +86,18 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
## Changelog ##
+### WP Offload Media Lite 2.0.1 - 2018-12-17 ###
+* Improvement: Streamlined UI for setting Storage Provider and Bucket
+* Bug fix: On/Off switches in settings look reversed
+* Bug fix: Latest upgrade routine runs on fresh install
+* Bug fix: Defined settings still found in database
+* Bug fix: More Info links in Storage Provider settings incorrect
+* Tested: WordPress 5.0
+
### WP Offload Media Lite 2.0 - 2018-09-24 ###
-* New: Plugin renamed to "WP Offload Media Lite"
-* New: DigitalOcean Spaces support
+* [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-supports-digitalocean-spaces/)
+* New: DigitalOcean Spaces is now supported
+* New: Plugin name updated from WP Offload S3 Lite to WP Offload Media Lite
* Improvement: More logical UI layout and better description of each setting
### WP Offload S3 Lite 1.4.3 - 2018-08-02 ###
diff --git a/assets/css/styles.css b/assets/css/styles.css
index 1b648261..a88e4e9e 100644
--- a/assets/css/styles.css
+++ b/assets/css/styles.css
@@ -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}
+.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}
diff --git a/assets/js/script.js b/assets/js/script.js
index 7ab0f9bc..b53828e0 100644
--- a/assets/js/script.js
+++ b/assets/js/script.js
@@ -2,7 +2,6 @@
var savedSettings = {};
var bucketNamePattern = /[^a-z0-9.-]/;
- var refreshBucketListOnLoad = false;
var $body = $( 'body' );
var $tabs = $( '.as3cf-tab' );
@@ -173,6 +172,9 @@
$bucketList.html( '' + $bucketList.data( 'working' ) + ' ' );
+ // Stop accidental submit while reloading list.
+ this.disabledButtons();
+
var data = {
action: as3cfModal.prefix + '-get-buckets',
_nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.get_buckets
@@ -199,7 +201,7 @@
if ( 'undefined' !== typeof data[ 'success' ] ) {
$( '.as3cf-bucket-error' ).hide();
- if ( 0 === data['buckets'].length ) {
+ if ( 0 === data[ 'buckets' ].length ) {
$bucketList.html( '' + $bucketList.data( 'nothing-found' ) + ' ' );
} else {
$( data[ 'buckets' ] ).each( function( idx, bucket ) {
@@ -208,6 +210,7 @@
} );
that.scrollToSelected();
+ that.disabledButtons();
}
} else {
that.showError( as3cf.strings.get_buckets_error, data[ 'error' ], 'as3cf-bucket-select' );
@@ -232,189 +235,44 @@
},
/**
- * Reset bucket modal
- */
- resetModal: function() {
- var $bucketContainer = $( '.as3cf-bucket-container.' + as3cfModal.prefix );
-
- if ( false === $activeTab.hasClass( 'as3cf-has-bucket' ) || 'manual' === $( '#' + as3cfModal.prefix + '-bucket-select' ).val() ) {
- $bucketContainer.find( '.as3cf-bucket-manual' ).show().siblings().hide();
- $bucketContainer.find( '.bucket-actions.manual' ).show().siblings( '.bucket-actions' ).hide();
- } else {
- $bucketContainer.find( '.as3cf-bucket-select' ).show().siblings().hide();
- $bucketContainer.find( '.bucket-actions.select' ).show().siblings( '.bucket-actions' ).hide();
-
- this.loadList( refreshBucketListOnLoad );
-
- refreshBucketListOnLoad = false;
- }
-
- $bucketContainer.find( '.as3cf-bucket-error' ).hide();
-
- // Reset manual select value
- var bucket = $( '#' + as3cfModal.prefix + '-bucket' ).val();
- $bucketContainer.find( '.as3cf-bucket-manual .as3cf-bucket-name' ).val( bucket );
-
- // Unlock setting the bucket
- this.bucketSelectLock = false;
- },
-
- /**
- * Save manual bucket
- */
- saveManual: function() {
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
- var $manualBucketRegion = $manualBucketForm.find( '.bucket-manual-region' );
- var $manualBucketInput = $manualBucketForm.find( '.as3cf-bucket-name' );
- var $manualBucketButton = $manualBucketForm.find( 'button[type=submit]' );
- var bucketName = $manualBucketInput.val();
- var originalBucketText = $manualBucketButton.first().text();
-
- if ( bucketName === $( '#' + as3cfModal.prefix + '-active-bucket' ).text() ) {
- $( '.as3cf-bucket-error' ).hide();
- $activeTab.addClass( 'as3cf-has-bucket' );
- as3cfModal.close();
- return;
- }
- $( '.as3cf-bucket-error' ).hide();
- $manualBucketButton.text( $manualBucketButton.data( 'working' ) );
- $manualBucketButton.prop( 'disabled', true );
-
- var data = {
- action: as3cfModal.prefix + '-manual-save-bucket',
- bucket_name: bucketName,
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.manual_bucket
- };
-
- if ( $manualBucketRegion.val() ) {
- data[ 'region' ] = $manualBucketRegion.val();
- }
-
- var that = this;
-
- $.ajax( {
- url: ajaxurl,
- type: 'POST',
- dataType: 'JSON',
- data: data,
- error: function( jqXHR, textStatus, errorThrown ) {
- $manualBucketButton.text( originalBucketText );
- that.showError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-manual' );
- },
- success: function( data, textStatus, jqXHR ) {
- $manualBucketButton.text( originalBucketText );
- $manualBucketButton.prop( 'disabled', false );
- if ( 'undefined' !== typeof data[ 'success' ] ) {
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
- $( '#' + as3cfModal.prefix + '-bucket-select' ).val( 'manual' );
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' ).filter( '[data-bucket="' + bucketName + '"]' ).addClass( 'selected' );
-
- // Make sure the bucket list will refresh the next time the modal loads
- refreshBucketListOnLoad = true;
-
- as3cf.showSettingsSavedNotice();
- } else {
- that.showError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-manual' );
- }
- }
- } );
- },
-
- /**
- * Save select bucket
+ * Set the selected bucket in list.
*
* @param {object} $link
*/
- saveSelected: function( $link ) {
- if ( this.bucketSelectLock ) {
-
- // Bail if a bucket has already been clicked
- return;
- }
-
- // Lock the bucket selection
- this.bucketSelectLock = true;
-
- var $selectBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
- var $selectBucketRegion = $selectBucketForm.find( '.bucket-select-region' );
- var $bucketList = $selectBucketForm.find( '.as3cf-bucket-list' );
-
- if ( $link.hasClass( 'selected' ) ) {
- $activeTab.addClass( 'as3cf-has-bucket' );
- as3cfModal.close();
- return;
- }
-
- var previousBucket = $selectBucketForm.find( '.as3cf-bucket-list a.selected' ).data( 'bucket' );
-
+ setSelected: function( $link ) {
$( '.as3cf-bucket-list a' ).removeClass( 'selected' );
$link.addClass( 'selected' );
-
- $bucketList.addClass( 'saving' );
- $link.find( '.spinner' ).show().css( 'visibility', 'visible' );
- var bucketName = $link.data( 'bucket' );
-
- var data = {
- action: as3cfModal.prefix + '-save-bucket',
- bucket_name: bucketName,
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.save_bucket
- };
-
- if ( $selectBucketRegion.val() ) {
- data[ 'region' ] = $selectBucketRegion.val();
- }
-
- var that = this;
-
- $.ajax( {
- url: ajaxurl,
- type: 'POST',
- dataType: 'JSON',
- data: data,
- error: function( jqXHR, textStatus, errorThrown ) {
- $bucketList.removeClass( 'saving' );
- that.showError( as3cf.strings.save_bucket_error, errorThrown, 'as3cf-bucket-select' );
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
- $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
- },
- success: function( data, textStatus, jqXHR ) {
- $link.find( '.spinner' ).hide().css( 'visibility', 'hidden' );
- $bucketList.removeClass( 'saving' );
- if ( 'undefined' !== typeof data[ 'success' ] ) {
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
- $( '#' + as3cfModal.prefix + '-bucket-select' ).val( '' );
-
- as3cf.showSettingsSavedNotice();
- } else {
- that.showError( as3cf.strings.save_bucket_error, data[ 'error' ], 'as3cf-bucket-select' );
- $( '.as3cf-bucket-list a' ).removeClass( 'selected' );
- $( '.as3cf-bucket-list a[data-bucket="' + previousBucket + '"]' ).addClass( 'selected' );
- }
- }
- } );
+ $( '#' + as3cfModal.prefix + '-bucket-select-name' ).val( $link.data( 'bucket' ) );
},
/**
* Disable bucket buttons
*/
disabledButtons: function() {
- if ( 0 === $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' ).length ) {
+ var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' );
+ var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' );
+ var $selectBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
+
+ if ( 0 === $createBucketForm.length && 0 === $manualBucketForm.length && 0 === $selectBucketForm.length ) {
return;
}
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
-
- if ( $createBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
- } else {
+ if ( 0 < $createBucketForm.length && this.isValidName( $createBucketForm.find( '.as3cf-bucket-name' ).val() ) ) {
$createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
+ } else {
+ $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
}
- if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < 3 ) {
+ if ( 0 < $manualBucketForm.length && this.isValidName( $manualBucketForm.find( '.as3cf-bucket-name' ).val() ) ) {
+ $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
+ } else {
$manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
+ }
+
+ if ( 0 < $selectBucketForm.length && 1 === $selectBucketForm.find( '.as3cf-bucket-list a.selected' ).length ) {
+ $selectBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
} else {
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
+ $selectBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
}
},
@@ -443,127 +301,6 @@
this.bucketSelectLock = false;
},
- /**
- * Set the selected bucket in the UI
- *
- * @param {string} bucket
- * @param {string} region
- * @param {string} region_name
- * @param {boolean} canWrite
- */
- set: function( bucket, region, region_name, canWrite ) {
- var $manualBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' );
- var $selectBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' );
- var $createBucket = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' );
- var $activeRegion = $( '#' + as3cfModal.prefix + '-active-region' );
- var $activeBucket = $( '#' + as3cfModal.prefix + '-active-bucket' );
-
- if ( 'as3cf' === as3cfModal.prefix && 0 === $activeBucket.text().trim().length ) {
-
- // First time bucket select - enable main options by default
- setCheckbox( 'as3cf-copy-to-s3-wrap' );
- setCheckbox( 'as3cf-serve-from-s3-wrap' );
-
- // Update the saved settings string so we don't trigger the navigation alert
- var id = $activeTab.attr( 'id' );
- savedSettings[ id ] = serializedForm( id );
- }
-
- // Remove previous permission errors
- $( '.as3cf-error.fatal' ).hide();
-
- $activeBucket.text( bucket );
- $manualBucket.find( '.as3cf-bucket-name' ).val( bucket );
- $( '#' + as3cfModal.prefix + '-bucket' ).val( bucket );
-
- $activeRegion.text( region_name );
- $manualBucket.find( '.bucket-manual-region' ).val( region );
- $selectBucket.find( '.bucket-select-region' ).val( region );
- $createBucket.find( '.bucket-create-region' ).val( region );
- $( '#' + as3cfModal.prefix + '-region' ).val( region );
-
- $( '.updated' ).not( '.as3cf-notice' ).show();
-
- $activeTab.addClass( 'as3cf-has-bucket' );
-
- // Check permission on bucket
- $activeTab.find( '.as3cf-can-write-error' ).toggle( ! canWrite );
- $activeTab.find( '.as3cf-bucket-error' ).hide();
-
- if ( 'as3cf' === as3cfModal.prefix ) {
- generateUrlPreview();
- }
-
- setBucketLink();
-
- as3cfModal.close( function() {
- $activeTab.trigger( 'bucket-change', [ canWrite ] );
-
- // Unlock setting the bucket
- as3cf.buckets.bucketSelectLock = false;
- } );
- },
-
- /**
- * Save create bucket
- */
- create: function() {
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
- var $createBucketInput = $createBucketForm.find( '.as3cf-bucket-name' );
- var $createBucketRegion = $createBucketForm.find( '.bucket-create-region' );
- var $createBucketButton = $createBucketForm.find( 'button[type=submit]' );
-
- var bucketName = $createBucketInput.val();
- var origButtonText = $createBucketButton.text();
-
- $( '.as3cf-bucket-error' ).hide();
- $createBucketButton.text( $createBucketButton.data( 'working' ) );
- $createBucketButton.prop( 'disabled', true );
-
- var data = {
- action: as3cfModal.prefix + '-create-bucket',
- bucket_name: bucketName,
- _nonce: window[ as3cfModal.prefix.replace( /-/g, '_' ) ].nonces.create_bucket
- };
-
- if ( $createBucketRegion.val() ) {
- data[ 'region' ] = $createBucketRegion.val();
- }
-
- var that = this;
-
- $.ajax( {
- url: ajaxurl,
- type: 'POST',
- dataType: 'JSON',
- data: data,
- error: function( jqXHR, textStatus, errorThrown ) {
- $createBucketButton.text( origButtonText );
- that.showError( as3cf.strings.create_bucket_error, errorThrown, 'as3cf-bucket-create' );
- },
- success: function( data, textStatus, jqXHR ) {
- $createBucketButton.text( origButtonText );
- $createBucketButton.prop( 'disabled', false );
- if ( 'undefined' !== typeof data[ 'success' ] ) {
- that.set( bucketName, data[ 'region' ], data['region_name'], data[ 'can_write' ] );
-
- // Tidy up create bucket form
- $( '.as3cf-bucket-select-region' ).hide();
- $( '.as3cf-bucket-select-region' ).prop( 'selected', false );
- $createBucketInput.val( '' );
- $createBucketButton.prop( 'disabled', true );
-
- // Make sure the bucket list will refresh the next time the modal loads
- refreshBucketListOnLoad = true;
-
- as3cf.showSettingsSavedNotice();
- } else {
- that.showError( as3cf.strings.create_bucket_error, data[ 'error' ], 'as3cf-bucket-create' );
- }
- }
- } );
- },
-
/**
* Check for a valid bucket name
*
@@ -658,6 +395,39 @@
$( '#' + as3cfModal.prefix + '-view-bucket' ).attr( 'href', url );
}
+ /*
+ * Toggle the lost files notice
+ */
+ function toggleLostFilesNotice() {
+ if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) && $( '#as3cf-serve-from-s3' ).is( ':not(:checked)' ) ) {
+ $( '#as3cf-lost-files-notice' ).show();
+ } else {
+ $( '#as3cf-lost-files-notice' ).hide();
+ }
+ }
+
+ /*
+ * Toggle the remove local files notice
+ */
+ function toggleRemoveLocalNotice() {
+ if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) ) {
+ $( '#as3cf-remove-local-notice' ).show();
+ } else {
+ $( '#as3cf-remove-local-notice' ).hide();
+ }
+ }
+
+ /*
+ * Toggle the seo friendly url notice.
+ */
+ function toggleSEOFriendlyURLNotice( seo_friendly ) {
+ if ( true !== seo_friendly ) {
+ $( '#as3cf-seo-friendly-url-notice' ).show();
+ } else {
+ $( '#as3cf-seo-friendly-url-notice' ).hide();
+ }
+ }
+
/**
* Generate URL preview
*/
@@ -697,39 +467,6 @@
} );
}
- /*
- * Toggle the lost files notice
- */
- function toggleLostFilesNotice() {
- if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) && $( '#as3cf-serve-from-s3' ).is( ':not(:checked)' ) ) {
- $( '#as3cf-lost-files-notice' ).show();
- } else {
- $( '#as3cf-lost-files-notice' ).hide();
- }
- }
-
- /*
- * Toggle the remove local files notice
- */
- function toggleRemoveLocalNotice() {
- if ( $( '#as3cf-remove-local-file' ).is( ':checked' ) ) {
- $( '#as3cf-remove-local-notice' ).show();
- } else {
- $( '#as3cf-remove-local-notice' ).hide();
- }
- }
-
- /*
- * Toggle the seo friendly url notice.
- */
- function toggleSEOFriendlyURLNotice( seo_friendly ) {
- if ( true !== seo_friendly ) {
- $( '#as3cf-seo-friendly-url-notice' ).show();
- } else {
- $( '#as3cf-seo-friendly-url-notice' ).hide();
- }
- }
-
/**
* Update the UI with the current active tab set in the URL hash.
*/
@@ -870,38 +607,8 @@
// Move bucket errors
$( '#tab-media > .as3cf-bucket-error' ).detach().insertAfter( '.as3cf-bucket-container h3' );
- // Action click handlers
- $body.on( 'click', '.bucket-action-manual', function( e ) {
- e.preventDefault();
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-manual' ).show().siblings().hide();
- } );
- $body.on( 'click', '.bucket-action-browse', function( e ) {
- e.preventDefault();
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' ).show().siblings().hide();
- as3cf.buckets.loadList( refreshBucketListOnLoad );
- refreshBucketListOnLoad = false;
- } );
- $body.on( 'click', '.bucket-action-create', function( e ) {
- e.preventDefault();
-
- // Reset create bucket modal
- $( '.as3cf-bucket-name' ).val( '' );
- $( '.as3cf-invalid-bucket-name' ).html( '' );
-
- $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-create' ).show().siblings().hide();
- } );
- $body.on( 'click', '.bucket-action-cancel', function( e ) {
- e.preventDefault();
- as3cf.buckets.resetModal();
- } );
- $body.on( 'click', '.bucket-action-save', function( e ) {
- e.preventDefault();
- as3cf.buckets.saveManual();
- } );
- $body.on( 'click', '.as3cf-create-bucket-form button[type="submit"]', function( e ) {
- e.preventDefault();
- as3cf.buckets.create();
- } );
+ // Enable/disable change bucket's save buttons.
+ as3cf.buckets.disabledButtons();
// Bucket list refresh handler
$body.on( 'click', '.bucket-action-refresh', function( e ) {
@@ -915,10 +622,16 @@
as3cf.buckets.loadList( true );
} );
+ // If select bucket form is available on load, populate its list.
+ if ( 0 < $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-bucket-select' ).length ) {
+ as3cf.buckets.loadList( true );
+ }
+
// Bucket list click handler
$body.on( 'click', '.as3cf-bucket-list a', function( e ) {
e.preventDefault();
- as3cf.buckets.saveSelected( $( this ) );
+ as3cf.buckets.setSelected( $( this ) );
+ as3cf.buckets.disabledButtons();
} );
// External links click handler
@@ -929,45 +642,25 @@
return false;
} );
- // Modal open
- $body.on( 'as3cf-modal-open', function( e, target ) {
- if ( '.as3cf-bucket-container.' + as3cfModal.prefix === target ) {
-
- // Reset modal
- as3cf.buckets.resetModal();
-
- // Change manual title text
- var title = $( '.as3cf-bucket-manual h3' ).data( 'modal-title' );
- $( '.as3cf-bucket-manual h3' ).text( title );
-
- // Hide buttons
- as3cf.buckets.disabledButtons();
- }
- } );
-
- as3cf.buckets.disabledButtons();
-
// Validate bucket name on create
- $body.on( 'input keyup', '.as3cf-create-bucket-form .as3cf-bucket-name', function( e ) {
+ $body.on( 'input keyup', '.as3cf-bucket-create .as3cf-bucket-name', function( e ) {
var bucketName = $( this ).val();
- var $createBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-create-bucket-form' );
+ as3cf.buckets.updateNameNotice( bucketName );
+ as3cf.buckets.disabledButtons();
+ } );
- if ( as3cf.buckets.isValidName( bucketName ) ) {
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
- } else {
- $createBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
- }
+ $body.on( 'input keyup', '.as3cf-bucket-manual .as3cf-bucket-name', function( e ) {
+ var bucketName = $( this ).val();
as3cf.buckets.updateNameNotice( bucketName );
+ as3cf.buckets.disabledButtons();
} );
- // Check bucket name length on manual
- $body.on( 'input keyup', '.as3cf-manual-save-bucket-form .as3cf-bucket-name', function( e ) {
- var $manualBucketForm = $( '.as3cf-bucket-container.' + as3cfModal.prefix + ' .as3cf-manual-save-bucket-form' );
+ // Don't allow 'enter' key to submit form on text input settings
+ $( '.as3cf-bucket-container input[type="text"]' ).keypress( function( event ) {
+ if ( 13 === event.which ) {
+ event.preventDefault();
- if ( $manualBucketForm.find( '.as3cf-bucket-name' ).val().length < as3cf.buckets.validLength ) {
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', true );
- } else {
- $manualBucketForm.find( 'button[type=submit]' ).prop( 'disabled', false );
+ return false;
}
} );
} );
diff --git a/assets/js/script.min.js b/assets/js/script.min.js
index 97aaabd4..e9ef10ca 100644
--- a/assets/js/script.min.js
+++ b/assets/js/script.min.js
@@ -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(''+f.data("working")+" ");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(''+f.data("nothing-found")+" "):(a(b.buckets).each(function(a,b){var c=b.Name===g?"selected":"";f.append(' '+b.Name+' ')}),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+" —"),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("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().length1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').addClass("selected"),void this.scrollToSelected();f.html(''+f.data("working")+" "),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(''+f.data("nothing-found")+" "):(a(b.buckets).each(function(a,b){var c=b.Name===g?"selected":"";f.append(' '+b.Name+' ')}),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||(063)&&!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("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 get_defined_setting( 'region', false ) ) {
- $region = $this->get_defined_setting( 'region' );
- } elseif (
- ( ! isset( $_POST['region'] ) || ! ( $region = sanitize_text_field( $_POST['region'] ) ) ) &&
- $region_required // It's very important that this test is after the above inline assign!
- ) { // input var okay
- $out = array( 'error' => __( 'No region provided.', 'amazon-s3-and-cloudfront' ) );
-
- $this->end_ajax( $out );
+ return AS3CF_REGION;
}
- return $region;
- }
+ // If defined in settings define, just use.
+ if ( false !== $this->get_defined_setting( 'region', false ) ) {
+ return $this->get_defined_setting( 'region' );
+ }
- /**
- * Returns cleaned up bucket name or kills ajax request if missing.
- *
- * @return string
- */
- function ajax_check_bucket() {
- if ( ! isset( $_POST['bucket_name'] ) || ! ( $bucket = sanitize_text_field( $_POST['bucket_name'] ) ) ) { // input var okay
- $out = array( 'error' => __( 'No bucket name provided.', 'amazon-s3-and-cloudfront' ) );
+ if ( ! empty( $region ) ) {
+ $region = sanitize_text_field( $region );
+ }
- $this->end_ajax( $out );
+ if ( $region_required && empty( $region ) ) {
+ return false;
}
- return strtolower( $bucket );
+ return $region;
}
/**
- * Handler for AJAX callback to create a bucket in provider
+ * Returns cleaned up bucket name or returns false if missing.
*
- * @throws Exception
+ * @param string $bucket
+ *
+ * @return string|bool
*/
- function ajax_create_bucket() {
- $this->verify_ajax_request();
-
- $region = $this->ajax_check_region( true );
- $bucket = $this->ajax_check_bucket();
-
- $result = $this->create_bucket( $bucket, $region );
-
- if ( is_wp_error( $result ) ) {
- $out = $this->prepare_bucket_error( $result, false );
+ function check_bucket( $bucket ) {
+ $bucket = sanitize_text_field( $bucket );
- $this->end_ajax( $out );
- }
-
- // check if we were previously selecting a bucket manually via the input
- $previous_manual_bucket_select = $this->get_setting( 'manual_bucket', false );
-
- $args = array(
- '_nonce' => wp_create_nonce( 'as3cf-create-bucket' ),
- );
-
- $this->save_bucket_for_ajax( $bucket, $previous_manual_bucket_select, $region, $args );
+ return empty( $bucket ) ? false : strtolower( $bucket );
}
/**
@@ -2481,76 +2450,20 @@ function create_bucket( $bucket_name, $region = false ) {
return true;
}
- /**
- * Handler for AJAX callback to save the selection of a bucket
- *
- * @throws Exception
- */
- function ajax_save_bucket() {
- $this->verify_ajax_request();
-
- $region = $this->ajax_check_region( $this->get_provider()->region_required() );
- $bucket = $this->ajax_check_bucket();
-
- $manual = false;
- // are we inputting the bucket manually?
- if ( isset( $_POST['action'] ) && false !== strpos( $_POST['action'], 'manual-save-bucket' ) ) {
- $manual = true;
- }
-
- $this->save_bucket_for_ajax( $bucket, $manual, $region );
- }
-
- /**
- * Wrapper method for saving a bucket when creating or selecting
- *
- * @param string $bucket
- * @param bool|false $manual_select
- * @param null|string $region
- * @param array $defaults
- *
- * @throws Exception
- */
- function save_bucket_for_ajax( $bucket, $manual_select = false, $region = null, $defaults = array() ) {
- $region = $this->save_bucket( $bucket, $manual_select, $region );
-
- if ( ! is_wp_error( $region ) ) {
- $out = array(
- 'success' => '1',
- 'region' => $region,
- 'region_name' => $this->get_provider()->get_region_name( $region ),
- );
-
- $out = wp_parse_args( $out, $defaults );
-
- $can_write = $this->check_write_permission( $bucket, $region );
-
- if ( is_wp_error( $can_write ) ) {
- $out = $this->prepare_bucket_error( $can_write );
- } else {
- $out['can_write'] = $can_write;
- }
- } else {
- $out = $this->prepare_bucket_error( $region );
- }
-
- $this->end_ajax( $out );
- }
-
/**
* Prepare the bucket error before returning to JS
*
* @param WP_Error $object
* @param bool $single Are we dealing with a single bucket?
*
- * @return array
+ * @return string
*/
function prepare_bucket_error( $object, $single = true ) {
if ( 'Access Denied' === $object->get_error_message() ) {
// If the bucket error is access denied, show our notice message
- $out = array( 'error' => $this->get_access_denied_notice_message( $single ) );
+ $out = $this->get_access_denied_notice_message( $single );
} else {
- $out = array( 'error' => $object->get_error_message() );
+ $out = $object->get_error_message();
}
return $out;
@@ -2577,7 +2490,7 @@ function pre_set_setting( $key, $value ) {
* @param bool $manual if we are entering the bucket via the manual input form
* @param null|string $region
*
- * @return string|bool region on success
+ * @return string|bool|WP_Error region on success
*/
function save_bucket( $bucket_name, $manual = false, $region = null ) {
if ( $bucket_name ) {
@@ -2780,12 +2693,15 @@ function get_provider_object_region( $provider_object, $post_id = null ) {
function ajax_get_buckets() {
$this->verify_ajax_request();
- $region = $this->ajax_check_region( $this->get_provider()->region_required() );
+ $region = empty( $_POST['region'] ) ? '' : $_POST['region'];
+ $region = $this->check_region( $region, $this->get_provider()->region_required() );
$result = $this->get_buckets( $region );
if ( is_wp_error( $result ) ) {
- $out = $this->prepare_bucket_error( $result, false );
+ $out = array(
+ 'error' => $this->prepare_bucket_error( $result, false ),
+ );
} else {
$out = array(
'success' => '1',
@@ -2829,6 +2745,11 @@ function check_write_permission( $bucket = null, $region = null ) {
}
if ( is_null( $bucket ) ) {
+ // If changing provider or bucket don't bother to test saved bucket permissions.
+ if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'change-provider', 'change-bucket' ) ) ) {
+ return false;
+ }
+
if ( ! ( $bucket = $this->get_setting( 'bucket' ) ) ) {
// if no bucket set then no need check
return true;
@@ -2868,16 +2789,22 @@ function check_write_permission( $bucket = null, $region = null ) {
/**
* Render error messages in a view for bucket permission and access issues
+ *
+ * @return bool
+ * @throws Exception
*/
function render_bucket_permission_errors() {
$can_write = $this->check_write_permission();
// catch any checking issues
if ( is_wp_error( $can_write ) ) {
$this->render_view( 'error-fatal', array( 'message' => $can_write->get_error_message() ) );
- $can_write = true;
+ $can_write = false;
+ } else {
+ // display a error message if the user does not have write permission to S3 bucket
+ $this->render_view( 'error-access', array( 'can_write' => $can_write ) );
}
- // display a error message if the user does not have write permission to S3 bucket
- $this->render_view( 'error-access', array( 'can_write' => $can_write ) );
+
+ return $can_write;
}
/**
@@ -2995,6 +2922,19 @@ function get_settings_whitelist() {
);
}
+ /**
+ * Get the blacklisted settings for monitoring changes in defines.
+ * These settings will not be saved in the database.
+ *
+ * @return array
+ */
+ function get_monitored_settings_blacklist() {
+ return array(
+ 'access-key-id',
+ 'secret-access-key',
+ );
+ }
+
/**
* List of settings that should skip full sanitize.
*
@@ -3007,7 +2947,7 @@ function get_skip_sanitize_settings() {
/**
* Handle the saving of the settings page
*/
- function handle_post_request() {
+ public function handle_post_request() {
if ( empty( $_POST['plugin'] ) || $this->get_plugin_slug() != sanitize_key( $_POST['plugin'] ) ) { // input var okay
return;
}
@@ -3020,9 +2960,176 @@ function handle_post_request() {
die( __( "Cheatin' eh?", 'amazon-s3-and-cloudfront' ) );
}
+ if ( $this->get_provider()->needs_access_keys() || ( ! empty( $_GET['action'] ) && 'change-provider' === $_GET['action'] ) ) {
+ // Changing Provider currently doesn't need anything special over saving settings,
+ // but if not already set needs to be handled rather than change-bucket raising its hand.
+ $changed_keys = $this->handle_save_settings();
+ } elseif ( empty( $this->get_setting( 'bucket' ) ) || ( ! empty( $_GET['action'] ) && 'change-bucket' === $_GET['action'] ) ) {
+ $changed_keys = $this->handle_change_bucket();
+ } elseif ( ! empty( $_GET['action'] ) ) {
+ $changed_keys = apply_filters( 'as3cf_handle_post_request', array() );
+ } else {
+ $changed_keys = $this->handle_save_settings();
+ }
+
+ // If the changes can't be saved, stay on same page.
+ // An admin notice should be created with the error message.
+ if ( false === $changed_keys ) {
+ return;
+ }
+
+ // No failures, so let's make things super green.
+ $url_args = array( 'updated' => '1' );
+
+ if ( ! empty( $changed_keys ) ) {
+ $action = null;
+
+ foreach ( $changed_keys as $key ) {
+ // If anything about the Provider has changed then we need to verify the bucket selection.
+ // Otherwise we can let the filter decide whether there is an action to take.
+ // Last implementer will win, but the above handlers take care of grouping things appropriately.
+ if ( in_array( $key, array( 'provider', 'access-key-id', 'secret-access-key' ) ) && ! $this->get_defined_setting( 'bucket', false ) ) {
+ $action = 'change-bucket';
+ break;
+ } else {
+ $action = apply_filters( 'as3cf_action_for_changed_settings_key', $action, $key );
+ }
+ }
+ }
+
+ // Stash which step we're on in possibly multi-step config.
+ $prev_action = ! empty( $_GET['action'] ) ? $_GET['action'] : null;
+
+ // Depending on the step we're on, we may need another step if not already determined by newly saved settings.
+ if ( empty( $action ) && ! empty( $prev_action ) ) {
+ // After change-provider we always want the user to confirm the bucket is still ok.
+ // This gets round the change-provider => change-bucket => "back" problem.
+ // but then no change in provider settings problem.
+ if ( 'change-provider' === $prev_action && ! $this->get_defined_setting( 'bucket', false ) ) {
+ $action = 'change-bucket';
+ }
+ }
+
+ if ( ! empty( $action ) ) {
+ $url_args['action'] = $action;
+ }
+
+ if ( ! empty( $prev_action ) ) {
+ $url_args['prev_action'] = $prev_action;
+ }
+
+ $url = $this->get_plugin_page_url( $url_args );
+ wp_redirect( $url );
+ exit;
+ }
+
+ /**
+ * Handle saving change in bucket as submitted by user, whether create, enter or select.
+ *
+ * @return array|bool
+ * @throws Exception
+ */
+ private function handle_change_bucket() {
+ // Quick check that bucket name actually given.
+ $bucket = empty( $_POST['bucket_name'] ) ? false : $_POST['bucket_name'];
+
+ if ( false === $bucket ) {
+ $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' ) );
+
+ return false;
+ }
+
+ // Check and set bucket.
+ $bucket = $this->check_bucket( $bucket );
+
+ if ( false === $bucket ) {
+ $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' ) );
+
+ return false;
+ }
+
+ $bucket_mode = empty( $_GET['bucket_mode'] ) ? 'manual' : $_GET['bucket_mode'];
+
+ // Check and set region.
+ $region = empty( $_POST['region_name'] ) ? '' : $_POST['region_name'];
+ $region_required = 'create' === $bucket_mode ? true : $this->get_provider()->region_required();
+ $region = $this->check_region( $region, $region_required );
+
+ if ( false === $region ) {
+ $this->notices->add_notice( __( 'No region provided.', 'amazon-s3-and-cloudfront' ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
+
+ return false;
+ }
+
+ // Are we creating a bucket?
+ if ( 'create' === $bucket_mode ) {
+ $result = $this->create_bucket( $bucket, $region );
+
+ if ( is_wp_error( $result ) ) {
+ $this->notices->add_notice( $this->prepare_bucket_error( $result, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
+
+ return false;
+ }
+
+ // Check if we were previously selecting a bucket manually via the input.
+ $manual_select = $this->get_setting( 'manual_bucket', false );
+
+ $args = array(
+ '_nonce' => wp_create_nonce( 'as3cf-create-bucket' ),
+ );
+ } elseif ( 'manual' === $bucket_mode ) {
+ $manual_select = true;
+ } else {
+ $manual_select = false;
+ }
+
+ // Stash the current bucket and region before they change.
+ $old_bucket = $this->get_setting( 'bucket', false );
+ $old_region = $this->get_setting( 'region', '' );
+
+ // Set bucket.
+ $region = $this->save_bucket( $bucket, $manual_select, $region );
+
+ if ( is_wp_error( $region ) ) {
+ $this->notices->add_notice( $this->prepare_bucket_error( $region, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
+
+ return false;
+ }
+
+ $can_write = $this->check_write_permission( $bucket, $region );
+
+ if ( is_wp_error( $can_write ) ) {
+ $this->notices->add_notice( $this->prepare_bucket_error( $can_write, false ), array( 'type' => 'error', 'only_show_in_settings' => true, 'only_show_on_tab' => 'media' ) );
+
+ return false;
+ }
+
+ // Tell the parent handler whether the bucket or region have changed.
+ $changed_keys = array();
+
+ if ( ! $old_bucket || $bucket !== $old_bucket ) {
+ $changed_keys[] = 'bucket';
+ }
+
+ if ( $region !== $old_region ) {
+ $changed_keys[] = 'region';
+ }
+
+ return $changed_keys;
+ }
+
+ /**
+ * Handle saving settings submitted by user.
+ *
+ * @return array
+ */
+ private function handle_save_settings() {
+ $changed_keys = array();
+
do_action( 'as3cf_pre_save_settings' );
- $post_vars = $this->get_settings_whitelist();
+ $post_vars = $this->get_settings_whitelist();
+ $old_settings = $this->get_settings();
foreach ( $post_vars as $var ) {
// Special case for when Secret Access Key is not changed.
@@ -3039,13 +3146,16 @@ function handle_post_request() {
$value = $this->sanitize_setting( $var, $_POST[ $var ] );
$this->set_setting( $var, $value );
+
+ // Some setting changes might have knock-on effects that require confirmation of secondary settings.
+ if ( isset( $old_settings[ $var ] ) && $old_settings[ $var ] !== $value ) {
+ $changed_keys[] = $var;
+ }
}
$this->save_settings();
- $url = $this->get_plugin_page_url( array( 'updated' => '1' ) );
- wp_redirect( $url );
- exit;
+ return $changed_keys;
}
/**
@@ -3340,7 +3450,6 @@ function get_image_sizes_details() {
} elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
$size_details .= $size . ' (' . $_wp_additional_image_sizes[ $size ]['width'] . 'x' . $_wp_additional_image_sizes[ $size ]['height'] . ')' . "\r\n";
}
-
}
return $size_details;
@@ -4429,7 +4538,7 @@ public function load_media_assets() {
}
/**
- * Handle retieving the S3 details for attachment modals.
+ * Handle retrieving the provider details for attachment modals.
*/
public function ajax_get_attachment_provider_details() {
if ( ! isset( $_POST['id'] ) ) {
@@ -4724,7 +4833,7 @@ public function handle_aws_access_key_form_header() {
* @return array Attachment's cleaned up metadata.
*/
public function maybe_cleanup_filesize_metadata( $post_id, $data, $update_metadata = true ) {
- if ( ! is_int( $post_id ) || empty( $post_id ) || empty( $data ) ) {
+ if ( ! is_int( $post_id ) || empty( $post_id ) || empty( $data ) || ! is_array( $data ) ) {
return $data;
}
diff --git a/classes/as3cf-compatibility-check.php b/classes/as3cf-compatibility-check.php
index 0091d596..e43d7440 100644
--- a/classes/as3cf-compatibility-check.php
+++ b/classes/as3cf-compatibility-check.php
@@ -369,7 +369,7 @@ public function get_error_msg() {
global $as3cfpro;
if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
// Don't show update link for addons of a licensed plugin where the license is invalid
- if ( ! $as3cfpro->is_valid_licence() ) {
+ if ( ! $as3cfpro->is_valid_licence( false, true ) ) {
$msg .= ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
$msg .= $hide_notice_msg;
@@ -407,7 +407,7 @@ public function get_error_msg() {
global $as3cfpro;
if ( ! empty( $as3cfpro ) && $as3cfpro->get_plugin_slug( true ) === $this->parent_plugin_slug ) {
// Don't show update link for addons of a licensed plugin where the license is invalid
- if ( ! $as3cfpro->is_valid_licence() ) {
+ if ( ! $as3cfpro->is_valid_licence( false, true ) ) {
$upgrade_msg = ' ' . sprintf( __( 'A valid license for %s is required to update.', 'amazon-s3-and-cloudfront' ), $this->get_parent_plugin_name() );
}
}
diff --git a/classes/as3cf-plugin-base.php b/classes/as3cf-plugin-base.php
index a45b19ce..42a1d1f2 100644
--- a/classes/as3cf-plugin-base.php
+++ b/classes/as3cf-plugin-base.php
@@ -114,7 +114,13 @@ public function get_plugin_pagenow() {
*/
function get_settings( $force = false ) {
if ( is_null( $this->settings ) || $force ) {
- $this->settings = $this->filter_settings( get_site_option( static::SETTINGS_KEY ) );
+ $saved_settings = get_site_option( static::SETTINGS_KEY );
+ $this->settings = $this->filter_settings( $saved_settings );
+
+ // If defined settings keys have changed since last time settings were saved to database, re-save to remove the new keys.
+ if ( ! empty( $saved_settings ) && ! empty( $this->defined_settings ) && ! empty( array_intersect_key( $saved_settings, $this->defined_settings ) ) ) {
+ $this->save_settings();
+ }
}
return $this->settings;
@@ -170,7 +176,7 @@ function get_defined_settings( $force = false ) {
// Normalize the defined settings before saving, so we can detect when a real change happens.
ksort( $this->defined_settings );
- update_site_option( 'as3cf_constant_' . static::settings_constant(), $this->defined_settings );
+ update_site_option( 'as3cf_constant_' . static::settings_constant(), array_diff_key( $this->defined_settings, array_flip( $this->get_monitored_settings_blacklist() ) ) );
}
return $this->defined_settings;
@@ -280,6 +286,17 @@ function get_settings_whitelist() {
return array();
}
+ /**
+ * Get the blacklisted settings for monitoring changes in defines.
+ * These settings will not be saved in the database.
+ * Meant to be overridden in child classes.
+ *
+ * @return array
+ */
+ function get_monitored_settings_blacklist() {
+ return array();
+ }
+
/**
* List of settings that should skip full sanitize.
*
@@ -424,7 +441,7 @@ public function save_settings() {
ksort( $this->settings );
}
- $this->update_site_option( static::SETTINGS_KEY, $this->settings );
+ $this->update_site_option( static::SETTINGS_KEY, array_diff_key( $this->settings, $this->defined_settings ) );
}
/**
diff --git a/classes/providers/aws-provider.php b/classes/providers/aws-provider.php
index 0e4c0a50..d876cca1 100644
--- a/classes/providers/aws-provider.php
+++ b/classes/providers/aws-provider.php
@@ -63,6 +63,13 @@ class AWS_Provider extends Provider {
*/
protected static $provider_service_name = 'Amazon S3';
+ /**
+ * The slug for the service's quick start guide doc.
+ *
+ * @var string
+ */
+ protected static $provider_service_quick_start_slug = 'amazon-s3-quick-start-guide';
+
/**
* @var array
*/
diff --git a/classes/providers/digitalocean-provider.php b/classes/providers/digitalocean-provider.php
index 7020f430..6062943f 100644
--- a/classes/providers/digitalocean-provider.php
+++ b/classes/providers/digitalocean-provider.php
@@ -45,6 +45,13 @@ class DigitalOcean_Provider extends AWS_Provider {
*/
protected static $provider_service_name = '';
+ /**
+ * The slug for the service's quick start guide doc.
+ *
+ * @var string
+ */
+ protected static $provider_service_quick_start_slug = 'digitalocean-spaces-quick-start-guide';
+
/**
* @var array
*/
diff --git a/classes/providers/provider.php b/classes/providers/provider.php
index 91c43433..88149541 100644
--- a/classes/providers/provider.php
+++ b/classes/providers/provider.php
@@ -60,6 +60,13 @@ abstract class Provider {
*/
protected static $provider_service_name = '';
+ /**
+ * The slug for the service's quick start guide doc.
+ *
+ * @var string
+ */
+ protected static $provider_service_quick_start_slug = 'quick-start-guide';
+
/**
* @var string
*/
@@ -166,6 +173,15 @@ public static function get_provider_service_name() {
return static::$provider_name . ' ' . static::$service_name;
}
+ /**
+ * Returns the slug for the service's quick start guide doc.
+ *
+ * @return string
+ */
+ public static function get_provider_service_quick_start_slug() {
+ return static::$provider_service_quick_start_slug;
+ }
+
/**
* Whether or not access keys are needed.
*
diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot
index a1821cdf..693c8537 100644
--- a/languages/amazon-s3-and-cloudfront-en.pot
+++ b/languages/amazon-s3-and-cloudfront-en.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: amazon-s3-and-cloudfront\n"
"Report-Msgid-Bugs-To: nom@deliciousbrains.com\n"
-"POT-Creation-Date: 2018-09-25 11:15+0100\n"
+"POT-Creation-Date: 2018-12-17 10:03+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -22,164 +22,168 @@ msgstr ""
msgid "Offload Media"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:279
-#: classes/amazon-s3-and-cloudfront.php:293
+#: classes/amazon-s3-and-cloudfront.php:276
+#: classes/amazon-s3-and-cloudfront.php:290
msgid "Unknown"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:347
+#: classes/amazon-s3-and-cloudfront.php:344
#: view/bucket-setting.php:17
-#: view/provider-select.php:85
+#: view/provider-select.php:88
msgid "defined in wp-config.php"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:1093
-#: classes/amazon-s3-and-cloudfront.php:1232
+#: classes/amazon-s3-and-cloudfront.php:1090
+#: classes/amazon-s3-and-cloudfront.php:1229
#, php-format
msgid "File %s does not exist"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:1106
+#: classes/amazon-s3-and-cloudfront.php:1103
#, php-format
msgid "Mime type %s is not allowed"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:1117
+#: classes/amazon-s3-and-cloudfront.php:1114
msgid "Already offloaded to a different provider"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:1196
-#: classes/amazon-s3-and-cloudfront.php:1240
+#: classes/amazon-s3-and-cloudfront.php:1193
+#: classes/amazon-s3-and-cloudfront.php:1237
#, php-format
msgid "Error offloading %s to provider: %s"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2364
+#: classes/amazon-s3-and-cloudfront.php:2361
msgid "This action can only be performed through an admin screen."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2366
+#: classes/amazon-s3-and-cloudfront.php:2363
msgid "Cheatin’ eh?"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2368
+#: classes/amazon-s3-and-cloudfront.php:2365
msgid "You do not have sufficient permissions to access this page."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2403
-msgid "No region provided."
-msgstr ""
-
-#: classes/amazon-s3-and-cloudfront.php:2418
-msgid "No bucket name provided."
-msgstr ""
-
-#: classes/amazon-s3-and-cloudfront.php:2732
+#: classes/amazon-s3-and-cloudfront.php:2645
msgid "Error Getting Bucket Region"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2733
+#: classes/amazon-s3-and-cloudfront.php:2646
#, php-format
msgid "There was an error attempting to get the region of the bucket %s: %s"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2852
+#: classes/amazon-s3-and-cloudfront.php:2773
msgid ""
"This is a test file to check if the user has write permission to S3. Delete "
"me if found."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2858
+#: classes/amazon-s3-and-cloudfront.php:2779
#, php-format
msgid ""
"There was an error attempting to check the permissions of the bucket %s: %s"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2934
+#: classes/amazon-s3-and-cloudfront.php:2861
msgid "Error creating bucket"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2935
+#: classes/amazon-s3-and-cloudfront.php:2862
msgid "Bucket name too short."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2936
+#: classes/amazon-s3-and-cloudfront.php:2863
msgid "Bucket name too long."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2937
+#: classes/amazon-s3-and-cloudfront.php:2864
msgid ""
"Invalid character. Bucket names can contain lowercase letters, numbers, "
"periods and hyphens."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2938
+#: classes/amazon-s3-and-cloudfront.php:2865
msgid "Error saving bucket"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2939
+#: classes/amazon-s3-and-cloudfront.php:2866
msgid "Error fetching buckets"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2940
+#: classes/amazon-s3-and-cloudfront.php:2867
msgid "Error getting URL preview: "
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2941
+#: classes/amazon-s3-and-cloudfront.php:2868
msgid "The changes you made will be lost if you navigate away from this page"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2942
+#: classes/amazon-s3-and-cloudfront.php:2869
msgid "Getting diagnostic info..."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2943
+#: classes/amazon-s3-and-cloudfront.php:2870
msgid "Error getting diagnostic info: "
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2944
+#: classes/amazon-s3-and-cloudfront.php:2871
msgctxt "placeholder for hidden access key, 39 char max"
msgid "-- not shown --"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:2946
-#: classes/amazon-s3-and-cloudfront.php:4662
+#: classes/amazon-s3-and-cloudfront.php:2873
+#: classes/amazon-s3-and-cloudfront.php:4771
msgid "Settings saved."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3020
+#: classes/amazon-s3-and-cloudfront.php:2960
msgid "Cheatin' eh?"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3029
-#: view/provider-select.php:219
+#: classes/amazon-s3-and-cloudfront.php:3037
+msgid "No bucket name provided."
+msgstr ""
+
+#: classes/amazon-s3-and-cloudfront.php:3046
+msgid "No bucket name not valid."
+msgstr ""
+
+#: classes/amazon-s3-and-cloudfront.php:3059
+msgid "No region provided."
+msgstr ""
+
+#: classes/amazon-s3-and-cloudfront.php:3136
+#: view/provider-select.php:227
msgctxt "placeholder for hidden secret access key, 39 char max"
msgid "-- not shown --"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3074
+#: classes/amazon-s3-and-cloudfront.php:3184
msgctxt "Show the media library tab"
msgid "Media Library"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3075
+#: classes/amazon-s3-and-cloudfront.php:3185
msgctxt "Show the addons tab"
msgid "Addons"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3076
+#: classes/amazon-s3-and-cloudfront.php:3186
msgctxt "Show the support tab"
msgid "Support"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3295
+#: classes/amazon-s3-and-cloudfront.php:3405
#, php-format
msgid ""
"WP Offload Media — The file %s has been given %s "
"permissions in the bucket."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3314
+#: classes/amazon-s3-and-cloudfront.php:3424
msgid ""
"WP Offload Media Requirement Missing — Looks like you "
"don't have an image manipulation library installed on this server and "
@@ -187,18 +191,18 @@ msgid ""
"Please setup GD or ImageMagick."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3942
+#: classes/amazon-s3-and-cloudfront.php:4051
#, php-format
msgid ""
"Define your access keys to enable write access to the "
"bucket"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3949
+#: classes/amazon-s3-and-cloudfront.php:4058
msgid "Quick Start Guide"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3951
+#: classes/amazon-s3-and-cloudfront.php:4060
#, php-format
msgid ""
"Looks like we don't have write access to this bucket. It's likely that the "
@@ -207,7 +211,7 @@ msgid ""
"correctly."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:3953
+#: classes/amazon-s3-and-cloudfront.php:4062
#, php-format
msgid ""
"Looks like we don't have access to the buckets. It's likely that the user "
@@ -215,39 +219,39 @@ msgid ""
"Please see our %s for instructions on setting up permissions correctly."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4103
+#: classes/amazon-s3-and-cloudfront.php:4212
msgid "WP Offload Media Activation"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4104
+#: classes/amazon-s3-and-cloudfront.php:4213
msgid ""
"WP Offload Media Lite and WP Offload Media cannot both be active. We've "
"automatically deactivated WP Offload Media Lite."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4106
+#: classes/amazon-s3-and-cloudfront.php:4215
msgid "WP Offload Media Lite Activation"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4107
+#: classes/amazon-s3-and-cloudfront.php:4216
msgid ""
"WP Offload Media Lite and WP Offload Media cannot both be active. We've "
"automatically deactivated WP Offload Media."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4159
+#: classes/amazon-s3-and-cloudfront.php:4268
msgid "More info »"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4254
+#: classes/amazon-s3-and-cloudfront.php:4363
msgid "this doc"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4256
+#: classes/amazon-s3-and-cloudfront.php:4365
msgid "WP Offload Media Feature Removed"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4257
+#: classes/amazon-s3-and-cloudfront.php:4366
#, php-format
msgid ""
"You had the \"Always non-SSL\" option selected in your settings, but we've "
@@ -258,59 +262,59 @@ msgid ""
"to the old behavior."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4287
+#: classes/amazon-s3-and-cloudfront.php:4396
msgid "Offload"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4395
+#: classes/amazon-s3-and-cloudfront.php:4504
msgctxt "Storage provider key name"
msgid "Storage Provider"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4396
+#: classes/amazon-s3-and-cloudfront.php:4505
msgctxt "Storage provider name"
msgid "Storage Provider"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4397
+#: classes/amazon-s3-and-cloudfront.php:4506
msgctxt "Bucket name"
msgid "Bucket"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4398
+#: classes/amazon-s3-and-cloudfront.php:4507
msgctxt "Path to file in bucket"
msgid "Path"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4399
+#: classes/amazon-s3-and-cloudfront.php:4508
msgctxt "Location of bucket"
msgid "Region"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4400
+#: classes/amazon-s3-and-cloudfront.php:4509
msgctxt "Access control list of the file in bucket"
msgid "Access"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4401
+#: classes/amazon-s3-and-cloudfront.php:4510
msgid "URL"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4625
+#: classes/amazon-s3-and-cloudfront.php:4734
msgid "Assets Pull"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4626
+#: classes/amazon-s3-and-cloudfront.php:4735
msgid ""
"An addon for WP Offload Media to serve your site's JS, CSS, and other "
"enqueued assets from Amazon CloudFront or another CDN."
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4630
+#: classes/amazon-s3-and-cloudfront.php:4739
msgid "Feature"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4676
+#: classes/amazon-s3-and-cloudfront.php:4785
#, php-format
msgid ""
"Amazon Web Services Plugin No Longer Required — As of "
@@ -321,7 +325,7 @@ msgid ""
"plugin, it should be safe to deactivate and delete it. %2$s"
msgstr ""
-#: classes/amazon-s3-and-cloudfront.php:4708
+#: classes/amazon-s3-and-cloudfront.php:4817
#, php-format
msgid ""
"WP Offload Media Settings Moved — You now define your "
@@ -441,7 +445,7 @@ msgstr ""
msgid "Invalid notice ID."
msgstr ""
-#: classes/as3cf-plugin-base.php:499
+#: classes/as3cf-plugin-base.php:516
msgid "Settings"
msgstr ""
@@ -465,7 +469,7 @@ msgid ""
"Offload Media will require PHP %2$s or later. %3$s"
msgstr ""
-#: classes/providers/provider.php:361
+#: classes/providers/provider.php:377
#, php-format
msgid "You must first set your access keys ."
msgstr ""
@@ -618,96 +622,86 @@ msgstr ""
msgid "File does not exist on server"
msgstr ""
-#: view/bucket-select.php:10
-msgid "Change bucket"
+#: view/bucket-select.php:30
+#: view/provider-select.php:14
+msgid "« Back"
msgstr ""
-#: view/bucket-select.php:10
+#: view/bucket-select.php:36
msgid "What bucket would you like to use?"
msgstr ""
-#: view/bucket-select.php:24
-#: view/bucket-select.php:80
-#: view/bucket-select.php:136
+#: view/bucket-select.php:49
+#: view/bucket-select.php:102
+#: view/bucket-select.php:155
msgid "Region:"
msgstr ""
-#: view/bucket-select.php:39
-#: view/bucket-select.php:95
-#: view/bucket-select.php:151
+#: view/bucket-select.php:64
+#: view/bucket-select.php:117
+#: view/bucket-select.php:170
#, php-format
msgid "%s (defined in wp-config.php)"
msgstr ""
-#: view/bucket-select.php:46
-#: view/bucket-select.php:101
-#: view/bucket-select.php:157
+#: view/bucket-select.php:71
+#: view/bucket-select.php:123
+#: view/bucket-select.php:176
#: view/bucket-setting.php:8
msgid "Bucket:"
msgstr ""
-#: view/bucket-select.php:49
+#: view/bucket-select.php:74
msgid "Existing bucket name"
msgstr ""
-#: view/bucket-select.php:54
-#: view/bucket-select.php:59
-msgid "Saving..."
-msgstr ""
-
-#: view/bucket-select.php:54
-#: view/bucket-select.php:59
-msgid "Save Bucket"
+#: view/bucket-select.php:80
+msgid "Save Bucket Setting"
msgstr ""
-#: view/bucket-select.php:55
+#: view/bucket-select.php:81
+#: view/bucket-select.php:186
msgid "Browse existing buckets"
msgstr ""
-#: view/bucket-select.php:56
-#: view/bucket-select.php:117
-#: view/bucket-select.php:122
+#: view/bucket-select.php:82
+#: view/bucket-select.php:137
+#: view/bucket-select.php:143
msgid "Create new bucket"
msgstr ""
-#: view/bucket-select.php:60
-#: view/bucket-select.php:112
-#: view/bucket-select.php:167
-msgid "Cancel"
-msgstr ""
-
-#: view/bucket-select.php:65
+#: view/bucket-select.php:87
msgid "Select bucket"
msgstr ""
-#: view/bucket-select.php:104
-#: view/bucket-select.php:109
+#: view/bucket-select.php:126
+#: view/bucket-select.php:131
msgid "Loading..."
msgstr ""
-#: view/bucket-select.php:104
-#: view/bucket-select.php:109
+#: view/bucket-select.php:126
+#: view/bucket-select.php:131
msgid "Nothing found"
msgstr ""
-#: view/bucket-select.php:113
-#: view/bucket-select.php:118
-msgid "Refresh"
+#: view/bucket-select.php:135
+msgid "Save Selected Bucket"
msgstr ""
-#: view/bucket-select.php:116
+#: view/bucket-select.php:136
+#: view/bucket-select.php:187
msgid "Enter bucket name"
msgstr ""
-#: view/bucket-select.php:160
-msgid "New bucket name"
+#: view/bucket-select.php:138
+msgid "Refresh"
msgstr ""
-#: view/bucket-select.php:166
-msgid "Creating..."
+#: view/bucket-select.php:179
+msgid "New bucket name"
msgstr ""
-#: view/bucket-select.php:166
+#: view/bucket-select.php:185
msgid "Create New Bucket"
msgstr ""
@@ -796,19 +790,15 @@ msgstr ""
msgid "Show"
msgstr ""
-#: view/provider-select.php:14
-msgid "« Back"
-msgstr ""
-
#: view/provider-select.php:17
msgid "Storage Provider"
msgstr ""
-#: view/provider-select.php:104
+#: view/provider-select.php:108
msgid "Define access keys in wp-config.php"
msgstr ""
-#: view/provider-select.php:112
+#: view/provider-select.php:117
#, php-format
msgctxt "Access Keys defined in multiple defines."
msgid ""
@@ -817,7 +807,7 @@ msgid ""
"config.php."
msgstr ""
-#: view/provider-select.php:114
+#: view/provider-select.php:119
#, php-format
msgctxt "Access Keys defined in single define."
msgid ""
@@ -826,28 +816,28 @@ msgid ""
"config.php."
msgstr ""
-#: view/provider-select.php:116
+#: view/provider-select.php:121
msgctxt "joins multiple define keys in notice"
msgid " & "
msgstr ""
-#: view/provider-select.php:125
+#: view/provider-select.php:130
msgid ""
"Please check your wp-config.php file as it looks like one of your access key "
"defines is missing or incorrect."
msgstr ""
-#: view/provider-select.php:131
+#: view/provider-select.php:136
msgid ""
"Copy the following snippet near the top of your wp-config."
"php and replace the stars with the keys."
msgstr ""
-#: view/provider-select.php:156
+#: view/provider-select.php:162
msgid "My server is on Amazon EC2 and I'd like to use IAM Roles"
msgstr ""
-#: view/provider-select.php:162
+#: view/provider-select.php:169
#, php-format
msgid ""
"You've defined the '%1$s' constant in your wp-config.php. To select a "
@@ -855,34 +845,43 @@ msgid ""
"config.php."
msgstr ""
-#: view/provider-select.php:166
+#: view/provider-select.php:172
msgid ""
"If you host your WordPress site on an Amazon EC2 instance you should make "
"use of IAM Roles. To tell WP Offload Media you're using IAM Roles, copy the "
"following snippet near the top of your wp-config.php."
msgstr ""
-#: view/provider-select.php:187
+#: view/provider-select.php:194
msgid ""
"I understand the risks but I'd like to store access keys in the database "
"anyway (not recommended)"
msgstr ""
-#: view/provider-select.php:193
+#: view/provider-select.php:201
msgid ""
"Storing your access keys in the database is less secure than the options "
"above, but if you're ok with that, go ahead and enter your keys in the form "
"below."
msgstr ""
-#: view/provider-select.php:198
+#: view/provider-select.php:206
msgid "Access Key ID"
msgstr ""
-#: view/provider-select.php:213
+#: view/provider-select.php:221
msgid "Secret Access Key"
msgstr ""
+#: view/provider-select.php:243
+msgid "Next"
+msgstr ""
+
+#: view/provider-select.php:243
+#: view/settings/media.php:261
+msgid "Save Changes"
+msgstr ""
+
#: view/provider-setting.php:6
msgid "Provider:"
msgstr ""
@@ -895,7 +894,7 @@ msgid ""
"\">deliciousbrains.com to purchase in just a few clicks."
msgstr ""
-#: view/settings/media.php:53
+#: view/settings/media.php:76
#, php-format
msgid ""
"Yikes! That's not a very SEO-friendly URL. We strongly recommend you "
@@ -903,103 +902,99 @@ msgid ""
"point at your CDN. %2$s"
msgstr ""
-#: view/settings/media.php:69
+#: view/settings/media.php:92
msgid "Storage"
msgstr ""
-#: view/settings/media.php:97
+#: view/settings/media.php:120
msgid "Copy Files to Bucket"
msgstr ""
-#: view/settings/media.php:99
+#: view/settings/media.php:122
msgid "When a file is uploaded to the Media Library, copy it to the bucket."
msgstr ""
-#: view/settings/media.php:114
+#: view/settings/media.php:137
msgid "Path"
msgstr ""
-#: view/settings/media.php:116
+#: view/settings/media.php:139
msgid "By default the path is the same as your local WordPress files."
msgstr ""
-#: view/settings/media.php:134
+#: view/settings/media.php:157
msgid "Year/Month"
msgstr ""
-#: view/settings/media.php:136
+#: view/settings/media.php:159
msgid ""
"Add the Year/Month to the end of the path above just like WordPress does by "
"default."
msgstr ""
-#: view/settings/media.php:149
+#: view/settings/media.php:172
msgid "Object Versioning"
msgstr ""
-#: view/settings/media.php:151
+#: view/settings/media.php:174
msgid ""
"Append a timestamp to the file's bucket path. Recommended when using a CDN "
"so you don't have to worry about cache invalidation."
msgstr ""
-#: view/settings/media.php:159
+#: view/settings/media.php:182
msgid "URL Rewriting"
msgstr ""
-#: view/settings/media.php:169
+#: view/settings/media.php:192
msgid "Rewrite Media URLs"
msgstr ""
-#: view/settings/media.php:171
+#: view/settings/media.php:194
msgid ""
"For Media Library files that have been copied to your bucket, rewrite the "
"URLs so that they are served from the bucket or CDN instead of your server."
msgstr ""
-#: view/settings/media.php:187
+#: view/settings/media.php:210
msgid "Force HTTPS"
msgstr ""
-#: view/settings/media.php:189
+#: view/settings/media.php:212
msgid ""
"By default we use HTTPS when the request is HTTPS and regular HTTP when the "
"request is HTTP, but you may want to force the use of HTTPS always, "
"regardless of the request."
msgstr ""
-#: view/settings/media.php:197
+#: view/settings/media.php:220
msgid "Advanced Options"
msgstr ""
-#: view/settings/media.php:207
+#: view/settings/media.php:230
msgid "Remove Files From Server"
msgstr ""
-#: view/settings/media.php:208
+#: view/settings/media.php:231
msgid ""
"Once a file has been copied to the bucket, remove it from the local server."
msgstr ""
-#: view/settings/media.php:212
+#: view/settings/media.php:235
msgid ""
"Broken URLs — There will be broken URLs for files "
"that don't exist locally. You can fix this by enabling Rewrite Media "
"URLs to use the offloaded media."
msgstr ""
-#: view/settings/media.php:223
+#: view/settings/media.php:246
#, php-format
msgid ""
"Warning — Some plugins depend on the file being "
"present on the local server and may not work when the file is removed. %s"
msgstr ""
-#: view/settings/media.php:236
-msgid "Save Changes"
-msgstr ""
-
-#: view/settings/media.php:248
+#: view/settings/media.php:273
#, php-format
msgid ""
"Need help getting your Access Keys? Check out the Quick Start "
diff --git a/readme.txt b/readme.txt
index 347a3f95..5bd76252 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,16 +1,18 @@
-=== WP Offload Media Lite ===
+=== WP Offload Media Lite for Amazon S3 and DigitalOcean Spaces ===
Contributors: bradt, deliciousbrains, ianmjones
Tags: uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, mirror, admin, media, cdn, cloudfront
Requires at least: 4.7
-Tested up to: 4.9
+Tested up to: 5.0
Requires PHP: 5.5
-Stable tag: 2.0
+Stable tag: 2.0.1
License: GPLv3
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.
== Description ==
+FORMERLY WP OFFLOAD S3 LITE
+
https://www.youtube.com/watch?v=_PVybEGaRXc
This plugin automatically copies images, videos, documents, and any other media added through WordPress' media uploader to [Amazon S3](http://aws.amazon.com/s3/) or [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/). It then automatically replaces the URL to each media file with their respective Amazon S3 or DigitalOcean Spaces URL or, if you have configured [Amazon CloudFront](http://aws.amazon.com/cloudfront/) or another CDN with or without a custom domain, that URL instead. Image thumbnails are also copied to the bucket and delivered through the correct remote URL.
@@ -19,6 +21,10 @@ Uploading files *directly* to your Amazon S3 or DigitalOcean Spaces account is n
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.
+**Image Optimization**
+
+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.
+
**PRO Upgrade with Email Support and More Features**
* Upload existing Media Library to Amazon S3 or DigitalOcean Spaces
@@ -34,10 +40,6 @@ The video below runs through the pro upgrade features...
https://www.youtube.com/watch?v=55xNGnbJ_CY
-*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.*
-
== Installation ==
1. Install this plugin using WordPress' built-in installer
@@ -52,10 +54,16 @@ Check out the [Quick Start Guide](https://deliciousbrains.com/wp-offload-media/d
You can see the minimum requirements [here](https://deliciousbrains.com/wp-offload-media/pricing/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting&utm_content=requirements#requirements).
+= Do you offer email support? =
+
+If you upgrade to the pro version of [WP Offload Media](https://deliciousbrains.com/wp-offload-media/upgrade/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting), we will gladly provide you with email support. We take pride in delivering exceptional customer support. We do not provide email support for the free version.
+
== Screenshots ==
-1. Choosing/creating a bucket
-2. Settings screen
+1. Select Cloud Storage Provider
+2. Select or Create Bucket
+3. Settings Screen
+3. Custom Domain Used With CDN
== Upgrade Notice ==
@@ -70,9 +78,18 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
== Changelog ==
+= WP Offload Media Lite 2.0.1 - 2018-12-17 =
+* Improvement: Streamlined UI for setting Storage Provider and Bucket
+* Bug fix: On/Off switches in settings look reversed
+* Bug fix: Latest upgrade routine runs on fresh install
+* Bug fix: Defined settings still found in database
+* Bug fix: More Info links in Storage Provider settings incorrect
+* Tested: WordPress 5.0
+
= WP Offload Media Lite 2.0 - 2018-09-24 =
-* New: Plugin renamed to "WP Offload Media Lite"
-* New: DigitalOcean Spaces support
+* [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-supports-digitalocean-spaces/)
+* New: DigitalOcean Spaces is now supported
+* New: Plugin name updated from WP Offload S3 Lite to WP Offload Media Lite
* Improvement: More logical UI layout and better description of each setting
= WP Offload S3 Lite 1.4.3 - 2018-08-02 =
diff --git a/view/bucket-select.php b/view/bucket-select.php
index 8d5e5331..69cd2ef9 100644
--- a/view/bucket-select.php
+++ b/view/bucket-select.php
@@ -3,12 +3,37 @@
$provider = $this->get_provider();
$provider_regions = $provider->get_regions();
$region_required = $provider->region_required();
+
+$bucket_mode = empty( $_GET['bucket_mode'] ) ? 'manual' : $_GET['bucket_mode'];
+$bucket_mode = in_array( $bucket_mode, array( 'manual', 'select', 'create' ) ) ? $bucket_mode : 'manual';
+
+$mode_args = array(
+ 'action' => 'change-bucket',
+);
+
+if ( ! empty( $_GET['prev_action'] ) ) {
+ $mode_args['prev_action'] = $_GET['prev_action'];
+}
+
+$manual_mode = $this->get_plugin_page_url( array_merge( $mode_args, array( 'bucket_mode' => 'manual' ) ) );
+$select_mode = $this->get_plugin_page_url( array_merge( $mode_args, array( 'bucket_mode' => 'select' ) ) );
+$create_mode = $this->get_plugin_page_url( array_merge( $mode_args, array( 'bucket_mode' => 'create' ) ) );
?>
\ No newline at end of file
diff --git a/view/bucket-setting.php b/view/bucket-setting.php
index b3c5ae9c..bc7ad6ca 100644
--- a/view/bucket-setting.php
+++ b/view/bucket-setting.php
@@ -16,7 +16,7 @@
get_defined_setting( 'bucket', false ) ) {
echo '' . __( 'defined in wp-config.php', 'amazon-s3-and-cloudfront' ) . ' ';
} elseif ( ! $needs_keys ) { ?>
-
+
diff --git a/view/checkbox.php b/view/checkbox.php
index 738a41e6..b3d19e11 100644
--- a/view/checkbox.php
+++ b/view/checkbox.php
@@ -6,8 +6,8 @@
$prefix = $this->get_plugin_prefix_slug();
?>
- ON
OFF
-
+ ON
+
/>
diff --git a/view/provider-select.php b/view/provider-select.php
index 471f99fa..8a474c4e 100644
--- a/view/provider-select.php
+++ b/view/provider-select.php
@@ -10,7 +10,7 @@
get_setting( 'bucket' ) && ! empty( $can_write ) ) {
echo '
' . __( '« Back', 'amazon-s3-and-cloudfront' ) . ' ';
}
?>
@@ -20,6 +20,7 @@
$provider_class ) {
+ /* @var \DeliciousBrains\WP_Offload_Media\Providers\Provider $provider */
$provider = new $provider_class( $this );
$provider_selected = $provider_key === $current_provider->get_provider_key_name();
$provider_selected_class = $provider_selected ? ' as3cf-provider-selected' : '';
@@ -65,6 +66,8 @@
$db_authmethod_attr = $provider_selected ? ' checked="checked"' : '';
break;
}
+
+ $provider_service_quick_start_slug = $provider_class::get_provider_service_quick_start_slug();
?>
@@ -101,7 +104,9 @@
>
-
+
+
+
>
@@ -116,7 +121,7 @@
$multiple_defined_keys_glue = _x( ' & ', 'joins multiple define keys in notice', 'amazon-s3-and-cloudfront' );
$defined_constants_str = join( $multiple_defined_keys_glue, $defined_constants );
printf( $remove_defines_msg, $defined_constants_str );
- echo ' ' . $this->more_info_link( '/wp-offload-media/doc/quick-start-guide/#save-access-keys' );
+ echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' );
if ( $provider_selected && ! $provider->are_access_keys_set() ) {
?>
@@ -129,7 +134,7 @@
}
} else {
_e( 'Copy the following snippet near the top of your wp-config.php and replace the stars with the keys.', 'amazon-s3-and-cloudfront' );
- echo ' ' . $this->more_info_link( '/wp-offload-media/doc/quick-start-guide/#save-access-keys' );
+ echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' );
?>
define( 'AS3CF_SETTINGS', serialize( array(
@@ -153,18 +158,19 @@
>
-
+
+
+
>
more_info_link( '/wp-offload-media/doc/quick-start-guide/#save-access-keys' );
-
+ echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' );
} else {
_e( 'If you host your WordPress site on an Amazon EC2 instance you should make use of IAM Roles. To tell WP Offload Media you\'re using IAM Roles, copy the following snippet near the top of your wp-config.php.', 'amazon-s3-and-cloudfront' );
- echo ' ' . $this->more_info_link( '/wp-offload-media/doc/quick-start-guide/#save-access-keys' );
+ echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' );
?>
define( 'AS3CF_AWS_USE_EC2_IAM_ROLE', true );
@@ -184,14 +190,16 @@
>
-
+
+
+
>
more_info_link( '/wp-offload-media/doc/quick-start-guide/#save-access-keys' );
+ echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' );
?>
+
+ get_defined_setting( 'bucket', false ) ) ? __( 'Next', 'amazon-s3-and-cloudfront' ) : __( 'Save Changes', 'amazon-s3-and-cloudfront' ); ?>
+
diff --git a/view/settings/media.php b/view/settings/media.php
index e5e9bea9..b59e9f06 100644
--- a/view/settings/media.php
+++ b/view/settings/media.php
@@ -1,4 +1,6 @@
get_plugin_prefix_slug();
$selected_provider = $this->get_setting( 'provider', static::$default_provider );
@@ -6,12 +8,27 @@
$selected_bucket = $this->get_setting( 'bucket' );
$selected_bucket_prefix = $this->get_object_prefix();
-$storage_classes = $this->get_provider()->needs_access_keys() ? ' as3cf-needs-access-keys' : ' as3cf-has-access-keys';
-$storage_classes .= $selected_bucket ? ' as3cf-has-bucket' : ' as3cf-needs-bucket';
+if ( $this->get_provider()->needs_access_keys() ) {
+ $storage_classes = ' as3cf-needs-access-keys';
+} else {
+ $storage_classes = ' as3cf-has-access-keys';
+}
+
+if ( $selected_bucket ) {
+ $storage_classes .= ' as3cf-has-bucket';
+} else {
+ $storage_classes .= ' as3cf-needs-bucket';
+}
if ( ! empty( $_GET['action'] ) && 'change-provider' === $_GET['action'] ) {
$storage_classes .= ' as3cf-change-provider';
}
+
+if ( ! empty( $_GET['action'] ) && 'change-bucket' === $_GET['action'] ) {
+ $storage_classes .= ' as3cf-change-bucket';
+}
+
+$storage_classes = apply_filters( 'as3cf_media_tab_storage_classes', $storage_classes );
?>
@@ -21,18 +38,24 @@
-
- render_bucket_permission_errors() ?>
+ render_bucket_permission_errors();
+ ?>
-
-
+
+
get_settings_nonce_key() );
do_action( 'as3cf_form_hidden_fields' );
- $this->render_view( 'provider-select' );
+ $this->render_view( 'provider-select', compact( 'can_write' ) );
+
+ $this->render_view( 'bucket-select', array( 'prefix' => $prefix, 'selected_provider' => $selected_provider, 'selected_region' => $selected_region, 'selected_bucket' => $selected_bucket ) );
+
+ do_action( 'as3cf_pre_media_settings' );
?>
-
- maybe_disable_save_button(); ?>>
-
render_view( 'bucket-select', array( 'prefix' => $prefix, 'selected_provider' => $selected_provider, 'selected_region' => $selected_region, 'selected_bucket' => $selected_bucket ) );
-
if ( $this->get_provider()->needs_access_keys() ) {
?>
diff --git a/wordpress-s3.php b/wordpress-s3.php
index 21fb9a06..23111245 100644
--- a/wordpress-s3.php
+++ b/wordpress-s3.php
@@ -4,7 +4,7 @@
Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/
Description: Automatically copies media uploads to Amazon S3 or DigitalOcean Spaces for storage and delivery. Optionally configure Amazon CloudFront or another CDN for even faster delivery.
Author: Delicious Brains
-Version: 2.0
+Version: 2.0.1
Author URI: https://deliciousbrains.com/
Network: True
Text Domain: amazon-s3-and-cloudfront
@@ -26,7 +26,7 @@
// Then completely rewritten.
*/
-$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.0';
+$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.0.1';
require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';