1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
class MC4WP_Admin_Tools {
/** * @return string */ public function get_plugin_page() { if ( empty( $_GET['page'] ) ) { return ''; }
$prefix = 'mailchimp-for-wp'; $page = ltrim( substr( $_GET['page'], strlen( $prefix ) ), '-' ); return $page; }
/** * @param string $page * * @return bool */ public function on_plugin_page( $page = null ) { // any settings page if ( is_null( $page ) ) { return isset( $_GET['page'] ) && strpos( $_GET['page'], 'mailchimp-for-wp' ) === 0; }
// specific page return $this->get_plugin_page() === $page; }
/** * Does the logged-in user have the required capability? * * @return bool */ public function is_user_authorized() { return current_user_can( $this->get_required_capability() ); }
/** * Get required capability to access settings page and view dashboard widgets. * * @return string */ public function get_required_capability() { $capability = 'manage_options';
/** * Filters the required user capability to access the settings pages & dashboard widgets. * * @ignore * @deprecated 3.0 */ $capability = apply_filters( 'mc4wp_settings_cap', $capability );
/** * Filters the required user capability to access the Mailchimp for WordPress' settings pages, view the dashboard widgets. * * Defaults to `manage_options` * * @since 3.0 * @param string $capability * @see https://codex.wordpress.org/Roles_and_Capabilities */ $capability = (string) apply_filters( 'mc4wp_admin_required_capability', $capability );
return $capability; } }
|