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
16 changes: 16 additions & 0 deletions cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,22 @@ function ct_account_status_check($api_key = null, $process_errors = true)
$apbct->data['notice_trial'] = TT::getArrayValueAsInt($result, 'trial', 0);
$apbct->data['notice_review'] = TT::getArrayValueAsInt($result, 'show_review', 0);

if ($apbct->data['notice_show']) {
$notice_banners = API::getNoticeBanners($api_key);

if (isset($notice_banners['operation_status'], $notice_banners['banners']) && $notice_banners['operation_status'] === 'SUCCESS') {
if (isset($notice_banners['banners']['TRIAL']['level'])) {
$apbct->data['notice_trial_level'] = strtolower($notice_banners['banners']['TRIAL']['level']);
}
if (isset($notice_banners['banners']['RENEW']['level'])) {
$apbct->data['notice_renew_level'] = strtolower($notice_banners['banners']['RENEW']['level']);
}
if (isset($notice_banners['banners']['REVIEW']['level'])) {
$apbct->data['notice_review_level'] = strtolower($notice_banners['banners']['REVIEW']['level']);
}
}
}

// Other
$apbct->data['service_id'] = TT::getArrayValueAsInt($result, 'service_id', 0);
$apbct->data['user_id'] = TT::getArrayValueAsInt($result, 'user_id', 0);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cleantalk/ApbctWP/AdminNotices.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function notice_trial() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.
$this->apbct->data['wl_brandname']
);

$banner_data->level = 'error';
$banner_data->level = isset($this->apbct->data['notice_trial_level']) ? $this->apbct->data['notice_trial_level'] : 'error';
$banner_data->is_dismissible = ! $this->is_cleantalk_page;

$banner = new ApbctUniversalBanner($banner_data);
Expand Down Expand Up @@ -245,7 +245,7 @@ public function notice_renew() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.
$this->apbct->data['wl_brandname']
);

$banner_data->level = 'error';
$banner_data->level = isset($this->apbct->data['notice_renew_level']) ? $this->apbct->data['notice_renew_level'] : 'error';
$banner_data->is_dismissible = ! $this->is_cleantalk_page;

$banner = new ApbctUniversalBanner($banner_data);
Expand Down Expand Up @@ -285,7 +285,7 @@ public function notice_review() // phpcs:ignore PSR1.Methods.CamelCapsMethodName
. '</a>';
$banner_data->additional_text = $support_link . '&nbsp;&nbsp;' . $close_link;

$banner_data->level = 'success';
$banner_data->level = isset($this->apbct->data['notice_review_level']) ? $this->apbct->data['notice_review_level'] : 'success';

$banner = new ApbctUniversalBanner($banner_data);
$banner->echoBannerBody();
Expand Down
18 changes: 18 additions & 0 deletions lib/Cleantalk/Common/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ public static function methodNoticePaidTill(
return static::sendRequest($request);
}

/**
* Wrapper for notice_banners API method.
* Gets notice banners.
*
* @param string $api_key
*
* @return array|bool|mixed
*/
public static function getNoticeBanners($api_key)
{
$request = array(
'method_name' => 'notice_banners',
'auth_key' => $api_key,
);

return static::sendRequest($request);
}

/**
* Wrapper for ip_info API method.
* Gets IP country.
Expand Down