PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 14.2.2
Jetpack – WP Security, Backup, Speed, & Growth v14.2.2
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 2 years ago customizer.css 5 years ago customizer.js 1 year ago form.php 2 years ago style.css 8 years ago widget.php 2 years ago
customizer.js
443 lines
1 /* global jpSimplePaymentsStrings */
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 =
305 // eslint-disable-next-line no-control-regex
306 /^((([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(
307 productEmail
308 );
309 if ( ! productEmail || ! isProductEmailValid ) {
310 widgetForm.find( '.jetpack-simple-payments-form-product-email' ).addClass( 'invalid' );
311 errors = true;
312 }
313
314 return ! errors;
315 }
316
317 function saveChanges( widgetForm ) {
318 return function ( event ) {
319 event.preventDefault();
320
321 if ( ! isFormValid( widgetForm ) ) {
322 return;
323 }
324
325 var productPostId = widgetForm.find( '.jetpack-simple-payments-form-product-id' ).val();
326
327 disableFormActions( widgetForm );
328
329 widgetForm.find( '.spinner' ).show();
330
331 var request = wp.ajax.post( 'customize-jetpack-simple-payments-button-save', {
332 'customize-jetpack-simple-payments-nonce':
333 api.settings.nonce[ 'customize-jetpack-simple-payments' ],
334 customize_changeset_uuid: api.settings.changeset.uuid,
335 params: {
336 product_post_id: productPostId,
337 post_title: widgetForm.find( '.jetpack-simple-payments-form-product-title' ).val(),
338 post_content: widgetForm
339 .find( '.jetpack-simple-payments-form-product-description' )
340 .val(),
341 image_id: widgetForm.find( '.jetpack-simple-payments-form-image-id' ).val(),
342 currency: widgetForm.find( '.jetpack-simple-payments-form-product-currency' ).val(),
343 price: widgetForm.find( '.jetpack-simple-payments-form-product-price' ).val(),
344 multiple: widgetForm
345 .find( '.jetpack-simple-payments-form-product-multiple' )
346 .is( ':checked' )
347 ? 1
348 : 0,
349 email: widgetForm.find( '.jetpack-simple-payments-form-product-email' ).val(),
350 },
351 } );
352
353 request.done( function ( data ) {
354 var select = widgetForm.find( 'select.jetpack-simple-payments-products' );
355 var productOption = select.find( 'option[value="' + productPostId + '"]' );
356
357 if ( productOption.length > 0 ) {
358 productOption.text( data.product_post_title );
359 } else {
360 select.append(
361 $( '<option>', {
362 value: data.product_post_id,
363 text: data.product_post_title,
364 } )
365 );
366 select.val( data.product_post_id ).change();
367 }
368
369 widgetForm.find( '.jetpack-simple-payments-products-fieldset' ).show();
370 widgetForm.find( '.jetpack-simple-payments-products-warning' ).hide();
371
372 changeFormAction( widgetForm, 'clear' );
373 hideForm( widgetForm );
374 } );
375
376 request.fail( function ( data ) {
377 var validCodes = {
378 post_title: 'product-title',
379 price: 'product-price',
380 email: 'product-email',
381 };
382
383 data.forEach( function ( item ) {
384 if ( Object.hasOwn( validCodes, item.code ) ) {
385 widgetForm
386 .find( '.jetpack-simple-payments-form-' + validCodes[ item.code ] )
387 .addClass( 'invalid' );
388 }
389 } );
390
391 enableFormActions( widgetForm );
392 } );
393 };
394 }
395
396 function deleteProduct( widgetForm ) {
397 return function ( event ) {
398 event.preventDefault();
399
400 if ( ! confirm( jpSimplePaymentsStrings.deleteConfirmation ) ) {
401 return;
402 }
403
404 var formProductId = parseInt(
405 widgetForm.find( '.jetpack-simple-payments-form-product-id' ).val(),
406 10
407 );
408 if ( ! formProductId ) {
409 return;
410 }
411
412 disableFormActions( widgetForm );
413
414 widgetForm.find( '.spinner' ).show();
415
416 var request = wp.ajax.post( 'customize-jetpack-simple-payments-button-delete', {
417 'customize-jetpack-simple-payments-nonce':
418 api.settings.nonce[ 'customize-jetpack-simple-payments' ],
419 customize_changeset_uuid: api.settings.changeset.uuid,
420 params: {
421 product_post_id: formProductId,
422 },
423 } );
424
425 request.done( function () {
426 var productList = widgetForm.find( 'select.jetpack-simple-payments-products' )[ 0 ];
427 productList.remove( productList.selectedIndex );
428 productList.dispatchEvent( new Event( 'change' ) );
429
430 if ( $( productList ).has( 'option' ).length === 0 ) {
431 //hide products select and label
432 widgetForm.find( '.jetpack-simple-payments-products-fieldset' ).hide();
433 //show empty products list warning
434 widgetForm.find( '.jetpack-simple-payments-products-warning' ).show();
435 }
436
437 changeFormAction( widgetForm, 'clear' );
438 hideForm( widgetForm );
439 } );
440 };
441 }
442 } )( wp.customize, wp, jQuery );
443