Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion friendly-captcha/includes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ class FriendlyCaptcha_Plugin
"plugins" => array("wp-job-openings/wp-job-openings.php", "pro-pack-for-wp-job-openings/pro-pack.php"),
"settings_description" => "Enable Friendly Captcha for the <a href=\"https://wordpress.org/plugins/wp-job-openings/\" target=\"_blank\">WP Job Openings</a> application form.",
),
array(
"name" => "SI Schedule+Registration",
"slug" => 'tws_siwp',
"entry" => "tws-siwp/tws-siwp.php",
"plugins" => array("tws-siwp/tws-siwp.php"),
"settings_description" => "Enable Friendly Captcha for the <a href=\"https://www.ballettschul-software.de/zusatzmodule.php#sischedreg\" target=\"_blank\">SI Schedule+Registration</a> trial lesson signup form.",
),
);

public function init()
Expand Down Expand Up @@ -394,6 +401,6 @@ public function remove_verification_failed_alert()

foreach (FriendlyCaptcha_Plugin::$integrations as $integration) {
if (FriendlyCaptcha_Plugin::$instance->get_integration_active($integration['slug'])) {
require_once plugin_dir_path(__FILE__) . '../modules/' . $integration['entry'];
include_once plugin_dir_path(__FILE__) . '../modules/' . $integration['entry'];
}
}
1 change: 1 addition & 0 deletions friendly-captcha/modules/tws-siwp/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php // Silence is golden.
54 changes: 54 additions & 0 deletions friendly-captcha/modules/tws-siwp/tws-siwp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* FriendlyCaptcha integration for SI Schedule+Registration (tws-siwp) plugin.
*
* Hooks into the tws-siwp form display and validation filters.
*/

// Add captcha widget to registration form
add_filter(
'tws_siwp_captcha_widget', function ($html) {
$plugin = FriendlyCaptcha_Plugin::$instance;
if (!$plugin->is_configured()) {
return $html;
}

frcaptcha_enqueue_widget_scripts();

$widget = frcaptcha_generate_widget_tag_from_plugin($plugin);
return $html . $widget;
}
);

// Validate captcha on form submission
// $form_data is passed for potential future use (e.g. logging)
add_filter(
'tws_siwp_validate_captcha', function ($error, $form_data) {
unset($form_data); // Currently unused, but available for future extensions
$plugin = FriendlyCaptcha_Plugin::$instance;
if (!$plugin->is_configured()) {
return $error;
}

$solution = frcaptcha_get_sanitized_frcaptcha_solution_from_post();

if (empty($solution)) {
/* translators: Error message when captcha was not completed */
return __("Bitte lösen Sie das Anti-Spam-Rätsel.", "frcaptcha");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this integration only relevant to german speaking users? All our other error messages are in english, I think it would be best to keep it that way.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, most StudioIntern users (and their customers) speak German.

}

$verification = frcaptcha_verify_captcha_solution(
$solution,
$plugin->get_sitekey(),
$plugin->get_api_key(),
'tws-siwp'
);

if (!$verification["success"]) {
return FriendlyCaptcha_Plugin::default_error_user_message();
}

return $error;
}, 10, 2
);