PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
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 | widgets/widget-mainwp-client-overview-sites.php +98 -86 5.1 → 6.2.1 View file →
@@ -8,8 +8,13 @@
8 8 */
9 9
10 10 namespace MainWP\Dashboard;
11 11
12 +// Exit if accessed directly.
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
16 +
12 17 /**
13 18 * Class MainWP_Client_Overview_Sites
14 19 *
15 20 * Displays the Client info.
@@ -102,23 +107,23 @@
102 107 $client_info = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $client_id, ARRAY_A );
103 108
104 109 ?>
105 110 <div class="mainwp-widget-header">
106 - <h3 class="ui header handle-drag">
107 - <?php
108 - /**
109 - * Filter: mainwp_clients_overview_websites_widget_title
110 - *
111 - * Filters the Site info widget title text.
112 - *
113 - * @param object $client_info Object containing the child site info.
114 - *
115 - * @since 4.1
116 - */
117 - echo esc_html( apply_filters( 'mainwp_clients_overview_websites_widget_title', esc_html__( 'Sites', 'mainwp' ), $client_info ) );
118 - ?>
119 - <div class="sub header"><?php echo esc_html__( 'Websites that belong to the client.', 'mainwp' ); ?></div>
120 - </h3>
111 + <h2 class="ui header handle-drag">
112 + <?php
113 + /**
114 + * Filter: mainwp_clients_overview_websites_widget_title
115 + *
116 + * Filters the Site info widget title text.
117 + *
118 + * @param object $client_info Object containing the child site info.
119 + *
120 + * @since 4.1
121 + */
122 + echo esc_html( apply_filters( 'mainwp_clients_overview_websites_widget_title', esc_html__( 'Sites', 'mainwp' ), $client_info ) );
123 + ?>
124 + <div class="sub header"><?php echo esc_html__( 'Websites that belong to the client.', 'mainwp' ); ?></div>
125 + </h2>
121 126 </div>
122 127 <div class="mainwp-widget-client-card mainwp-scrolly-overflow">
123 128 <?php
124 129 /**
@@ -142,11 +147,8 @@
142 147 </thead>
143 148 <tbody id="mainwp-manage-sites-body-table">
144 149 <?php $this->display_rows_or_placeholder(); ?>
145 150 </tbody>
146 - <tfoot>
147 - <tr><?php $this->print_column_headers( false ); ?></tr>
148 - </tfoot>
149 151 </table>
150 152 <?php } ?>
151 153 <?php
152 154 /**
@@ -160,8 +162,13 @@
160 162 */
161 163 do_action( 'mainwp_clients_overview_websites_widget_bottom', $client_info );
162 164 ?>
163 165 </div>
166 + <div class="ui grid mainwp-widget-footer">
167 + <div class="column">
168 + <a href="admin.php?page=managesites&client=<?php echo intval( $client_id ); ?>" title="" class="ui mini basic button"><?php echo esc_html__( 'Manage Client Sites', 'mainwp' ); ?></a>
169 + </div>
170 + </div>
164 171
165 172 <?php
166 173 // @NO_SONAR_START@ - duplicated issue.
167 174
@@ -188,17 +195,17 @@
188 195 $pagelength_title = implode( ',', array_values( $pages_length ) );
189 196
190 197 $table_features = array(
191 198 'searching' => 'true',
192 - 'paging' => 'false',
193 - 'pagingType' => 'full_numbers',
194 - 'info' => 'true',
199 + 'paging' => 'true',
200 + 'info' => 'false',
195 201 'colReorder' => '{ columns:":not(.manage-status-column):not(.manage-site_actions-column)"} ',
196 202 'stateSave' => 'true',
197 - 'stateDuration' => '0',
203 + 'stateDuration' => '60 * 60 * 24 * 30',
198 204 'order' => '[]',
199 205 'scrollX' => 'true',
200 206 'responsive' => 'true',
207 + 'searchDelay' => 350,
201 208 );
202 209
203 210 ?>
204 211
@@ -212,10 +219,14 @@
212 219 $manage_sites_table = jQuery( '#mainwp-manage-sites-monitor-table' ).DataTable( {
213 220 "searching" : <?php echo esc_js( $table_features['searching'] ); ?>,
214 221 "responsive": responsive,
215 222 "paging" : <?php echo esc_js( $table_features['paging'] ); ?>,
216 - "pagingType" : "<?php echo esc_js( $table_features['pagingType'] ); ?>",
217 223 "info" : <?php echo esc_js( $table_features['info'] ); ?>,
224 + "layout": {
225 + "bottom": 'paging',
226 + "bottomStart": null,
227 + "bottomEnd": null
228 + },
218 229 "scrollX" : <?php echo esc_js( $table_features['scrollX'] ); ?>,
219 230 "colReorder" : <?php echo $table_features['colReorder']; // phpcs:ignore -- specical chars. ?>,
220 231 "stateSave" : <?php echo esc_js( $table_features['stateSave'] ); ?>,
221 232 "stateDuration" : <?php echo esc_js( $table_features['stateDuration'] ); ?>,
@@ -220,19 +231,9 @@
220 231 "stateSave" : <?php echo esc_js( $table_features['stateSave'] ); ?>,
221 232 "stateDuration" : <?php echo esc_js( $table_features['stateDuration'] ); ?>,
222 233 "order" : <?php echo $table_features['order']; // phpcs:ignore -- specical chars. ?>,
223 234 "lengthMenu" : [ [<?php echo esc_js( $pagelength_val ); ?>, -1 ], [<?php echo esc_js( $pagelength_title ); ?>, "All" ] ],
224 - "columnDefs": [
225 - {
226 - "targets": 'no-sort',
227 - "orderable": false
228 - },
229 - {
230 - "targets": 'manage-site-column',
231 - "type": 'natural-nohtml'
232 - },
233 - <?php do_action( 'mainwp_manage_sites_table_columns_defs' ); ?>
234 - ],
235 + "columnDefs": <?php echo wp_json_encode( $this->get_columns_defines() ); ?>,
235 236 "pageLength": <?php echo intval( $sites_per_page ); ?>,
236 237 "initComplete": function( settings, json ) {
237 238 },
238 239 "language": {
@@ -241,11 +242,19 @@
241 242 "drawCallback": function( settings ) {
242 243 if ( jQuery('#mainwp-manage-sites-body-table td.dt-empty').length > 0 && jQuery('#sites-table-count-empty').length ){
243 244 jQuery('#mainwp-manage-sites-body-table td.dt-empty').html(jQuery('#sites-table-count-empty').html());
244 245 }
245 - }
246 + },
247 + stateSaveParams: function (settings, data) {
248 + data._mwpv = mainwpParams.mainwpVersion || 'dev';
249 + },
250 + stateLoadParams: function (settings, data) {
251 + if ((mainwpParams.mainwpVersion || 'dev') !== data._mwpv) return false;
252 + },
253 + search: { regex: false, smart: false },
254 + orderMulti: false,
255 + searchDelay: <?php echo intval( $table_features['searchDelay'] ); ?>
246 256 } ).on( 'columns-reordered', function () {
247 - console.log('columns-reordered');
248 257 setTimeout(() => {
249 258 $( '#mainwp-manage-sites-monitor-table .ui.dropdown' ).dropdown();
250 259 $( '#mainwp-manage-sites-monitor-table .ui.checkbox' ).checkbox();
251 260 mainwp_datatable_fix_menu_overflow( '#mainwp-manage-sites-monitor-table' );
@@ -254,9 +263,9 @@
254 263 } catch(err) {
255 264 // to fix js error.
256 265 console.log(err);
257 266 }
258 - mainwp_datatable_fix_menu_overflow();
267 + mainwp_datatable_fix_menu_overflow( '#mainwp-manage-sites-monitor-table' );
259 268 });
260 269 </script>
261 270 <?php
262 271 // @NO_SONAR_END@ .
@@ -395,9 +404,8 @@
395 404 public function get_default_columns() {
396 405 return array(
397 406 'status' => '',
398 407 'site' => esc_html__( 'Site', 'mainwp' ),
399 - 'login' => '<i class="sign in alternate icon"></i>',
400 408 'update' => esc_html__( 'Updates', 'mainwp' ),
401 409 );
402 410 }
403 411
@@ -449,23 +457,23 @@
449 457 'targets' => 'no-sort',
450 458 'orderable' => false,
451 459 );
452 460 $defines[] = array(
461 + 'targets' => array( 'manage-status-column' ),
462 + 'className' => 'collapsing center aligned',
463 + );
464 + $defines[] = array(
453 465 'targets' => 'manage-site-column',
454 466 'className' => 'column-site-bulk mainwp-site-cell',
455 467 );
456 468 $defines[] = array(
457 - 'targets' => 'manage-url-column',
458 - 'className' => 'mainwp-url-cell',
469 + 'targets' => array( 'manage-update-column' ),
470 + 'className' => 'collapsing center aligned',
459 471 );
460 472 $defines[] = array(
461 - 'targets' => array( 'manage-login-column', 'manage-status_code-column', 'manage-site_actions-column', 'manage-client_name-column' ),
462 - 'className' => 'collapsing',
473 + 'targets' => array( 'manage-site_actions-column' ),
474 + 'className' => 'collapsing right aligned',
463 475 );
464 - $defines[] = array(
465 - 'targets' => array( 'manage-status-column' ),
466 - 'className' => 'collapsing',
467 - );
468 476 return $defines;
469 477 }
470 478
471 479 /**
@@ -482,17 +490,21 @@
482 490 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
483 491 */
484 492 protected function single_row_columns( $website ) { // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
485 493
494 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
495 + $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
496 +
486 497 // @NO_SONAR_START@ - duplicated issue.
487 498 $total_wp_upgrades = 0;
488 499 $total_plugin_upgrades = 0;
489 500 $total_theme_upgrades = 0;
490 501
491 - $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'premium_upgrades', 'primary_lasttime_backup' ) );
492 - $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array();
502 + $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'ignored_wp_upgrades', 'premium_upgrades', 'primary_lasttime_backup' ) );
503 + $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array();
504 + $ignored_core_upgrades = isset( $site_options['ignored_wp_upgrades'] ) ? json_decode( $site_options['ignored_wp_upgrades'], true ) : array();
493 505
494 - if ( $website['is_ignoreCoreUpdates'] ) {
506 + if ( $website['is_ignoreCoreUpdates'] || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) {
495 507 $wp_upgrades = array();
496 508 }
497 509
498 510 if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
@@ -537,14 +549,15 @@
537 549 if ( is_array( $plugin_upgrades ) ) {
538 550
539 551 $ignored_plugins = json_decode( $website['ignored_plugins'], true );
540 552 if ( is_array( $ignored_plugins ) ) {
541 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
553 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
554 +
542 555 }
543 556
544 557 $ignored_plugins = json_decode( $this->userExtension->ignored_plugins, true );
545 558 if ( is_array( $ignored_plugins ) ) {
546 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins );
559 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
547 560 }
548 561
549 562 $total_plugin_upgrades += count( $plugin_upgrades );
550 563 }
@@ -552,14 +565,14 @@
552 565 if ( is_array( $theme_upgrades ) ) {
553 566
554 567 $ignored_themes = json_decode( $website['ignored_themes'], true );
555 568 if ( is_array( $ignored_themes ) ) {
556 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
569 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
557 570 }
558 571
559 572 $ignored_themes = json_decode( $this->userExtension->ignored_themes, true );
560 573 if ( is_array( $ignored_themes ) ) {
561 - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes );
574 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
562 575 }
563 576
564 577 $total_theme_upgrades += count( $theme_upgrades );
565 578 }
@@ -564,36 +577,25 @@
564 577 $total_theme_upgrades += count( $theme_upgrades );
565 578 }
566 579
567 580 $total_updates = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades;
568 -
569 - if ( 5 < $total_updates ) {
570 - $a_color = 'red';
571 - } elseif ( 0 < $total_updates && 5 >= $total_updates ) {
572 - $a_color = 'yellow';
573 - } else {
574 - $a_color = 'green';
575 - }
576 -
577 581 $hasSyncErrors = ( '' !== $website['sync_errors'] );
578 582
579 583 // @NO_SONAR_END@ .
580 584
581 - if ( $hasSyncErrors ) {
582 - $a_color = '';
583 - }
584 -
585 585 list( $columns ) = $this->get_column_info();
586 586
587 587 foreach ( $columns as $column_name => $column_display_name ) {
588 + ?>
588 589
589 - ?>
590 590 <?php if ( 'status' === $column_name ) { ?>
591 591 <td class="center aligned collapsing">
592 592 <?php if ( $hasSyncErrors ) : ?>
593 - <a class="mainwp_site_reconnect" href="#"><i class="circular inverted red unlink icon"></i></a>
593 + <a class="mainwp_site_reconnect" href="#"><i class="red large times icon"></i></a>
594 594 <?php else : ?>
595 - <a class="managesites_syncdata" href="#"><?php echo '1' === $website['suspended'] ? '<i class="pause circular yellow inverted circle icon"></i>' : '<i class="circular inverted green check icon"></i>'; ?></a>
595 + <a class="managesites_syncdata" href="#">
596 + <?php echo '1' === $website['suspended'] ? '<i class="yellow pause large icon"></i>' : '<i class="green large check icon"></i>'; ?>
597 + </a>
596 598 <?php endif; ?>
597 599 </td>
598 600 <?php
599 601 } elseif ( 'site' === $column_name ) {
@@ -601,28 +603,38 @@
601 603 if ( ! empty( $website['sync_errors'] ) ) {
602 604 $cls_site = 'site-sync-error';
603 605 }
604 606 ?>
605 - <td class="column-site-bulk mainwp-site-cell all <?php echo esc_html( $cls_site ); ?>"><a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Open the site overview', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( stripslashes( $website['name'] ) ); ?></a><i class="ui active inline loader tiny" style="display:none"></i><span id="site-status-<?php echo esc_attr( $website['id'] ); ?>" class="status hidden"></span></td>
606 - <?php } elseif ( 'login' === $column_name ) { ?>
607 - <td class="collapsing">
608 - <?php if ( ! mainwp_current_user_have_right( 'dashboard', 'access_wpadmin_on_child_sites' ) ) : ?>
609 - <i class="sign in icon"></i>
610 - <?php else : ?>
611 - <a href="<?php MainWP_Site_Open::get_open_site_url( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="right center" data-inverted="" class="open_newwindow_wpadmin" target="_blank"><i class="sign in icon"></i></a>
612 - <?php endif; ?>
607 + <td class="column-site-bulk mainwp-site-cell all <?php echo esc_html( $cls_site ); ?>">
608 + <?php if ( ! \mainwp_current_user_can( 'dashboard', 'access_wpadmin_on_child_sites' ) ) : ?>
609 + <i class="sign in icon"></i>
610 + <?php else : ?>
611 + <a href="<?php MainWP_Site_Open::get_open_site_url( $website['id'] ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the site WP Admin', 'mainwp' ); ?>" data-position="right center" data-inverted="" class="open_newwindow_wpadmin" target="_blank"><i class="sign in icon"></i></a>
612 + <?php endif; ?>
613 + <a href="<?php echo 'admin.php?page=managesites&dashboard=' . intval( $website['id'] ); ?>" >
614 + <?php echo esc_html( stripslashes( $website['name'] ) ); ?>
615 + </a>
616 + <div>
617 + <span class="ui small text">
618 + <a href="<?php echo esc_url( $website['url'] ); ?>" class="mainwp-may-hide-referrer open_site_url ui grey text" target="_blank">
619 + <?php echo esc_html( MainWP_Utility::get_nice_url( $website['url'] ) ); ?>
620 + </a>
621 + </span>
622 + </div>
613 623 </td>
624 + <?php } elseif ( 'update' === $column_name ) { ?>
625 + <td>
626 + <a class="ui mini basic grey button" href="admin.php?page=managesites&updateid=<?php echo intval( $website['id'] ); ?>">
627 + <i class="sync alternate icon"></i> <?php echo intval( $total_updates ); ?>
628 + </a>
629 + </td>
614 630 <?php
615 - } elseif ( 'update' === $column_name ) {
616 - ?>
617 - <td class="collapsing center aligned"><span data-tooltip="<?php esc_attr_e( 'Number of available updates. Click to see details.', 'mainwp' ); ?>" data-position="left center" data-inverted=""><a class="ui mini compact button <?php echo esc_attr( $a_color ); ?>" href="admin.php?page=managesites&updateid=<?php echo intval( $website['id'] ); ?>"><?php echo intval( $total_updates ); ?></a></span></td>
618 - <?php
619 631 } elseif ( 'site_actions' === $column_name ) {
620 632 // @NO_SONAR_START@ - duplicated issue.
621 633 ?>
622 634 <td class="collapsing not-selectable">
623 - <div class="ui right pointing dropdown icon mini basic green button" style="z-index: 99;">
624 - <i class="ellipsis horizontal icon"></i>
635 + <div class="ui right pointing dropdown" style="z-index: 99;">
636 + <i class="ellipsis vertical icon"></i>
625 637 <div class="menu" siteid="<?php echo intval( $website['id'] ); ?>">
626 638 <?php if ( '' !== $website['sync_errors'] ) : ?>
627 639 <a class="mainwp_site_reconnect item" href="#"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
628 640 <?php else : ?>
@@ -627,13 +639,13 @@
627 639 <a class="mainwp_site_reconnect item" href="#"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
628 640 <?php else : ?>
629 641 <a class="managesites_syncdata item" href="#"><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a>
630 642 <?php endif; ?>
631 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'access_individual_dashboard' ) ) : ?>
643 + <?php if ( \mainwp_current_user_can( 'dashboard', 'access_individual_dashboard' ) ) : ?>
632 644 <a class="item" href="admin.php?page=managesites&dashboard=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Overview', 'mainwp' ); ?></a>
633 645 <?php endif; ?>
634 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'edit_sites' ) ) : ?>
635 - <a class="item" href="admin.php?page=managesites&id=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Edit Site', 'mainwp' ); ?></a>
646 + <?php if ( \mainwp_current_user_can( 'dashboard', 'edit_sites' ) ) : ?>
647 + <a class="item" href="admin.php?page=managesites&id=<?php echo intval( $website['id'] ); ?>"><?php esc_html_e( 'Settings', 'mainwp' ); ?></a>
636 648 <?php endif; ?>
637 649 </div>
638 650 </div>
639 651 </td>