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
3 changes: 2 additions & 1 deletion cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,8 @@ function ct_sfw_send_logs($api_key = '')
if (
time() - $apbct->stats['sfw']['sending_logs__timestamp'] < 180 ||
empty($api_key) ||
$apbct->settings['sfw__enabled'] != 1
$apbct->settings['sfw__enabled'] != 1 ||
apbct__is_hosting_license()
) {
return true;
}
Expand Down
15 changes: 14 additions & 1 deletion inc/cleantalk-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,13 @@ function apbct_settings__error__output($return = false)
continue;
}

if (! empty($type) &&
apbct__is_hosting_license() &&
in_array($type, array('sfw_update', 'sfw_send_logs', 'key_invalid', 'account_check'))
) {
continue;
}

if ( isset($error['error']) && strpos($error['error'], 'SFW_IS_DISABLED') !== false ) {
continue;
}
Expand Down Expand Up @@ -1840,7 +1847,7 @@ function apbct_settings__field__state()
'cleantalk-spam-protect'
);
}
if ( $apbct->moderate_ip ) {
if ( apbct__is_hosting_license() ) {
print "<br /><br />The Anti-Spam service is paid by your hosting provider. License #" . $apbct->data['ip_license'] . ".<br />";
if ( $apbct->api_key ) {
print esc_html__('The Access key is not required.', 'cleantalk-spam-protect');
Expand All @@ -1856,6 +1863,11 @@ function apbct_settings__field__state()
function apbct_settings__field__apikey()
{
global $apbct;

if (apbct__is_hosting_license()) {
return;
}

$template = @file_get_contents(CLEANTALK_PLUGIN_DIR . 'templates/settings/settings_key_wrapper.html');

$define_key_is_provided_by_admin = APBCT_WPMS && ! is_main_site() && ( ! $apbct->allow_custom_key || defined('CLEANTALK_ACCESS_KEY'));
Expand Down Expand Up @@ -1953,6 +1965,7 @@ function apbct_settings__field__apikey()
foreach ($replaces as $key => $value) {
$template = str_replace('%' . strtoupper($key) . '%', TT::toString($value), $template);
}

echo $template;
}

Expand Down
2 changes: 1 addition & 1 deletion js/cleantalk-admin-settings-page.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/cleantalk-admin-settings-page.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/src/cleantalk-admin-settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jQuery(document).ready(function() {
/**
* Handle synchronization errors when key is no ok to force user check the key and restart the sync
*/
if ( !ctSettingsPage.key_is_ok ) {
if ( !ctSettingsPage.key_is_ok && !ctSettingsPage.ip_license ) {
jQuery('button.cleantalk_link[value="save_changes"]').on('click',
function(e) {
e.preventDefault();
Expand Down Expand Up @@ -777,7 +777,7 @@ function apbctSaveButtonPosition() {
return;
}

if (!ctSettingsPage.key_is_ok) {
if (!ctSettingsPage.key_is_ok && !ctSettingsPage.ip_license) {
jQuery('#apbct_settings__main_save_button').hide();
return;
}
Expand Down
15 changes: 15 additions & 0 deletions lib/Cleantalk/ApbctWP/Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Cleantalk\ApbctWP\AdjustToEnvironmentModule\AdjustToEnvironmentHandler;
use Cleantalk\ApbctWP\ServerRequirementsChecker\ServerRequirementsChecker;
use Cleantalk\ApbctWP\UpdatePlugin\DbTablesCreator;
use Cleantalk\Common\TT;

class Activator
{
Expand Down Expand Up @@ -88,6 +89,20 @@ public static function activation($network_wide, $concrete_blog_id = null)
// Try to adjust to environment
$adjust = new AdjustToEnvironmentHandler();
$adjust->handle();

// Check if the user has a hosting license
$result = API::methodNoticePaidTill(
'check_hosting_license',
preg_replace('/http[s]?:\/\//', '', get_option('home'), 1),
! is_main_site() && $apbct->white_label ? 'anti-spam-hosting' : 'antispam'
);

$apbct->data['moderate_ip'] = isset($result['moderate_ip'], $result['ip_license']) ?
TT::getArrayValueAsInt($result, 'moderate_ip', 0)
: 0;
$apbct->data['ip_license'] = TT::getArrayValueAsInt($result, 'ip_license', 0);

$apbct->saveData();
}

/**
Expand Down