PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 13.3.3
Jetpack – WP Security, Backup, Speed, & Growth v13.3.3
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 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7.3.0.1 7.3.1 7.3.1.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4 7.4.1 7.4.2 7.4.3 7.4.4 7.4.5 7.5 7.5.0.1 7.5.1 7.5.2 7.5.3 7.5.4 7.5.5 7.5.6 7.5.7 7.6 7.6.1 7.6.2 7.6.3 7.6.4 7.7 7.7.1 7.7.2 7.7.3 7.7.4 7.7.5 7.7.6 7.8 7.8.1 7.8.2 7.8.3 7.8.4 7.9 7.9.1 7.9.2 7.9.3 7.9.4 8.0 8.0.1 8.0.2 8.0.3 8.1 8.1.1 8.1.2 8.1.3 8.1.4 8.2 8.2.0.1 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3 8.3.1 8.3.2 8.3.3 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.5 8.5.1 8.5.2 8.5.3 8.6 8.6.1 8.6.2 8.6.3 8.6.4 8.7 8.7.0.1 8.7.1 8.7.2 8.7.3 8.7.4 8.8 8.8.1 8.8.2 8.8.3 8.8.4 8.8.5 8.9 8.9.1 8.9.2 8.9.3 8.9.4 9.0 9.0.1 9.0.2 9.0.3 9.0.4 9.0.5 9.1 9.1.1 9.1.2 9.1.3 9.2 9.2.1 9.2.2 9.2.3 9.2.4 9.3 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.4 9.4.1 9.4.2 9.4.3 9.4.4 9.5 9.5.1 9.5.2 9.5.3 9.5.4 9.5.5 9.6 9.6.1 9.6.2 9.6.3 9.6.4 9.7 9.7.1 9.7.2 15.7-beta.2 9.7.3 15.7.1 9.8 15.8-a.1 9.8.1 15.8-a.3 9.8.2 2.0.9 9.8.3 2.1.7 9.9 2.2.10 9.9.1 2.3.10 9.9.2 2.4.7 9.9.3 2.5.5 2.6.6 2.7.5 2.8.5 2.9.6 3.0.6 3.1.5 3.2.5 3.3.6 3.4.6 3.5.6 3.6.4 3.7.5 3.8.5 3.9.10 4.0.7 4.1.4 4.2.5 4.3.5 4.4.5 4.5.3 4.6.3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / widgets / simple-payments / customizer.js
jetpack / modules / widgets / simple-payments Last commit date
admin-warning.php 4 years ago customizer.css 5 years ago customizer.js 6 years ago form.php 2 years ago style.css 8 years ago widget.php 2 years ago
customizer.js
440 lines
1 /* global jQuery, jpSimplePaymentsStrings, confirm, _ */
2 /* eslint no-var: 0, quote-props: 0 */
3
4 ( function ( api, wp, $ ) {
5 var $document = $( document );
6
7 $document.ready( function () {
8 $document.on( 'widget-added', function ( event, widgetContainer ) {
9 if ( widgetContainer.is( '[id*="jetpack_simple_payments_widget"]' ) ) {
10 initWidget( widgetContainer );
11 }
12 } );
13
14 $document.on( 'widget-synced widget-updated', function ( event, widgetContainer ) {
15 //this fires for all widgets, this prevent errors for non SP widgets
16 if ( ! widgetContainer.is( '[id*="jetpack_simple_payments_widget"]' ) ) {
17 return;
18 }
19
20 event.preventDefault();
21
22 syncProductLists();
23
24 var widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' );
25
26 enableFormActions( widgetForm );
27
28 updateProductImage( widgetForm );
29 } );
30 } );
31
32 function initWidget( widgetContainer ) {
33 var widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' );
34
35 //Add New Button
36 widgetForm
37 .find( '.jetpack-simple-payments-add-product' )
38 .on( 'click', showAddNewForm( widgetForm ) );
39 //Edit Button
40 widgetForm
41 .find( '.jetpack-simple-payments-edit-product' )
42 .on( 'click', showEditForm( widgetForm ) );
43 //Select an Image
44 widgetForm
45 .find(
46 '.jetpack-simple-payments-image-fieldset .placeholder, .jetpack-simple-payments-image > img'
47 )
48 .on( 'click', selectImage( widgetForm ) );
49 //Remove Image Button
50 widgetForm
51 .find( '.jetpack-simple-payments-remove-image' )
52 .on( 'click', removeImage( widgetForm ) );
53 //Save Product button
54 widgetForm
55 .find( '.jetpack-simple-payments-save-product' )
56 .on( 'click', saveChanges( widgetForm ) );
57 //Cancel Button
58 widgetForm
59 .find( '.jetpack-simple-payments-cancel-form' )
60 .on( 'click', clearForm( widgetForm ) );
61 //Delete Selected Product
62 widgetForm
63 .find( '.jetpack-simple-payments-delete-product' )
64 .on( 'click', deleteProduct( widgetForm ) );
65 //Input, Select and Checkbox change
66 widgetForm.find( 'select, input, textarea, checkbox' ).on(
67 'change input propertychange',
68 _.debounce( function () {
69 disableFormActions( widgetForm );
70 }, 250 )
71 );
72 }
73
74 function syncProductLists() {
75 var request = wp.ajax.post( 'customize-jetpack-simple-payments-buttons-get', {
76 'customize-jetpack-simple-payments-nonce':
77 api.settings.nonce[ 'customize-jetpack-simple-payments' ],
78 customize_changeset_uuid: api.settings.changeset.uuid,
79 } );
80
81 request.done( function ( data ) {
82 var selectedProduct = 0;
83
84 $( document )
85 .find( 'select.jetpack-simple-payments-products' )
86 .each( function ( index, select ) {
87 var $select = $( select );
88 selectedProduct = $select.val();
89
90 $select.find( 'option' ).remove();
91 $select.append(
92 $.map( data, function ( product ) {
93 return $( '<option>', { value: product.ID, text: product.post_title } );
94 } )
95 );
96 $select.val( selectedProduct );
97 } );
98 } );
99 }
100
101 function showForm( widgetForm ) {
102 //reset validations
103 widgetForm.find( '.invalid' ).removeClass( 'invalid' );
104 //disable widget title and product selector
105 widgetForm
106 .find( '.jetpack-simple-payments-widget-title' )
107 .add( '.jetpack-simple-payments-products' )
108 //disable add and edit buttons
109 .add( '.jetpack-simple-payments-add-product' )
110 .add( '.jetpack-simple-payments-edit-product' )
111 //disable save, delete and cancel until the widget update event is fired
112 .add( '.jetpack-simple-payments-save-product' )
113 .add( '.jetpack-simple-payments-cancel-form' )
114 .add( '.jetpack-simple-payments-delete-product' )
115 .attr( 'disabled', 'disabled' );
116 //show form
117 widgetForm.find( '.jetpack-simple-payments-form' ).show();
118 }
119
120 function hideForm( widgetForm ) {
121 //enable widget title and product selector
122 widgetForm
123 .find( '.jetpack-simple-payments-widget-title' )
124 .add( '.jetpack-simple-payments-products' )
125 .removeAttr( 'disabled' );
126 //hide the form
127 widgetForm.find( '.jetpack-simple-payments-form' ).hide();
128 }
129
130 function changeFormAction( widgetForm, action ) {
131 widgetForm.find( '.jetpack-simple-payments-form-action' ).val( action ).change();
132 }
133
134 function showAddNewForm( widgetForm ) {
135 return function ( event ) {
136 event.preventDefault();
137
138 showForm( widgetForm );
139 changeFormAction( widgetForm, 'add' );
140 };
141 }
142
143 function showEditForm( widgetForm ) {
144 return function ( event ) {
145 event.preventDefault();
146
147 showForm( widgetForm );
148 changeFormAction( widgetForm, 'edit' );
149 };
150 }
151
152 function clearForm( widgetForm ) {
153 return function ( event ) {
154 event.preventDefault();
155
156 hideForm( widgetForm );
157 widgetForm
158 .find( '.jetpack-simple-payments-add-product, .jetpack-simple-payments-edit-product' )
159 .attr( 'disabled', 'disabled' );
160 changeFormAction( widgetForm, 'clear' );
161 };
162 }
163
164 function enableFormActions( widgetForm ) {
165 var isFormVisible = widgetForm.find( '.jetpack-simple-payments-form' ).is( ':visible' );
166 var isProductSelectVisible = widgetForm
167 .find( '.jetpack-simple-payments-products' )
168 .is( ':visible' ); //areProductsVisible ?
169 var isEdit = widgetForm.find( '.jetpack-simple-payments-form-action' ).val() === 'edit';
170
171 if ( isFormVisible ) {
172 widgetForm
173 .find( '.jetpack-simple-payments-save-product' )
174 .add( '.jetpack-simple-payments-cancel-form' )
175 .removeAttr( 'disabled' );
176 } else {
177 widgetForm.find( '.jetpack-simple-payments-add-product' ).removeAttr( 'disabled' );
178 }
179
180 if ( isFormVisible && isEdit ) {
181 widgetForm.find( '.jetpack-simple-payments-delete-product' ).removeAttr( 'disabled' );
182 }
183
184 if ( isProductSelectVisible && ! isFormVisible ) {
185 widgetForm.find( '.jetpack-simple-payments-edit-product' ).removeAttr( 'disabled' );
186 }
187 }
188
189 function disableFormActions( widgetForm ) {
190 widgetForm
191 .find( '.jetpack-simple-payments-add-product' )
192 .add( '.jetpack-simple-payments-edit-product' )
193 .add( '.jetpack-simple-payments-save-product' )
194 .add( '.jetpack-simple-payments-cancel-form' )
195 .add( '.jetpack-simple-payments-delete-product' )
196 .attr( 'disabled', 'disabled' );
197 }
198
199 function selectImage( widgetForm ) {
200 return function ( event ) {
201 event.preventDefault();
202
203 var imageContainer = widgetForm.find( '.jetpack-simple-payments-image' );
204
205 var mediaFrame = new wp.media.view.MediaFrame.Select( {
206 title: 'Choose Product Image',
207 multiple: false,
208 library: { type: 'image' },
209 button: { text: 'Choose Image' },
210 } );
211
212 mediaFrame.on( 'select', function () {
213 var selection = mediaFrame.state().get( 'selection' ).first().toJSON();
214 //hide placeholder
215 widgetForm.find( '.jetpack-simple-payments-image-fieldset .placeholder' ).hide();
216
217 //load image from media library
218 imageContainer.find( 'img' ).attr( 'src', selection.url ).show();
219
220 //show image and remove button
221 widgetForm.find( '.jetpack-simple-payments-image' ).show();
222
223 //set hidden field for the selective refresh
224 widgetForm.find( '.jetpack-simple-payments-form-image-id' ).val( selection.id ).change();
225 } );
226
227 mediaFrame.open();
228 };
229 }
230
231 function removeImage( widgetForm ) {
232 return function ( event ) {
233 event.preventDefault();
234
235 //show placeholder
236 widgetForm.find( '.jetpack-simple-payments-image-fieldset .placeholder' ).show();
237
238 //hide image and remove button
239 widgetForm.find( '.jetpack-simple-payments-image' ).hide();
240
241 //set hidden field for the selective refresh
242 widgetForm.find( '.jetpack-simple-payments-form-image-id' ).val( '' ).change();
243 };
244 }
245
246 function updateProductImage( widgetForm ) {
247 var newImageId = parseInt(
248 widgetForm.find( '.jetpack-simple-payments-form-image-id' ).val(),
249 10
250 );
251 var newImageSrc = widgetForm.find( '.jetpack-simple-payments-form-image-src' ).val();
252
253 var placeholder = widgetForm.find( '.jetpack-simple-payments-image-fieldset .placeholder' );
254 var image = widgetForm.find( '.jetpack-simple-payments-image > img' );
255 var imageControls = widgetForm.find( '.jetpack-simple-payments-image' );
256
257 if ( newImageId && newImageSrc ) {
258 image.attr( 'src', newImageSrc );
259 placeholder.hide();
260 imageControls.show();
261 } else {
262 placeholder.show();
263 image.removeAttr( 'src' );
264 imageControls.hide();
265 }
266 }
267
268 function decimalPlaces( number ) {
269 var parts = number.split( '.' );
270 if ( parts.length > 2 ) {
271 return null;
272 }
273
274 return parts[ 1 ] ? parts[ 1 ].length : 0;
275 }
276
277 function isFormValid( widgetForm ) {
278 widgetForm.find( '.invalid' ).removeClass( 'invalid' );
279
280 var errors = false;
281
282 var postTitle = widgetForm.find( '.jetpack-simple-payments-form-product-title' ).val();
283 if ( ! postTitle ) {
284 widgetForm.find( '.jetpack-simple-payments-form-product-title' ).addClass( 'invalid' );
285 errors = true;
286 }
287
288 var productPrice = widgetForm.find( '.jetpack-simple-payments-form-product-price' ).val();
289 if ( ! productPrice || isNaN( productPrice ) || parseFloat( productPrice ) <= 0 ) {
290 widgetForm.find( '.jetpack-simple-payments-form-product-price' ).addClass( 'invalid' );
291 errors = true;
292 }
293
294 // Japan's Yen is the only supported currency with a zero decimal precision.
295 var precision =
296 widgetForm.find( '.jetpack-simple-payments-form-product-currency' ).val() === 'JPY' ? 0 : 2;
297 var priceDecimalPlaces = decimalPlaces( productPrice );
298 if ( priceDecimalPlaces === null || priceDecimalPlaces > precision ) {
299 widgetForm.find( '.jetpack-simple-payments-form-product-price' ).addClass( 'invalid' );
300 errors = true;
301 }
302
303 var productEmail = widgetForm.find( '.jetpack-simple-payments-form-product-email' ).val();
304 var isProductEmailValid = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(
305 productEmail
306 );
307 if ( ! productEmail || ! isProductEmailValid ) {
308 widgetForm.find( '.jetpack-simple-payments-form-product-email' ).addClass( 'invalid' );
309 errors = true;
310 }
311
312 return ! errors;
313 }
314
315 function saveChanges( widgetForm ) {
316 return function ( event ) {
317 event.preventDefault();
318 var productPostId = widgetForm.find( '.jetpack-simple-payments-form-product-id' ).val();
319
320 if ( ! isFormValid( widgetForm ) ) {
321 return;
322 }
323
324 disableFormActions( widgetForm );
325
326 widgetForm.find( '.spinner' ).show();
327
328 var request = wp.ajax.post( 'customize-jetpack-simple-payments-button-save', {
329 'customize-jetpack-simple-payments-nonce':
330 api.settings.nonce[ 'customize-jetpack-simple-payments' ],
331 customize_changeset_uuid: api.settings.changeset.uuid,
332 params: {
333 product_post_id: productPostId,
334 post_title: widgetForm.find( '.jetpack-simple-payments-form-product-title' ).val(),
335 post_content: widgetForm
336 .find( '.jetpack-simple-payments-form-product-description' )
337 .val(),
338 image_id: widgetForm.find( '.jetpack-simple-payments-form-image-id' ).val(),
339 currency: widgetForm.find( '.jetpack-simple-payments-form-product-currency' ).val(),
340 price: widgetForm.find( '.jetpack-simple-payments-form-product-price' ).val(),
341 multiple: widgetForm
342 .find( '.jetpack-simple-payments-form-product-multiple' )
343 .is( ':checked' )
344 ? 1
345 : 0,
346 email: widgetForm.find( '.jetpack-simple-payments-form-product-email' ).val(),
347 },
348 } );
349
350 request.done( function ( data ) {
351 var select = widgetForm.find( 'select.jetpack-simple-payments-products' );
352 var productOption = select.find( 'option[value="' + productPostId + '"]' );
353
354 if ( productOption.length > 0 ) {
355 productOption.text( data.product_post_title );
356 } else {
357 select.append(
358 $( '<option>', {
359 value: data.product_post_id,
360 text: data.product_post_title,
361 } )
362 );
363 select.val( data.product_post_id ).change();
364 }
365
366 widgetForm.find( '.jetpack-simple-payments-products-fieldset' ).show();
367 widgetForm.find( '.jetpack-simple-payments-products-warning' ).hide();
368
369 changeFormAction( widgetForm, 'clear' );
370 hideForm( widgetForm );
371 } );
372
373 request.fail( function ( data ) {
374 var validCodes = {
375 post_title: 'product-title',
376 price: 'product-price',
377 email: 'product-email',
378 };
379
380 data.forEach( function ( item ) {
381 if ( validCodes.hasOwnProperty( item.code ) ) {
382 widgetForm
383 .find( '.jetpack-simple-payments-form-' + validCodes[ item.code ] )
384 .addClass( 'invalid' );
385 }
386 } );
387
388 enableFormActions( widgetForm );
389 } );
390 };
391 }
392
393 function deleteProduct( widgetForm ) {
394 return function ( event ) {
395 event.preventDefault();
396
397 if ( ! confirm( jpSimplePaymentsStrings.deleteConfirmation ) ) {
398 return;
399 }
400
401 var formProductId = parseInt(
402 widgetForm.find( '.jetpack-simple-payments-form-product-id' ).val(),
403 10
404 );
405 if ( ! formProductId ) {
406 return;
407 }
408
409 disableFormActions( widgetForm );
410
411 widgetForm.find( '.spinner' ).show();
412
413 var request = wp.ajax.post( 'customize-jetpack-simple-payments-button-delete', {
414 'customize-jetpack-simple-payments-nonce':
415 api.settings.nonce[ 'customize-jetpack-simple-payments' ],
416 customize_changeset_uuid: api.settings.changeset.uuid,
417 params: {
418 product_post_id: formProductId,
419 },
420 } );
421
422 request.done( function () {
423 var productList = widgetForm.find( 'select.jetpack-simple-payments-products' )[ 0 ];
424 productList.remove( productList.selectedIndex );
425 productList.dispatchEvent( new Event( 'change' ) );
426
427 if ( $( productList ).has( 'option' ).length === 0 ) {
428 //hide products select and label
429 widgetForm.find( '.jetpack-simple-payments-products-fieldset' ).hide();
430 //show empty products list warning
431 widgetForm.find( '.jetpack-simple-payments-products-warning' ).show();
432 }
433
434 changeFormAction( widgetForm, 'clear' );
435 hideForm( widgetForm );
436 } );
437 };
438 }
439 } )( wp.customize, wp, jQuery );
440