PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.3.7.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.3.7.1
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / src / admin_notices / Cookiebot_Temp_Notice.php
cookiebot / src / admin_notices Last commit date
Cookiebot_Recommendation_Notice.php 3 years ago Cookiebot_Temp_Notice.php 2 years ago
Cookiebot_Temp_Notice.php
99 lines
1 <?php
2
3 namespace cybot\cookiebot\admin_notices;
4
5 use Exception;
6 use cybot\cookiebot\lib\Cookiebot_WP;
7 use InvalidArgumentException;
8 use LogicException;
9 use function cybot\cookiebot\lib\asset_url;
10 use function cybot\cookiebot\lib\include_view;
11
12 class Cookiebot_Temp_Notice {
13
14 const COOKIEBOT_TEMP_OPTION_KEY = 'cookiebot_notice_temp';
15
16 public function register_hooks() {
17 add_action( 'admin_notices', array( $this, 'show_notice_temp' ) );
18 }
19
20 public function show_notice_temp() {
21 /** Save actions when someone click on the notice message */
22 $this->save_notice_link();
23
24 try {
25 $this->do_we_need_to_show_the_notice_message();
26 $this->show_notice();
27 // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
28 } catch ( Exception $e ) {
29 // If exception has been thrown, then we don't need to show the notice.
30 }
31 }
32
33 /**
34 * @throws InvalidArgumentException
35 */
36 private function show_notice() {
37 $show_temp = wp_nonce_url(
38 add_query_arg( array( 'cookiebot_notice_temp' => 'hide' ) ),
39 'hide_temp_notice',
40 'temp_nonce'
41 );
42
43 $update_notice = array(
44 'title' => '',
45 'msg' => __(
46 'Cookiebot CMP Plugin will soon no longer support PHP 5. If your website still runs on this version we recommend upgrading so you can continue enjoying the features Cookiebot CMP offers.',
47 'cookiebot'
48 ),
49 'link_html' => '',
50 'later_link' => $show_temp,
51 'int' => 14,
52 );
53
54 include_view( 'admin/notices/cookiebot-recommendation-notice.php', array( 'notice' => $update_notice ) );
55
56 wp_enqueue_style(
57 'cookiebot-admin-notices',
58 asset_url( 'css/notice.css' ),
59 null,
60 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
61 );
62 }
63
64 /**
65 * Validate if the last user action is valid for plugin recommendation
66 *
67 * @throws Exception
68 *
69 * @version 2.0.5
70 * @since 2.0.5
71 */
72 private function do_we_need_to_show_the_notice_message() {
73 $option = get_option( static::COOKIEBOT_TEMP_OPTION_KEY );
74
75 if ( $option !== false ) {
76 // "Never show again" is clicked
77 if ( $option === 'hide' ) {
78 throw new LogicException( 'Never show again is clicked' );
79 } elseif ( is_numeric( $option ) && strtotime( 'now' ) < $option ) {
80 throw new LogicException( 'Show me after 1 day' );
81 }
82 }
83 }
84
85 /**
86 * Save the user action on cookiebot recommendation link
87 *
88 * @version 2.0.5
89 * @since 2.0.5
90 */
91 private function save_notice_link() {
92 if ( isset( $_GET['cookiebot_notice_temp'] ) &&
93 isset( $_GET['temp_nonce'] ) &&
94 wp_verify_nonce( $_GET['temp_nonce'], 'hide_temp_notice' ) ) {
95 update_option( static::COOKIEBOT_TEMP_OPTION_KEY, 'hide' );
96 }
97 }
98 }
99