WP Offload S3 Lite - Version 2.6.1

Version Description

= 2.6 = This is a major upgrade that updates the format of information stored about offloaded Media Library items. Once upgraded you will not be able to downgrade without restoring data from a backup. This version requires PHP 5.6+

= 2.3 = This is a major upgrade that switches to using a custom table for storing data about offloaded Media Library items. Once upgraded you will not be able to downgrade without restoring data from a backup.

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

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

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

Download this release

Release Info

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

Code changes from version 2.6.0 to 2.6.1

README.md CHANGED
@@ -4,7 +4,7 @@
4
  **Requires at least:** 4.9
5
  **Tested up to:** 5.9
6
  **Requires PHP:** 5.6
7
- **Stable tag:** 2.6.0
8
  **License:** GPLv3
9
 
10
  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.
@@ -93,6 +93,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
93
 
94
  ## Changelog ##
95
 
 
 
 
96
  ### WP Offload Media Lite 2.6 - 2022-03-09 ###
97
  * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting)
98
  * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing
4
  **Requires at least:** 4.9
5
  **Tested up to:** 5.9
6
  **Requires PHP:** 5.6
7
+ **Stable tag:** 2.6.1
8
  **License:** GPLv3
9
 
10
  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.
93
 
94
  ## Changelog ##
95
 
96
+ ### WP Offload Media Lite 2.6.1 - 2022-03-21 ###
97
+ * Bug fix: Local files are no longer removed if as3cf_pre_upload_attachment filter is used to abort upload
98
+
99
  ### WP Offload Media Lite 2.6 - 2022-03-09 ###
100
  * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting)
101
  * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing
classes/amazon-s3-and-cloudfront.php CHANGED
@@ -26,6 +26,7 @@ use DeliciousBrains\WP_Offload_Media\Providers\Storage\DigitalOcean_Provider;
26
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\GCP_Provider;
27
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Null_Provider;
28
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider;
 
29
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade;
30
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_Content_Replace_URLs;
31
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_EDD_Replace_URLs;
@@ -166,7 +167,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
166
  */
167
  protected $integration_manager;
168
 
169
- const LATEST_UPGRADE_ROUTINE = 10;
170
 
171
  /**
172
  * @param string $plugin_file_path
@@ -231,6 +232,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base {
231
  new Upgrade_Items_Table( $this );
232
  new Upgrade_Tools_Errors( $this );
233
  new Upgrade_Item_Extra_Data( $this );
 
234
 
235
  // Plugin setup
236
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
26
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\GCP_Provider;
27
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Null_Provider;
28
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider;
29
+ use DeliciousBrains\WP_Offload_Media\Upgrades\Clear_Postmeta_Cache;
30
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade;
31
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_Content_Replace_URLs;
32
  use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_EDD_Replace_URLs;
167
  */
168
  protected $integration_manager;
169
 
170
+ const LATEST_UPGRADE_ROUTINE = 11;
171
 
172
  /**
173
  * @param string $plugin_file_path
232
  new Upgrade_Items_Table( $this );
233
  new Upgrade_Tools_Errors( $this );
234
  new Upgrade_Item_Extra_Data( $this );
235
+ new Clear_Postmeta_Cache( $this );
236
 
237
  // Plugin setup
238
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
classes/as3cf-filter.php CHANGED
@@ -441,7 +441,7 @@ abstract class AS3CF_Filter {
441
  * @return bool
442
  */
443
  public function item_matches_src( $item_source, $url ) {
444
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) || Media_Library_Item::source_type() !== $item_source['source_type'] ) {
445
  return false;
446
  }
447
  $meta = get_post_meta( $item_source['id'], '_wp_attachment_metadata', true );
