Remove all plugins / install base theme
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./js/src/frontend.js":
|
||||
/*!****************************!*\
|
||||
!*** ./js/src/frontend.js ***!
|
||||
\****************************/
|
||||
/***/ (function() {
|
||||
|
||||
var _this = this;
|
||||
|
||||
/* global jQuery, gform, gforms_recaptcha_recaptcha_strings, grecaptcha */
|
||||
(function ($, gform, grecaptcha, strings) {
|
||||
/**
|
||||
* Make the API request to Google to get the reCAPTCHA token right before submission.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {Object} e The event object.
|
||||
* @return {void}
|
||||
*/
|
||||
var getToken = function getToken(e) {
|
||||
var form = $(e.data.form);
|
||||
var recaptchaField = form.find('.ginput_recaptchav3');
|
||||
var dataInput = recaptchaField.find('.gfield_recaptcha_response');
|
||||
|
||||
if (!dataInput.length || dataInput.val().length) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
grecaptcha.ready(function () {
|
||||
grecaptcha.execute(strings.site_key, {
|
||||
action: 'submit'
|
||||
}).then(function (token) {
|
||||
if (token.length && typeof token === 'string') {
|
||||
dataInput.val(token);
|
||||
} // Sometimes the submit button is disabled to prevent the user from clicking it again,
|
||||
// for example when 3DS is being processed for stripe elements.
|
||||
// We need to enable it before submitting the form, otherwise it won't be submitted.
|
||||
|
||||
|
||||
var $submitButton = $('#gform_submit_button_' + form[0].dataset.formid);
|
||||
|
||||
if ($submitButton.prop('disabled') === true) {
|
||||
$submitButton.prop('disabled', false);
|
||||
}
|
||||
|
||||
form.submit();
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Add event listeners to the form.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {string|number} formId The numeric ID of the form.
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
var addFormEventListeners = function addFormEventListeners(formId) {
|
||||
var $form = $("#gform_".concat(formId, ":not(.recaptcha-v3-initialized)"));
|
||||
$form.on('submit', {
|
||||
form: $form
|
||||
}, getToken);
|
||||
$form.addClass('recaptcha-v3-initialized');
|
||||
};
|
||||
/**
|
||||
* The reCAPTCHA handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
var gfRecaptcha = function gfRecaptcha() {
|
||||
var self = _this;
|
||||
/**
|
||||
* Initialize the Recaptcha handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
self.init = function () {
|
||||
self.elements = {
|
||||
formIds: self.getFormIds()
|
||||
};
|
||||
self.addEventListeners();
|
||||
};
|
||||
/**
|
||||
* Get an array of form IDs.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {Array} Array of form IDs.
|
||||
*/
|
||||
|
||||
|
||||
self.getFormIds = function () {
|
||||
var ids = [];
|
||||
var forms = document.querySelectorAll('.gform_wrapper form');
|
||||
forms.forEach(function (form) {
|
||||
if ('formid' in form.dataset) {
|
||||
ids.push(form.dataset.formid);
|
||||
} else {
|
||||
ids.push(form.getAttribute('id').split('gform_')[1]);
|
||||
}
|
||||
});
|
||||
return ids;
|
||||
};
|
||||
/**
|
||||
* Add event listeners to the page.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
self.addEventListeners = function () {
|
||||
self.elements.formIds.forEach(function (formId) {
|
||||
addFormEventListeners(formId);
|
||||
});
|
||||
$(document).on('gform_post_render', function (event, formId) {
|
||||
addFormEventListeners(formId);
|
||||
});
|
||||
};
|
||||
|
||||
self.init();
|
||||
}; // Initialize and run the whole shebang.
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
gfRecaptcha();
|
||||
});
|
||||
})(jQuery, gform, grecaptcha, gforms_recaptcha_recaptcha_strings);
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/
|
||||
/******/ // startup
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ // This entry module is referenced by other modules so it can't be inlined
|
||||
/******/ var __webpack_exports__ = {};
|
||||
/******/ __webpack_modules__["./js/src/frontend.js"]();
|
||||
/******/
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=frontend.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
({"./js/src/frontend.js":function(){var r,i,o,e,n=this;function a(t){(t=r("#gform_".concat(t,":not(.recaptcha-v3-initialized)"))).on("submit",{form:t},e),t.addClass("recaptcha-v3-initialized")}r=jQuery,gform,i=grecaptcha,o=gforms_recaptcha_recaptcha_strings,e=function(t){var e=r(t.data.form),n=e.find(".ginput_recaptchav3").find(".gfield_recaptcha_response");n.length&&!n.val().length&&(t.preventDefault(),i.ready(function(){i.execute(o.site_key,{action:"submit"}).then(function(t){t.length&&"string"==typeof t&&n.val(t);t=r("#gform_submit_button_"+e[0].dataset.formid);!0===t.prop("disabled")&&t.prop("disabled",!1),e.submit()})}))},r(document).ready(function(){var t;(t=n).init=function(){t.elements={formIds:t.getFormIds()},t.addEventListeners()},t.getFormIds=function(){var e=[];return document.querySelectorAll(".gform_wrapper form").forEach(function(t){"formid"in t.dataset?e.push(t.dataset.formid):e.push(t.getAttribute("id").split("gform_")[1])}),e},t.addEventListeners=function(){t.elements.formIds.forEach(function(t){a(t)}),r(document).on("gform_post_render",function(t,e){a(e)})},t.init()})}})["./js/src/frontend.js"]();
|
||||
@@ -1,444 +0,0 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
var __webpack_exports__ = {};
|
||||
/*!***********************************!*\
|
||||
!*** ./js/src/plugin_settings.js ***!
|
||||
\***********************************/
|
||||
/* global jQuery, gform, grecaptcha, gforms_recaptcha_recaptcha_strings */
|
||||
(function ($) {
|
||||
/**
|
||||
* Handles reCAPTCHA v2 plugin settings validation.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
var recaptchaV2Settings = function recaptchaV2Settings() {
|
||||
var v2Settings = {};
|
||||
/**
|
||||
* Initialize reCAPTCHA v2 settings.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
v2Settings.init = function () {
|
||||
v2Settings.cacheElements();
|
||||
v2Settings.addEventListeners();
|
||||
};
|
||||
/**
|
||||
* Cache the fields used by this handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v2Settings.cacheElements = function () {
|
||||
v2Settings.container = $('div[id="gform_setting_reset_v2"]');
|
||||
v2Settings.fields = {
|
||||
siteKey: $('input[name="_gform_setting_site_key_v2"]'),
|
||||
secretKey: $('input[name="_gform_setting_secret_key_v2"]'),
|
||||
reset: $('input[name="_gform_setting_reset_v2"]'),
|
||||
type: $('input[name="_gform_setting_type_v2"]')
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Add event listeners for this handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v2Settings.addEventListeners = function () {
|
||||
v2Settings.fields.siteKey.on('change', window.loadRecaptcha);
|
||||
v2Settings.fields.secretKey.on('change', window.loadRecaptcha);
|
||||
v2Settings.fields.type.on('change', function () {
|
||||
return window.loadRecaptcha();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Handles showing and hiding the reCAPTCHA itself.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
window.loadRecaptcha = function () {
|
||||
var self = {};
|
||||
/**
|
||||
* Initialize the reCAPTCHA rendering process.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
self.init = function () {
|
||||
v2Settings.recaptcha = $('#recaptcha');
|
||||
v2Settings.save = $('#gform-settings-save');
|
||||
self.flushExistingState(); // Reset key status.
|
||||
// Note: recaptcha is misspelled here for legacy reasons.
|
||||
|
||||
$('#recpatcha .gform-settings-field__feedback').remove(); // If no public or private key is provided, exit.
|
||||
|
||||
if (!self.canBeDisplayed()) {
|
||||
self.hideRecaptcha();
|
||||
return;
|
||||
}
|
||||
|
||||
v2Settings.save.prop('disabled', true);
|
||||
self.showSelectedRecaptcha();
|
||||
};
|
||||
/**
|
||||
* Renders the v2 reCAPTCHA.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {string} typeValue The selected type to render.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
self.render = function (typeValue) {
|
||||
// Render reCAPTCHA.
|
||||
grecaptcha.render('recaptcha', {
|
||||
sitekey: v2Settings.fields.siteKey.val().trim(),
|
||||
size: typeValue === 'invisible' ? typeValue : '',
|
||||
badge: 'inline',
|
||||
'error-callback': function errorCallback() {},
|
||||
callback: function callback() {
|
||||
return v2Settings.save.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Flush the existing state of the reCAPTCHA handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
self.flushExistingState = function () {
|
||||
window.___grecaptcha_cfg.clients = {};
|
||||
window.___grecaptcha_cfg.count = 0;
|
||||
v2Settings.recaptcha.html('');
|
||||
v2Settings.fields.reset.val('1');
|
||||
};
|
||||
/**
|
||||
* Determines whether the reCAPTCHA can be shown.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {boolean} Whether the reCAPTCHA can be shown.
|
||||
*/
|
||||
|
||||
|
||||
self.canBeDisplayed = function () {
|
||||
return v2Settings.fields.siteKey.val() && v2Settings.fields.secretKey.val();
|
||||
};
|
||||
/**
|
||||
* Hides the reCAPTCHA element.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
self.hideRecaptcha = function () {
|
||||
v2Settings.save.prop('disabled', false);
|
||||
v2Settings.container.hide();
|
||||
};
|
||||
/**
|
||||
* Show the selected reCAPTCHA type.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
self.showSelectedRecaptcha = function () {
|
||||
var typeValue = $('input[name="_gform_setting_type_v2"]:checked').val();
|
||||
self.render(typeValue);
|
||||
|
||||
switch (typeValue) {
|
||||
case 'checkbox':
|
||||
$('#gforms_checkbox_recaptcha_message, label[for="reset"]').show();
|
||||
break;
|
||||
|
||||
case 'invisible':
|
||||
$('#gforms_checkbox_recaptcha_message, label[for="reset"]').hide();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Unexpected type selected.');
|
||||
}
|
||||
|
||||
v2Settings.container.show();
|
||||
|
||||
if (typeValue === 'invisible') {
|
||||
grecaptcha.execute();
|
||||
}
|
||||
};
|
||||
|
||||
self.init();
|
||||
};
|
||||
|
||||
v2Settings.init();
|
||||
};
|
||||
/**
|
||||
* Handles reCAPTCHA v3 plugin settings validation.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
var recaptchaV3Settings = function recaptchaV3Settings() {
|
||||
var v3Settings = {};
|
||||
/**
|
||||
* Initializes the reCAPTCHA v3 settings handler.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
v3Settings.init = function () {
|
||||
v3Settings.token = '';
|
||||
v3Settings.strings = gforms_recaptcha_recaptcha_strings;
|
||||
v3Settings.cacheElements();
|
||||
v3Settings.validateKeysV3();
|
||||
v3Settings.addEventListeners();
|
||||
};
|
||||
/**
|
||||
* Cache HTML elements for the v3 reCAPTCHA settings.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.cacheElements = function () {
|
||||
v3Settings.fields = {
|
||||
siteKey: '#site_key_v3',
|
||||
secretKey: '#secret_key_v3',
|
||||
threshold: '#score_threshold_v3',
|
||||
disableBadge: '#disable_badge_v3',
|
||||
keysStatus: '#gform_setting_recaptcha_keys_status_v3'
|
||||
};
|
||||
v3Settings.cache = {
|
||||
siteKey: $(v3Settings.fields.siteKey),
|
||||
secretKey: $(v3Settings.fields.secretKey),
|
||||
keysStatus: $(v3Settings.fields.keysStatus),
|
||||
save: $('#gform-settings-save')
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Setup event listeners for field validation.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.addEventListeners = function () {
|
||||
if (!v3Settings.strings.site_key.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(v3Settings.fields.siteKey).on('keyup', function () {
|
||||
return v3Settings.clearValidationFeedback();
|
||||
});
|
||||
$(v3Settings.fields.secretKey).on('keyup', function () {
|
||||
return v3Settings.clearValidationFeedback();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Empty out the validation feedback if the fields are modified, as we can't yet know the status.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.clearValidationFeedback = function () {
|
||||
v3Settings.unsetValid(v3Settings.cache.siteKey.closest('.gform-settings-input__container'));
|
||||
v3Settings.unsetValid(v3Settings.cache.secretKey.closest('.gform-settings-input__container'));
|
||||
};
|
||||
/**
|
||||
* Handles validation of the v3 site key.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {Promise<unknown>} Returns a promise so this can be verified synchronously if checking the secret key.
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.getRecaptchaToken = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var siteKeyContainer = v3Settings.cache.siteKey.closest('.gform-settings-input__container');
|
||||
|
||||
try {
|
||||
var siteKey = v3Settings.cache.siteKey;
|
||||
var siteKeyValue = siteKey.val().trim();
|
||||
|
||||
if (0 === siteKeyValue.length) {
|
||||
v3Settings.unsetValid(siteKeyContainer);
|
||||
v3Settings.unsetValid(v3Settings.cache.keysStatus.closest('.gform-settings-input__container'));
|
||||
$(v3Settings.fields.keysStatus).find('input').val('0');
|
||||
return;
|
||||
}
|
||||
|
||||
grecaptcha.ready(function () {
|
||||
try {
|
||||
grecaptcha.execute(siteKeyValue, {
|
||||
action: 'submit'
|
||||
}).then(function (token) {
|
||||
resolve(token);
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Handles validation of the v3 site and secret keys.
|
||||
*
|
||||
* On page load, attempt to generate a reCAPTCHA token and immediately validate it on the server. If it's good,
|
||||
* we'll update the presentation of the keys to indicate success or failure.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.validateKeysV3 = function () {
|
||||
var siteKeyContainer = v3Settings.cache.siteKey.closest('.gform-settings-input__container');
|
||||
var secretKeyContainer = v3Settings.cache.secretKey.closest('.gform-settings-input__container');
|
||||
var keysStatusInput = $(v3Settings.fields.keysStatus).find('input');
|
||||
|
||||
if (!$(v3Settings.fields.siteKey).val().trim().length) {
|
||||
v3Settings.unsetValid(siteKeyContainer);
|
||||
v3Settings.unsetValid(secretKeyContainer);
|
||||
keysStatusInput.val('0');
|
||||
return;
|
||||
}
|
||||
|
||||
v3Settings.getRecaptchaToken().then(function (token) {
|
||||
v3Settings.token = token;
|
||||
}).catch(function () {
|
||||
v3Settings.setInvalid(siteKeyContainer);
|
||||
v3Settings.setInvalid(secretKeyContainer);
|
||||
keysStatusInput.val('0');
|
||||
}).finally(function () {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: v3Settings.strings.ajaxurl,
|
||||
data: {
|
||||
action: 'verify_secret_key',
|
||||
nonce: v3Settings.strings.nonce,
|
||||
token: v3Settings.token,
|
||||
site_key_v3: $(v3Settings.fields.siteKey).val(),
|
||||
secret_key_v3: $(v3Settings.fields.secretKey).val()
|
||||
}
|
||||
}).then(function (response) {
|
||||
switch (response.data.keys_status) {
|
||||
case '1':
|
||||
v3Settings.setValid(siteKeyContainer);
|
||||
v3Settings.setValid(secretKeyContainer);
|
||||
keysStatusInput.val('1');
|
||||
break;
|
||||
|
||||
case '0':
|
||||
v3Settings.setInvalid(siteKeyContainer);
|
||||
v3Settings.setInvalid(secretKeyContainer);
|
||||
keysStatusInput.val('0');
|
||||
break;
|
||||
|
||||
default:
|
||||
v3Settings.unsetValid(siteKeyContainer);
|
||||
v3Settings.unsetValid(secretKeyContainer);
|
||||
keysStatusInput.val('0');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Updates the text field to display no feedback.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {Object} el The jQuery element.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.unsetValid = function (el) {
|
||||
el.removeClass('gform-settings-input__container--feedback-success');
|
||||
el.removeClass('gform-settings-input__container--feedback-error');
|
||||
};
|
||||
/**
|
||||
* Updates the text field to display the successful feedback.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {Object} el The jQuery element.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.setValid = function (el) {
|
||||
el.addClass('gform-settings-input__container--feedback-success');
|
||||
el.removeClass('gform-settings-input__container--feedback-error');
|
||||
};
|
||||
/**
|
||||
* Updates the text field to display the error feedback.
|
||||
*
|
||||
* @since 1.0
|
||||
*
|
||||
* @param {Object} el The jQuery element.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
|
||||
|
||||
v3Settings.setInvalid = function (el) {
|
||||
el.removeClass('gform-settings-input__container--feedback-success');
|
||||
el.addClass('gform-settings-input__container--feedback-error');
|
||||
};
|
||||
|
||||
v3Settings.init();
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
recaptchaV3Settings();
|
||||
recaptchaV2Settings();
|
||||
gform.adminUtils.handleUnsavedChanges('#gform-settings');
|
||||
});
|
||||
})(jQuery);
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=plugin_settings.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
!function(){var i;(i=jQuery)(document).ready(function(){var a,n;(a={init:function(){a.token="",a.strings=gforms_recaptcha_recaptcha_strings,a.cacheElements(),a.validateKeysV3(),a.addEventListeners()},cacheElements:function(){a.fields={siteKey:"#site_key_v3",secretKey:"#secret_key_v3",threshold:"#score_threshold_v3",disableBadge:"#disable_badge_v3",keysStatus:"#gform_setting_recaptcha_keys_status_v3"},a.cache={siteKey:i(a.fields.siteKey),secretKey:i(a.fields.secretKey),keysStatus:i(a.fields.keysStatus),save:i("#gform-settings-save")}},addEventListeners:function(){a.strings.site_key.length&&(i(a.fields.siteKey).on("keyup",function(){return a.clearValidationFeedback()}),i(a.fields.secretKey).on("keyup",function(){return a.clearValidationFeedback()}))},clearValidationFeedback:function(){a.unsetValid(a.cache.siteKey.closest(".gform-settings-input__container")),a.unsetValid(a.cache.secretKey.closest(".gform-settings-input__container"))},getRecaptchaToken:function(){return new Promise(function(t,n){var e=a.cache.siteKey.closest(".gform-settings-input__container");try{var s=a.cache.siteKey.val().trim();0===s.length?(a.unsetValid(e),a.unsetValid(a.cache.keysStatus.closest(".gform-settings-input__container")),i(a.fields.keysStatus).find("input").val("0")):grecaptcha.ready(function(){try{grecaptcha.execute(s,{action:"submit"}).then(function(e){t(e)})}catch(e){n(e)}})}catch(e){n(e)}})},validateKeysV3:function(){var t=a.cache.siteKey.closest(".gform-settings-input__container"),n=a.cache.secretKey.closest(".gform-settings-input__container"),s=i(a.fields.keysStatus).find("input");i(a.fields.siteKey).val().trim().length?a.getRecaptchaToken().then(function(e){a.token=e}).catch(function(){a.setInvalid(t),a.setInvalid(n),s.val("0")}).finally(function(){i.ajax({method:"POST",dataType:"JSON",url:a.strings.ajaxurl,data:{action:"verify_secret_key",nonce:a.strings.nonce,token:a.token,site_key_v3:i(a.fields.siteKey).val(),secret_key_v3:i(a.fields.secretKey).val()}}).then(function(e){switch(e.data.keys_status){case"1":a.setValid(t),a.setValid(n),s.val("1");break;case"0":a.setInvalid(t),a.setInvalid(n),s.val("0");break;default:a.unsetValid(t),a.unsetValid(n),s.val("0")}})}):(a.unsetValid(t),a.unsetValid(n),s.val("0"))},unsetValid:function(e){e.removeClass("gform-settings-input__container--feedback-success"),e.removeClass("gform-settings-input__container--feedback-error")},setValid:function(e){e.addClass("gform-settings-input__container--feedback-success"),e.removeClass("gform-settings-input__container--feedback-error")},setInvalid:function(e){e.removeClass("gform-settings-input__container--feedback-success"),e.addClass("gform-settings-input__container--feedback-error")}}).init(),n={init:function(){n.cacheElements(),n.addEventListeners()},cacheElements:function(){n.container=i('div[id="gform_setting_reset_v2"]'),n.fields={siteKey:i('input[name="_gform_setting_site_key_v2"]'),secretKey:i('input[name="_gform_setting_secret_key_v2"]'),reset:i('input[name="_gform_setting_reset_v2"]'),type:i('input[name="_gform_setting_type_v2"]')}},addEventListeners:function(){n.fields.siteKey.on("change",window.loadRecaptcha),n.fields.secretKey.on("change",window.loadRecaptcha),n.fields.type.on("change",function(){return window.loadRecaptcha()})}},window.loadRecaptcha=function(){var t={init:function(){n.recaptcha=i("#recaptcha"),n.save=i("#gform-settings-save"),t.flushExistingState(),i("#recpatcha .gform-settings-field__feedback").remove(),t.canBeDisplayed()?(n.save.prop("disabled",!0),t.showSelectedRecaptcha()):t.hideRecaptcha()},render:function(e){grecaptcha.render("recaptcha",{sitekey:n.fields.siteKey.val().trim(),size:"invisible"===e?e:"",badge:"inline","error-callback":function(){},callback:function(){return n.save.prop("disabled",!1)}})},flushExistingState:function(){window.___grecaptcha_cfg.clients={},window.___grecaptcha_cfg.count=0,n.recaptcha.html(""),n.fields.reset.val("1")},canBeDisplayed:function(){return n.fields.siteKey.val()&&n.fields.secretKey.val()},hideRecaptcha:function(){n.save.prop("disabled",!1),n.container.hide()},showSelectedRecaptcha:function(){var e=i('input[name="_gform_setting_type_v2"]:checked').val();switch(t.render(e),e){case"checkbox":i('#gforms_checkbox_recaptcha_message, label[for="reset"]').show();break;case"invisible":i('#gforms_checkbox_recaptcha_message, label[for="reset"]').hide();break;default:throw new Error("Unexpected type selected.")}n.container.show(),"invisible"===e&&grecaptcha.execute()}};t.init()},n.init(),gform.adminUtils.handleUnsavedChanges("#gform-settings")})}();
|
||||
Reference in New Issue
Block a user