Skip to content

Commit 867f9cf

Browse files
authored
New. Integration. Newsletter plugin integration implemented. (#599)
* New. Integration. Newsletter plugin integration implemented. * Fix. Integration. Newsletter integration fixed - prevent double requests.
1 parent 9cd4c25 commit 867f9cf

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

inc/cleantalk-integrations-by-hook.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@
399399
'setting' => 'forms__contact_forms_test',
400400
'ajax' => true
401401
),
402+
'Newsletter' => array(
403+
'hook' => 'newsletter_action',
404+
'setting' => 'forms__contact_forms_test',
405+
'ajax' => false
406+
),
402407
);
403408

404409
add_action('plugins_loaded', function () use ($apbct_active_integrations) {

inc/cleantalk-pluggable.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,14 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
15211521
) {
15221522
return 'fusion_form/avada_theme skip';
15231523
}
1524+
1525+
// skip Newsletter - have direct integration
1526+
if (
1527+
apbct_is_plugin_active('newsletter/plugin.php') &&
1528+
Request::getString('action') === 'tnp'
1529+
) {
1530+
return 'Newsletter';
1531+
}
15241532
} else {
15251533
/*****************************************/
15261534
/* Here is non-ajax requests skipping */
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Cleantalk\Antispam\Integrations;
4+
5+
use Cleantalk\ApbctWP\Variables\Post;
6+
use Cleantalk\ApbctWP\Variables\Request;
7+
8+
class Newsletter extends IntegrationBase
9+
{
10+
/**
11+
* @inheritDoc
12+
*/
13+
public function getDataForChecking($argument)
14+
{
15+
if ( Request::getString('nhr') ) {
16+
// Prevent double redundant requests - this is the `success redirect` request
17+
return null;
18+
}
19+
20+
if (
21+
$argument === 's' ||
22+
$argument === 'subscribe' ||
23+
$argument === 'sa' ||
24+
$argument === 'ajaxsub'
25+
) {
26+
$posted = stripslashes_deep($_REQUEST);
27+
$email = $posted['ne'];
28+
$name = '';
29+
if (isset($posted['nn'])) {
30+
$name = $posted['nn'];
31+
unset($posted['nn']);
32+
}
33+
if (isset($posted['ns'])) {
34+
$name .= ' ' . $posted['ns'];
35+
unset($posted['ns']);
36+
}
37+
$data = ct_gfa_dto(apply_filters('apbct__filter_post', $posted), $email, $name)->getArray();
38+
if ( Post::getString('ct_bot_detector_event_token') ) {
39+
$data['event_token'] = Post::get('ct_bot_detector_event_token');
40+
}
41+
return $data;
42+
}
43+
return null;
44+
}
45+
46+
/**
47+
* @inheritDoc
48+
*/
49+
public function doBlock($message)
50+
{
51+
global $ct_comment;
52+
$ct_comment = $message;
53+
ct_die($message, 403);
54+
}
55+
}

0 commit comments

Comments
 (0)