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