Skip to content

Commit 44e7561

Browse files
committed
Fix. Integrations. Fixed SiteGround cache SFW block page.
1 parent 4004313 commit 44e7561

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

cleantalk.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ function apbct_wpms__delete_blog(WP_Site $old_site)
694694
// After plugin loaded - to load locale as described in manual
695695
add_action('init', 'apbct_plugin_loaded');
696696

697+
// SiteGround Speed Optimizer: skip cache for URLs with apbct_no_cache.
698+
add_action('plugins_loaded', 'apbct_sgo_optimizer__register_bypass_query_params', 1);
699+
697700
if ( ! empty($apbct->settings['data__use_ajax']) &&
698701
! apbct_is_in_uri('.xml') &&
699702
! apbct_is_in_uri('.xsl')

inc/cleantalk-public.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,36 @@ class_exists('Jetpack', false) &&
378378
}
379379
}
380380

381+
/**
382+
* SiteGround Speed Optimizer: register sgo_bypass_query_params filter.
383+
*/
384+
function apbct_sgo_optimizer__register_bypass_query_params()
385+
{
386+
if ( ! defined('SG_OPTIMIZER_VERSION') ) {
387+
return;
388+
}
389+
add_filter('sgo_bypass_query_params', 'apbct_sgo_bypass_query_params', 10, 1);
390+
}
391+
392+
/**
393+
* Adds apbct_no_cache to SG Optimizer bypass list.
394+
*
395+
* @param string[] $bypass_query_params
396+
*
397+
* @return string[]
398+
*/
399+
function apbct_sgo_bypass_query_params($bypass_query_params)
400+
{
401+
if ( ! is_array($bypass_query_params) ) {
402+
$bypass_query_params = array();
403+
}
404+
if ( ! in_array('apbct_no_cache', $bypass_query_params, true) ) {
405+
$bypass_query_params[] = 'apbct_no_cache';
406+
}
407+
408+
return $bypass_query_params;
409+
}
410+
381411
function apbct_buffer__start()
382412
{
383413
ob_start();

0 commit comments

Comments
 (0)