PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / modules / logs / connectors / class-connector-client.php

class-connector-client.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.2.2, at modules/logs/connectors/class-connector-client.php

170 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module Logs User connector class.
4 *
5 * @package MainWP\Dashboard
6 * @version 4.5.1
7 */
8
9 namespace MainWP\Dashboard\Module\Log;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Class Connector_Client.
15 *
16 * @package MainWP\Dashboard
17 */
18 class Connector_Client extends Log_Connector {
19
20 /**
21 * Connector name.
22 *
23 * @var string Connector slug.
24 * */
25 public $name = 'client';
26
27
28 /**
29 * Actions registered for this connector
30 *
31 * @var array
32 */
33 public $actions = array(
34 'mainwp_client_updated',
35 'mainwp_client_deleted',
36 'mainwp_client_suspend',
37 );
38
39 /**
40 * Return translated connector label
41 *
42 * @return string Translated connector label
43 */
44 public function get_label() {
45 return esc_html__( 'Clients', 'mainwp' );
46 }
47
48 /**
49 * Return translated action term labels
50 *
51 * @return array Action terms label translation
52 */
53 public function get_action_labels() {
54 return array(
55 'updated' => esc_html__( 'Updated', 'mainwp' ),
56 'created' => esc_html__( 'Created', 'mainwp' ),
57 'deleted' => esc_html__( 'Deleted', 'mainwp' ),
58 'suspend' => esc_html__( 'Suspend', 'mainwp' ),
59 'unsuspend' => esc_html__( 'Unsuspend', 'mainwp' ),
60 'lead' => esc_html__( 'Lead', 'mainwp' ),
61 'lost' => esc_html__( 'Lost', 'mainwp' ),
62 );
63 }
64
65 /**
66 * Return translated context labels
67 *
68 * @return array Context label translations
69 */
70 public function get_context_labels() {
71 return array(
72 'clients' => esc_html__( 'Clients', 'mainwp' ),
73 );
74 }
75
76 /**
77 * Log client update
78 *
79 * @action mainwp_client_updated
80 *
81 * @param object $client Client object.
82 * @param bool $created true add new, false updated.
83 */
84 public function callback_mainwp_client_updated( $client, $created = false ) {
85 $action = $created ? 'created' : 'updated';
86 $message = '%s';
87
88 $state = 1;
89 $this->log(
90 $message,
91 array(
92 'name' => $client->name,
93 'client_id' => $client->client_id,
94 ),
95 0,
96 'clients',
97 $action,
98 $state
99 );
100 }
101
102 /**
103 * Log client delete
104 *
105 * @action mainwp_client_deleted
106 *
107 * @param object $client Client deleted.
108 */
109 public function callback_mainwp_client_deleted( $client ) {
110 $message = '%s';
111 $state = 1;
112 $this->log(
113 $message,
114 array(
115 'name' => $client->name,
116 'client_id' => $client->client_id,
117 ),
118 0,
119 'clients',
120 'deleted',
121 $state
122 );
123 }
124
125 /**
126 * Log client suspend/unsuspend.
127 *
128 * @action mainwp_client_suspend
129 *
130 * @param object $client Client deleted.
131 * @param bool $status client status.
132 */
133 public function callback_mainwp_client_suspend( $client, $status ) {
134
135 if ( ! is_object( $client ) ) {
136 return;
137 }
138
139 $status = intval( $status );
140
141 $action = 'unsuspend';
142
143 if ( 0 === $status ) {
144 $action = 'unsuspend';
145 } elseif ( 1 === $status ) {
146 $action = 'suspend'; // actived.
147 } elseif ( 2 === $status ) {
148 $action = 'lead';
149 } elseif ( 3 === $status ) {
150 $action = 'lost';
151 }
152
153 $message = '%s';
154
155 $state = 1;
156 $this->log(
157 $message,
158 array(
159 'name' => $client->name,
160 'client_id' => $client->client_id,
161 'suspend_value' => $status,
162 ),
163 0,
164 'clients',
165 $action,
166 $state
167 );
168 }
169 }
170