Skip to content

Commit a140dff

Browse files
committed
1.10.0
1 parent 4faf066 commit a140dff

File tree

8 files changed

+90
-15
lines changed

8 files changed

+90
-15
lines changed

altcha.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
* Description: ALTCHA is a free, open-source CAPTCHA alternative that offers robust protection without using cookies, ensuring full GDPR compliance by design. It also provides invisible anti-spam and anti-bot protection through ALTCHA's API.
88
* Author: Altcha.org
99
* Author URI: https://altcha.org
10-
* Version: 1.9.3
11-
* Stable tag: 1.9.3
10+
* Version: 1.10.0
11+
* Stable tag: 1.10.0
1212
* Requires at least: 5.0
1313
* Requires PHP: 7.3
1414
* Tested up to: 6.6
1515
* License: GPLv2 or later
1616
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
1717
*/
1818

19-
define('ALTCHA_VERSION', '1.9.3');
19+
define('ALTCHA_VERSION', '1.10.0');
2020
define('ALTCHA_WEBSITE', 'https://altcha.org/');
2121
define('ALTCHA_WIDGET_VERSION', '1.0.0');
2222
define('ALTCHA_LANGUAGES', [
@@ -65,6 +65,7 @@
6565
require plugin_dir_path( __FILE__ ) . './integrations/forminator.php';
6666
require plugin_dir_path( __FILE__ ) . './integrations/html-forms.php';
6767
require plugin_dir_path( __FILE__ ) . './integrations/gravityforms.php';
68+
require plugin_dir_path( __FILE__ ) . './integrations/wpdiscuz.php';
6869
require plugin_dir_path( __FILE__ ) . './integrations/wpforms.php';
6970
require plugin_dir_path( __FILE__ ) . './integrations/wordpress.php';
7071

includes/core.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class AltchaPlugin
6868

6969
public static $option_integration_wordpress_comments = "altcha_integration_wordpress_comments";
7070

71+
public static $option_integration_wpdiscuz = "altcha_integration_wpdiscuz";
72+
7173
public static $option_integration_wpforms = "altcha_integration_wpforms";
7274

7375
public static $html_espace_allowed_tags = array(
@@ -81,6 +83,7 @@ class AltchaPlugin
8183
'hidefooter' => array(),
8284
'blockspam' => array(),
8385
'spamfilter' => array(),
86+
'name' => array(),
8487
),
8588
'div' => array(
8689
'class' => array(),
@@ -224,6 +227,11 @@ public function get_integration_wordpress_comments()
224227
return trim(get_option(AltchaPlugin::$option_integration_wordpress_comments));
225228
}
226229

230+
public function get_integration_wpdiscuz()
231+
{
232+
return trim(get_option(AltchaPlugin::$option_integration_wpdiscuz));
233+
}
234+
227235
public function get_integration_wpforms()
228236
{
229237
return trim(get_option(AltchaPlugin::$option_integration_wpforms));
@@ -391,7 +399,7 @@ public function generate_challenge($hmac_key = null, $complexity = null, $expire
391399
return $response;
392400
}
393401

394-
public function get_widget_attrs($mode, $language = null)
402+
public function get_widget_attrs($mode, $language = null, $name = null)
395403
{
396404
$challengeurl = $this->get_challengeurl();
397405
$api = $this->get_api();
@@ -408,6 +416,9 @@ public function get_widget_attrs($mode, $language = null)
408416
'challengeurl' => $challengeurl,
409417
'strings' => $strings,
410418
);
419+
if ($name) {
420+
$attrs['name'] = $name;
421+
}
411422
if ($auto) {
412423
$attrs['auto'] = $auto;
413424
}
@@ -432,9 +443,9 @@ public function get_widget_attrs($mode, $language = null)
432443
return $attrs;
433444
}
434445

435-
public function render_widget($mode, $wrap = false, $language = null)
446+
public function render_widget($mode, $wrap = false, $language = null, $name = null)
436447
{
437-
$attrs = $this->get_widget_attrs($mode, $language);
448+
$attrs = $this->get_widget_attrs($mode, $language, $name);
438449
$attributes = join(' ', array_map(function ($key) use ($attrs) {
439450
if (is_bool($attrs[$key])) {
440451
return $attrs[$key] ? $key : '';

includes/helpers.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function altcha_plugin_active($name) {
1414
return is_plugin_active('html-forms/html-forms.php');
1515
case 'contact-form-7':
1616
return is_plugin_active('contact-form-7/wp-contact-form-7.php');
17+
case 'wpdiscuz':
18+
return is_plugin_active('wpdiscuz/class.WpdiscuzCore.php');
1719
case 'wpforms':
1820
return is_plugin_active('wpforms/wpforms.php') || is_plugin_active('wpforms-lite/wpforms.php');
1921
default:

includes/settings.php

+25
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ function altcha_settings_init()
122122
AltchaPlugin::$option_integration_wordpress_reset_password
123123
);
124124

125+
register_setting(
126+
'altcha_options',
127+
AltchaPlugin::$option_integration_wpdiscuz
128+
);
129+
125130
register_setting(
126131
'altcha_options',
127132
AltchaPlugin::$option_integration_wpforms
@@ -461,6 +466,26 @@ function altcha_settings_init()
461466
)
462467
);
463468

469+
add_settings_field(
470+
'altcha_settings_wpdiscuz_integration_field',
471+
'WPDiscuz',
472+
'altcha_settings_select_callback',
473+
'altcha_admin',
474+
'altcha_integrations_settings_section',
475+
array(
476+
"name" => AltchaPlugin::$option_integration_wpdiscuz,
477+
"disabled" => !altcha_plugin_active('wpdiscuz'),
478+
"spamfilter_options" => array(
479+
"spamfilter",
480+
"captcha_spamfilter",
481+
),
482+
"options" => array(
483+
"" => "Disable",
484+
"captcha" => "Captcha",
485+
"captcha_spamfilter" => "Captcha + Spam Filter",
486+
),
487+
)
488+
);
464489

465490
add_settings_field(
466491
'altcha_settings_wpforms_integration_field',

integrations/wordpress.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function () {
88
$plugin = AltchaPlugin::$instance;
99
$mode = $plugin->get_integration_wordpress_register();
1010
if (!empty($mode)) {
11-
altcha_wordpress_comments_render_widget($mode, true);
11+
altcha_wordpress_comments_render_widget($mode, 'altcha_register');
1212
}
1313
},
1414
10,
@@ -21,7 +21,7 @@ function ($user_login, $user_email, $errors) {
2121
$plugin = AltchaPlugin::$instance;
2222
$mode = $plugin->get_integration_wordpress_register();
2323
if (!empty($mode)) {
24-
$altcha = isset($_POST['altcha']) ? trim(sanitize_text_field($_POST['altcha'])) : '';
24+
$altcha = isset($_POST['altcha_register']) ? trim(sanitize_text_field($_POST['altcha_register'])) : '';
2525
if ($plugin->verify($altcha) === false) {
2626
return $errors->add(
2727
'altcha_error_message',
@@ -41,7 +41,7 @@ function () {
4141
$plugin = AltchaPlugin::$instance;
4242
$mode = $plugin->get_integration_wordpress_login();
4343
if (!empty($mode)) {
44-
altcha_wordpress_comments_render_widget($mode, true);
44+
altcha_wordpress_comments_render_widget($mode);
4545
}
4646
},
4747
10,
@@ -74,7 +74,7 @@ function () {
7474
$plugin = AltchaPlugin::$instance;
7575
$mode = $plugin->get_integration_wordpress_reset_password();
7676
if (!empty($mode)) {
77-
altcha_wordpress_comments_render_widget($mode, true);
77+
altcha_wordpress_comments_render_widget($mode);
7878
}
7979
},
8080
10,
@@ -135,7 +135,7 @@ function ($comment) {
135135
return $comment;
136136
}
137137
$plugin = AltchaPlugin::$instance;
138-
$mode = $plugin->get_integration_wordpress_comments();
138+
$mode = (altcha_plugin_active('wpdiscuz') && $plugin->get_integration_wpdiscuz()) || $plugin->get_integration_wordpress_comments();
139139
if (!empty($mode)) {
140140
$altcha = isset($_POST['altcha']) ? trim(sanitize_text_field($_POST['altcha'])) : '';
141141
if ($plugin->verify($altcha) === false) {
@@ -148,10 +148,10 @@ function ($comment) {
148148
1
149149
);
150150

151-
function altcha_wordpress_comments_render_widget($mode, $full_width = false)
151+
function altcha_wordpress_comments_render_widget($mode, $name = null)
152152
{
153153
$plugin = AltchaPlugin::$instance;
154154
altcha_enqueue_scripts();
155155
altcha_enqueue_styles();
156-
echo wp_kses($plugin->render_widget($mode, true), AltchaPlugin::$html_espace_allowed_tags);
156+
echo wp_kses($plugin->render_widget($mode, true, null, $name), AltchaPlugin::$html_espace_allowed_tags);
157157
}

integrations/wpdiscuz.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
if ( ! defined( 'ABSPATH' ) ) exit;
4+
5+
add_action(
6+
'wpdiscuz_button_actions',
7+
function () {
8+
$plugin = AltchaPlugin::$instance;
9+
$mode = $plugin->get_integration_wpdiscuz();
10+
if (!empty($mode)) {
11+
$plugin = AltchaPlugin::$instance;
12+
altcha_enqueue_scripts();
13+
altcha_enqueue_styles();
14+
$output = "<div class=\"altcha-widget-wrap-wpdiscuz\">";
15+
$output .= $plugin->render_widget($mode, false);
16+
$output .= "</div>";
17+
echo wp_kses($output, AltchaPlugin::$html_espace_allowed_tags);
18+
}
19+
},
20+
10,
21+
0
22+
);

public/altcha.css

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
display: block;
1515
}
1616

17+
.altcha-widget-wrap-wpdiscuz {
18+
display: flex;
19+
justify-content: end;
20+
margin-bottom: 0.5rem;
21+
}
22+
23+
.altcha-widget-wrap-wpdiscuz > * {
24+
min-width: 260px;
25+
}
26+
1727
.login .altcha:not([data-floating]) {
1828
--altcha-max-width: 100%;
1929
}

readme.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Tags: altcha, captcha, spam, anti-spam, anti-bot, antispam, recaptcha, hcaptcha, gdpr
33
Author: Altcha.org
44
Author URI: https://altcha.org
5-
Version: 1.9.3
6-
Stable tag: 1.9.3
5+
Version: 1.10.0
6+
Stable tag: 1.10.0
77
Requires at least: 5.0
88
Requires PHP: 7.3
99
Tested up to: 6.6
@@ -67,6 +67,7 @@ This plugin requires the WordPress REST API. If you are using any "Disable REST
6767
* Forminator
6868
* GravityForms
6969
* HTML Forms
70+
* WPDiscuz
7071
* WPForms
7172
* WordPress Login, Register, Password reset
7273
* WordPress Comments
@@ -94,6 +95,9 @@ All source code for the plugin, and the ALTCHA widget is available on GitHub. In
9495

9596
== Changelog ==
9697

98+
= 1.10.0 =
99+
* Added support for WPDiscuz
100+
97101
= 1.9.3 =
98102
* Fix REST API Cache-Control header
99103

0 commit comments

Comments
 (0)