PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.3.12
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.3.12
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
135 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' => false,
90 'condition' => false,
91 ),
92 );
93 }
94
95 private function add_links() {
96 return array(
97 array(
98 'url' => add_query_arg( 'page', 'cookiebot', admin_url( 'admin.php' ) ),
99 'label' => 'Dashboard',
100 'strong' => false,
101 'override' => false,
102 'condition' => false,
103 'index' => 'dashboard',
104 ),
105 array(
106 'url' => 'https://admin.cookiebot.com/signup/?utm_source=wordpress&utm_medium=referral&utm_campaign=banner',
107 'label' => 'Upgrade your plan',
108 'strong' => true,
109 'override' => false,
110 'condition' => false,
111 'index' => 'a',
112 ),
113 );
114 }
115
116 private function get_link_html( $link ) {
117 $link_html = '<a href="' . esc_url( $link['url'] ) . '">';
118
119 if ( $link['strong'] ) {
120 $link_html .= '<b>';
121 }
122
123 // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings,WordPress.WP.I18n.MissingTranslatorsComment
124 $link_html .= esc_html( sprintf( __( '%s', 'cookiebot' ), $link['label'] ) );
125
126 if ( $link['strong'] ) {
127 $link_html .= '</b>';
128 }
129
130 $link_html .= '</a>';
131
132 return $link_html;
133 }
134 }
135