PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / traits / defender-dashboard-client.php

defender-dashboard-client.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/traits/defender-dashboard-client.php

118 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle Dashboard based functionalities of WPMUDEV class.
4 *
5 * @package WP_Defender\Behavior
6 */
7
8 namespace WP_Defender\Traits;
9
10 /**
11 * Traits to handle Dashboard based functionalities of WPMUDEV class.
12 */
13 trait Defender_Dashboard_Client {
14 /**
15 * Get membership status.
16 *
17 * @return bool
18 */
19 public function is_pro() {
20 return $this->get_apikey() !== false;
21 }
22
23 /**
24 * Check if user is a paid one in WPMU DEV.
25 *
26 * @return bool
27 */
28 public function is_member() {
29 if (
30 class_exists( 'WPMUDEV_Dashboard' )
31 && method_exists( 'WPMUDEV_Dashboard_Api', 'get_membership_projects' )
32 ) {
33 if ( method_exists( 'WPMUDEV_Dashboard_Api', 'get_membership_status' ) ) {
34 $type = \WPMUDEV_Dashboard::$api->get_membership_status();
35 } elseif ( method_exists( 'WPMUDEV_Dashboard_Api', 'get_membership_type' ) ) {
36 $type = \WPMUDEV_Dashboard::$api->get_membership_type();
37 } else {
38 return false;
39 }
40
41 $projects = \WPMUDEV_Dashboard::$api->get_membership_projects();
42 $def_pid = 1081723;
43
44 if (
45 ( 'unit' === $type && in_array( $def_pid, $projects, true ) )
46 || ( 'single' === $type && $def_pid === $projects )
47 ) {
48 return true;
49 }
50
51 if ( function_exists( 'is_wpmudev_member' ) ) {
52 return is_wpmudev_member();
53 }
54
55 return false;
56 }
57
58 return false;
59 }
60
61 /**
62 * Check if user is a WPMU DEV admin.
63 *
64 * @since 2.6.3
65 *
66 * @return bool
67 */
68 public function is_wpmu_dev_admin() {
69 if (
70 class_exists( 'WPMUDEV_Dashboard' )
71 && method_exists( 'WPMUDEV_Dashboard_Site', 'allowed_user' )
72 ) {
73 $user_id = get_current_user_id();
74
75 return \WPMUDEV_Dashboard::$site->allowed_user( $user_id );
76 }
77
78 return false;
79 }
80
81 /**
82 * Bring the plugin menu title.
83 *
84 * @return string Menu title.
85 */
86 public function get_menu_title() {
87 if ( $this->is_pro() ) {
88 $menu_title = esc_html__( 'Defender Pro', 'wpdef' );
89 } else {
90 // Check if it's Pro but user logged the WPMU DEV Dashboard out.
91 require_once ABSPATH . 'wp-admin/includes/plugin.php';
92 $menu_title = file_exists( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . WP_DEFENDER_PRO_PATH )
93 && is_plugin_active( WP_DEFENDER_PRO_PATH )
94 ? esc_html__( 'Defender Pro', 'wpdef' )
95 : esc_html__( 'Defender', 'wpdef' );
96 }
97
98 return $menu_title;
99 }
100
101 /**
102 * Return icon svg image.
103 *
104 * @return string
105 */
106 public function get_menu_icon() {
107 ob_start();
108 ?>
109 <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
110 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.99999 2.08899L3 4.21792V9.99502H9.99912V18.001H10C13.47 18.001 17 13.9231 17 11.0045V9.99501H9.99999V2.08899ZM10 0L1 2.73862V11.0045C1 15.1125 5.49 20 10 20C14.51 20 19 15.1225 19 11.0045V2.73862L10 0Z" fill="#F0F6FC" fill-opacity="0.6"/>
111 </svg>
112 <?php
113 $svg = ob_get_clean();
114
115 return 'data:image/svg+xml;base64,' . base64_encode( $svg );
116 }
117 }
118