PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0
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 5.2.2 5.3 All 153 releases
mainwp / modules / logs / widgets / widget-log-users-widget.php

widget-log-users-widget.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.0, at modules/logs/widgets/widget-log-users-widget.php

204 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Logs Widget
4 *
5 * Displays the Logs Info.
6 *
7 * @package MainWP/Dashboard
8 * @version 4.6
9 */
10
11 namespace MainWP\Dashboard\Module\Log;
12
13 use MainWP\Dashboard\MainWP_Utility;
14
15 /**
16 * Class Log_Users_Widget
17 *
18 * Displays the Logs info.
19 */
20 class Log_Users_Widget {
21
22 /**
23 * Protected static variable to hold the single instance of the class.
24 *
25 * @var mixed Default null
26 */
27 protected static $instance = null;
28
29 /**
30 * Return the single instance of the class.
31 *
32 * @return mixed $instance The single instance of the class.
33 */
34 public static function instance() {
35 if ( is_null( self::$instance ) ) {
36 self::$instance = new self();
37 }
38 return self::$instance;
39 }
40
41
42 /**
43 * Method get_class_name()
44 *
45 * @return string __CLASS__ Class name.
46 */
47 public static function get_class_name() {
48 return __CLASS__;
49 }
50
51 /**
52 * Method render()
53 *
54 * @param array ...$args Widget callback args.
55 * @return mixed render_site_info()
56 */
57 public function render( ...$args ) {
58 $this->render_widget( $args );
59 }
60
61
62 /**
63 * Render client overview Info.
64 *
65 * @param array $args Args data.
66 */
67 public function render_widget( $args ) {
68 $data = is_array( $args ) && ! empty( $args[1][0] ) && is_array( $args[1][0] ) ? $args[1][0] : array();
69 $stats_data = is_array( $data ) && ! empty( $data['stats_data']['users']['users'] ) ? $data['stats_data']['users']['users'] : array();
70 if ( ! is_array( $stats_data ) ) {
71 $stats_data = array();
72 }
73
74 $stats_prev_data = is_array( $data ) && ! empty( $data['stats_prev_data']['users']['users'] ) ? $data['stats_prev_data']['users']['users'] : array();
75 if ( ! is_array( $stats_prev_data ) ) {
76 $stats_prev_data = array();
77 }
78
79 ?>
80 <div class="mainwp-widget-header">
81 <h3 class="ui header handle-drag">
82 <?php esc_html_e( 'User Management Events Summary', 'mainwp' ); ?>
83 <div class="sub header">
84 <?php esc_html_e( 'Displays a tally of user-related actions with a total event count.', 'mainwp' ); ?>
85 </div>
86 </h3>
87 </div>
88
89 <div class="mainwp-widget-insights-card">
90 <?php
91 /**
92 * Action: mainwp_logs_widget_top
93 *
94 * Fires at the top of the widget.
95 *
96 * @since 4.6
97 */
98 do_action( 'mainwp_logs_widget_top', 'users' );
99 ?>
100 <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
101 <?php
102 wp_nonce_field( 'mainwp-admin-nonce' );
103 $this->render_widget_content( $stats_data, $stats_prev_data );
104 ?>
105 <?php
106 /**
107 * Action: mainwp_logs_widget_bottom
108 *
109 * Fires at the bottom of the widget.
110 *
111 * @since 4.6
112 */
113 do_action( 'mainwp_logs_widget_bottom', 'users' );
114 ?>
115 </div>
116 <div class="mainwp-widget-footer ui four columns stackable grid">
117 <div class="column">
118 </div>
119 <div class="column">
120 </div>
121 </div>
122 <?php
123 }
124
125 /**
126 * Method render_widget_content().
127 *
128 * @param array $data Stats data.
129 * @param array $prev_data Previous stats data.
130 */
131 public function render_widget_content( $data, $prev_data ) {
132 $columns = array(
133 'created' => esc_html__( 'Created', 'mainwp' ),
134 'updated' => esc_html__( 'Updated', 'mainwp' ),
135 'delete' => esc_html__( 'Deleted', 'mainwp' ),
136 'update_password' => esc_html__( 'Password Updates', 'mainwp' ),
137 'change_role' => esc_html__( 'Role Changes', 'mainwp' ),
138 'total_events' => esc_html__( 'Total', 'mainwp' ),
139 );
140 ?>
141 <div class="ui one column grid">
142 <div class="left aligned middle aligned column">
143 <div class="ui equal width grid">
144 <?php
145 foreach ( $columns as $act => $title ) {
146 Log_Stats::render_stats_info( $data, $act, $title, $prev_data );
147 }
148 ?>
149 </div>
150 </div>
151 <div class="left aligned middle aligned column">
152 <div id="mainwp-module-log-chart-users-management-wrapper" ></div>
153 <script type="text/javascript">
154 jQuery( document ).ready( function() {
155 var options = {
156 chart: {
157 type: 'bar',
158 height: 350,
159 },
160 plotOptions: {
161 bar: {
162 columnWidth: '60%'
163 }
164 },
165 series: [ {
166 name: 'Events:',
167 data: [
168 <?php
169 foreach ( $columns as $act => $title ) {
170 Log_Stats::render_chart_series( $data, $act, $title, $prev_data );
171 }
172 ?>
173 ],
174 } ],
175 xaxis: {
176 labels: {
177 style: {
178 colors: '#999999',
179 }
180 }
181 },
182 yaxis: {
183 labels: {
184 style: {
185 colors: '#999999',
186 }
187 }
188 },
189 tooltip: {
190 theme: 'dark'
191 },
192 }
193 var clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-users-management-wrapper"), options);
194 setTimeout(() => {
195 clients.render();
196 }, 1000);
197 } );
198 </script>
199 </div>
200 </div>
201 <?php
202 }
203 }
204