diff --git a/README.md b/README.md index b296fa98..648fdccb 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage # **Contributors:** bradt, deliciousbrains, ianmjones **Tags:** uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google cloud storage, gcs, mirror, admin, media, cdn, cloudfront -**Requires at least:** 4.7 +**Requires at least:** 4.9 **Tested up to:** 5.2 **Requires PHP:** 5.5 -**Stable tag:** 2.2-dev +**Stable tag:** 2.2 **License:** GPLv3 Copies files to Amazon S3, DigitalOcean Spaces or Google Cloud Storage as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery. @@ -86,6 +86,13 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog ## +### WP Offload Media Lite 2.2 - 2019-06-10 ### +* [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-2-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting) +* New: Use IAM Roles without having to update wp-config.php +* New: Frankfurt (FRA1) region now supported on DigitalOcean Spaces +* Improvement: WP dashboard performance +* Bug fix: Uploaded media files with uppercase extensions get second extension added + ### WP Offload Media Lite 2.1.1 - 2019-04-29 ### * New: Multisite domain mapping via WordPress MU Domain Mapping plugin is now supported * Improvement: Local to Provider content filtering performance improvements diff --git a/classes/amazon-s3-and-cloudfront.php b/classes/amazon-s3-and-cloudfront.php index 4e6248e2..3fdfbc4a 100644 --- a/classes/amazon-s3-and-cloudfront.php +++ b/classes/amazon-s3-and-cloudfront.php @@ -1526,6 +1526,7 @@ public function filter_unique_filename( $filename, $ext, $dir, $post_id = null ) // sanitize the file name before we begin processing $filename = sanitize_file_name( $filename ); + $ext = strtolower( $ext ); $name = wp_basename( $filename, $ext ); // Edge case: if file is named '.ext', treat as an empty name. @@ -1534,7 +1535,6 @@ public function filter_unique_filename( $filename, $ext, $dir, $post_id = null ) } // Rebuild filename with lowercase extension as provider will have converted extension on upload. - $ext = strtolower( $ext ); $filename = $name . $ext; $time = current_time( 'mysql' ); @@ -2925,6 +2925,7 @@ function get_settings_whitelist() { 'secret-access-key', 'key-file-path', 'key-file', + 'use-server-roles', 'bucket', 'region', 'domain', @@ -3011,7 +3012,7 @@ public function handle_post_request() { // 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', 'key-file' ) ) && ! $this->get_defined_setting( 'bucket', false ) ) { + if ( in_array( $key, array( 'provider', 'access-key-id', 'secret-access-key', 'key-file', 'use-server-roles' ) ) && ! $this->get_defined_setting( 'bucket', false ) ) { $action = 'change-bucket'; break; } else { @@ -3189,6 +3190,10 @@ protected function handle_save_settings() { } } + if ( 'use-server-roles' === $var && 'server-role' !== $_POST['authmethod'] ) { + continue; + } + $this->set_setting( $var, $value ); // Some setting changes might have knock-on effects that require confirmation of secondary settings. @@ -3713,14 +3718,14 @@ function output_diagnostic_info( $escape = true ) { * Media */ - $media_counts = $this->diagnostic_media_counts(); + $media_counts = $this->media_counts(); $output .= 'Media Files: '; - $output .= number_format_i18n( $media_counts['all'] ); + $output .= number_format_i18n( $media_counts['total'] ); $output .= "\r\n"; $output .= 'Offloaded Media Files: '; - $output .= number_format_i18n( $media_counts['s3'] ); + $output .= number_format_i18n( $media_counts['offloaded'] ); $output .= "\r\n"; $output .= 'Number of Image Sizes: '; @@ -3815,9 +3820,9 @@ function output_diagnostic_info( $escape = true ) { $output .= "\r\n"; if ( $provider::use_server_roles_allowed() ) { - $output .= 'Use Server Role: ' . $this->on_off( $provider::use_server_roles() ); + $output .= 'Use Server Roles: ' . $this->on_off( $provider->use_server_roles() ); } else { - $output .= 'Use Server Role: N/A'; + $output .= 'Use Server Roles: N/A'; } $output .= "\r\n"; @@ -4273,70 +4278,80 @@ public function get_memory_limit() { } /** - * Count attachments on a site + * Count attachments on a site. * - * @param string $prefix - * @param null|bool $uploaded_to_provider - * null - All attachments - * true - Attachments only uploaded to provider - * false - Attachments not uploaded to provider - * @param bool $skip_transient Whether to force database query and skip transient, default false + * @param string $prefix + * @param bool $skip_transient Whether to force database query and skip transient, default false + * @param bool $force Whether to force database query and skip static cache, implies $skip_transient, default false * - * @return int + * @return array Keys: + * total: Total media count for site (prefix) + * offloaded: Count of offloaded media for site (prefix) + * not_offloaded: Difference between total and offloaded */ - public function count_attachments( $prefix, $uploaded_to_provider = null, $skip_transient = false ) { + public function count_attachments( $prefix, $skip_transient = false, $force = false ) { global $wpdb; - $transient_key = 'as3cf_' . $prefix . '_media_count'; + static $counts; + static $skips; - $sql = "SELECT COUNT(DISTINCT p.ID) - FROM `{$prefix}posts` p"; + $transient_key = 'as3cf_' . $prefix . '_attachment_counts'; - $where = "WHERE p.post_type = 'attachment'"; - - if ( ! is_null( $uploaded_to_provider ) && is_bool( $uploaded_to_provider ) ) { - $sql .= " LEFT OUTER JOIN `{$prefix}postmeta` pm - ON p.`ID` = pm.`post_id` - AND pm.`meta_key` = 'amazonS3_info'"; + // Been here, done it, won't do it again! + // Well, unless this is the first transient skip for the prefix, then we need to do it. + if ( ! $force && ! empty( $counts[ $transient_key ] ) && ( false === $skip_transient || ! empty( $skips[ $transient_key ] ) ) ) { + return $counts[ $transient_key ]; + } - $operator = $uploaded_to_provider ? 'not ' : ''; - $where .= " AND pm.`post_id` is {$operator}null"; + if ( $force || $skip_transient || false === ( $attachment_counts = get_site_transient( $transient_key ) ) ) { + $sql = " + SELECT COUNT(DISTINCT p.`ID`) total, COUNT(DISTINCT pm.`post_id`) offloaded + FROM `{$prefix}posts` p + LEFT OUTER JOIN `{$prefix}postmeta` pm ON p.`ID` = pm.`post_id` AND pm.`meta_key` = 'amazonS3_info' + WHERE p.`post_type` = 'attachment' + "; - $transient_key .= ( $uploaded_to_provider ) ? '_offloaded' : 'not_offloaded'; - } + $attachment_counts = $wpdb->get_row( $sql, ARRAY_A ); - $sql .= ' ' . $where; + $attachment_counts['not_offloaded'] = $attachment_counts['total'] - $attachment_counts['offloaded']; - if ( true === $skip_transient || false === ( $count = get_site_transient( $transient_key ) ) ) { - $count = (int) $wpdb->get_var( $sql ); + set_site_transient( $transient_key, $attachment_counts, 2 * MINUTE_IN_SECONDS ); - set_site_transient( $transient_key, $count, 2 * MINUTE_IN_SECONDS ); + // One way or another we've skipped the transient. + $skips[ $transient_key ] = true; } - return $count; + $counts[ $transient_key ] = $attachment_counts; + + return $attachment_counts; } /** - * Get the total attachment and total S3 attachment counts for the diagnostic log + * Get the total attachment and total offloaded/not offloaded attachment counts + * + * @param bool $skip_transient Whether to force database query and skip transient, default false + * @param bool $force Whether to force database query and skip static cache, implies $skip_transient, default false * * @return array */ - protected function diagnostic_media_counts() { - if ( false === ( $attachment_counts = get_site_transient( 'as3cf_attachment_counts' ) ) ) { - $table_prefixes = $this->get_all_blog_table_prefixes(); - $all_media = 0; - $all_media_provider = 0; + public function media_counts( $skip_transient = false, $force = false ) { + if ( $skip_transient || false === ( $attachment_counts = get_site_transient( 'as3cf_attachment_counts' ) ) ) { + $table_prefixes = $this->get_all_blog_table_prefixes(); + $total = 0; + $offloaded = 0; + $not_offloaded = 0; foreach ( $table_prefixes as $blog_id => $table_prefix ) { - $count = $this->count_attachments( $table_prefix ); - $all_media += $count; - $provider_count = $this->count_attachments( $table_prefix, true ); - $all_media_provider += $provider_count; + $counts = $this->count_attachments( $table_prefix, $skip_transient, $force ); + $total += $counts['total']; + $offloaded += $counts['offloaded']; + $not_offloaded += $counts['not_offloaded']; } $attachment_counts = array( - 'all' => $all_media, - 's3' => $all_media_provider, + 'total' => $total, + 'offloaded' => $offloaded, + 'not_offloaded' => $not_offloaded, ); set_site_transient( 'as3cf_attachment_counts', $attachment_counts, 2 * MINUTE_IN_SECONDS ); diff --git a/classes/as3cf-notices.php b/classes/as3cf-notices.php index d38d2e84..fd8e0a3a 100644 --- a/classes/as3cf-notices.php +++ b/classes/as3cf-notices.php @@ -61,7 +61,7 @@ protected function __clone() { */ public function add_notice( $message, $args = array() ) { $defaults = array( - 'type' => 'info', + 'type' => 'notice-info', 'dismissible' => true, 'inline' => false, 'flash' => true, @@ -250,7 +250,7 @@ public function undismiss_notice_for_all( $notice_id ) { $users = get_users( $args ); - foreach( $users as $user ) { + foreach ( $users as $user ) { $this->undismiss_notice_for_user( $notice_id, $user->ID ); } } @@ -464,7 +464,7 @@ public function ajax_dismiss_notice() { */ protected function update_user_meta( $user_id, $key, $value ) { if ( empty( $value ) ) { - delete_user_meta( $user_id, $key); + delete_user_meta( $user_id, $key ); } else { update_user_meta( $user_id, $key, $value ); } diff --git a/classes/providers/digitalocean-provider.php b/classes/providers/digitalocean-provider.php index 1e423180..5952b104 100644 --- a/classes/providers/digitalocean-provider.php +++ b/classes/providers/digitalocean-provider.php @@ -79,6 +79,7 @@ class DigitalOcean_Provider extends AWS_Provider { 'ams3' => 'Amsterdam', 'sgp1' => 'Singapore', 'sfo2' => 'San Francisco', + 'fra1' => 'Frankfurt', ); /** diff --git a/classes/providers/provider.php b/classes/providers/provider.php index 99a7a566..f9c09486 100644 --- a/classes/providers/provider.php +++ b/classes/providers/provider.php @@ -77,6 +77,11 @@ abstract class Provider { */ protected static $secret_access_key_setting_name = 'secret-access-key'; + /** + * @var string + */ + protected static $use_server_roles_setting_name = 'use-server-roles'; + /** * @var string */ @@ -218,7 +223,7 @@ public static function use_access_keys_allowed() { * @return bool */ public function needs_access_keys() { - if ( static::use_server_roles() ) { + if ( $this->use_server_roles() ) { return false; } @@ -313,7 +318,7 @@ public static function use_server_roles_allowed() { * * @return string */ - public static function preferred_use_server_role_constant() { + public static function preferred_use_server_roles_constant() { if ( static::use_server_roles_allowed() ) { return static::$use_server_roles_constants[0]; } else { @@ -328,22 +333,26 @@ public static function preferred_use_server_role_constant() { * * @return bool */ - public static function use_server_roles() { + public function use_server_roles() { if ( ! static::use_server_roles_allowed() ) { return false; } - $constant = static::use_server_role_constant(); + if ( static::use_server_roles_constant() ) { + $constant = static::use_server_roles_constant(); - return $constant && constant( $constant ); + return $constant ? constant( $constant ) : false; + } + + return $this->as3cf->get_core_setting( static::$use_server_roles_setting_name, false ); } /** - * Get the constant used to enable the use of EC2 IAM roles. + * Get the constant used to enable the use of IAM roles. * * @return string|false Constant name if defined, otherwise false */ - public static function use_server_role_constant() { + public static function use_server_roles_constant() { return AS3CF_Utils::get_first_defined_constant( static::$use_server_roles_constants ); } @@ -572,7 +581,7 @@ private function _init_client( Array $args ) { if ( is_null( $this->client ) ) { // There's no extra client authentication config required when using server roles. - if ( ! static::use_server_roles() ) { + if ( ! $this->use_server_roles() ) { // Some providers can supply Key File contents or Key File Path. if ( static::use_key_file() ) { // Key File contents take precedence over Key File Path. diff --git a/classes/upgrades/upgrade.php b/classes/upgrades/upgrade.php index 71d4ebfa..babd2cb3 100644 --- a/classes/upgrades/upgrade.php +++ b/classes/upgrades/upgrade.php @@ -298,7 +298,6 @@ protected function run_upgrade() { break; } } while ( $blog_id = $this->next_blog_id() ); - } catch ( No_More_Blogs_Exception $e ) { /* * The upgrade is complete when there are no more blogs left to finish. @@ -322,10 +321,10 @@ protected function run_upgrade() { /** * Upgrade the current blog. * - * @throws Too_Many_Errors_Exception + * @return bool true if all items for the blog were upgraded, otherwise false. * @throws Batch_Limits_Exceeded_Exception * - * @return bool true if all items for the blog were upgraded, otherwise false. + * @throws Too_Many_Errors_Exception */ protected function upgrade_blog() { $total = $this->count_items_to_process(); @@ -358,9 +357,9 @@ protected function upgrade_blog() { /** * Get the next sequential blog ID if there is one. * + * @return int * @throws No_More_Blogs_Exception * - * @return int */ protected function next_blog_id() { $blog_id = $this->blog_id ?: $this->last_blog_id; @@ -371,7 +370,6 @@ protected function next_blog_id() { if ( $blog_id < 1 ) { throw new No_More_Blogs_Exception; } - } while ( ! $this->is_blog_processable( $blog_id ) ); return $blog_id; @@ -505,16 +503,16 @@ protected function calculate_progress() { } else { // Set up any per-site state $this->switch_to_blog( get_current_blog_id() ); - $total_items = $this->as3cf->count_attachments( $this->blog_prefix ); + $counts = $this->as3cf->count_attachments( $this->blog_prefix ); // If there are no attachments, disable progress calculation // and protect against division by zero. - if ( ! $total_items ) { + if ( ! $counts['total'] ) { return false; } $remaining = $this->count_items_to_process(); - $decimal = ( $total_items - $remaining ) / $total_items; + $decimal = ( $counts['total'] - $remaining ) / $counts['total']; } return round( $decimal * 100, 2 ); diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index 2d3d50cd..f3402615 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: 2019-04-29 10:28+0100\n" +"POT-Creation-Date: 2019-06-11 14:00+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,7 +29,7 @@ msgstr "" #: classes/amazon-s3-and-cloudfront.php:345 #: view/bucket-setting.php:17 -#: view/provider-select.php:108 +#: view/provider-select.php:122 msgid "defined in wp-config.php" msgstr "" @@ -135,59 +135,59 @@ msgid "-- not shown --" msgstr "" #: classes/amazon-s3-and-cloudfront.php:2891 -#: classes/amazon-s3-and-cloudfront.php:4913 +#: classes/amazon-s3-and-cloudfront.php:4928 msgid "Settings saved." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2980 +#: classes/amazon-s3-and-cloudfront.php:2981 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3064 +#: classes/amazon-s3-and-cloudfront.php:3065 msgid "No bucket name provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3073 +#: classes/amazon-s3-and-cloudfront.php:3074 msgid "Bucket name not valid." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3086 +#: classes/amazon-s3-and-cloudfront.php:3087 msgid "No region provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3163 -#: view/provider-select.php:314 +#: classes/amazon-s3-and-cloudfront.php:3164 +#: view/provider-select.php:329 msgctxt "placeholder for hidden secret access key, 39 char max" msgid "-- not shown --" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3186 +#: classes/amazon-s3-and-cloudfront.php:3187 msgid "Key File not valid JSON." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3228 +#: classes/amazon-s3-and-cloudfront.php:3233 msgctxt "Show the media library tab" msgid "Media Library" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3229 +#: classes/amazon-s3-and-cloudfront.php:3234 msgctxt "Show the addons tab" msgid "Addons" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3230 +#: classes/amazon-s3-and-cloudfront.php:3235 msgctxt "Show the support tab" msgid "Support" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3450 +#: classes/amazon-s3-and-cloudfront.php:3455 #, php-format msgid "" "WP Offload Media — The file %s has been given %s " "permissions in the bucket." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3469 +#: classes/amazon-s3-and-cloudfront.php:3474 msgid "" "WP Offload Media Requirement Missing — Looks like you " "don't have an image manipulation library installed on this server and " @@ -195,18 +195,18 @@ msgid "" "Please setup GD or ImageMagick." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4182 +#: classes/amazon-s3-and-cloudfront.php:4187 #, php-format msgid "" "Define your access keys to enable write access to the " "bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4189 +#: classes/amazon-s3-and-cloudfront.php:4194 msgid "Quick Start Guide" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4191 +#: classes/amazon-s3-and-cloudfront.php:4196 #, php-format msgid "" "Looks like we don't have write access to this bucket. It's likely that the " @@ -215,7 +215,7 @@ msgid "" "correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4193 +#: classes/amazon-s3-and-cloudfront.php:4198 #, php-format msgid "" "Looks like we don't have access to the buckets. It's likely that the user " @@ -223,39 +223,39 @@ msgid "" "Please see our %s for instructions on setting up permissions correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4354 +#: classes/amazon-s3-and-cloudfront.php:4369 msgid "WP Offload Media Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4355 +#: classes/amazon-s3-and-cloudfront.php:4370 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:4357 +#: classes/amazon-s3-and-cloudfront.php:4372 msgid "WP Offload Media Lite Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4358 +#: classes/amazon-s3-and-cloudfront.php:4373 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:4410 +#: classes/amazon-s3-and-cloudfront.php:4425 msgid "More info »" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4505 +#: classes/amazon-s3-and-cloudfront.php:4520 msgid "this doc" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4507 +#: classes/amazon-s3-and-cloudfront.php:4522 msgid "WP Offload Media Feature Removed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4508 +#: classes/amazon-s3-and-cloudfront.php:4523 #, php-format msgid "" "You had the \"Always non-SSL\" option selected in your settings, but we've " @@ -266,59 +266,59 @@ msgid "" "to the old behavior." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4538 +#: classes/amazon-s3-and-cloudfront.php:4553 msgid "Offload" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4646 +#: classes/amazon-s3-and-cloudfront.php:4661 msgctxt "Storage provider key name" msgid "Storage Provider" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4647 +#: classes/amazon-s3-and-cloudfront.php:4662 msgctxt "Storage provider name" msgid "Storage Provider" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4648 +#: classes/amazon-s3-and-cloudfront.php:4663 msgctxt "Bucket name" msgid "Bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4649 +#: classes/amazon-s3-and-cloudfront.php:4664 msgctxt "Path to file in bucket" msgid "Path" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4650 +#: classes/amazon-s3-and-cloudfront.php:4665 msgctxt "Location of bucket" msgid "Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4651 +#: classes/amazon-s3-and-cloudfront.php:4666 msgctxt "Access control list of the file in bucket" msgid "Access" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4652 +#: classes/amazon-s3-and-cloudfront.php:4667 msgid "URL" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4876 +#: classes/amazon-s3-and-cloudfront.php:4891 msgid "Assets Pull" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4877 +#: classes/amazon-s3-and-cloudfront.php:4892 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:4881 +#: classes/amazon-s3-and-cloudfront.php:4896 msgid "Feature" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4927 +#: classes/amazon-s3-and-cloudfront.php:4942 #, php-format msgid "" "Amazon Web Services Plugin No Longer Required — As of " @@ -329,7 +329,7 @@ msgid "" "plugin, it should be safe to deactivate and delete it. %2$s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4959 +#: classes/amazon-s3-and-cloudfront.php:4974 #, php-format msgid "" "WP Offload Media Settings Moved — You now define your " @@ -482,20 +482,20 @@ msgid "" "Offload Media will require PHP %2$s or later. %3$s" msgstr "" -#: classes/providers/provider.php:434 +#: classes/providers/provider.php:443 msgid "Given Key File Path is invalid or could not be accessed." msgstr "" -#: classes/providers/provider.php:444 -#: classes/providers/provider.php:449 +#: classes/providers/provider.php:453 +#: classes/providers/provider.php:458 msgid "Could not read Key File Path's contents." msgstr "" -#: classes/providers/provider.php:457 +#: classes/providers/provider.php:466 msgid "Given Key File Path does not contain valid JSON." msgstr "" -#: classes/providers/provider.php:570 +#: classes/providers/provider.php:579 #, php-format msgid "You must first set your access keys." msgstr "" @@ -569,19 +569,19 @@ msgid "" "version." msgstr "" -#: classes/upgrades/upgrade.php:405 +#: classes/upgrades/upgrade.php:403 msgid "Pause Update" msgstr "" -#: classes/upgrades/upgrade.php:413 +#: classes/upgrades/upgrade.php:411 msgid "Restart Update" msgstr "" -#: classes/upgrades/upgrade.php:417 +#: classes/upgrades/upgrade.php:415 msgid "Try Run It Again" msgstr "" -#: classes/upgrades/upgrade.php:440 +#: classes/upgrades/upgrade.php:438 #, php-format msgid "" "Running %1$s Update%2$s — We’re going through " @@ -591,14 +591,14 @@ msgid "" "performance." msgstr "" -#: classes/upgrades/upgrade.php:454 +#: classes/upgrades/upgrade.php:452 #, php-format msgid "" "%1$s Update Paused%2$s — Updating Media Library %3$s " "has been paused." msgstr "" -#: classes/upgrades/upgrade.php:467 +#: classes/upgrades/upgrade.php:465 #, php-format msgid "" "Error Updating %1$s — We ran into some errors " @@ -606,12 +606,12 @@ msgid "" "been offloaded. Please check your error log for details. (#%3$d)" msgstr "" -#: classes/upgrades/upgrade.php:491 +#: classes/upgrades/upgrade.php:489 #, php-format msgid " (%s%% Complete)" msgstr "" -#: classes/upgrades/upgrade.php:625 +#: classes/upgrades/upgrade.php:623 #, php-format msgid "Every %d Minutes" msgstr "" @@ -653,7 +653,7 @@ msgid "File exists on server" msgstr "" #: view/bucket-select.php:38 -#: view/provider-select.php:19 +#: view/provider-select.php:21 msgid "« Back" msgstr "" @@ -820,22 +820,22 @@ msgstr "" msgid "Show" msgstr "" -#: view/provider-select.php:22 +#: view/provider-select.php:24 msgid "Storage Provider" msgstr "" -#: view/provider-select.php:125 +#: view/provider-select.php:139 #, php-format msgid "" "Warning: You have %s offloaded Media Library items, you " "should remove them from the bucket before changing storage provider." msgstr "" -#: view/provider-select.php:148 +#: view/provider-select.php:162 msgid "Define access keys in wp-config.php" msgstr "" -#: view/provider-select.php:157 +#: view/provider-select.php:171 #, php-format msgctxt "Access Keys defined in multiple defines." msgid "" @@ -844,7 +844,7 @@ msgid "" "config.php." msgstr "" -#: view/provider-select.php:159 +#: view/provider-select.php:173 #, php-format msgctxt "Access Keys defined in single define." msgid "" @@ -853,29 +853,30 @@ msgid "" "config.php." msgstr "" -#: view/provider-select.php:161 -#: view/provider-select.php:211 +#: view/provider-select.php:175 +#: view/provider-select.php:225 +#: view/provider-select.php:267 msgctxt "joins multiple define keys in notice" msgid " & " msgstr "" -#: view/provider-select.php:170 +#: view/provider-select.php:184 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:176 +#: view/provider-select.php:190 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:202 +#: view/provider-select.php:216 msgid "Define key file path in wp-config.php" msgstr "" -#: view/provider-select.php:210 +#: view/provider-select.php:224 #, php-format msgctxt "Key file path defined in single define." msgid "" @@ -884,72 +885,72 @@ msgid "" "your wp-config.php." msgstr "" -#: view/provider-select.php:216 +#: view/provider-select.php:230 msgid "" "Copy the following snippet near the top of your wp-config." "php and replace \"/path/to/key/file.json\"." msgstr "" -#: view/provider-select.php:245 +#: view/provider-select.php:259 #, php-format msgid "My server is on %s and I'd like to use IAM Roles" msgstr "" -#: view/provider-select.php:252 +#: view/provider-select.php:266 #, php-format +msgctxt "Use Server Roles defined in single define." msgid "" -"You've defined the '%1$s' constant in your wp-config.php. To select a " -"different option here, simply comment out or remove the define in your wp-" -"config.php." +"You've defined use of server roles in your wp-config.php. To select a " +"different option here, simply comment out or remove the '%1$s' define in " +"your wp-config.php." msgstr "" -#: view/provider-select.php:255 +#: view/provider-select.php:272 #, php-format msgid "" -"If you host your WordPress site on %s 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." +"If you host your WordPress site on %s, choose this option and make use of " +"IAM Roles." msgstr "" -#: view/provider-select.php:281 +#: view/provider-select.php:296 msgid "" "I understand the risks but I'd like to store access keys in the database " "anyway (not recommended)" msgstr "" -#: view/provider-select.php:288 +#: view/provider-select.php:303 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:293 +#: view/provider-select.php:308 msgid "Access Key ID" msgstr "" -#: view/provider-select.php:308 +#: view/provider-select.php:323 msgid "Secret Access Key" msgstr "" -#: view/provider-select.php:335 +#: view/provider-select.php:350 msgid "" "I understand the risks but I'd like to store the key file's contents in the " "database anyway (not recommended)" msgstr "" -#: view/provider-select.php:342 +#: view/provider-select.php:357 msgid "" "Storing your key file's contents in the database is less secure than the " "options above, but if you're ok with that, go ahead and enter your key " "file's JSON data in the field below." msgstr "" -#: view/provider-select.php:358 +#: view/provider-select.php:373 msgid "Next" msgstr "" -#: view/provider-select.php:358 +#: view/provider-select.php:373 #: view/settings/media.php:261 msgid "Save Changes" msgstr "" diff --git a/readme.txt b/readme.txt index 8ea94894..6d1b27bb 100644 --- a/readme.txt +++ b/readme.txt @@ -1,10 +1,10 @@ === WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage === Contributors: bradt, deliciousbrains, ianmjones Tags: uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google cloud storage, gcs, mirror, admin, media, cdn, cloudfront -Requires at least: 4.7 +Requires at least: 4.9 Tested up to: 5.2 Requires PHP: 5.5 -Stable tag: 2.1.1 +Stable tag: 2.2 License: GPLv3 Copies files to Amazon S3, DigitalOcean Spaces or Google Cloud Storage as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery. @@ -78,6 +78,13 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin == Changelog == += WP Offload Media Lite 2.2 - 2019-06-10 = +* [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-2-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting) +* New: Use IAM Roles without having to update wp-config.php +* New: Frankfurt (FRA1) region now supported on DigitalOcean Spaces +* Improvement: WP dashboard performance +* Bug fix: Uploaded media files with uppercase extensions get second extension added + = WP Offload Media Lite 2.1.1 - 2019-04-29 = * New: Multisite domain mapping via WordPress MU Domain Mapping plugin is now supported * Improvement: Local to Provider content filtering performance improvements diff --git a/view/provider-select.php b/view/provider-select.php index 289e7741..00115d71 100644 --- a/view/provider-select.php +++ b/view/provider-select.php @@ -1,16 +1,18 @@ get_provider(); -$provider_defined = (bool) defined( 'AS3CF_PROVIDER' ) || $this->get_defined_setting( 'provider', false ); -$key_defined = $this->get_defined_setting( 'access-key-id', false ); -$secret_defined = $this->get_defined_setting( 'secret-access-key', false ); -$keys_settings_constant = ( $key_defined || $secret_defined ) ? $this->settings_constant() : false; -$key_file_path_defined = $this->get_defined_setting( 'key-file-path', false ); -$key_file_defined = $this->get_defined_setting( 'key-file', false ); -$key_file_path_settings_constant = ( $key_file_path_defined || $key_file_defined ) ? $this->settings_constant() : false; -$providers = $this->get_provider_classes(); -$media_counts = $this->diagnostic_media_counts(); -$media_offloaded_string = empty( $media_counts['s3'] ) ? '' : number_format( $media_counts['s3'] ); +$current_provider = $this->get_provider(); +$provider_defined = (bool) defined( 'AS3CF_PROVIDER' ) || $this->get_defined_setting( 'provider', false ); +$key_defined = $this->get_defined_setting( 'access-key-id', false ); +$secret_defined = $this->get_defined_setting( 'secret-access-key', false ); +$keys_settings_constant = ( $key_defined || $secret_defined ) ? $this->settings_constant() : false; +$key_file_path_defined = $this->get_defined_setting( 'key-file-path', false ); +$key_file_defined = $this->get_defined_setting( 'key-file', false ); +$key_file_path_settings_constant = ( $key_file_path_defined || $key_file_defined ) ? $this->settings_constant() : false; +$use_server_roles_defined = $this->get_defined_setting( 'use-server-roles', false ); +$use_server_roles_settings_constant = $use_server_roles_defined ? $this->settings_constant() : false; +$providers = $this->get_provider_classes(); +$media_counts = $this->media_counts(); +$media_offloaded_string = empty( $media_counts['offloaded'] ) ? '' : number_format( $media_counts['offloaded'] ); ?>
@@ -50,6 +52,7 @@ foreach ( array( $key_file_path_constant, $key_file_path_settings_constant ) as $defined_constant ) { if ( $defined_constant ) { $defined_constants[] = $defined_constant; + break; } } } else { @@ -57,11 +60,22 @@ continue; } - $use_server_role_constant = $provider_class::use_server_role_constant(); + if ( $provider_class::use_server_roles_allowed() ) { + $use_server_roles_constant = $provider_class::use_server_roles_constant(); + $any_use_server_roles_constant_defined = (bool) $use_server_roles_constant || $use_server_roles_settings_constant; + + $defined_use_server_roles_constants = array(); + foreach ( array( $use_server_roles_constant, $use_server_roles_settings_constant ) as $defined_constant ) { + if ( $defined_constant ) { + $defined_use_server_roles_constants[] = $defined_constant; + break; + } + } + } $selected_authmethod = 'define'; - if ( ! $any_access_key_constant_defined && $provider_class::use_server_roles() ) { + if ( ! $any_access_key_constant_defined && $provider_selected && $current_provider->use_server_roles() ) { $selected_authmethod = 'server-role'; } elseif ( ! $any_access_key_constant_defined && $provider_selected && ( $current_provider->are_access_keys_set() || $current_provider->get_key_file() ) ) { $selected_authmethod = 'db'; @@ -79,8 +93,8 @@ break; case 'server-role': $server_role_authmethod_attr = $provider_selected ? ' checked="checked"' : ''; - $define_authmethod_attr = ' data-as3cf-disabled="true" disabled="disabled"'; - $db_authmethod_attr = ' data-as3cf-disabled="true" disabled="disabled"'; + $define_authmethod_attr = $any_use_server_roles_constant_defined ? ' data-as3cf-disabled="true" disabled="disabled"' : ''; + $db_authmethod_attr = $any_use_server_roles_constant_defined ? ' data-as3cf-disabled="true" disabled="disabled"' : ''; break; case 'db': $db_authmethod_attr = $provider_selected ? ' checked="checked"' : ''; @@ -248,16 +262,17 @@ > - more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' ); } else { - printf( __( 'If you host your WordPress site on %s 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' ), $provider_class::get_provider_name() ); - echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#save-access-keys' ); + printf( __( 'If you host your WordPress site on %s, choose this option and make use of IAM Roles.', 'amazon-s3-and-cloudfront' ), $provider_class::get_provider_name() ); + echo ' ' . $this->more_info_link( '/wp-offload-media/doc/' . $provider_service_quick_start_slug . '/#iam-roles' ); ?> - + /> diff --git a/wordpress-s3.php b/wordpress-s3.php index a64fb34a..13b616d8 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, DigitalOcean Spaces or Google Cloud Storage for storage and delivery. Optionally configure Amazon CloudFront or another CDN for even faster delivery. Author: Delicious Brains -Version: 2.1.1 +Version: 2.2 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.1.1'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.2'; require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';