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-graph-clients-widget.php +137 -130 5.0 → 6.2.2 View file →
@@ -11,9 +11,15 @@
11 11 namespace MainWP\Dashboard\Module\Log;
12 12
13 13 use MainWP\Dashboard\MainWP_DB;
14 14 use MainWP\Dashboard\MainWP_DB_Client;
15 +use MainWP\Dashboard\MainWP_UI;
15 16
17 +// Exit if accessed directly.
18 +if ( ! defined( 'ABSPATH' ) ) {
19 + exit;
20 +}
21 +
16 22 /**
17 23 * Class Log_Graph_Clients_Widget
18 24 *
19 25 * Displays the Logs info.
@@ -19,143 +25,144 @@
19 25 * Displays the Logs info.
20 26 */
21 27 class Log_Graph_Clients_Widget {
22 28
23 - /**
24 - * Protected static variable to hold the single instance of the class.
25 - *
26 - * @var mixed Default null
27 - */
28 - 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;
29 35
30 - /**
31 - * Return the single instance of the class.
32 - *
33 - * @return mixed $instance The single instance of the class.
34 - */
35 - public static function instance() {
36 - if ( is_null( self::$instance ) ) {
37 - self::$instance = new self();
38 - }
39 - return self::$instance;
40 - }
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 + }
41 47
42 48
43 - /**
44 - * Method get_class_name()
45 - *
46 - * @return string __CLASS__ Class name.
47 - */
48 - public static function get_class_name() {
49 - return __CLASS__;
50 - }
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 + }
51 57
52 - /**
53 - * Method render()
54 - */
55 - public function render() {
56 - $this->render_widget();
57 - }
58 + /**
59 + * Method render()
60 + */
61 + public function render() {
62 + $this->render_widget();
63 + }
58 64
59 65
60 - /**
61 - * Render client overview Info.
62 - */
63 - public function render_widget() {
64 - ?>
65 - <div class="mainwp-widget-header">
66 - <h3 class="ui header handle-drag">
67 - <?php esc_html_e( 'Client Sites Distribution', 'mainwp' ); ?>
68 - <div class="sub header">
69 - <?php esc_html_e( 'Count of sites assigned to each client. Easily compare the site allocations among your client base.', 'mainwp' ); ?>
70 - </div>
71 - </h3>
72 - </div>
66 + /**
67 + * Render client overview Info.
68 + */
69 + public function render_widget() {
70 + $clients = MainWP_DB_Client::instance()->get_wp_clients();
71 + $clients_count = count( $clients );
72 + ?>
73 + <div class="mainwp-widget-header">
74 + <h2 class="ui header handle-drag">
75 + <?php esc_html_e( 'Client Sites Distribution', 'mainwp' ); ?>
76 + <div class="sub header">
77 + <?php esc_html_e( 'Count of sites assigned to each client. Easily compare the site allocations among your client base.', 'mainwp' ); ?>
78 + </div>
79 + </h2>
80 + </div>
73 81
74 - <div class="mainwp-widget-insights-card">
75 - <?php
76 - /**
77 - * Action: mainwp_logs_widget_top
78 - *
79 - * Fires at the top of the widget.
80 - *
81 - * @since 4.6
82 - */
83 - do_action( 'mainwp_logs_widget_top', 'status' );
84 - ?>
85 - <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
86 - <?php
87 - wp_nonce_field( 'mainwp-admin-nonce' );
88 - $this->render_widget_content();
89 - ?>
90 - <?php
91 - /**
92 - * Action: mainwp_logs_widget_bottom
93 - *
94 - * Fires at the bottom of the widget.
95 - *
96 - * @since 4.6
97 - */
98 - do_action( 'mainwp_logs_widget_bottom', 'status' );
99 - ?>
100 - </div>
101 - <div class="mainwp-widget-footer ui four columns stackable grid">
102 - <div class="column">
103 - </div>
104 - <div class="column">
105 - </div>
106 - </div>
107 - <?php
108 - }
82 + <div class="mainwp-widget-insights-card mainwp-scrolly-overflow">
83 + <?php
84 + /**
85 + * Action: mainwp_logs_widget_top
86 + *
87 + * Fires at the top of the widget.
88 + *
89 + * @since 4.6
90 + */
91 + do_action( 'mainwp_logs_widget_top', 'status' );
92 + ?>
93 + <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
94 + <?php
95 + MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' );
96 + if ( 0 < intval( $clients_count ) ) {
97 + $this->render_widget_content();
98 + } else {
99 + MainWP_UI::render_empty_element_placeholder( __( 'No Clients Data Yet', 'mainwp' ), '<a href="admin.php?page=ClientAddNew">' . __( 'Start adding your clients now', 'mainwp' ) . '</a>', '<em data-emoji=":bar_chart:" class="medium"></em>' );
100 + }
101 + ?>
102 + <?php
103 + /**
104 + * Action: mainwp_logs_widget_bottom
105 + *
106 + * Fires at the bottom of the widget.
107 + *
108 + * @since 4.6
109 + */
110 + do_action( 'mainwp_logs_widget_bottom', 'status' );
111 + ?>
112 + </div>
113 + <div class="mainwp-widget-footer ui four columns stackable grid">
114 + <div class="column">
115 + </div>
116 + <div class="column">
117 + </div>
118 + </div>
119 + <?php
120 + }
109 121
110 - /**
111 - * Method render_widget_content()
112 - */
113 - public function render_widget_content() {
114 - $clients = MainWP_DB_Client::instance()->get_wp_clients();
115 - ?>
116 - <div id="mainwp-module-log-chart-clients-wrapper" ></div>
117 - <script type="text/javascript">
118 - jQuery( document ).ready( function() {
119 - var options = {
120 - chart: {
121 - type: 'bar',
122 - },
123 - xaxis: {
124 - labels: {
125 - style: {
126 - colors: '#999999',
127 - }
128 - }
129 - },
130 - yaxis: {
131 - labels: {
132 - style: {
133 - colors: '#999999',
134 - }
135 - }
136 - },
137 - tooltip: {
138 - theme: 'dark'
139 - },
140 - series: [ {
141 - name: 'Sites',
142 - data: [
143 - <?php foreach ( $clients as $client ) : ?>
144 - {
145 - x: '<?php echo esc_js( $client['name'] ); ?>',
146 - y: <?php echo ! empty( $client['selected_sites'] ) ? count( explode( ',', $client['selected_sites'] ) ) : 0; ?>,
147 - fillColor: "#18a4e0",
148 - },
149 - <?php endforeach; ?>
150 - ]
151 - } ],
152 - }
153 - var clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-clients-wrapper"), options);
154 - setTimeout(() => {
155 - clients.render();
156 - }, 1000);
157 - } );
158 - </script>
159 - <?php
160 - }
122 + /**
123 + * Method render_widget_content()
124 + */
125 + public function render_widget_content() {
126 + $clients = MainWP_DB_Client::instance()->get_wp_clients();
127 + ?>
128 + <div id="mainwp-module-log-chart-clients-wrapper" ></div>
129 + <script type="text/javascript">
130 + jQuery( document ).ready( function() {
131 + let options = {
132 + chart: {
133 + type: 'pie',
134 + height: 350,
135 + },
136 + tooltip: {
137 + theme: 'dark'
138 + },
139 + legend: {
140 + labels: {
141 + colors: '#999'
142 + }
143 + },
144 + stroke: {
145 + width: 0
146 + },
147 + series: [ {
148 + name: 'Sites',
149 + data: [
150 + <?php foreach ( $clients as $client ) : ?>
151 + {
152 + x: '<?php echo esc_js( $client['name'] ); ?>',
153 + y: <?php echo ! empty( $client['selected_sites'] ) ? count( explode( ',', $client['selected_sites'] ) ) : 0; ?>,
154 + fillColor: "#18a4e0",
155 + },
156 + <?php endforeach; ?>
157 + ]
158 + } ],
159 + }
160 + let clients = new ApexCharts(document.querySelector("#mainwp-module-log-chart-clients-wrapper"), options);
161 + setTimeout(() => {
162 + clients.render();
163 + }, 1000);
164 + } );
165 + </script>
166 + <?php
167 + }
161 168 }