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/gutenberg-video-upload.js +8 -12 13.5.2 → 16.3 View file →
@@ -1,7 +1,5 @@
1 -/* globals wp, lodash */
2 1 window.videoPressUploadPoster = function ( guid, data ) {
3 - // eslint-disable-next-line no-undef
4 2 return new Promise( function ( resolve, reject ) {
5 3 wp.media.ajax( 'videopress-get-upload-token', { async: true } ).done( function ( response ) {
6 4 // Set auth header with upload token.
7 5 var headers = {},
@@ -6,9 +4,9 @@
6 4 // Set auth header with upload token.
7 5 var headers = {},
8 6 options = {};
9 7 var body = new FormData();
10 - headers[ 'Authorization' ] =
8 + headers.Authorization =
11 9 'X_UPLOAD_TOKEN token="' +
12 10 response.upload_token +
13 11 '" blog_id="' +
14 12 response.upload_blog_id +
@@ -72,19 +70,18 @@
72 70 } );
73 71 } );
74 72 };
75 73
76 -window.videoPressUploadTrack = function ( guid, kind, srcLang, label, vttFile ) {
77 - // eslint-disable-next-line no-undef
74 +window.videoPressUploadTrack = function ( guid, kind, srcLang, label, tmpFile ) {
78 75 return new Promise( function ( resolve, reject ) {
79 76 wp.media
80 - .ajax( 'videopress-get-upload-token', { async: true, data: { filename: vttFile.name } } ) // todo: maybe remove filename from here (not needed)
77 + .ajax( 'videopress-get-upload-token', { async: true, data: { filename: tmpFile.name } } ) // todo: maybe remove filename from here (not needed)
81 78 .done( function ( response ) {
82 79 // Set auth header with upload token.
83 80 var headers = {},
84 81 options = {};
85 82 var body = new FormData();
86 - headers[ 'Authorization' ] =
83 + headers.Authorization =
87 84 'X_UPLOAD_TOKEN token="' +
88 85 response.upload_token +
89 86 '" blog_id="' +
90 87 response.upload_blog_id +
@@ -98,9 +95,9 @@
98 95
99 96 body.append( 'kind', kind );
100 97 body.append( 'srclang', srcLang );
101 98 body.append( 'label', label );
102 - body.append( 'vtt', vttFile );
99 + body.append( 'vtt', tmpFile );
103 100
104 101 options.body = body;
105 102
106 103 wp.apiFetch( options )
@@ -114,9 +111,8 @@
114 111 } );
115 112 };
116 113
117 114 window.videoPressDeleteTrack = function ( guid, kind, srcLang ) {
118 - // eslint-disable-next-line no-undef
119 115 return new Promise( function ( resolve, reject ) {
120 116 wp.media.ajax( 'videopress-get-upload-token', { async: true } ).done( function ( response ) {
121 117 // Set auth header with upload token.
122 118 var headers = {},
@@ -121,9 +117,9 @@
121 117 // Set auth header with upload token.
122 118 var headers = {},
123 119 options = {};
124 120 var body = new FormData();
125 - headers[ 'Authorization' ] =
121 + headers.Authorization =
126 122 'X_UPLOAD_TOKEN token="' +
127 123 response.upload_token +
128 124 '" blog_id="' +
129 125 response.upload_blog_id +
@@ -205,10 +201,10 @@
205 201
206 202 return response; // if not a response object, then its our parsed body so return that
207 203 } )
208 204 .then( function ( data ) {
209 - var wpcomMediaObject = lodash.get( data, 'media[0]' );
210 - var id = lodash.get( wpcomMediaObject, 'ID' );
205 + var wpcomMediaObject = data?.media?.[ 0 ];
206 + var id = wpcomMediaObject?.ID;
211 207 var gutenbergMediaObject = wp.apiFetch( {
212 208 path: '/wp/v2/media/' + id,
213 209 } );
214 210 resolve( gutenbergMediaObject );