Disable captcha on nested forms #11

Merged
ogrecooper merged 2 commits from nested-forms into main 2026-08-19 17:29:30 +00:00
Showing only changes of commit b3bc2f2772 - Show all commits
+14
View File
@@ -116,9 +116,19 @@ final class Addon extends GFAddOn {
} }
public function is_enabled(array|null $form = null): bool { public function is_enabled(array|null $form = null): bool {
// Check to make sure that we're enabled on the plugin level first
$plugin_enabled = $this->get_plugin_setting('enabled') === '1'; $plugin_enabled = $this->get_plugin_setting('enabled') === '1';
if (is_null($form) || !$plugin_enabled) return $plugin_enabled; if (is_null($form) || !$plugin_enabled) return $plugin_enabled;
$form_id = !is_null($form) ? absint(rgar($form, 'id')) : 0;
// If Gravity Perks Nested Forms is active and the current form is nested, disable entirely (it's not compatible at the moment)
if (class_exists('GP_Nested_Forms')) {
$gp_nested_forms = GP_Nested_Forms::get_instance();
if ($gp_nested_forms->is_nested_form_submission() && $gp_nested_forms->get_parent_form_id() !== $form_id) return false;
}
// Now check to see if the opt-out is enabled within the form settings
$form_settings = $this->get_form_settings($form); $form_settings = $this->get_form_settings($form);
$form_disabled = (bool) rgar($form_settings, 'disabled'); $form_disabled = (bool) rgar($form_settings, 'disabled');
return !$form_disabled; return !$form_disabled;
@@ -160,7 +170,11 @@ final class Addon extends GFAddOn {
if ($context != 'form-submit') return $validation_result; if ($context != 'form-submit') return $validation_result;
$form = $validation_result['form']; $form = $validation_result['form'];
// Make sure that we are actually processing the end of the form
if (!GFFormDisplay::is_last_page($form) || rgpost('action') == 'heartbeat') return $validation_result; if (!GFFormDisplay::is_last_page($form) || rgpost('action') == 'heartbeat') return $validation_result;
// Make sure that we are connected and enabled
if (!Settings::is_connected() || !$this->is_enabled($form)) return $validation_result; if (!Settings::is_connected() || !$this->is_enabled($form)) return $validation_result;
$errors = API::process(Widget::get_token()); $errors = API::process(Widget::get_token());