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.3 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 All 156 releases
← All changes | modules/logs/widgets/widget-log-sites-widget.php +183 -172 5.0 → 6.2.2 View file →
@@ -10,9 +10,16 @@
10 10
11 11 namespace MainWP\Dashboard\Module\Log;
12 12
13 13 use MainWP\Dashboard\MainWP_Utility;
14 +use MainWP\Dashboard\MainWP_UI;
14 15
16 +// Exit if accessed directly.
17 +if ( ! defined( 'ABSPATH' ) ) {
18 + exit;
19 +}
20 +
21 +
15 22 /**
16 23 * Class Log_Sites_Widget
17 24 *
18 25 * Displays the Logs info.
@@ -18,189 +25,193 @@
18 25 * Displays the Logs info.
19 26 */
20 27 class Log_Sites_Widget {
21 28
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;
29 + /**
30 + * Protected static variable to hold the single instance of the class.
31 + *
32 + * @var mixed Default null
33 + */
34 + protected static $instance = null;
28 35
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 - }
36 + /**
37 + * Return the single instance of the class.
38 + *
39 + * @return mixed $instance The single instance of the class.
40 + */
41 + public static function instance() {
42 + if ( is_null( static::$instance ) ) {
43 + static::$instance = new self();
44 + }
45 + return static::$instance;
46 + }
40 47
41 48
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 - }
49 + /**
50 + * Method get_class_name()
51 + *
52 + * @return string __CLASS__ Class name.
53 + */
54 + public static function get_class_name() {
55 + return __CLASS__;
56 + }
50 57
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 - }
58 + /**
59 + * Method render()
60 + *
61 + * @param array ...$args Widget callback args.
62 + * @return mixed render_site_info()
63 + */
64 + public function render( ...$args ) {
65 + $this->render_widget( $args );
66 + }
60 67
61 68
62 - /**
63 - * Render client overview Info.
64 - *
65 - * @param array $args Args data.
66 - */
67 - public function render_widget( $args ) {
69 + /**
70 + * Render client overview Info.
71 + *
72 + * @param array $args Args data.
73 + */
74 + public function render_widget( $args ) {
75 + $data = is_array( $args ) && ! empty( $args[1][0] ) && is_array( $args[1][0] ) ? $args[1][0] : array();
76 + $stats_data = is_array( $data ) && ! empty( $data['stats_data']['site']['sites'] ) ? $data['stats_data']['site']['sites'] : array();
77 + if ( ! is_array( $stats_data ) ) {
78 + $stats_data = array();
79 + }
68 80
69 - $data = is_array( $args ) && ! empty( $args[1][0] ) && is_array( $args[1][0] ) ? $args[1][0] : array();
70 - $stats_data = is_array( $data ) && ! empty( $data['stats_data']['site']['sites'] ) ? $data['stats_data']['site']['sites'] : array();
71 - if ( ! is_array( $stats_data ) ) {
72 - $stats_data = array();
73 - }
81 + $stats_prev_data = is_array( $data ) && ! empty( $data['stats_prev_data']['site']['sites'] ) ? $data['stats_prev_data']['site']['sites'] : array();
82 + if ( ! is_array( $stats_prev_data ) ) {
83 + $stats_prev_data = array();
84 + }
74 85
75 - $stats_prev_data = is_array( $data ) && ! empty( $data['stats_prev_data']['site']['sites'] ) ? $data['stats_prev_data']['site']['sites'] : array();
76 - if ( ! is_array( $stats_prev_data ) ) {
77 - $stats_prev_data = array();
78 - }
86 + ?>
87 + <div class="mainwp-widget-header">
88 + <h2 class="ui header handle-drag">
89 + <?php esc_html_e( 'Site Management Activity Metrics', 'mainwp' ); ?>
90 + <div class="sub header">
91 + <?php esc_html_e( 'Summarizing site activities, alongside the total count for a complete overview.', 'mainwp' ); ?>
92 + </div>
93 + </h2>
94 + </div>
79 95
80 - ?>
81 - <div class="mainwp-widget-header">
82 - <h3 class="ui header handle-drag">
83 - <?php esc_html_e( 'Site Management Activity Metrics', 'mainwp' ); ?>
84 - <div class="sub header">
85 - <?php esc_html_e( 'Summarizing site activities, alongside the total count for a complete overview.', 'mainwp' ); ?>
86 - </div>
87 - </h3>
88 - </div>
96 + <div class="mainwp-widget-insights-card mainwp-scrolly-overflow">
97 + <?php
98 + /**
99 + * Action: mainwp_logs_widget_top
100 + *
101 + * Fires at the top of the widget.
102 + *
103 + * @since 4.6
104 + */
105 + do_action( 'mainwp_logs_widget_top', 'core' );
106 + ?>
107 + <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
108 + <?php
109 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
89 110
90 - <div class="mainwp-widget-insights-card">
91 - <?php
92 - /**
93 - * Action: mainwp_logs_widget_top
94 - *
95 - * Fires at the top of the widget.
96 - *
97 - * @since 4.6
98 - */
99 - do_action( 'mainwp_logs_widget_top', 'core' );
100 - ?>
101 - <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
102 - <?php
103 - wp_nonce_field( 'mainwp-admin-nonce' );
104 - $this->render_widget_content( $stats_data, $stats_prev_data );
105 - ?>
106 - <?php
107 - /**
108 - * Action: mainwp_logs_widget_bottom
109 - *
110 - * Fires at the bottom of the widget.
111 - *
112 - * @since 4.6
113 - */
114 - do_action( 'mainwp_logs_widget_bottom', 'core' );
115 - ?>
116 - </div>
117 - <div class="mainwp-widget-footer ui four columns stackable grid">
118 - <div class="column">
119 - </div>
120 - <div class="column">
121 - </div>
122 - </div>
123 - <?php
124 - }
111 + if ( ! empty( $data ) ) {
112 + $this->render_widget_content( $stats_data, $stats_prev_data );
113 + } else {
114 + MainWP_UI::render_empty_element_placeholder( __( 'No activity recorded', 'mainwp' ), __( 'Data will appear here once actions are tracked.', 'mainwp' ), '<em data-emoji=":bar_chart:" class="medium"></em>' );
115 + }
116 + ?>
117 + <?php
118 + /**
119 + * Action: mainwp_logs_widget_bottom
120 + *
121 + * Fires at the bottom of the widget.
122 + *
123 + * @since 4.6
124 + */
125 + do_action( 'mainwp_logs_widget_bottom', 'core' );
126 + ?>
127 + </div>
128 + <div class="mainwp-widget-footer ui four columns stackable grid">
129 + <div class="column">
130 + </div>
131 + <div class="column">
132 + </div>
133 + </div>
134 + <?php
135 + }
125 136
126 - /**
127 - * Method render_widget_content().
128 - *
129 - * @param array $data Stats data.
130 - * @param array $prev_data Previous stats data.
131 - */
132 - public function render_widget_content( $data, $prev_data ) {
133 - $columns = array(
134 - 'added' => esc_html__( 'Added', 'mainwp' ),
135 - 'sync' => esc_html__( 'Synced', 'mainwp' ),
136 - 'reconnected' => esc_html__( 'Reconnected', 'mainwp' ),
137 - 'deleted' => esc_html__( 'Deleted', 'mainwp' ),
138 - 'suspend' => esc_html__( 'Suspended', 'mainwp' ),
139 - 'unsuspend' => esc_html__( 'Unsuspended', 'mainwp' ),
140 - 'total_events' => esc_html__( 'Total', 'mainwp' ),
141 - );
137 + /**
138 + * Method render_widget_content().
139 + *
140 + * @param array $data Stats data.
141 + * @param array $prev_data Previous stats data.
142 + */
143 + public function render_widget_content( $data, $prev_data ) {
144 + $columns = array(
145 + 'added' => esc_html__( 'Added', 'mainwp' ),
146 + 'sync' => esc_html__( 'Synced', 'mainwp' ),
147 + 'reconnected' => esc_html__( 'Reconnected', 'mainwp' ),
148 + 'deleted' => esc_html__( 'Deleted', 'mainwp' ),
149 + 'suspend' => esc_html__( 'Suspended', 'mainwp' ),
150 + 'unsuspend' => esc_html__( 'Unsuspended', 'mainwp' ),
151 + 'total_events' => esc_html__( 'Total', 'mainwp' ),
152 + );
142 153
143 - ?>
144 - <div class="ui one column grid">
145 - <div class="left aligned middle aligned column">
146 - <div class="ui equal width grid">
147 - <?php
148 - foreach ( $columns as $act => $title ) {
149 - Log_Stats::render_stats_info( $data, $act, $title, $prev_data );
150 - }
151 - ?>
152 - </div>
153 - </div>
154 - <div class="left aligned middle aligned column">
155 - <div id="mainwp-module-log-chart-sites-management-wrapper" ></div>
156 - <script type="text/javascript">
157 - jQuery( document ).ready( function() {
158 - var options = {
159 - chart: {
160 - type: 'bar',
161 - height: 350,
162 - },
163 - plotOptions: {
164 - bar: {
165 - columnWidth: '60%'
166 - }
167 - },
168 - series: [ {
169 - name: 'Events:',
170 - data: [
171 - <?php
172 - foreach ( $columns as $act => $title ) {
173 - Log_Stats::render_chart_series( $data, $act, $title, $prev_data );
174 - }
175 - ?>
176 - ],
177 - } ],
178 - xaxis: {
179 - labels: {
180 - style: {
181 - colors: '#999999',
182 - }
183 - }
184 - },
185 - yaxis: {
186 - labels: {
187 - style: {
188 - colors: '#999999',
189 - }
190 - }
191 - },
192 - tooltip: {
193 - theme: 'dark'
194 - },
195 - }
196 - var clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-sites-management-wrapper"), options);
197 - setTimeout(() => {
198 - clients.render();
199 - }, 1000);
200 - } );
201 - </script>
202 - </div>
203 - </div>
204 - <?php
205 - }
154 + ?>
155 + <div class="ui grid">
156 + <div class="sixteen wide column">
157 + <div class="ui equal width grid">
158 + <?php
159 + foreach ( $columns as $act => $title ) {
160 + Log_Stats::render_stats_info( $data, $act, $title, $prev_data );
161 + }
162 + ?>
163 + </div>
164 + </div>
165 + <div class="sixteen wide column">
166 + <div id="mainwp-module-log-chart-sites-management-wrapper"></div>
167 + <script type="text/javascript">
168 + jQuery( document ).ready( function() {
169 + let options = {
170 + chart: {
171 + type: 'bar',
172 + height: 350,
173 + },
174 + plotOptions: {
175 + bar: {
176 + columnWidth: '60%'
177 + }
178 + },
179 + series: [ {
180 + name: 'Events:',
181 + data: [
182 + <?php
183 + foreach ( $columns as $act => $title ) {
184 + Log_Stats::render_chart_series( $data, $act, $title, $prev_data );
185 + }
186 + ?>
187 + ],
188 + } ],
189 + xaxis: {
190 + labels: {
191 + style: {
192 + colors: '#999999',
193 + }
194 + }
195 + },
196 + yaxis: {
197 + labels: {
198 + style: {
199 + colors: '#999999',
200 + }
201 + }
202 + },
203 + tooltip: {
204 + theme: 'dark'
205 + },
206 + }
207 + let clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-sites-management-wrapper"), options);
208 + setTimeout(() => {
209 + clients.render();
210 + }, 1000);
211 + } );
212 + </script>
213 + </div>
214 + </div>
215 + <?php
216 + }
206 217 }