← All changes
|
modules/logs/widgets/widget-log-graph-clients-widget.php
+25
-18
5.1
→
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. |
| @@ -60,19 +66,21 @@ | ||
| 60 | 66 | /** |
| 61 | 67 | * Render client overview Info. |
| 62 | 68 | */ |
| 63 | 69 | public function render_widget() { |
| 70 | + $clients = MainWP_DB_Client::instance()->get_wp_clients(); | |
| 71 | + $clients_count = count( $clients ); | |
| 64 | 72 | ?> |
| 65 | 73 | <div class="mainwp-widget-header"> |
| 66 | - <h3 class="ui header handle-drag"> | |
| 74 | + <h2 class="ui header handle-drag"> | |
| 67 | 75 | <?php esc_html_e( 'Client Sites Distribution', 'mainwp' ); ?> |
| 68 | 76 | <div class="sub header"> |
| 69 | 77 | <?php esc_html_e( 'Count of sites assigned to each client. Easily compare the site allocations among your client base.', 'mainwp' ); ?> |
| 70 | 78 | </div> |
| 71 | - </h3> | |
| 79 | + </h2> | |
| 72 | 80 | </div> |
| 73 | 81 | |
| 74 | - <div class="mainwp-widget-insights-card"> | |
| 82 | + <div class="mainwp-widget-insights-card mainwp-scrolly-overflow"> | |
| 75 | 83 | <?php |
| 76 | 84 | /** |
| 77 | 85 | * Action: mainwp_logs_widget_top |
| 78 | 86 | * |
| @@ -83,10 +91,14 @@ | ||
| 83 | 91 | do_action( 'mainwp_logs_widget_top', 'status' ); |
| 84 | 92 | ?> |
| 85 | 93 | <div id="mainwp-message-zone" style="display:none;" class="ui message"></div> |
| 86 | 94 | <?php |
| 87 | - wp_nonce_field( 'mainwp-admin-nonce' ); | |
| 88 | - $this->render_widget_content(); | |
| 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 | + } | |
| 89 | 101 | ?> |
| 90 | 102 | <?php |
| 91 | 103 | /** |
| 92 | 104 | * Action: mainwp_logs_widget_bottom |
| @@ -117,26 +129,21 @@ | ||
| 117 | 129 | <script type="text/javascript"> |
| 118 | 130 | jQuery( document ).ready( function() { |
| 119 | 131 | let options = { |
| 120 | 132 | chart: { |
| 121 | - type: 'bar', | |
| 133 | + type: 'pie', | |
| 134 | + height: 350, | |
| 122 | 135 | }, |
| 123 | - xaxis: { | |
| 124 | - labels: { | |
| 125 | - style: { | |
| 126 | - colors: '#999999', | |
| 127 | - } | |
| 128 | - } | |
| 136 | + tooltip: { | |
| 137 | + theme: 'dark' | |
| 129 | 138 | }, |
| 130 | - yaxis: { | |
| 139 | + legend: { | |
| 131 | 140 | labels: { |
| 132 | - style: { | |
| 133 | - colors: '#999999', | |
| 134 | - } | |
| 141 | + colors: '#999' | |
| 135 | 142 | } |
| 136 | 143 | }, |
| 137 | - tooltip: { | |
| 138 | - theme: 'dark' | |
| 144 | + stroke: { | |
| 145 | + width: 0 | |
| 139 | 146 | }, |
| 140 | 147 | series: [ { |
| 141 | 148 | name: 'Sites', |
| 142 | 149 | data: [ |