@@ -533,7 +533,7 @@ abstract class AS3CF_Filter {
533
  * @return null|string
534
  */
535
  public function get_size_string_from_url( $item_source, $url ) {
536
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) {
537
  return false;
538
  }
539
 
441
  * @return bool
442
  */
443
  public function item_matches_src( $item_source, $url ) {
444
+ if ( Item::is_empty_item_source( $item_source ) || Media_Library_Item::source_type() !== $item_source['source_type'] ) {
445
  return false;
446
  }
447
  $meta = get_post_meta( $item_source['id'], '_wp_attachment_metadata', true );
533
  * @return null|string
534
  */
535
  public function get_size_string_from_url( $item_source, $url ) {
536
+ if ( Item::is_empty_item_source( $item_source ) ) {
537
  return false;
538
  }
539
 
classes/filters/as3cf-local-to-s3.php CHANGED
@@ -183,7 +183,7 @@ class AS3CF_Local_To_S3 extends AS3CF_Filter {
183
  * @return bool|string
184
  */
185
  protected function get_url( $item_source, $object_key = null ) {
186
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) {
187
  return false;
188
  }
189
 
@@ -207,7 +207,7 @@ class AS3CF_Local_To_S3 extends AS3CF_Filter {
207
  * @return string|false
208
  */
209
  protected function get_base_url( $item_source ) {
210
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) {
211
  return false;
212
  }
213
 
183
  * @return bool|string
184
  */
185
  protected function get_url( $item_source, $object_key = null ) {
186
+ if ( Item::is_empty_item_source( $item_source ) ) {
187
  return false;
188
  }
189
 
207
  * @return string|false
208
  */
209
  protected function get_base_url( $item_source ) {
210
+ if ( Item::is_empty_item_source( $item_source ) ) {
211
  return false;
212
  }
213
 
classes/filters/as3cf-s3-to-local.php CHANGED
@@ -110,7 +110,7 @@ class AS3CF_S3_To_Local extends AS3CF_Filter {
110
  * @return bool|string
111
  */
112
  protected function get_url( $item_source, $object_key = null ) {
113
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) {
114
  return false;
115
  }
116
 
@@ -134,7 +134,7 @@ class AS3CF_S3_To_Local extends AS3CF_Filter {
134
  * @return string|false
135
  */
136
  protected function get_base_url( $item_source ) {
137
- if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) {
138
  return false;
139
  }
140
 
@@ -155,7 +155,7 @@ class AS3CF_S3_To_Local extends AS3CF_Filter {
155
  *
156
  * @param string $url
157
  *
158
- * @return bool|int
159
  */
160
  public function get_item_source_from_url( $url ) {
161
  // Result for sized URL already cached in request, return it.
@@ -165,7 +165,7 @@ class AS3CF_S3_To_Local extends AS3CF_Filter {
165
 
166
  $item_source = Item::get_item_source_by_remote_url( $url );
167
 
168
- if ( ! empty( $item_source['id'] ) ) {
169
  $this->query_cache[ $url ] = $item_source;
170
 
171
  return $item_source;
@@ -187,7 +187,7 @@ class AS3CF_S3_To_Local extends AS3CF_Filter {
187
 
188
  $item_source = Item::get_item_source_by_remote_url( $full_url );
189
 
190
- $this->query_cache[ $full_url ] = ! empty( $item_source['id'] ) ? $item_source : false;
191
 
192
  return $this->query_cache[ $full_url ];
193
  }
110
  * @return bool|string
111
  */
112
  protected function get_url( $item_source, $object_key = null ) {
113
+ if ( Item::is_empty_item_source( $item_source ) ) {
114
  return false;
115
  }
116
 
134
  * @return string|false
135
  */
136
  protected function get_base_url( $item_source ) {
137
+ if ( Item::is_empty_item_source( $item_source ) ) {
138
  return false;
139
  }
140
 
155
  *
156
  * @param string $url
157
  *
158
+ * @return bool|array
159
  */
160
  public function get_item_source_from_url( $url ) {
161
  // Result for sized URL already cached in request, return it.
165
 
166
  $item_source = Item::get_item_source_by_remote_url( $url );
167
 
168
+ if ( ! Item::is_empty_item_source( $item_source ) ) {
169
  $this->query_cache[ $url ] = $item_source;
170
 
171
  return $item_source;
187
 
188
  $item_source = Item::get_item_source_by_remote_url( $full_url );
189
 
190
+ $this->query_cache[ $full_url ] = ! Item::is_empty_item_source( $item_source ) ? $item_source : false;
191
 
192
  return $this->query_cache[ $full_url ];
193
  }
classes/integrations/core.php CHANGED
@@ -34,7 +34,7 @@ class Core extends Integration {
34
  * @param array $options Handler dependent options that may have been set for the action.
35
  */
36
  public function maybe_remove_local_files( $result, Item $as3cf_item, array $options ) {
37
- if ( ! is_wp_error( $result ) && $this->as3cf->get_setting( 'remove-local-file', false ) && $as3cf_item->exists_locally() ) {
38
  $remove_local_handler = $this->as3cf->get_item_handler( Remove_Local_Handler::get_item_handler_key_name() );
39
 
40
  $remove_local_handler->handle( $as3cf_item );
34
  * @param array $options Handler dependent options that may have been set for the action.
35
  */
36
  public function maybe_remove_local_files( $result, Item $as3cf_item, array $options ) {
37
+ if ( ! is_wp_error( $result ) && $as3cf_item->id() && $this->as3cf->get_setting( 'remove-local-file', false ) && $as3cf_item->exists_locally() ) {
38
  $remove_local_handler = $this->as3cf->get_item_handler( Remove_Local_Handler::get_item_handler_key_name() );
39
 
40
  $remove_local_handler->handle( $as3cf_item );
classes/integrations/media-library.php CHANGED
@@ -225,13 +225,7 @@ class Media_Library extends Integration {
225
  */
226
  protected function upload_item( Media_Library_Item $as3cf_item, array $offloaded_files ) {
227
  $upload_handler = $this->as3cf->get_item_handler( Upload_Handler::get_item_handler_key_name() );
228
- $upload_result = $upload_handler->handle( $as3cf_item, array( 'offloaded_files' => $offloaded_files ) );
229
-
230
- if ( is_wp_error( $upload_result ) ) {
231
- foreach ( $upload_result->get_error_messages() as $error_message ) {
232
- AS3CF_Error::Log( $error_message );
233
- }
234
- }
235
  }
236
 
237
  /**
@@ -1124,7 +1118,7 @@ class Media_Library extends Integration {
1124
  public function get_attachment_id_from_provider_url( $url ) {
1125
  $item_source = $this->as3cf->filter_provider->get_item_source_from_url( $url );
1126
 
1127
- if ( ! empty( $item_source['id'] ) && ! empty( $item_source['source_type'] ) && Media_Library_Item::source_type() === $item_source['source_type'] ) {
1128
  return $item_source['id'];
1129
  }
1130
 
@@ -1141,7 +1135,7 @@ class Media_Library extends Integration {
1141
  public function get_attachment_id_from_local_url( $url ) {
1142
  $item_source = $this->as3cf->filter_local->get_item_source_from_url( $url );
1143
 
1144
- if ( ! empty( $item_source['id'] ) && ! empty( $item_source['source_type'] ) && Media_Library_Item::source_type() === $item_source['source_type'] ) {
1145
  return $item_source['id'];
1146
  }
1147
 
225
  */
226
  protected function upload_item( Media_Library_Item $as3cf_item, array $offloaded_files ) {
227
  $upload_handler = $this->as3cf->get_item_handler( Upload_Handler::get_item_handler_key_name() );
228
+ $upload_handler->handle( $as3cf_item, array( 'offloaded_files' => $offloaded_files ) );
 
 
 
 
 
 
229
  }
230
 
231
  /**
1118
  public function get_attachment_id_from_provider_url( $url ) {
1119
  $item_source = $this->as3cf->filter_provider->get_item_source_from_url( $url );
1120
 
1121
+ if ( ! Item::is_empty_item_source( $item_source ) && Media_Library_Item::source_type() === $item_source['source_type'] ) {
1122
  return $item_source['id'];
1123
  }
1124
 
1135
  public function get_attachment_id_from_local_url( $url ) {
1136
  $item_source = $this->as3cf->filter_local->get_item_source_from_url( $url );
1137
 
1138
+ if ( ! Item::is_empty_item_source( $item_source ) && Media_Library_Item::source_type() === $item_source['source_type'] ) {
1139
  return $item_source['id'];
1140
  }
1141
 
classes/items/download-handler.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
5
- use AS3CF_Error;
6
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider;
7
  use Exception;
8
  use WP_Error;
@@ -80,13 +79,13 @@ class Download_Handler extends Item_Handler {
80
  // we'll return an error.
81
  $current_provider = $this->as3cf->get_storage_provider();
82
  if ( ! empty( $current_provider ) && $current_provider::get_provider_key_name() !== $as3cf_item->provider() ) {
83
- $message = sprintf(
84
  __( '%1$s with ID %d is offloaded to a different provider than currently configured', 'amazon-s3-and-cloudfront' ),
85
  $this->as3cf->get_source_type_name( $as3cf_item->source_type() ),
86
  $as3cf_item->source_id()
87
  );
88
 
89
- return new WP_Error( 'exception', $message );
90
  } else {
91
  $provider_client = $this->as3cf->get_provider_client( $as3cf_item->region() );
92
 
@@ -148,20 +147,21 @@ class Download_Handler extends Item_Handler {
148
  // Make sure the local directory exists.
149
  $dir = dirname( $object['SaveAs'] );
150
  if ( ! is_dir( $dir ) && ! wp_mkdir_p( $dir ) ) {
151
- $error_message = sprintf( __( 'The local directory %s does not exist and could not be created.', 'amazon-s3-and-cloudfront' ), $dir );
152
- AS3CF_Error::log( sprintf( __( 'There was an error attempting to download the file %s from the bucket: %s', 'amazon-s3-and-cloudfront' ), $object['Key'], $error_message ) );
 
 
153
  }
154
 
155
  try {
156
  $provider_client->get_object( $object );
157
  } catch ( Exception $e ) {
158
- $error_msg = sprintf( __( 'Error downloading %1$s from bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $e->getMessage() );
159
- AS3CF_Error::log( $error_msg );
160
-
161
  // If storage provider file doesn't exist, an empty local file will be created, clean it up.
162
  @unlink( $object['SaveAs'] );
163
 
164
- return new WP_Error( 'download_object', $error_msg );
 
 
165
  }
166
 
167
  return true;
2
 
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
 
5
  use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider;
6
  use Exception;
7
  use WP_Error;
79
  // we'll return an error.
80
  $current_provider = $this->as3cf->get_storage_provider();
81
  if ( ! empty( $current_provider ) && $current_provider::get_provider_key_name() !== $as3cf_item->provider() ) {
82
+ $error_msg = sprintf(
83
  __( '%1$s with ID %d is offloaded to a different provider than currently configured', 'amazon-s3-and-cloudfront' ),
84
  $this->as3cf->get_source_type_name( $as3cf_item->source_type() ),
85
  $as3cf_item->source_id()
86
  );
87
 
88
+ return $this->return_handler_error( $error_msg );
89
  } else {
90
  $provider_client = $this->as3cf->get_provider_client( $as3cf_item->region() );
91
 
147
  // Make sure the local directory exists.
148
  $dir = dirname( $object['SaveAs'] );
149
  if ( ! is_dir( $dir ) && ! wp_mkdir_p( $dir ) ) {
150
+ $error_msg = sprintf( __( 'The local directory %s does not exist and could not be created.', 'amazon-s3-and-cloudfront' ), $dir );
151
+ $error_msg = sprintf( __( 'There was an error attempting to download the file %1$s from the bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $error_msg );
152
+
153
+ return $this->return_handler_error( $error_msg );
154
  }
155
 
156
  try {
157
  $provider_client->get_object( $object );
158
  } catch ( Exception $e ) {
 
 
 
159
  // If storage provider file doesn't exist, an empty local file will be created, clean it up.
160
  @unlink( $object['SaveAs'] );
161
 
162
+ $error_msg = sprintf( __( 'Error downloading %1$s from bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $e->getMessage() );
163
+
164
+ return $this->return_handler_error( $error_msg );
165
  }
166
 
167
  return true;
classes/items/item-handler.php CHANGED
@@ -121,6 +121,11 @@ abstract class Item_Handler {
121
 
122
  // Cancelled, let caller know that request was not handled.
123
  if ( false !== $cancel ) {
 
 
 
 
 
124
  return $this->return_result( false, $as3cf_item, $options );
125
  }
126
 
@@ -177,18 +182,24 @@ abstract class Item_Handler {
177
  abstract protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options );
178
 
179
  /**
180
- * Helper to record errors and return meta data on handler error.
181
  *
182
- * @param string $error_msg
183
- * @param array|null $return
184
  *
185
- * @return array|WP_Error
186
  */
187
  protected function return_handler_error( $error_msg, $return = null ) {
188
- AS3CF_Error::log( $error_msg );
 
 
 
 
 
 
189
 
190
  if ( is_null( $return ) ) {
191
- return new WP_Error( 'exception', $error_msg );
192
  }
193
 
194
  return $return;
121
 
122
  // Cancelled, let caller know that request was not handled.
123
  if ( false !== $cancel ) {
124
+ // If something unexpected happened, let the caller know.
125
+ if ( is_wp_error( $cancel ) ) {
126
+ return $this->return_result( $cancel, $as3cf_item, $options );
127
+ }
128
+
129
  return $this->return_result( false, $as3cf_item, $options );
130
  }
131
 
182
  abstract protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options );
183
 
184
  /**
185
+ * Helper to record errors and return them or optional supplied value.
186
  *
187
+ * @param string|WP_Error $error_msg An error message or already constructed WP_Error.
188
+ * @param mixed|null $return Optional return value instead of WP_Error.
189
  *
190
+ * @return mixed|WP_Error
191
  */
192
  protected function return_handler_error( $error_msg, $return = null ) {
193
+ if ( is_wp_error( $error_msg ) ) {
194
+ foreach ( $error_msg->get_error_messages() as $msg ) {
195
+ AS3CF_Error::Log( $msg );
196
+ }
197
+ } else {
198
+ AS3CF_Error::log( $error_msg );
199
+ }
200
 
201
  if ( is_null( $return ) ) {
202
+ return is_wp_error( $error_msg ) ? $error_msg : new WP_Error( 'exception', $error_msg );
203
  }
204
 
205
  return $return;
classes/items/item.php CHANGED
@@ -800,7 +800,7 @@ abstract class Item {
800
 
801
  $source_id = (int) $source_id;
802
 
803
- if ( empty( $source_id ) ) {
804
  return false;
805
  }
806
 
@@ -1410,7 +1410,7 @@ abstract class Item {
1410
  *
1411
  * While source id isn't strictly unique, it is by source type, which is always used in queries based on called class.
1412
  *
1413
- * @param int $upper_bound Returned source_ids should be lower than this, use null/0 for no upper bound.
1414
  * @param int $limit Maximum number of source_ids to return. Required if not counting.
1415
  * @param bool $count Just return a count of matching source_ids? Negates $limit, default false.
1416
  * @param int $originator Optionally restrict to only records with given originator type from ORIGINATORS const.
@@ -1421,17 +1421,16 @@ abstract class Item {
1421
  public static function get_source_ids( $upper_bound, $limit, $count = false, $originator = null, $is_verified = null ) {
1422
  global $wpdb;
1423
 
1424
- $args = array( static::$source_type );
1425
-
1426
  if ( $count ) {
1427
  $sql = 'SELECT COUNT(DISTINCT source_id)';
1428
  } else {
1429
  $sql = 'SELECT DISTINCT source_id';
1430
  }
1431
 
1432
- $sql .= ' FROM ' . static::items_table() . ' WHERE source_type = %s';
 
1433
 
1434
- if ( ! empty( $upper_bound ) ) {
1435
  $sql .= ' AND source_id < %d';
1436
  $args[] = $upper_bound;
1437
  }
@@ -1967,4 +1966,24 @@ abstract class Item {
1967
 
1968
  return $offloaded_files;
1969
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1970
  }
800
 
801
  $source_id = (int) $source_id;
802
 
803
+ if ( $source_id < 0 ) {
804
  return false;
805
  }
806
 
1410
  *
1411
  * While source id isn't strictly unique, it is by source type, which is always used in queries based on called class.
1412
  *
1413
+ * @param int $upper_bound Returned source_ids should be lower than this, use null for no upper bound.
1414
  * @param int $limit Maximum number of source_ids to return. Required if not counting.
1415
  * @param bool $count Just return a count of matching source_ids? Negates $limit, default false.
1416
  * @param int $originator Optionally restrict to only records with given originator type from ORIGINATORS const.
1421
  public static function get_source_ids( $upper_bound, $limit, $count = false, $originator = null, $is_verified = null ) {
1422
  global $wpdb;
1423
 
 
 
1424
  if ( $count ) {
1425
  $sql = 'SELECT COUNT(DISTINCT source_id)';
1426
  } else {
1427
  $sql = 'SELECT DISTINCT source_id';
1428
  }
1429
 
1430
+ $sql .= ' FROM ' . static::items_table() . ' WHERE source_type = %s';
1431
+ $args = array( static::$source_type );
1432
 
1433
+ if ( is_numeric( $upper_bound ) ) {
1434
  $sql .= ' AND source_id < %d';
1435
  $args[] = $upper_bound;
1436
  }
1966
 
1967
  return $offloaded_files;
1968
  }
1969
+
1970
+ /**
1971
+ * Is the supplied item_source considered to be empty?
1972
+ *
1973
+ * @param array $item_source
1974
+ *
1975
+ * @return bool
1976
+ */
1977
+ public static function is_empty_item_source( $item_source ) {
1978
+ if (
1979
+ empty( $item_source['source_type'] ) ||
1980
+ ! isset( $item_source['id'] ) ||
1981
+ ! is_numeric( $item_source['id'] ) ||
1982
+ $item_source['id'] < 0
1983
+ ) {
1984
+ return true;
1985
+ }
1986
+
1987
+ return false;
1988
+ }
1989
  }
classes/items/remove-local-handler.php CHANGED
@@ -3,7 +3,6 @@
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
5
  use AS3CF_Error;
6
- use WP_Error;
7
 
8
  class Remove_Local_Handler extends Item_Handler {
9
  /**
@@ -51,7 +50,7 @@ class Remove_Local_Handler extends Item_Handler {
51
  * @param Item $as3cf_item
52
  * @param array $options
53
  *
54
- * @return Manifest|WP_Error
55
  */
56
  protected function pre_handle( Item $as3cf_item, array $options ) {
57
  $manifest = new Manifest();
@@ -143,7 +142,7 @@ class Remove_Local_Handler extends Item_Handler {
143
  * @param Manifest $manifest
144
  * @param array $options
145
  *
146
- * @return bool|WP_Error
147
  */
148
  protected function handle_item( Item $as3cf_item, Manifest $manifest, array $options ) {
149
  foreach ( $manifest->objects as &$file_to_remove ) {
@@ -175,7 +174,7 @@ class Remove_Local_Handler extends Item_Handler {
175
  * @param Manifest $manifest
176
  * @param array $options
177
  *
178
- * @return bool|WP_Error
179
  */
180
  protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) {
181
  if ( empty( $manifest->objects ) ) {
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
5
  use AS3CF_Error;
 
6
 
7
  class Remove_Local_Handler extends Item_Handler {
8
  /**
50
  * @param Item $as3cf_item
51
  * @param array $options
52
  *
53
+ * @return Manifest
54
  */
55
  protected function pre_handle( Item $as3cf_item, array $options ) {
56
  $manifest = new Manifest();
142
  * @param Manifest $manifest
143
  * @param array $options
144
  *
145
+ * @return bool
146
  */
147
  protected function handle_item( Item $as3cf_item, Manifest $manifest, array $options ) {
148
  foreach ( $manifest->objects as &$file_to_remove ) {
174
  * @param Manifest $manifest
175
  * @param array $options
176
  *
177
+ * @return bool
178
  */
179
  protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) {
180
  if ( empty( $manifest->objects ) ) {
classes/items/remove-provider-handler.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
5
- use AS3CF_Error;
6
  use Exception;
7
  use WP_Error;
8
 
@@ -37,15 +36,15 @@ class Remove_Provider_Handler extends Item_Handler {
37
  $paths = array();
38
 
39
  if ( ! empty( $options['object_keys'] ) && ! is_array( $options['object_keys'] ) ) {
40
- return new WP_Error( 'remove-error', __( 'Invalid object_keys option provided.', 'amazon-s3-and-cloudfront' ) );
41
  }
42
 
43
  if ( ! empty( $options['offloaded_files'] ) && ! is_array( $options['offloaded_files'] ) ) {
44
- return new WP_Error( 'remove-error', __( 'Invalid offloaded_files option provided.', 'amazon-s3-and-cloudfront' ) );
45
  }
46
 
47
  if ( ! empty( $options['object_keys'] ) && ! empty( $options['offloaded_files'] ) ) {
48
- return new WP_Error( 'remove-error', __( 'Providing both object_keys and offloaded_files options is not supported.', 'amazon-s3-and-cloudfront' ) );
49
  }
50
 
51
  if ( empty( $options['offloaded_files'] ) ) {
@@ -118,9 +117,9 @@ class Remove_Provider_Handler extends Item_Handler {
118
  ) );
119
  }
120
  } catch ( Exception $e ) {
121
- AS3CF_Error::log( 'Error removing files from bucket: ' . $e->getMessage() );
122
 
123
- return new WP_Error( 'remove-error', $e->getMessage() );
124
  }
125
 
126
  return true;
@@ -133,7 +132,7 @@ class Remove_Provider_Handler extends Item_Handler {
133
  * @param Manifest $manifest
134
  * @param array $options
135
  *
136
- * @return bool|WP_Error
137
  */
138
  protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) {
139
  return true;
2
 
3
  namespace DeliciousBrains\WP_Offload_Media\Items;
4
 
 
5
  use Exception;
6
  use WP_Error;
7
 
36
  $paths = array();
37
 
38
  if ( ! empty( $options['object_keys'] ) && ! is_array( $options['object_keys'] ) ) {
39
+ return $this->return_handler_error( __( 'Invalid object_keys option provided.', 'amazon-s3-and-cloudfront' ) );
40
  }
41
 
42
  if ( ! empty( $options['offloaded_files'] ) && ! is_array( $options['offloaded_files'] ) ) {
43
+ return $this->return_handler_error( __( 'Invalid offloaded_files option provided.', 'amazon-s3-and-cloudfront' ) );
44
  }
45
 
46
  if ( ! empty( $options['object_keys'] ) && ! empty( $options['offloaded_files'] ) ) {
47
+ return $this->return_handler_error( __( 'Providing both object_keys and offloaded_files options is not supported.', 'amazon-s3-and-cloudfront' ) );
48
  }
49
 
50
  if ( empty( $options['offloaded_files'] ) ) {
117
  ) );
118
  }
119
  } catch ( Exception $e ) {
120
+ $error_msg = sprintf( __( 'Error removing files from bucket: %s', 'amazon-s3-and-cloudfront' ), $e->getMessage() );
121
 
122
+ return $this->return_handler_error( $error_msg );
123
  }
124
 
125
  return true;
132
  * @param Manifest $manifest
133
  * @param array $options
134
  *
135
+ * @return bool
136
  */
137
  protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) {
138
  return true;
classes/upgrades/clear-postmeta-cache.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace DeliciousBrains\WP_Offload_Media\Upgrades;
4
+
5
+ /**
6
+ * Clear_Postmeta_Cache Class
7
+ *
8
+ * This class clears the postmeta cache after upgrade to 2.6.1
9
+ *
10
+ * @since 2.6.1
11
+ */
12
+ class Clear_Postmeta_Cache extends Upgrade {
13
+
14
+ /**
15
+ * @var int
16
+ */
17
+ protected $upgrade_id = 11;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $upgrade_name = 'clear_postmeta_cache';
23
+
24
+ /**
25
+ * @var string 'metadata', 'attachment'
26
+ */
27
+ protected $upgrade_type = 'metadata';
28
+
29
+ /**
30
+ * @var int
31
+ */
32
+ private $batch_limit = 1000;
33
+
34
+ /**
35
+ * Get running update text.
36
+ *
37
+ * @return string
38
+ */
39
+ protected function get_running_update_text() {
40
+ return __( 'and clear old post meta cache items.', 'amazon-s3-and-cloudfront' );
41
+ }
42
+
43
+ /**
44
+ * Remove one chunk of post meta cache records.
45
+ *
46
+ * @param string $item Table prefix for the current blog.
47
+ *
48
+ * @return bool
49
+ */
50
+ protected function upgrade_item( $item ) {
51
+ global $wpdb;
52
+
53
+ $sql = "DELETE FROM wp_postmeta WHERE meta_key = 'amazonS3_cache' AND meta_id <= %d LIMIT {$this->batch_limit}";
54
+ $wpdb->query( $wpdb->prepare( $sql, array( $this->session[ $item ] ) ) );
55
+
56
+ return true;
57
+ }
58
+
59
+ /**
60
+ * Count items left to process for the current blog.
61
+ *
62
+ * @return int
63
+ */
64
+ protected function count_items_to_process() {
65
+ global $wpdb;
66
+
67
+ // Store the highest known meta_id at the time we begin processing.
68
+ if ( empty( $this->session[ $this->blog_prefix ] ) ) {
69
+ $sql = "SELECT meta_id FROM {$this->blog_prefix}postmeta WHERE meta_key = 'amazonS3_cache' ORDER BY meta_id DESC LIMIT 0, 1;";
70
+ $last = $wpdb->get_var( $sql );
71
+
72
+ $this->session[ $this->blog_prefix ] = $last;
73
+ }
74
+
75
+ return count( $this->get_items_to_process( $this->blog_prefix, 0 ) );
76
+ }
77
+
78
+ /**
79
+ * Get array of items that each represent one chunk to be cleared.
80
+ *
81
+ * @param string $prefix Table prefix for blog.
82
+ * @param int $limit
83
+ * @param bool|mixed $offset
84
+ *
85
+ * @return array
86
+ */
87
+ protected function get_items_to_process( $prefix, $limit, $offset = false ) {
88
+ $count = $this->get_real_count( $prefix );
89
+ if ( 0 === $count ) {
90
+ return array();
91
+ }
92
+
93
+ $chunks = ceil( $count / $this->batch_limit );
94
+
95
+ return array_fill( 0, $chunks, $prefix );
96
+ }
97
+
98
+ /**
99
+ * Return the real number of remaining amazonS3_cache items to clear out.
100
+ *
101
+ * @param string $prefix
102
+ *
103
+ * @return int
104
+ */
105
+ private function get_real_count( $prefix ) {
106
+ global $wpdb;
107
+
108
+ $sql = "SELECT count(meta_id) FROM {$prefix}postmeta WHERE meta_key = 'amazonS3_cache' AND meta_id <= %d";
109
+ $count = $wpdb->get_var( $wpdb->prepare( $sql, $this->session[ $prefix ] ) );
110
+
111
+ return (int) $count;
112
+ }
113
+ }
languages/amazon-s3-and-cloudfront-en.pot CHANGED
@@ -8,7 +8,7 @@ msgid ""
8
  msgstr ""
9
  "Project-Id-Version: amazon-s3-and-cloudfront\n"
10
  "Report-Msgid-Bugs-To: nom@deliciousbrains.com\n"
11
- "POT-Creation-Date: 2022-03-09 13:52+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,17 +17,17 @@ msgstr ""
17
  "Content-Type: text/plain; charset=UTF-8\n"
18
  "Content-Transfer-Encoding: 8bit\n"
19
 
20
- #: classes/amazon-s3-and-cloudfront.php:195
21
  #: classes/amazon-s3-and-cloudfront.php:196
 
22
  msgid "Offload Media Lite"
23
  msgstr ""
24
 
25
- #: classes/amazon-s3-and-cloudfront.php:436
26
- #: classes/amazon-s3-and-cloudfront.php:453
27
  msgid "Unknown"
28
  msgstr ""
29
 
30
- #: classes/amazon-s3-and-cloudfront.php:534
31
  #: view/bucket-select.php:87
32
  #: view/delivery-provider-select.php:129
33
  #: view/delivery-provider-select.php:149
@@ -38,185 +38,185 @@ msgstr ""
38
  msgid "defined in wp-config.php"
39
  msgstr ""
40
 
41
- #: classes/amazon-s3-and-cloudfront.php:1521
42
  msgid "This action can only be performed through an admin screen."
43
  msgstr ""
44
 
45
- #: classes/amazon-s3-and-cloudfront.php:1523
46
  msgid "Cheatin&#8217; eh?"
47
  msgstr ""
48
 
49
- #: classes/amazon-s3-and-cloudfront.php:1525
50
  msgid "You do not have sufficient permissions to access this page."
51
  msgstr ""
52
 
53
- #: classes/amazon-s3-and-cloudfront.php:1849
54
  msgid "Error Getting Bucket Region"
55
  msgstr ""
56
 
57
- #: classes/amazon-s3-and-cloudfront.php:1850
58
  #, php-format
59
  msgid "There was an error attempting to get the region of the bucket %s: %s"
60
  msgstr ""
61
 
62
- #: classes/amazon-s3-and-cloudfront.php:1953
63
  msgid ""
64
  "This is a test file to check if the user has write permission to the bucket. "
65
  "Delete me if found."
66
  msgstr ""
67
 
68
- #: classes/amazon-s3-and-cloudfront.php:1959
69
  #, php-format
70
  msgid ""
71
  "There was an error attempting to check the permissions of the bucket %s: %s"
72
  msgstr ""
73
 
74
- #: classes/amazon-s3-and-cloudfront.php:2077
75
  msgid "Error creating bucket"
76
  msgstr ""
77
 
78
- #: classes/amazon-s3-and-cloudfront.php:2078
79
  msgid "Bucket name too short."
80
  msgstr ""
81
 
82
- #: classes/amazon-s3-and-cloudfront.php:2079
83
  msgid "Bucket name too long."
84
  msgstr ""
85
 
86
- #: classes/amazon-s3-and-cloudfront.php:2080
87
  msgid ""
88
  "Invalid character. Bucket names can contain lowercase letters, numbers, "
89
  "periods and hyphens."
90
  msgstr ""
91
 
92
- #: classes/amazon-s3-and-cloudfront.php:2081
93
  msgid "Error saving bucket"
94
  msgstr ""
95
 
96
- #: classes/amazon-s3-and-cloudfront.php:2082
97
  msgid "Error fetching buckets"
98
  msgstr ""
99
 
100
- #: classes/amazon-s3-and-cloudfront.php:2083
101
  msgid "Error getting URL preview: "
102
  msgstr ""
103
 
104
- #: classes/amazon-s3-and-cloudfront.php:2084
105
  msgid "The changes you made will be lost if you navigate away from this page"
106
  msgstr ""
107
 
108
- #: classes/amazon-s3-and-cloudfront.php:2085
109
  msgid "Getting diagnostic info..."
110
  msgstr ""
111
 
112
- #: classes/amazon-s3-and-cloudfront.php:2086
113
  msgid "Error getting diagnostic info: "
114
  msgstr ""
115
 
116
- #: classes/amazon-s3-and-cloudfront.php:2087
117
  msgctxt "placeholder for hidden access key, 39 char max"
118
  msgid "-- not shown --"
119
  msgstr ""
120
 
121
- #: classes/amazon-s3-and-cloudfront.php:2089
122
- #: classes/amazon-s3-and-cloudfront.php:4210
123
  msgid "Settings saved."
124
  msgstr ""
125
 
126
- #: classes/amazon-s3-and-cloudfront.php:2211
127
  msgid "Cheatin' eh?"
128
  msgstr ""
129
 
130
- #: classes/amazon-s3-and-cloudfront.php:2284
131
  #, php-format
132
  msgid "Could not set new Delivery Provider: %s"
133
  msgstr ""
134
 
135
- #: classes/amazon-s3-and-cloudfront.php:2359
136
- #: classes/amazon-s3-and-cloudfront.php:2489
137
  msgid "No bucket name provided."
138
  msgstr ""
139
 
140
- #: classes/amazon-s3-and-cloudfront.php:2368
141
  msgid "Bucket name not valid."
142
  msgstr ""
143
 
144
- #: classes/amazon-s3-and-cloudfront.php:2381
145
  msgid "No region provided."
146
  msgstr ""
147
 
148
- #: classes/amazon-s3-and-cloudfront.php:2458
149
  #, php-format
150
  msgctxt "Trying to change public access setting for given provider's bucket."
151
  msgid "Can't change Block All Public Access setting for %s buckets."
152
  msgstr ""
153
 
154
- #: classes/amazon-s3-and-cloudfront.php:2467
155
  msgid "No block public access setting provided."
156
  msgstr ""
157
 
158
- #: classes/amazon-s3-and-cloudfront.php:2480
159
  msgid "Storage Provider not configured with access credentials."
160
  msgstr ""
161
 
162
- #: classes/amazon-s3-and-cloudfront.php:2507
163
  msgid "Could not change Block All Public Access status for bucket."
164
  msgstr ""
165
 
166
- #: classes/amazon-s3-and-cloudfront.php:2524
167
  msgid ""
168
  "<strong>Failed to Enable Block All Public Access</strong> &mdash; We could "
169
  "not enable Block All Public Access. You will need to log in to the AWS "
170
  "Console and do it manually."
171
  msgstr ""
172
 
173
- #: classes/amazon-s3-and-cloudfront.php:2526
174
  msgid ""
175
  "<strong>Failed to Disable Block All Public Access</strong> &mdash; We could "
176
  "not disable Block All Public Access. You will need to log in to the AWS "
177
  "Console and do it manually."
178
  msgstr ""
179
 
180
- #: classes/amazon-s3-and-cloudfront.php:2561
181
  #: view/provider-select.php:329
182
  msgctxt "placeholder for hidden secret access key, 39 char max"
183
  msgid "-- not shown --"
184
  msgstr ""
185
 
186
- #: classes/amazon-s3-and-cloudfront.php:2584
187
  msgid "Key File not valid JSON."
188
  msgstr ""
189
 
190
- #: classes/amazon-s3-and-cloudfront.php:2604
191
- #: classes/amazon-s3-and-cloudfront.php:2618
192
- #: classes/amazon-s3-and-cloudfront.php:2627
193
  msgctxt "missing form field"
194
  msgid " not provided."
195
  msgstr ""
196
 
197
- #: classes/amazon-s3-and-cloudfront.php:2670
198
  msgctxt "Show the media library tab"
199
  msgid "Media Library"
200
  msgstr ""
201
 
202
- #: classes/amazon-s3-and-cloudfront.php:2671
203
  msgctxt "Show the addons tab"
204
  msgid "Addons"
205
  msgstr ""
206
 
207
- #: classes/amazon-s3-and-cloudfront.php:2672
208
  msgctxt "Show the support tab"
209
  msgid "Support"
210
  msgstr ""
211
 
212
- #: classes/amazon-s3-and-cloudfront.php:2849
213
  #, php-format
214
  msgid ""
215
  "<strong>WP Offload Media</strong> &mdash; The file %s has been given %s "
216
  "permissions in the bucket."
217
  msgstr ""
218
 
219
- #: classes/amazon-s3-and-cloudfront.php:2868
220
  msgid ""
221
  "<strong>WP Offload Media Requirement Missing</strong> &mdash; Looks like you "
222
  "don't have an image manipulation library installed on this server and "
@@ -224,7 +224,7 @@ msgid ""
224
  "Please setup GD or ImageMagick."
225
  msgstr ""
226
 
227
- #: classes/amazon-s3-and-cloudfront.php:2892
228
  #, php-format
229
  msgid ""
230
  "<strong>Missing Table</strong> &mdash; One or more required database tables "
@@ -232,18 +232,18 @@ msgid ""
232
  "details. %s"
233
  msgstr ""
234
 
235
- #: classes/amazon-s3-and-cloudfront.php:3714
236
  #, php-format
237
  msgid ""
238
  "<a href=\"%s\">Define your access keys</a> to enable write access to the "
239
  "bucket"
240
  msgstr ""
241
 
242
- #: classes/amazon-s3-and-cloudfront.php:3721
243
  msgid "Quick Start Guide"
244
  msgstr ""
245
 
246
- #: classes/amazon-s3-and-cloudfront.php:3723
247
  #, php-format
248
  msgid ""
249
  "Looks like we don't have write access to this bucket. It's likely that the "
@@ -252,7 +252,7 @@ msgid ""
252
  "correctly."
253
  msgstr ""
254
 
255
- #: classes/amazon-s3-and-cloudfront.php:3725
256
  #, php-format
257
  msgid ""
258
  "Looks like we don't have access to the buckets. It's likely that the user "
@@ -260,39 +260,39 @@ msgid ""
260
  "Please see our %s for instructions on setting up permissions correctly."
261
  msgstr ""
262
 
263
- #: classes/amazon-s3-and-cloudfront.php:3895
264
  msgid "WP Offload Media Activation"
265
  msgstr ""
266
 
267
- #: classes/amazon-s3-and-cloudfront.php:3896
268
  msgid ""
269
  "WP Offload Media Lite and WP Offload Media cannot both be active. We've "
270
  "automatically deactivated WP Offload Media Lite."
271
  msgstr ""
272
 
273
- #: classes/amazon-s3-and-cloudfront.php:3898
274
  msgid "WP Offload Media Lite Activation"
275
  msgstr ""
276
 
277
- #: classes/amazon-s3-and-cloudfront.php:3899
278
  msgid ""
279
  "WP Offload Media Lite and WP Offload Media cannot both be active. We've "
280
  "automatically deactivated WP Offload Media."
281
  msgstr ""
282
 
283
- #: classes/amazon-s3-and-cloudfront.php:3953
284
  msgid "More&nbsp;info&nbsp;&raquo;"
285
  msgstr ""
286
 
287
- #: classes/amazon-s3-and-cloudfront.php:4022
288
  msgid "this doc"
289
  msgstr ""
290
 
291
- #: classes/amazon-s3-and-cloudfront.php:4024
292
  msgid "WP Offload Media Feature Removed"
293
  msgstr ""
294
 
295
- #: classes/amazon-s3-and-cloudfront.php:4025
296
  #, php-format
297
  msgid ""
298
  "You had the \"Always non-SSL\" option selected in your settings, but we've "
@@ -303,21 +303,21 @@ msgid ""
303
  "to the old behavior."
304
  msgstr ""
305
 
306
- #: classes/amazon-s3-and-cloudfront.php:4173
307
  msgid "Assets Pull"
308
  msgstr ""
309
 
310
- #: classes/amazon-s3-and-cloudfront.php:4174
311
  msgid ""
312
  "An addon for WP Offload Media to serve your site's JS, CSS, and other "
313
  "enqueued assets from Amazon CloudFront or another CDN."
314
  msgstr ""
315
 
316
- #: classes/amazon-s3-and-cloudfront.php:4178
317
  msgid "Feature"
318
  msgstr ""
319
 
320
- #: classes/amazon-s3-and-cloudfront.php:4224
321
  #, php-format
322
  msgid ""
323
  "<strong>Amazon Web Services Plugin No Longer Required</strong> &mdash; As of "
@@ -328,7 +328,7 @@ msgid ""
328
  "plugin, it should be safe to deactivate and delete it. %2$s"
329
  msgstr ""
330
 
331
- #: classes/amazon-s3-and-cloudfront.php:4256
332
  #, php-format
333
  msgid ""
334
  "<strong>WP Offload Media Settings Moved</strong> &mdash; You now define your "
@@ -473,72 +473,71 @@ msgstr ""
473
  msgid "Can't create item from media library item %d"
474
  msgstr ""
475
 
476
- #: classes/integrations/media-library.php:497
477
  msgid "Offload"
478
  msgstr ""
479
 
480
- #: classes/integrations/media-library.php:923
481
  msgid "No"
482
  msgstr ""
483
 
484
- #: classes/integrations/media-library.php:933
485
  msgctxt "Storage provider key name"
486
  msgid "Storage Provider"
487
  msgstr ""
488
 
489
- #: classes/integrations/media-library.php:934
490
  msgctxt "Storage provider name"
491
  msgid "Storage Provider"
492
  msgstr ""
493
 
494
- #: classes/integrations/media-library.php:935
495
  msgctxt "Bucket name"
496
  msgid "Bucket"
497
  msgstr ""
498
 
499
- #: classes/integrations/media-library.php:936
500
  msgctxt "Path to file in bucket"
501
  msgid "Path"
502
  msgstr ""
503
 
504
- #: classes/integrations/media-library.php:937
505
  msgctxt "Location of bucket"
506
  msgid "Region"
507
  msgstr ""
508
 
509
- #: classes/integrations/media-library.php:938
510
  msgctxt "Access control list of the file in bucket"
511
  msgid "Access"
512
  msgstr ""
513
 
514
- #: classes/integrations/media-library.php:939
515
  msgid "URL"
516
  msgstr ""
517
 
518
- #: classes/integrations/media-library.php:940
519
  msgctxt "Whether or not metadata has been verified"
520
  msgid "Verified"
521
  msgstr ""
522
 
523
- #: classes/items/download-handler.php:84
524
  msgid ""
525
  "%1$s with ID %d is offloaded to a different provider than currently "
526
  "configured"
527
  msgstr ""
528
 
529
- #: classes/items/download-handler.php:151
530
  #, php-format
531
  msgid "The local directory %s does not exist and could not be created."
532
  msgstr ""
533
 
534
- #: classes/items/download-handler.php:152
535
- #: classes/upgrades/upgrade-meta-wp-error.php:81
536
  #, php-format
537
  msgid ""
538
- "There was an error attempting to download the file %s from the bucket: %s"
539
  msgstr ""
540
 
541
- #: classes/items/download-handler.php:158
542
  #, php-format
543
  msgid "Error downloading %1$s from bucket: %2$s"
544
  msgstr ""
@@ -565,19 +564,24 @@ msgstr ""
565
  msgid "Edit"
566
  msgstr ""
567
 
568
- #: classes/items/remove-provider-handler.php:40
569
  msgid "Invalid object_keys option provided."
570
  msgstr ""
571
 
572
- #: classes/items/remove-provider-handler.php:44
573
  msgid "Invalid offloaded_files option provided."
574
  msgstr ""
575
 
576
- #: classes/items/remove-provider-handler.php:48
577
  msgid ""
578
  "Providing both object_keys and offloaded_files options is not supported."
579
  msgstr ""
580
 
 
 
 
 
 
581
  #: classes/items/upload-handler.php:49
582
  #, php-format
583
  msgid "%s with id %d does not have a valid file path"
@@ -688,6 +692,10 @@ msgstr ""
688
  msgid "You must first <a href=\"%s\">set your access keys</a>."
689
  msgstr ""
690
 
 
 
 
 
691
  #: classes/upgrades/upgrade-content-replace-urls.php:36
692
  msgid "and ensuring that only the local URL exists in post content."
693
  msgstr ""
@@ -755,6 +763,12 @@ msgid ""
755
  "and rebuilding the metadata for attachments that may have been corrupted."
756
  msgstr ""
757
 
 
 
 
 
 
 
758
  #: classes/upgrades/upgrade-region-meta.php:47
759
  msgid ""
760
  "and updating the metadata with the bucket region it is served from. This "
8
  msgstr ""
9
  "Project-Id-Version: amazon-s3-and-cloudfront\n"
10
  "Report-Msgid-Bugs-To: nom@deliciousbrains.com\n"
11
+ "POT-Creation-Date: 2022-03-21 15:00+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
17
  "Content-Type: text/plain; charset=UTF-8\n"
18
  "Content-Transfer-Encoding: 8bit\n"
19
 
 
20
  #: classes/amazon-s3-and-cloudfront.php:196
21
+ #: classes/amazon-s3-and-cloudfront.php:197
22
  msgid "Offload Media Lite"
23
  msgstr ""
24
 
25
+ #: classes/amazon-s3-and-cloudfront.php:438
26
+ #: classes/amazon-s3-and-cloudfront.php:455
27
  msgid "Unknown"
28
  msgstr ""
29
 
30
+ #: classes/amazon-s3-and-cloudfront.php:536
31
  #: view/bucket-select.php:87
32
  #: view/delivery-provider-select.php:129
33
  #: view/delivery-provider-select.php:149
38
  msgid "defined in wp-config.php"
39
  msgstr ""
40
 
41
+ #: classes/amazon-s3-and-cloudfront.php:1523
42
  msgid "This action can only be performed through an admin screen."
43
  msgstr ""
44
 
45
+ #: classes/amazon-s3-and-cloudfront.php:1525
46
  msgid "Cheatin&#8217; eh?"
47
  msgstr ""
48
 
49
+ #: classes/amazon-s3-and-cloudfront.php:1527
50
  msgid "You do not have sufficient permissions to access this page."
51
  msgstr ""
52
 
53
+ #: classes/amazon-s3-and-cloudfront.php:1851
54
  msgid "Error Getting Bucket Region"
55
  msgstr ""
56
 
57
+ #: classes/amazon-s3-and-cloudfront.php:1852
58
  #, php-format
59
  msgid "There was an error attempting to get the region of the bucket %s: %s"
60
  msgstr ""
61
 
62
+ #: classes/amazon-s3-and-cloudfront.php:1955
63
  msgid ""
64
  "This is a test file to check if the user has write permission to the bucket. "
65
  "Delete me if found."
66
  msgstr ""
67
 
68
+ #: classes/amazon-s3-and-cloudfront.php:1961
69
  #, php-format
70
  msgid ""
71
  "There was an error attempting to check the permissions of the bucket %s: %s"
72
  msgstr ""
73
 
74
+ #: classes/amazon-s3-and-cloudfront.php:2079
75
  msgid "Error creating bucket"
76
  msgstr ""
77
 
78
+ #: classes/amazon-s3-and-cloudfront.php:2080
79
  msgid "Bucket name too short."
80
  msgstr ""
81
 
82
+ #: classes/amazon-s3-and-cloudfront.php:2081
83
  msgid "Bucket name too long."
84
  msgstr ""
85
 
86
+ #: classes/amazon-s3-and-cloudfront.php:2082
87
  msgid ""
88
  "Invalid character. Bucket names can contain lowercase letters, numbers, "
89
  "periods and hyphens."
90
  msgstr ""
91
 
92
+ #: classes/amazon-s3-and-cloudfront.php:2083
93
  msgid "Error saving bucket"
94
  msgstr ""
95
 
96
+ #: classes/amazon-s3-and-cloudfront.php:2084
97
  msgid "Error fetching buckets"
98
  msgstr ""
99
 
100
+ #: classes/amazon-s3-and-cloudfront.php:2085
101
  msgid "Error getting URL preview: "
102
  msgstr ""
103
 
104
+ #: classes/amazon-s3-and-cloudfront.php:2086
105
  msgid "The changes you made will be lost if you navigate away from this page"
106
  msgstr ""
107
 
108
+ #: classes/amazon-s3-and-cloudfront.php:2087
109
  msgid "Getting diagnostic info..."
110
  msgstr ""
111
 
112
+ #: classes/amazon-s3-and-cloudfront.php:2088
113
  msgid "Error getting diagnostic info: "
114
  msgstr ""
115
 
116
+ #: classes/amazon-s3-and-cloudfront.php:2089
117
  msgctxt "placeholder for hidden access key, 39 char max"
118
  msgid "-- not shown --"
119
  msgstr ""
120
 
121
+ #: classes/amazon-s3-and-cloudfront.php:2091
122
+ #: classes/amazon-s3-and-cloudfront.php:4212
123
  msgid "Settings saved."
124
  msgstr ""
125
 
126
+ #: classes/amazon-s3-and-cloudfront.php:2213
127
  msgid "Cheatin' eh?"
128
  msgstr ""
129
 
130
+ #: classes/amazon-s3-and-cloudfront.php:2286
131
  #, php-format
132
  msgid "Could not set new Delivery Provider: %s"
133
  msgstr ""
134
 
135
+ #: classes/amazon-s3-and-cloudfront.php:2361
136
+ #: classes/amazon-s3-and-cloudfront.php:2491
137
  msgid "No bucket name provided."
138
  msgstr ""
139
 
140
+ #: classes/amazon-s3-and-cloudfront.php:2370
141
  msgid "Bucket name not valid."
142
  msgstr ""
143
 
144
+ #: classes/amazon-s3-and-cloudfront.php:2383
145
  msgid "No region provided."
146
  msgstr ""
147
 
148
+ #: classes/amazon-s3-and-cloudfront.php:2460
149
  #, php-format
150
  msgctxt "Trying to change public access setting for given provider's bucket."
151
  msgid "Can't change Block All Public Access setting for %s buckets."
152
  msgstr ""
153
 
154
+ #: classes/amazon-s3-and-cloudfront.php:2469
155
  msgid "No block public access setting provided."
156
  msgstr ""
157
 
158
+ #: classes/amazon-s3-and-cloudfront.php:2482
159
  msgid "Storage Provider not configured with access credentials."
160
  msgstr ""
161
 
162
+ #: classes/amazon-s3-and-cloudfront.php:2509
163
  msgid "Could not change Block All Public Access status for bucket."
164
  msgstr ""
165
 
166
+ #: classes/amazon-s3-and-cloudfront.php:2526
167
  msgid ""
168
  "<strong>Failed to Enable Block All Public Access</strong> &mdash; We could "
169
  "not enable Block All Public Access. You will need to log in to the AWS "
170
  "Console and do it manually."
171
  msgstr ""
172
 
173
+ #: classes/amazon-s3-and-cloudfront.php:2528
174
  msgid ""
175
  "<strong>Failed to Disable Block All Public Access</strong> &mdash; We could "
176
  "not disable Block All Public Access. You will need to log in to the AWS "
177
  "Console and do it manually."
178
  msgstr ""
179
 
180
+ #: classes/amazon-s3-and-cloudfront.php:2563
181
  #: view/provider-select.php:329
182
  msgctxt "placeholder for hidden secret access key, 39 char max"
183
  msgid "-- not shown --"
184
  msgstr ""
185
 
186
+ #: classes/amazon-s3-and-cloudfront.php:2586
187
  msgid "Key File not valid JSON."
188
  msgstr ""
189
 
190
+ #: classes/amazon-s3-and-cloudfront.php:2606
191
+ #: classes/amazon-s3-and-cloudfront.php:2620
192
+ #: classes/amazon-s3-and-cloudfront.php:2629
193
  msgctxt "missing form field"
194
  msgid " not provided."
195
  msgstr ""
196
 
197
+ #: classes/amazon-s3-and-cloudfront.php:2672
198
  msgctxt "Show the media library tab"
199
  msgid "Media Library"
200
  msgstr ""
201
 
202
+ #: classes/amazon-s3-and-cloudfront.php:2673
203
  msgctxt "Show the addons tab"
204
  msgid "Addons"
205
  msgstr ""
206
 
207
+ #: classes/amazon-s3-and-cloudfront.php:2674
208
  msgctxt "Show the support tab"
209
  msgid "Support"
210
  msgstr ""
211
 
212
+ #: classes/amazon-s3-and-cloudfront.php:2851
213
  #, php-format
214
  msgid ""
215
  "<strong>WP Offload Media</strong> &mdash; The file %s has been given %s "
216
  "permissions in the bucket."
217
  msgstr ""
218
 
219
+ #: classes/amazon-s3-and-cloudfront.php:2870
220
  msgid ""
221
  "<strong>WP Offload Media Requirement Missing</strong> &mdash; Looks like you "
222
  "don't have an image manipulation library installed on this server and "
224
  "Please setup GD or ImageMagick."
225
  msgstr ""
226
 
227
+ #: classes/amazon-s3-and-cloudfront.php:2894
228
  #, php-format
229
  msgid ""
230
  "<strong>Missing Table</strong> &mdash; One or more required database tables "
232
  "details. %s"
233
  msgstr ""
234
 
235
+ #: classes/amazon-s3-and-cloudfront.php:3716
236
  #, php-format
237
  msgid ""
238
  "<a href=\"%s\">Define your access keys</a> to enable write access to the "
239
  "bucket"
240
  msgstr ""
241
 
242
+ #: classes/amazon-s3-and-cloudfront.php:3723
243
  msgid "Quick Start Guide"
244
  msgstr ""
245
 
246
+ #: classes/amazon-s3-and-cloudfront.php:3725
247
  #, php-format
248
  msgid ""
249
  "Looks like we don't have write access to this bucket. It's likely that the "
252
  "correctly."
253
  msgstr ""
254
 
255
+ #: classes/amazon-s3-and-cloudfront.php:3727
256
  #, php-format
257
  msgid ""
258
  "Looks like we don't have access to the buckets. It's likely that the user "
260
  "Please see our %s for instructions on setting up permissions correctly."
261
  msgstr ""
262
 
263
+ #: classes/amazon-s3-and-cloudfront.php:3897
264
  msgid "WP Offload Media Activation"
265
  msgstr ""
266
 
267
+ #: classes/amazon-s3-and-cloudfront.php:3898
268
  msgid ""
269
  "WP Offload Media Lite and WP Offload Media cannot both be active. We've "
270
  "automatically deactivated WP Offload Media Lite."
271
  msgstr ""
272
 
273
+ #: classes/amazon-s3-and-cloudfront.php:3900
274
  msgid "WP Offload Media Lite Activation"
275
  msgstr ""
276
 
277
+ #: classes/amazon-s3-and-cloudfront.php:3901
278
  msgid ""
279
  "WP Offload Media Lite and WP Offload Media cannot both be active. We've "
280
  "automatically deactivated WP Offload Media."
281
  msgstr ""
282
 
283
+ #: classes/amazon-s3-and-cloudfront.php:3955
284
  msgid "More&nbsp;info&nbsp;&raquo;"
285
  msgstr ""
286
 
287
+ #: classes/amazon-s3-and-cloudfront.php:4024
288
  msgid "this doc"
289
  msgstr ""
290
 
291
+ #: classes/amazon-s3-and-cloudfront.php:4026
292
  msgid "WP Offload Media Feature Removed"
293
  msgstr ""
294
 
295
+ #: classes/amazon-s3-and-cloudfront.php:4027
296
  #, php-format
297
  msgid ""
298
  "You had the \"Always non-SSL\" option selected in your settings, but we've "
303
  "to the old behavior."
304
  msgstr ""
305
 
306
+ #: classes/amazon-s3-and-cloudfront.php:4175
307
  msgid "Assets Pull"
308
  msgstr ""
309
 
310
+ #: classes/amazon-s3-and-cloudfront.php:4176
311
  msgid ""
312
  "An addon for WP Offload Media to serve your site's JS, CSS, and other "
313
  "enqueued assets from Amazon CloudFront or another CDN."
314
  msgstr ""
315
 
316
+ #: classes/amazon-s3-and-cloudfront.php:4180
317
  msgid "Feature"
318
  msgstr ""
319
 
320
+ #: classes/amazon-s3-and-cloudfront.php:4226
321
  #, php-format
322
  msgid ""
323
  "<strong>Amazon Web Services Plugin No Longer Required</strong> &mdash; As of "
328
  "plugin, it should be safe to deactivate and delete it. %2$s"
329
  msgstr ""
330
 
331
+ #: classes/amazon-s3-and-cloudfront.php:4258
332
  #, php-format
333
  msgid ""
334
  "<strong>WP Offload Media Settings Moved</strong> &mdash; You now define your "
473
  msgid "Can't create item from media library item %d"
474
  msgstr ""
475
 
476
+ #: classes/integrations/media-library.php:491
477
  msgid "Offload"
478
  msgstr ""
479
 
480
+ #: classes/integrations/media-library.php:917
481
  msgid "No"
482
  msgstr ""
483
 
484
+ #: classes/integrations/media-library.php:927
485
  msgctxt "Storage provider key name"
486
  msgid "Storage Provider"
487
  msgstr ""
488
 
489
+ #: classes/integrations/media-library.php:928
490
  msgctxt "Storage provider name"
491
  msgid "Storage Provider"
492
  msgstr ""
493
 
494
+ #: classes/integrations/media-library.php:929
495
  msgctxt "Bucket name"
496
  msgid "Bucket"
497
  msgstr ""
498
 
499
+ #: classes/integrations/media-library.php:930
500
  msgctxt "Path to file in bucket"
501
  msgid "Path"
502
  msgstr ""
503
 
504
+ #: classes/integrations/media-library.php:931
505
  msgctxt "Location of bucket"
506
  msgid "Region"
507
  msgstr ""
508
 
509
+ #: classes/integrations/media-library.php:932
510
  msgctxt "Access control list of the file in bucket"
511
  msgid "Access"
512
  msgstr ""
513
 
514
+ #: classes/integrations/media-library.php:933
515
  msgid "URL"
516
  msgstr ""
517
 
518
+ #: classes/integrations/media-library.php:934
519
  msgctxt "Whether or not metadata has been verified"
520
  msgid "Verified"
521
  msgstr ""
522
 
523
+ #: classes/items/download-handler.php:83
524
  msgid ""
525
  "%1$s with ID %d is offloaded to a different provider than currently "
526
  "configured"
527
  msgstr ""
528
 
529
+ #: classes/items/download-handler.php:150
530
  #, php-format
531
  msgid "The local directory %s does not exist and could not be created."
532
  msgstr ""
533
 
534
+ #: classes/items/download-handler.php:151
 
535
  #, php-format
536
  msgid ""
537
+ "There was an error attempting to download the file %1$s from the bucket: %2$s"
538
  msgstr ""
539
 
540
+ #: classes/items/download-handler.php:162
541
  #, php-format
542
  msgid "Error downloading %1$s from bucket: %2$s"
543
  msgstr ""
564
  msgid "Edit"
565
  msgstr ""
566
 
567
+ #: classes/items/remove-provider-handler.php:39
568
  msgid "Invalid object_keys option provided."
569
  msgstr ""
570
 
571
+ #: classes/items/remove-provider-handler.php:43
572
  msgid "Invalid offloaded_files option provided."
573
  msgstr ""
574
 
575
+ #: classes/items/remove-provider-handler.php:47
576
  msgid ""
577
  "Providing both object_keys and offloaded_files options is not supported."
578
  msgstr ""
579
 
580
+ #: classes/items/remove-provider-handler.php:120
581
+ #, php-format
582
+ msgid "Error removing files from bucket: %s"
583
+ msgstr ""
584
+
585
  #: classes/items/upload-handler.php:49
586
  #, php-format
587
  msgid "%s with id %d does not have a valid file path"
692
  msgid "You must first <a href=\"%s\">set your access keys</a>."
693
  msgstr ""
694
 
695
+ #: classes/upgrades/clear-postmeta-cache.php:40
696
+ msgid "and clear old post meta cache items."
697
+ msgstr ""
698
+
699
  #: classes/upgrades/upgrade-content-replace-urls.php:36
700
  msgid "and ensuring that only the local URL exists in post content."
701
  msgstr ""
763
  "and rebuilding the metadata for attachments that may have been corrupted."
764
  msgstr ""
765
 
766
+ #: classes/upgrades/upgrade-meta-wp-error.php:81
767
+ #, php-format
768
+ msgid ""
769
+ "There was an error attempting to download the file %s from the bucket: %s"
770
+ msgstr ""
771
+
772
  #: classes/upgrades/upgrade-region-meta.php:47
773
  msgid ""
774
  "and updating the metadata with the bucket region it is served from. This "
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google
4
  Requires at least: 4.9
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
- Stable tag: 2.6.0
8
  License: GPLv3
9
 
10
  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.
@@ -85,6 +85,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin
85
 
86
  == Changelog ==
87
 
 
 
 
88
  = WP Offload Media Lite 2.6 - 2022-03-09 =
89
  * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting)
90
  * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing
4
  Requires at least: 4.9
5
  Tested up to: 5.9
6
  Requires PHP: 5.6
7
+ Stable tag: 2.6.1
8
  License: GPLv3
9
 
10
  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.
85
 
86
  == Changelog ==
87
 
88
+ = WP Offload Media Lite 2.6.1 - 2022-03-21 =
89
+ * Bug fix: Local files are no longer removed if as3cf_pre_upload_attachment filter is used to abort upload
90
+
91
  = WP Offload Media Lite 2.6 - 2022-03-09 =
92
  * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting)
93
  * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing
wordpress-s3.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Offload Media Lite
4
  Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/
5
  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.
6
  Author: Delicious Brains
7
- Version: 2.6.0
8
  Author URI: https://deliciousbrains.com/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting
9
  Network: True
10
  Text Domain: amazon-s3-and-cloudfront
@@ -26,7 +26,7 @@ Domain Path: /languages/
26
  // Then completely rewritten.
27
  */
28
 
29
- $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.6.0';
30
 
31
  require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';
32
 
4
  Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/
5
  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.
6
  Author: Delicious Brains
7
+ Version: 2.6.1
8
  Author URI: https://deliciousbrains.com/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting
9
  Network: True
10
  Text Domain: amazon-s3-and-cloudfront
26
  // Then completely rewritten.
27
  */
28
 
29
+ $GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.6.1';
30
 
31
  require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';
32