PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
← All changes | resources/frontend/js/convertkit.js +38 -2 3.3.63.4.3 View file →
@@ -82,15 +82,51 @@
82 82
83 83 // Get the parent form of the submit button.
84 84 const form = submitButton.closest('form');
85 85
86 - // Submit the form.
87 - form.submit();
86 + // Submit the form, using requestSubmit() so any submit event listeners are honored
87 + // e.g. the Member Content login form, which submits using AJAX.
88 + form.requestSubmit();
88 89 }
89 90
90 91 // Scope the function to the window object as webpack will wrap everything in a closure,
91 92 // resulting in the function not being available globally.
92 93 window.convertKitRecaptchaFormSubmit = convertKitRecaptchaFormSubmit;
94 +
95 +/**
96 + * Handles form submissions when Cloudflare Turnstile is enabled.
97 + *
98 + * Turnstile auto-populates a hidden `cf-turnstile-response` input inside the
99 + * enclosing form once the challenge is solved, so we just need to submit the
100 + * containing form when the callback fires.
101 + *
102 + * @param {string} token Turnstile response token.
103 + */
104 +function convertKitTurnstileFormSubmit(token) {
105 + // Find the Turnstile widget div with the data-callback attribute.
106 + const widget = document.querySelector(
107 + '.cf-turnstile[data-callback="convertKitTurnstileFormSubmit"]'
108 + );
109 +
110 + if (!widget) {
111 + return;
112 + }
113 +
114 + // Get the parent form of the widget.
115 + const form = widget.closest('form');
116 +
117 + if (!form) {
118 + return;
119 + }
120 +
121 + // Submit the form, using requestSubmit() so any submit event listeners are honored
122 + // e.g. the Member Content login form, which submits using AJAX.
123 + form.requestSubmit();
124 +}
125 +
126 +// Scope the function to the window object as webpack will wrap everything in a closure,
127 +// resulting in the function not being available globally.
128 +window.convertKitTurnstileFormSubmit = convertKitTurnstileFormSubmit;
93 129 /* eslint-enable no-unused-vars */
94 130
95 131 /**
96 132 * Register events on frontend.