PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.3.11
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.3.11
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 / lib / Cookiebot_Admin_Links.php
cookiebot / src / lib Last commit date
buffer 3 years ago script_loader_tag 2 years ago traits 3 years ago Consent_API_Helper.php 2 years ago Cookie_Consent.php 3 years ago Cookie_Consent_Interface.php 4 years ago Cookiebot_Activated.php 2 years ago Cookiebot_Admin_Links.php 1 year ago Cookiebot_Automatic_Updates.php 3 years ago Cookiebot_Deactivated.php 4 years ago Cookiebot_Javascript_Helper.php 1 year ago Cookiebot_Review.php 1 year ago Cookiebot_WP.php 1 year ago Dependency_Container.php 3 years ago Settings_Page_Tab.php 3 years ago Settings_Service.php 3 years ago Settings_Service_Interface.php 3 years ago Supported_Languages.php 4 years ago Supported_Regions.php 2 years ago WP_Rocket_Helper.php 3 years ago Widgets.php 3 years ago global-deprecations.php 3 years ago helper.php 2 years ago
Cookiebot_Admin_Links.php
139 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 class Cookiebot_Admin_Links {
6 /**
7 * Extra admin links
8 *
9 * @var array
10 */
11 protected $admin_links;
12 protected $menu_links;
13
14 public function __construct() {
15 $this->admin_links = $this->add_links();
16 $this->menu_links = $this->add_menu_links();
17 }
18
19 public function register_hooks() {
20 add_filter( 'plugin_action_links_cookiebot/cookiebot.php', array( $this, 'set_settings_action_link' ) );
21 add_action( 'admin_init', array( $this, 'handle_external_redirects' ) );
22 add_action( 'admin_menu', array( $this, 'add_extra_menu' ) );
23 }
24
25 public function handle_external_redirects() {
26 //phpcs:ignore WordPress.Security.NonceVerification.Recommended
27 if ( empty( $_GET['page'] ) ) {
28 return;
29 }
30
31 //phpcs:ignore WordPress.Security.NonceVerification.Recommended
32 foreach ( $this->menu_links as $slug => $link ) {
33 //phpcs:ignore WordPress.Security.NonceVerification.Recommended
34 if ( $slug === $_GET['page'] ) {
35 $link = $link['override'] && $link['condition'] ? $link['over_url'] : $link['url'];
36 //phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
37 wp_redirect( $link );
38 exit;
39 }
40 }
41 }
42
43 public function display() {
44 return true;
45 }
46
47 public function add_extra_menu() {
48 foreach ( $this->menu_links as $slug => $link ) {
49 add_submenu_page(
50 'cookiebot',
51 $link['label'],
52 $link['override'] && $link['condition'] ?
53 // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings,WordPress.WP.I18n.MissingTranslatorsComment
54 esc_html( sprintf( __( '%s', 'cookiebot' ), $link['over_label'] ) ) :
55 // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings,WordPress.WP.I18n.MissingTranslatorsComment
56 esc_html( sprintf( __( '%s', 'cookiebot' ), $link['label'] ) ),
57 'manage_options',
58 $slug,
59 array( $this, 'display' ),
60 20
61 );
62 }
63 }
64
65 public function set_settings_action_link( $actions ) {
66 $cb_actions = array();
67
68 foreach ( $this->admin_links as $link ) {
69 $item = array(
70 'url' => $link['override'] && $link['condition'] ? $link['over_url'] : $link['url'],
71 'label' => $link['override'] && $link['condition'] ? $link['over_label'] : $link['label'],
72 'strong' => $link['strong'],
73 );
74
75 $cb_actions[ $link['index'] ] = $this->get_link_html( $item );
76 }
77
78 $actions = array_merge( $actions, $cb_actions );
79 ksort( $actions );
80
81 return $actions;
82 }
83
84 private function add_menu_links() {
85 return array(
86 'cookiebot_upgrade' => array(
87 'url' => 'https://admin.cookiebot.com/signup/?utm_source=wordpress&utm_medium=referral&utm_campaign=banner',
88 'label' => 'Upgrade a plan',
89 'override' => true,
90 'over_url' => 'https://admin.cookiebot.com/signup?coupon=BFRIDAYWP10&utm_source=wordpress&utm_medium=referral&utm_campaign=banner',
91 'over_label' => 'Upgrade a plan',
92 'condition' => empty( Cookiebot_WP::get_cbid() ) && ( strtotime( 'now' ) < strtotime( '2024-12-03' ) ),
93 ),
94 );
95 }
96
97 private function add_links() {
98 return array(
99 array(
100 'url' => add_query_arg( 'page', 'cookiebot', admin_url( 'admin.php' ) ),
101 'label' => 'Dashboard',
102 'strong' => false,
103 'override' => false,
104 'condition' => false,
105 'index' => 'dashboard',
106 ),
107 array(
108 'url' => 'https://admin.cookiebot.com/signup/?utm_source=wordpress&utm_medium=referral&utm_campaign=banner',
109 'label' => 'Upgrade your plan',
110 'strong' => true,
111 'override' => true,
112 'over_url' => 'https://admin.cookiebot.com/signup?coupon=BFRIDAYWP10&utm_source=wordpress&utm_medium=referral&utm_campaign=banner',
113 'over_label' => 'Get 10% off until 02.12',
114 'condition' => empty( Cookiebot_WP::get_cbid() ) && ( strtotime( 'now' ) < strtotime( '2024-12-03' ) ),
115 'index' => 'a',
116 ),
117 );
118 }
119
120 private function get_link_html( $link ) {
121 $link_html = '<a href="' . esc_url( $link['url'] ) . '">';
122
123 if ( $link['strong'] ) {
124 $link_html .= '<b>';
125 }
126
127 // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings,WordPress.WP.I18n.MissingTranslatorsComment
128 $link_html .= esc_html( sprintf( __( '%s', 'cookiebot' ), $link['label'] ) );
129
130 if ( $link['strong'] ) {
131 $link_html .= '</b>';
132 }
133
134 $link_html .= '</a>';
135
136 return $link_html;
137 }
138 }
139