Skip to content

Commit

Permalink
Merge pull request #6 from CleanTalk/dev
Browse files Browse the repository at this point in the history
Fixed antispam_activity_status after saved settings
  • Loading branch information
ArtemAnoshin committed Sep 21, 2021
2 parents e7eb4e3 + cef3aa3 commit 3f3c507
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cleantalk/inc/cron_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ function apbct_sfw_send_logs(){
*/
function apbct__plugin_get_latest_version() {
$path_to_config = CLEANTALK_ROOT . 'config.php';
global $antispam_activity_status;

$updater = new \Cleantalk\Updater\Updater( CLEANTALK_ROOT );
$latest_version = $updater->getLatestVersion();
File::clean__variable($path_to_config, 'latest_version');
File::inject__variable($path_to_config, 'latest_version', $latest_version);
File::clean__variable(CLEANTALK_CONFIG_FILE, 'antispam_activity_status');
File::inject__variable(CLEANTALK_CONFIG_FILE, 'antispam_activity_status', true);
if (! isset($antispam_activity_status)) {
File::clean__variable($path_to_config, 'antispam_activity_status');
File::inject__variable($path_to_config, 'antispam_activity_status', true);
}
}
9 changes: 8 additions & 1 deletion cleantalk/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
$path_to_config = CLEANTALK_ROOT . 'config.php';
$apikey = Post::get( 'apikey' );
global $account_name_ob;
global $antispam_activity_status;

/**
* Apikey validation
Expand All @@ -79,8 +80,14 @@
die(Err::add('Please, enter the access key')->get_last( 'as_json' ));
}

if (! isset($antispam_activity_status) && Post::is_set( 'antispam_activity_status' )) {
File::clean__variable($path_to_config, 'antispam_activity_status');
File::inject__variable($path_to_config, 'antispam_activity_status', (bool)Post::get( 'antispam_activity_status' ));
} else {
File::replace__variable( $path_to_config, 'antispam_activity_status', (bool)Post::get( 'antispam_activity_status' ) );
}

File::replace__variable( $path_to_config, 'apikey', $apikey );
File::replace__variable( $path_to_config, 'antispam_activity_status', (bool)Post::get( 'antispam_activity_status' ) );
File::replace__variable( $path_to_config, 'registrations_test', (bool)Post::get( 'registrations_test' ) );
File::replace__variable( $path_to_config, 'general_postdata_test', (bool)Post::get( 'general_postdata_test' ) );
File::replace__variable( $path_to_config, 'spam_firewall', (bool)Post::get( 'spam_firewall' ) );
Expand Down

0 comments on commit 3f3c507

Please sign in to comment.