PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | modules/videopress/js/videopress-plupload.js +35 -29 13.0.2 → 16.3 View file →
@@ -1,5 +1,5 @@
1 -/* global pluploadL10n, plupload, _wpPluploadSettings, JSON */
1 +/* global pluploadL10n, plupload, _wpPluploadSettings */
2 2
3 3 window.wp = window.wp || {};
4 4
5 5 ( function ( exports, $ ) {
@@ -98,9 +98,9 @@
98 98 if (
99 99 ! isIE &&
100 100 'flash' === plupload.predictRuntime( this.plupload ) &&
101 101 ( ! this.plupload.required_features ||
102 - ! this.plupload.required_features.hasOwnProperty( 'send_binary_string' ) )
102 + ! Object.hasOwn( this.plupload.required_features, 'send_binary_string' ) )
103 103 ) {
104 104 this.plupload.required_features = this.plupload.required_features || {};
105 105 this.plupload.required_features.send_binary_string = true;
106 106 }
@@ -124,13 +124,13 @@
124 124 /**
125 125 * Custom error callback.
126 126 *
127 127 * Add a new error to the errors collection, so other modules can track
128 - * and display errors. @see wp.Uploader.errors.
128 + * and display errors. {@see wp.Uploader.errors}.
129 129 *
130 - * @param {string} message
131 - * @param {object} data
132 - * @param {plupload.File} file File that was uploaded.
130 + * @param {string} message
131 + * @param {object} data
132 + * @param {plupload.File} file File that was uploaded.
133 133 */
134 134 error = function ( message, data, file ) {
135 135 if ( file.attachment ) {
136 136 file.attachment.destroy();
@@ -221,9 +221,9 @@
221 221 * @param {plupload.Uploader} uploader Uploader instance.
222 222 * @param {Array} files Array of file objects that were added to queue by the user.
223 223 */
224 224 this.uploader.bind( 'FilesAdded', function ( up, files ) {
225 - _.each( files, function ( file ) {
225 + for ( const file of files ) {
226 226 var attributes, image;
227 227
228 228 // Ignore failed uploads.
229 229 if ( plupload.FAILED === file.status ) {
@@ -230,19 +230,21 @@
230 230 return;
231 231 }
232 232
233 233 // Generate attributes for a new `Attachment` model.
234 - attributes = _.extend(
235 - {
236 - file: file,
237 - uploading: true,
238 - date: new Date(),
239 - filename: file.name,
240 - menuOrder: 0,
241 - uploadedTo: wp.media.model.settings.post.id,
242 - },
243 - _.pick( file, 'loaded', 'size', 'percent' )
244 - );
234 + attributes = {
235 + file: file,
236 + uploading: true,
237 + date: new Date(),
238 + filename: file.name,
239 + menuOrder: 0,
240 + uploadedTo: wp.media.model.settings.post.id,
241 + ...Object.fromEntries(
242 + Object.entries( file ).filter(
243 + ( [ k ] ) => k === 'loaded' || k === 'size' || k === 'percent'
244 + )
245 + ),
246 + };
245 247
246 248 // Handle early mime type scanning for images.
247 249 image = /(?:jpe?g|png|gif|webp)$/i.exec( file.name );
248 250
@@ -260,9 +262,9 @@
260 262 file.attachment = wp.media.model.Attachment.create( attributes );
261 263 Uploader.queue.add( file.attachment );
262 264
263 265 self.added( file.attachment );
264 - } );
266 + }
265 267
266 268 up.refresh();
267 269 up.start();
268 270 } );
@@ -267,9 +269,13 @@
267 269 up.start();
268 270 } );
269 271
270 272 this.uploader.bind( 'UploadProgress', function ( up, file ) {
271 - file.attachment.set( _.pick( file, 'loaded', 'percent' ) );
273 + file.attachment.set(
274 + Object.fromEntries(
275 + Object.entries( file ).filter( ( [ k ] ) => k === 'loaded' || k === 'percent' )
276 + )
277 + );
272 278 self.progress( file.attachment );
273 279 } );
274 280
275 281 /**
@@ -294,13 +300,13 @@
294 300 } else {
295 301 response = vp.handleStandardResponse( response, file );
296 302 }
297 303
298 - _.each( [ 'file', 'loaded', 'size', 'percent' ], function ( key ) {
299 - file.attachment.unset( key );
300 - } );
304 + for ( const k of [ 'file', 'loaded', 'size', 'percent' ] ) {
305 + file.attachment.unset( k );
306 + }
301 307
302 - file.attachment.set( _.extend( response.data, { uploading: false } ) );
308 + file.attachment.set( { ...response.data, uploading: false } );
303 309 var att = wp.media.model.Attachment.get( response.data.id, file.attachment );
304 310
305 311 /* Once the new "empty" attachment is added to the collection above, check if it exists on the server, then set the new data.
306 312 * If it happens to not exist on the server yet (xmlrpc delayed or not working), then the empty media item will still be on the page,
@@ -335,13 +341,13 @@
335 341 this.uploader.bind( 'Error', function ( up, pluploadError ) {
336 342 var message = pluploadL10n.default_error;
337 343
338 344 // Check for plupload errors.
339 - for ( var key in Uploader.errorMap ) {
340 - if ( pluploadError.code === plupload[ key ] ) {
341 - message = Uploader.errorMap[ key ];
345 + for ( var k in Uploader.errorMap ) {
346 + if ( pluploadError.code === plupload[ k ] ) {
347 + message = Uploader.errorMap[ k ];
342 348
343 - if ( _.isFunction( message ) ) {
349 + if ( typeof message === 'function' ) {
344 350 message = message( pluploadError.file, pluploadError );
345 351 }
346 352
347 353 break;
@@ -362,9 +368,9 @@
362 368 if ( 'message' in pluploadResponseObject ) {
363 369 message = pluploadResponseObject.message;
364 370 }
365 371 }
366 - } catch ( e ) {
372 + } catch {
367 373 // Do nothing ...
368 374 }
369 375 }
370 376