Skip to content
Merged
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
5 changes: 5 additions & 0 deletions inc/cleantalk-integrations-by-hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@
'setting' => 'forms__contact_forms_test',
'ajax' => true
),
'Newsletter' => array(
'hook' => 'newsletter_action',
'setting' => 'forms__contact_forms_test',
'ajax' => false
),
);

add_action('plugins_loaded', function () use ($apbct_active_integrations) {
Expand Down
8 changes: 8 additions & 0 deletions inc/cleantalk-pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,14 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
) {
return 'fusion_form/avada_theme skip';
}

// skip Newsletter - have direct integration
if (
apbct_is_plugin_active('newsletter/plugin.php') &&
Request::getString('action') === 'tnp'
) {
return 'Newsletter';
}
} else {
/*****************************************/
/* Here is non-ajax requests skipping */
Expand Down
55 changes: 55 additions & 0 deletions lib/Cleantalk/Antispam/Integrations/Newsletter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Cleantalk\Antispam\Integrations;

use Cleantalk\ApbctWP\Variables\Post;
use Cleantalk\ApbctWP\Variables\Request;

class Newsletter extends IntegrationBase
{
/**
* @inheritDoc
*/
public function getDataForChecking($argument)
{
if ( Request::getString('nhr') ) {
// Prevent double redundant requests - this is the `success redirect` request
return null;
}

if (
$argument === 's' ||
$argument === 'subscribe' ||
$argument === 'sa' ||
$argument === 'ajaxsub'
) {
$posted = stripslashes_deep($_REQUEST);
$email = $posted['ne'];
$name = '';
if (isset($posted['nn'])) {
$name = $posted['nn'];
unset($posted['nn']);
}
if (isset($posted['ns'])) {
$name .= ' ' . $posted['ns'];
unset($posted['ns']);
}
$data = ct_gfa_dto(apply_filters('apbct__filter_post', $posted), $email, $name)->getArray();
if ( Post::getString('ct_bot_detector_event_token') ) {
$data['event_token'] = Post::get('ct_bot_detector_event_token');
}
return $data;
}
return null;
}

/**
* @inheritDoc
*/
public function doBlock($message)
{
global $ct_comment;
$ct_comment = $message;
ct_die($message, 403);
}
}