Skip to content

Commit 8b95e4f

Browse files
committed
Fix. Search forms. Add a sign of 's' GET param to a native search form signs.
1 parent 4beeecc commit 8b95e4f

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

lib/Cleantalk/Antispam/IntegrationsByClass/WPSearchForm.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
namespace Cleantalk\Antispam\IntegrationsByClass;
44

5-
use Cleantalk\ApbctWP\Escape;
6-
use Cleantalk\ApbctWP\Variables\Post;
7-
use Cleantalk\ApbctWP\Variables\Server;
8-
use Cleantalk\Common\TT;
9-
use Cleantalk\ApbctWP\Sanitize;
10-
use Cleantalk\ApbctWP\Variables\Cookie;
11-
use Cleantalk\ApbctWP\State;
125
use Cleantalk\ApbctWP\Honeypot;
136
use DOMDocument;
147

@@ -32,10 +25,10 @@ public function doAjaxWork()
3225
public function doPublicWork()
3326
{
3427
global $apbct;
35-
if ( $apbct->settings['forms__search_test'] ) {
28+
if ($apbct->settings['forms__search_test']) {
3629
add_filter('get_search_form', array($this, 'apbctFormSearchAddFields'), 999);
3730
}
38-
if ( ! is_admin() && ! apbct_is_ajax() && ! apbct_is_customize_preview() ) {
31+
if ($this->isNativeSearchFormRequest()) {
3932
// Default search
4033
add_filter('get_search_query', array($this, 'testSpam'));
4134
add_action('wp_head', array($this, 'addNoindex'), 1);
@@ -168,4 +161,22 @@ public function addNoindex()
168161
echo '<!-- meta by CleanTalk Anti-Spam Protection plugin -->' . "\n";
169162
echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
170163
}
164+
165+
/**
166+
* Process signs for the default search request.
167+
* - not an admin page
168+
* - not an ajax call
169+
* - not a preview
170+
* - has a 's' param in the GET array
171+
* @return bool
172+
*/
173+
public function isNativeSearchFormRequest()
174+
{
175+
return (
176+
!is_admin() &&
177+
!apbct_is_ajax() &&
178+
!apbct_is_customize_preview() &&
179+
isset($_GET['s']) // https://app.doboard.com/1/task/47523#comment_305493
180+
);
181+
}
171182
}

0 commit comments

Comments
 (0)