diff --git a/cleantalk.php b/cleantalk.php index de261ff1f..23bf90590 100644 --- a/cleantalk.php +++ b/cleantalk.php @@ -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); diff --git a/lib/Cleantalk/ApbctWP/AdminNotices.php b/lib/Cleantalk/ApbctWP/AdminNotices.php index 4c01c7e44..3c60bb247 100644 --- a/lib/Cleantalk/ApbctWP/AdminNotices.php +++ b/lib/Cleantalk/ApbctWP/AdminNotices.php @@ -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); @@ -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); @@ -285,7 +285,7 @@ public function notice_review() // phpcs:ignore PSR1.Methods.CamelCapsMethodName . ''; $banner_data->additional_text = $support_link . '  ' . $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(); diff --git a/lib/Cleantalk/Common/API.php b/lib/Cleantalk/Common/API.php index 2b74d2751..ee3ae7a25 100644 --- a/lib/Cleantalk/Common/API.php +++ b/lib/Cleantalk/Common/API.php @@ -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.