Skip to content

Commit 64eabd7

Browse files
committed
Fix. TRP. Cleantalk allowed moderation discussion state.
1 parent da27a89 commit 64eabd7

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

inc/cleantalk-settings.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function apbct_settings_add_page()
6363
global $apbct;
6464

6565
$filtered = ($value === '1' || $value === 1) ? '1' : '0';
66+
//sync discussion and plugin settings
6667
if ($old_value !== $filtered) {
6768
$apbct->settings['cleantalk_allowed_moderation'] = $filtered;
6869
$apbct->saveSettings();
@@ -2101,7 +2102,7 @@ function apbct_discussion_settings__field__moderation()
21012102
name="cleantalk_allowed_moderation"
21022103
id="cleantalk_allowed_moderation"
21032104
value="1" ' .
2104-
checked('1', $apbct->settings['cleantalk_allowed_moderation'], false) .
2105+
checked('1', TT::toString($apbct->settings['cleantalk_allowed_moderation'], '0'), false) .
21052106
'/> ';
21062107
$output .= esc_html__('Skip manual approving for the very first comment if a comment has been allowed by CleanTalk Anti-Spam protection.', 'cleantalk-spam-protect');
21072108
$output .= '</label>';
@@ -2575,6 +2576,11 @@ function apbct_settings__validate($incoming_settings)
25752576
$incoming_settings['data__email_decoder_obfuscation_custom_text'] = ContactsEncoder::getDefaultReplacingText();
25762577
}
25772578

2579+
//sync discussion and plugin settings
2580+
if (isset($incoming_settings['cleantalk_allowed_moderation'])) {
2581+
update_option('cleantalk_allowed_moderation', TT::toString($incoming_settings['cleantalk_allowed_moderation'], '0'));
2582+
}
2583+
25782584
/**
25792585
* Triggered before returning the settings
25802586
*/

lib/Cleantalk/Antispam/Integrations/CleantalkPreprocessComment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function allow()
218218
{
219219
$wp_comment_moderation_enabled = get_option('comment_moderation') === '1';
220220
$wp_auto_approve_for_user_who_has_approved_comment = get_option('comment_previously_approved') === '1';
221-
$clentalk_option_skip_moderation_for_first_comment = get_option('cleantalk_allowed_moderation', 1) == 1;
221+
$cleantalk_option_skip_moderation_for_first_comment = CleantalkRealPerson::isAutomodEnabled();
222222
$is_allowed_because_of_inactive_license = false;
223223

224224
$args = array(
@@ -251,7 +251,7 @@ public function allow()
251251
// if anu of options is disabled - standard WP recheck and exit
252252
if (
253253
!$wp_auto_approve_for_user_who_has_approved_comment ||
254-
!$clentalk_option_skip_moderation_for_first_comment
254+
!$cleantalk_option_skip_moderation_for_first_comment
255255
) {
256256
if (
257257
$this->rerunWPcheckCommentFunction()

lib/Cleantalk/ApbctWP/CleantalkRealPerson.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function publicCommentAddTrpClass($classes, $_css_class, $comment_id, $co
5555
/**
5656
* @return bool
5757
*/
58-
private static function isAutomodEnabled()
58+
public static function isFirstCommentAutoModEnabled()
5959
{
6060
global $apbct;
6161
return !empty($apbct->settings['cleantalk_allowed_moderation']) && $apbct->settings['cleantalk_allowed_moderation'] == '1';
@@ -68,7 +68,7 @@ private static function isAutomodEnabled()
6868
*/
6969
public static function isTRPHashExist($comment_id)
7070
{
71-
if (self::isAutomodEnabled()) {
71+
if (self::isFirstCommentAutoModEnabled()) {
7272
// Only for auto-moderated
7373
$trp_hash = get_comment_meta((int)$comment_id, self::$meta_hash_name__automod, true);
7474
} else {
@@ -89,7 +89,7 @@ public static function setTRPHash($comment_id)
8989
{
9090
$hash = ct_hash();
9191
if ( ! empty($hash) ) {
92-
if (self::isAutomodEnabled()) {
92+
if (self::isFirstCommentAutoModEnabled()) {
9393
update_comment_meta((int)$comment_id, self::$meta_hash_name__automod, $hash);
9494
} else {
9595
update_comment_meta((int)$comment_id, self::$meta_hash_name__old, $hash);

0 commit comments

Comments
 (0)