| @@ -124,8 +124,9 @@ | ||
| 124 | 124 | |
| 125 | 125 | this.saveSettingsSubmit(); |
| 126 | 126 | this.installPlugins(); |
| 127 | 127 | this.onChangedPluginSliderCheckbox(); |
| 128 | + this.subscribeSubmit(); | |
| 128 | 129 | |
| 129 | 130 | const featureItems = document.querySelectorAll('.bdt-feature-item'); |
| 130 | 131 | featureItems.forEach(item => { |
| 131 | 132 | item.addEventListener('mouseenter', () => { |
| @@ -325,8 +326,40 @@ | ||
| 325 | 326 | widgetItem.classList.add('item-highlight'); |
| 326 | 327 | setTimeout(() => { |
| 327 | 328 | widgetItem.classList.remove('item-highlight'); |
| 328 | 329 | }, 600); |
| 330 | + }); | |
| 331 | + }, | |
| 332 | + | |
| 333 | + /** | |
| 334 | + * The newsletter opt-in sits in the welcome step and has no submit | |
| 335 | + * button of its own: the choice is sent when the user moves on with | |
| 336 | + * "Get Started". | |
| 337 | + * | |
| 338 | + * Fire and forget — the step change is never delayed and shows no | |
| 339 | + * status. The box is unticked by default and gates the subscription | |
| 340 | + * server side; an unticked box sends nothing to the newsletter list. | |
| 341 | + */ | |
| 342 | + subscribeSubmit: function () { | |
| 343 | + $(document).on('click', '.bdt-wizard-step[data-step="welcome"] .bdt-wizard-next', function () { | |
| 344 | + const $email = $('#bdt-subscribe-email'); | |
| 345 | + | |
| 346 | + if (!$email.length) { | |
| 347 | + return; | |
| 348 | + } | |
| 349 | + | |
| 350 | + $.ajax({ | |
| 351 | + url: UPK_SetupWizard.ajax_url, | |
| 352 | + type: 'POST', | |
| 353 | + data: { | |
| 354 | + action: 'ultimate_post_kit_setup_wizard_subscribe', | |
| 355 | + nonce: UPK_SetupWizard.nonce, | |
| 356 | + email: ($email.val() || '').trim(), | |
| 357 | + consent: $('#bdt-subscribe-consent').is(':checked') ? 'yes' : 'no' | |
| 358 | + } | |
| 359 | + }); | |
| 360 | + | |
| 361 | + // No preventDefault: the step change proceeds immediately. | |
| 329 | 362 | }); |
| 330 | 363 | }, |
| 331 | 364 | |
| 332 | 365 | saveSettingsSubmit: function () { |