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
← All changes | modules/logs/widgets/widget-log-pages-widget.php +196 -186 5.0 → 6.2.2 View file →
@@ -10,9 +10,15 @@
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 +
15 21 /**
16 22 * Class Log_Pages_Widget
17 23 *
18 24 * Displays the Logs info.
@@ -18,205 +24,209 @@
18 24 * Displays the Logs info.
19 25 */
20 26 class Log_Pages_Widget {
21 27
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 + * Protected static variable to hold the single instance of the class.
30 + *
31 + * @var mixed Default null
32 + */
33 + protected static $instance = null;
28 34
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 - }
35 + /**
36 + * Return the single instance of the class.
37 + *
38 + * @return mixed $instance The single instance of the class.
39 + */
40 + public static function instance() {
41 + if ( is_null( static::$instance ) ) {
42 + static::$instance = new self();
43 + }
44 + return static::$instance;
45 + }
40 46
41 47
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 - }
48 + /**
49 + * Method get_class_name()
50 + *
51 + * @return string __CLASS__ Class name.
52 + */
53 + public static function get_class_name() {
54 + return __CLASS__;
55 + }
50 56
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 - }
57 + /**
58 + * Method render()
59 + *
60 + * @param array ...$args Widget callback args.
61 + * @return mixed render_site_info()
62 + */
63 + public function render( ...$args ) {
64 + $this->render_widget( $args );
65 + }
60 66
61 67
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']['posts'] ) ? $data['stats_data']['posts'] : array();
70 - if ( ! is_array( $stats_data ) ) {
71 - $stats_data = array();
72 - }
68 + /**
69 + * Render client overview Info.
70 + *
71 + * @param array $args Args data.
72 + */
73 + public function render_widget( $args ) {
74 + $data = is_array( $args ) && ! empty( $args[1][0] ) && is_array( $args[1][0] ) ? $args[1][0] : array();
75 + $stats_data = is_array( $data ) && ! empty( $data['stats_data']['posts'] ) ? $data['stats_data']['posts'] : array();
76 + if ( ! is_array( $stats_data ) ) {
77 + $stats_data = array();
78 + }
73 79
74 - $stats_prev_data = is_array( $data ) && ! empty( $data['stats_prev_data']['posts'] ) ? $data['stats_prev_data']['posts'] : array();
75 - if ( ! is_array( $stats_prev_data ) ) {
76 - $stats_prev_data = array();
77 - }
80 + $stats_prev_data = is_array( $data ) && ! empty( $data['stats_prev_data']['posts'] ) ? $data['stats_prev_data']['posts'] : array();
81 + if ( ! is_array( $stats_prev_data ) ) {
82 + $stats_prev_data = array();
83 + }
78 84
79 - ?>
80 - <div class="mainwp-widget-header">
81 - <h3 class="ui header handle-drag">
82 - <?php esc_html_e( 'Page Management Event Tracker', 'mainwp' ); ?>
83 - <div class="sub header">
84 - <?php esc_html_e( 'Overview of page-related activities with total events tallied.', 'mainwp' ); ?>
85 - </div>
86 - </h3>
87 - </div>
85 + ?>
86 + <div class="mainwp-widget-header">
87 + <h2 class="ui header handle-drag">
88 + <?php esc_html_e( 'Page Management Event Tracker', 'mainwp' ); ?>
89 + <div class="sub header">
90 + <?php esc_html_e( 'Overview of page-related activities with total events tallied.', 'mainwp' ); ?>
91 + </div>
92 + </h2>
93 + </div>
88 94
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', 'pages' );
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', 'pages' );
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 - }
95 + <div class="mainwp-widget-insights-card mainwp-scrolly-overflow">
96 + <?php
97 + /**
98 + * Action: mainwp_logs_widget_top
99 + *
100 + * Fires at the top of the widget.
101 + *
102 + * @since 4.6
103 + */
104 + do_action( 'mainwp_logs_widget_top', 'pages' );
105 + ?>
106 + <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
107 + <?php
108 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
109 + if ( ! empty( $data ) ) {
110 + $this->render_widget_content( $stats_data, $stats_prev_data );
111 + } else {
112 + 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>' );
113 + }
114 + ?>
115 + <?php
116 + /**
117 + * Action: mainwp_logs_widget_bottom
118 + *
119 + * Fires at the bottom of the widget.
120 + *
121 + * @since 4.6
122 + */
123 + do_action( 'mainwp_logs_widget_bottom', 'pages' );
124 + ?>
125 + </div>
126 + <div class="mainwp-widget-footer ui four columns stackable grid">
127 + <div class="column">
128 + </div>
129 + <div class="column">
130 + </div>
131 + </div>
132 + <?php
133 + }
124 134
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 ) {
135 + /**
136 + * Method render_widget_content()
137 + *
138 + * @param array $data Stats data.
139 + * @param array $prev_data Previous stats data.
140 + */
141 + public function render_widget_content( $data, $prev_data ) {
132 142
133 - $pages_data = array();
134 - if ( is_array( $data ) && isset( $data['page'] ) ) {
135 - $pages_data = $data['page'];
136 - if ( ! is_array( $pages_data ) ) {
137 - $pages_data = array();
138 - }
139 - }
143 + $pages_data = array();
144 + if ( is_array( $data ) && isset( $data['page'] ) ) {
145 + $pages_data = $data['page'];
146 + if ( ! is_array( $pages_data ) ) {
147 + $pages_data = array();
148 + }
149 + }
140 150
141 - $pages_prev_data = array();
142 - if ( is_array( $prev_data ) && isset( $prev_data['page'] ) ) {
143 - $pages_prev_data = $prev_data['page'];
144 - if ( ! is_array( $pages_prev_data ) ) {
145 - $pages_prev_data = array();
146 - }
147 - }
151 + $pages_prev_data = array();
152 + if ( is_array( $prev_data ) && isset( $prev_data['page'] ) ) {
153 + $pages_prev_data = $prev_data['page'];
154 + if ( ! is_array( $pages_prev_data ) ) {
155 + $pages_prev_data = array();
156 + }
157 + }
148 158
149 - $columns = array(
150 - 'created' => esc_html__( 'Created', 'mainwp' ),
151 - 'published' => esc_html__( 'Published', 'mainwp' ),
152 - 'updated' => esc_html__( 'Updated', 'mainwp' ),
153 - 'trashed' => esc_html__( 'Trashed', 'mainwp' ),
154 - 'untrashed' => esc_html__( 'Untrashed', 'mainwp' ),
155 - 'deleted' => esc_html__( 'Deleted', 'mainwp' ),
156 - 'total_events' => esc_html__( 'Total', 'mainwp' ),
157 - );
159 + $columns = array(
160 + 'created' => esc_html__( 'Created', 'mainwp' ),
161 + 'published' => esc_html__( 'Published', 'mainwp' ),
162 + 'updated' => esc_html__( 'Updated', 'mainwp' ),
163 + 'trashed' => esc_html__( 'Trashed', 'mainwp' ),
164 + 'untrashed' => esc_html__( 'Untrashed', 'mainwp' ),
165 + 'deleted' => esc_html__( 'Deleted', 'mainwp' ),
166 + 'total_events' => esc_html__( 'Total', 'mainwp' ),
167 + );
158 168
159 - ?>
160 - <div class="ui one column grid">
161 - <div class="left aligned middle aligned column">
162 - <div class="ui equal width grid">
163 - <?php
164 - foreach ( $columns as $act => $title ) {
165 - Log_Stats::render_stats_info( $pages_data, $act, $title, $pages_prev_data );
166 - }
167 - ?>
168 - </div>
169 - </div>
170 - <div class="left aligned middle aligned column">
171 - <div id="mainwp-module-log-chart-pages-management-wrapper" ></div>
172 - <script type="text/javascript">
173 - jQuery( document ).ready( function() {
174 - var options = {
175 - chart: {
176 - type: 'bar',
177 - height: 350,
178 - },
179 - plotOptions: {
180 - bar: {
181 - columnWidth: '60%'
182 - }
183 - },
184 - series: [ {
185 - name: 'Events:',
186 - data: [
187 - <?php
188 - foreach ( $columns as $act => $title ) {
189 - Log_Stats::render_chart_series( $pages_data, $act, $title, $pages_prev_data );
190 - }
191 - ?>
192 - ],
193 - } ],
194 - xaxis: {
195 - labels: {
196 - style: {
197 - colors: '#999999',
198 - }
199 - }
200 - },
201 - yaxis: {
202 - labels: {
203 - style: {
204 - colors: '#999999',
205 - }
206 - }
207 - },
208 - tooltip: {
209 - theme: 'dark'
210 - },
211 - }
212 - var clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-pages-management-wrapper"), options);
213 - setTimeout(() => {
214 - clients.render();
215 - }, 1000);
216 - } );
217 - </script>
218 - </div>
219 - </div>
220 - <?php
221 - }
169 + ?>
170 + <div class="ui grid">
171 + <div class="sixteen wide column">
172 + <div class="ui equal width grid">
173 + <?php
174 + foreach ( $columns as $act => $title ) {
175 + Log_Stats::render_stats_info( $pages_data, $act, $title, $pages_prev_data );
176 + }
177 + ?>
178 + </div>
179 + </div>
180 + <div class="sixteen wide column">
181 + <div id="mainwp-module-log-chart-pages-management-wrapper" ></div>
182 + <script type="text/javascript">
183 + jQuery( document ).ready( function() {
184 + let options = {
185 + chart: {
186 + type: 'bar',
187 + height: 350,
188 + },
189 + plotOptions: {
190 + bar: {
191 + columnWidth: '60%'
192 + }
193 + },
194 + series: [ {
195 + name: 'Events:',
196 + data: [
197 + <?php
198 + foreach ( $columns as $act => $title ) {
199 + Log_Stats::render_chart_series( $pages_data, $act, $title, $pages_prev_data );
200 + }
201 + ?>
202 + ],
203 + } ],
204 + xaxis: {
205 + labels: {
206 + style: {
207 + colors: '#999999',
208 + }
209 + }
210 + },
211 + yaxis: {
212 + labels: {
213 + style: {
214 + colors: '#999999',
215 + }
216 + }
217 + },
218 + tooltip: {
219 + theme: 'dark'
220 + },
221 + }
222 + let clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-pages-management-wrapper"), options);
223 + setTimeout(() => {
224 + clients.render();
225 + }, 1000);
226 + } );
227 + </script>
228 + </div>
229 + </div>
230 + <?php
231 + }
222 232 }