PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1.6
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.1.6
6.3 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 All 157 releases
mainwp / widgets / widget-mainwp-connection-status.php

widget-mainwp-connection-status.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.1.6, at widgets/widget-mainwp-connection-status.php

819 lines 33.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Connection Status
4 *
5 * Build the MainWP Operations page Connection Status Widget.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 namespace MainWP\Dashboard;
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class MainWP_Connection_Status
19 *
20 * Build the Connection Status Widget.
21 */
22 class MainWP_Connection_Status { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
23
24 /**
25 * Public variable to hold Items information.
26 *
27 * @var array
28 */
29 public $items;
30
31 /**
32 * Public variable to hold total items number.
33 *
34 * @var integer
35 */
36 public $total_items;
37
38 /**
39 * Private static variable to hold the single instance of the class.
40 *
41 * @static
42 *
43 * @var mixed Default null
44 */
45 private static $instance = null;
46
47 /**
48 * Method instance()
49 *
50 * Return public static instance.
51 *
52 * @static
53 * @return self
54 */
55 public static function instance() {
56 if ( null === static::$instance ) {
57 static::$instance = new self();
58 }
59 return static::$instance;
60 }
61
62
63 /**
64 * Method get_class_name()
65 *
66 * @return string __CLASS__ Class Name
67 */
68 public static function get_class_name() {
69 return __CLASS__;
70 }
71
72 /**
73 * Method render()
74 *
75 * @return mixed render_sites()
76 */
77 public static function render() {
78 static::render_widget_content();
79 }
80
81 /**
82 * Method render_widget_content()
83 *
84 * Build the Connection Status Widget
85 * Displays $SYNCERRORS|$UP|$ALL.
86 *
87 * @uses \MainWP\Dashboard\MainWP_DB::query()
88 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_id()
89 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_id()
90 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_search_websites_for_current_user()
91 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
92 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
93 * @uses \MainWP\Dashboard\MainWP_DB::free_result()
94 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
95 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
96 */
97 public static function render_widget_content() { // phpcs:ignore -- NOSONAR - current complexity required to achieve desired results. Pull request solutions appreciated.
98
99 $counts = MainWP_DB::instance()->get_sites_connections_status();
100
101 if ( ! is_array( $counts ) ) {
102 $counts = array();
103 }
104
105 $count_connected = ! empty( $counts['connected_sites'] ) ? (int) $counts['connected_sites'] : 0;
106 $count_disconnected = ! empty( $counts['disconnected_sites'] ) ? (int) $counts['disconnected_sites'] : 0;
107
108 static::render_content( $count_connected, $count_disconnected );
109
110 MainWP_UI::render_modal_reconnect();
111 }
112
113 /**
114 * The renders the MainWP Operations page Connection Status Widget Header and Drop down Box.
115 *
116 * @param int $count_connected Number of connected sites.
117 * @param int $count_disconnected Number of disconnected sites.
118 */
119 public static function render_content( $count_connected, $count_disconnected ) {
120 ?>
121 <div class="mainwp-widget-header">
122 <div class="ui grid">
123 <div class="twelve wide column">
124 <h2 class="ui header handle-drag">
125 <?php
126 /**
127 * Filter: mainwp_connection_status_widget_title
128 *
129 * Filters the Connection Status widget title text.
130 *
131 * @since 4.1
132 */
133 echo esc_html( apply_filters( 'mainwp_connection_status_widget_title', esc_html__( 'Connection Status', 'mainwp' ) ) );
134 ?>
135 <div class="sub header"><?php esc_html_e( 'Child sites connection status', 'mainwp' ); ?></div>
136 </h2>
137 </div>
138
139 <div class="four wide column right aligned">
140 <div id="widget-connect-status-dropdown-selector" class="ui dropdown top right tiny pointing not-auto-init mainwp-dropdown-tab">
141 <i class="vertical ellipsis icon"></i>
142 <div class="menu">
143 <a class="item" data-tab="all-sites" data-value="all-sites" data-position="left center" data-inverted="" data-tooltip="<?php esc_attr_e( 'View all child sites', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></a>
144 <a class="item" data-tab="connected" data-value="connected" data-position="left center" data-inverted="" data-tooltip="<?php esc_attr_e( 'View all connected child sites', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Connected', 'mainwp' ); ?></a>
145 <a class="item" data-tab="disconnected" data-value="disconnected" data-position="left center" data-inverted="" data-tooltip="<?php esc_attr_e( 'View all disconnected child sites', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Disconnected', 'mainwp' ); ?></a>
146 <a class="item" data-tab="no-sites" data-value="no-sites" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Hide the child sites list', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Hide Details', 'mainwp' ); ?></a>
147 </div>
148 </div>
149 </div>
150 </div>
151 <div>
152 <?php static::render_multi_status( $count_connected, $count_disconnected ); ?>
153 </div>
154 </div>
155
156 <?php
157 /**
158 * Action: mainwp_connection_status_widget_top
159 *
160 * Fires at the top of the Connection Status widget.
161 *
162 * @since 4.1
163 */
164 do_action( 'mainwp_connection_status_widget_top' );
165 ?>
166
167 <div class="mainwp-scrolly-overflow" id="widget-connections-status-details">
168 <?php
169 foreach ( array( 'all-sites', 'connected', 'disconnected' ) as $tab ) {
170 static::render_tab( $tab );
171 }
172 ?>
173 <div class="ui tab" data-tab="no-sites"></div>
174 </div>
175 <div class="ui two column grid mainwp-widget-footer">
176 <div class="left aligned middle aligned column">
177 <?php
178 /**
179 * Action: mainwp_connection_status_widget_footer_left
180 *
181 * Fires in the left column of the Connection status widget
182 *
183 * @since 5.3
184 */
185 do_action( 'mainwp_connection_status_widget_footer_left' )
186 ?>
187 </div>
188 <div class="right aligned middle aligned column">
189 <?php
190 /**
191 * Action: mainwp_connection_status_widget_footer_right
192 *
193 * Fires in the right column of the Connection status widget
194 *
195 * @since 5.3
196 */
197 do_action( 'mainwp_connection_status_widget_footer_right' )
198 ?>
199 </div>
200 </div>
201 <script type="text/javascript">
202
203 let mainwp_widgets_connections_status_get_table = function(tab){
204 switch(tab){
205 case 'all-sites':
206 return $widget_connections_status_table_all_sites;
207 case 'connected':
208 return $widget_connections_status_table_connected;
209 case 'disconnected':
210 return $widget_connections_status_table_disconnected;
211 default:
212 return null;
213 }
214 };
215
216 let mainwp_widgets_connections_status_tab_onchange = function( current_tab ){
217 if( ! ['all-sites', 'connected', 'disconnected'].includes(current_tab) || jQuery('#widget-connections-status-details div[data-tab=' + current_tab +'][loaded-data="loaded"]').length > 0 ){
218 return;
219 }
220 let current_page = jQuery('#widget-connections-status-details div[data-tab=' + current_tab + ']').attr('current-page');
221 mainwp_widgets_connections_status_get_table(current_tab).ajax.reload();
222 }
223
224 jQuery( document ).ready( function () {
225 setTimeout(() => {
226 jQuery( '#widget-connect-status-dropdown-selector' ).dropdown( {
227 onChange: function( val ) {
228 if ( typeof( Storage ) !== 'undefined' ) {
229 localStorage.setItem( 'lsWidgetConnectStatusDropdownVal', val );
230 mainwp_widgets_connections_status_tab_onchange( val );
231 }
232 }
233 } );
234 jQuery( '#widget-connect-status-dropdown-selector .menu .item' ).tab();
235 if ( typeof( Storage ) !== "undefined" ) {
236 let val = localStorage.getItem( 'lsWidgetConnectStatusDropdownVal' );
237 if(!['all-sites', 'connected', 'disconnected', 'no-sites'].includes(val)) {
238 val = 'all-sites';
239 }
240 jQuery( '#widget-connect-status-dropdown-selector' ).dropdown( 'set selected',val );
241 jQuery( '#widget-connect-status-dropdown-selector' ).closest( '.mainwp-widget' ).find( 'div.ui.tab' ).removeClass( 'active');
242 jQuery( '#widget-connect-status-dropdown-selector' ).closest( '.mainwp-widget' ).find( 'div[data-tab="' + val + '"]' ).addClass( 'active' );
243 mainwp_widgets_connections_status_tab_onchange( val );
244 }
245 }, 1000);
246 } );
247 </script>
248 <?php
249 }
250
251 /**
252 * The renders the connections status tab.
253 *
254 * @param string $tab The tab.
255 */
256 public static function render_tab( $tab ) {
257 $sites_per_page = 25;
258 $tbl_id = 'widget-connections-status-details-table-' . $tab;
259
260 if ( 'all-sites' === $tab ) {
261 $hook_before = 'mainwp_connection_status_before_all_sites_list';
262 $hook_after = 'mainwp_connection_status_after_all_sites_list';
263 } elseif ( 'connected' === $tab ) {
264 $hook_before = 'mainwp_connection_status_before_connected_sites_list';
265 $hook_after = 'mainwp_connection_status_after_connected_sites_list';
266 } else {
267 $hook_before = 'mainwp_connection_status_before_disconnected_sites_list';
268 $hook_after = 'mainwp_connection_status_after_disconnected_sites_list';
269 }
270
271 ?>
272
273 <div class="ui tab" data-tab="<?php echo esc_attr( $tab ); ?>" loaded-data="no" current-page="1">
274 <div class="ui message widget-connections-status-message-zone" style="display:none;" ></div>
275
276 <?php
277 /**
278 * Fires before the list of all sites in the connection status widgets
279 *
280 * @since 4.1
281 */
282 do_action( $hook_before );
283 ?>
284 <div class="widget-connections-status-details-table-list-container">
285 <table id="<?php echo esc_attr( $tbl_id ); ?>" style="width:100%" class="ui single line unstackable table">
286 <thead>
287 <tr><?php static::print_column_headers(); ?></tr>
288 </thead>
289 </table>
290 </div>
291 <?php
292 /**
293 * Fires after the list of all sites in the connection status widgets
294 *
295 * @since 4.1
296 */
297 do_action( $hook_after );
298 ?>
299 </div>
300 <?php
301
302 $table_features = array(
303 'searching' => 'false',
304 'paging' => 'true',
305 'pagingType' => 'full_numbers',
306 'info' => 'false',
307 'colReorder' => '{columns:":not(.check-column):not(:last-child)"}',
308 'stateSave' => 'false',
309 'stateDuration' => '60 * 60 * 24 * 30',
310 'order' => '[]',
311 'scrollX' => 'true',
312 'responsive' => 'true',
313 'fixedColumns' => '',
314 'searchDelay' => 350,
315 'numbers' => 3,
316 );
317
318 $pages_length = array(
319 25 => '25',
320 );
321
322 $pagelength_val = implode( ',', array_keys( $pages_length ) );
323 $pagelength_title = implode( ',', array_values( $pages_length ) );
324
325 ?>
326 <script type="text/javascript">
327 let $widget_connections_status_table_<?php echo esc_js( str_replace( '-', '_', $tab ) ); ?> = null;
328 jQuery( document ).ready( function ($) {
329 let responsive = true;
330 if( jQuery( window ).width() > 1140 ) {
331 responsive = false;
332 }
333 let manage_tbl_id = '#<?php echo esc_js( $tbl_id ); ?>';
334 $widget_connections_status_table_<?php echo esc_js( str_replace( '-', '_', $tab ) ); ?> = jQuery( manage_tbl_id ).on( 'processing.dt', function ( e, settings, processing ) {
335 jQuery( '#mainwp-loading-sites' ).css( 'display', processing ? 'block' : 'none' );
336 if (!processing) {
337 $( manage_tbl_id + ' .ui.dropdown' ).dropdown();
338 }
339 } ).DataTable( {
340 "ajax": {
341 "url": ajaxurl,
342 "type": "POST",
343 "data": function ( d ) {
344 let data = mainwp_secure_data( {
345 action: 'mainwp_widgets_connections_status_details_display_rows',
346 current_tab: '<?php echo esc_js( $tab ); ?>',
347 } );
348 return $.extend( {}, d, data );
349 },
350 "dataSrc": function ( json ) {
351 for ( let i=0, ien=json.data.length ; i < ien ; i++ ) {
352 json.data[i].rowClass = json.rowsInfo[i].rowClass;
353 json.data[i].site_id = json.rowsInfo[i].site_id;
354 }
355 return json.data;
356 }
357 },
358 "layout": {
359 "topStart": null,
360 "bottomEnd": {
361 "paging": {
362 "numbers": <?php echo intval( $table_features['numbers'] ); ?>
363 }
364 }
365 },
366 'responsive': responsive,
367 'deferLoading': 0,
368 'searching' : <?php echo esc_js( $table_features['searching'] ); ?>,
369 "paging" : <?php echo esc_js( $table_features['paging'] ); ?>,
370 "pagingType" : "<?php echo esc_js( $table_features['pagingType'] ); ?>",
371 "info" : <?php echo esc_js( $table_features['info'] ); ?>,
372 "colReorder" : <?php echo $table_features['colReorder']; // phpcs:ignore -- specical chars. ?>,
373 "scrollX" : <?php echo esc_js( $table_features['scrollX'] ); ?>,
374 "stateSave" : <?php echo esc_js( $table_features['stateSave'] ); ?>,
375 "order" : <?php echo $table_features['order']; // phpcs:ignore -- specical chars. ?>,
376 "fixedColumns" : <?php echo ! empty( $table_features['fixedColumns'] ) ? esc_js( $table_features['fixedColumns'] ) : '""'; ?>,
377 "lengthMenu" : [ [<?php echo esc_js( $pagelength_val ); ?>], [<?php echo esc_js( $pagelength_title ); ?>] ],
378 "serverSide": true,
379 "pageLength": <?php echo intval( $sites_per_page ); ?>,
380 "columnDefs": "[]",
381 "columns": [{"data":"status_details"}],
382 "language": {
383 "emptyTable": "<?php echo esc_html__( 'No sites found.', 'mainwp' ); ?>"
384 },
385 "drawCallback": function( settings ) {
386 setTimeout(() => {
387 jQuery( manage_tbl_id + ' .ui.dropdown').dropdown();
388 mainwp_datatable_fix_menu_overflow(manage_tbl_id, -60, -30);
389 }, 1000);
390 },
391 "initComplete": function( settings, json ) {
392 },
393 rowCallback: function (row, data) {
394 jQuery( row ).addClass(data.rowClass);
395 },
396 orderMulti: false,
397 searchDelay: <?php echo intval( $table_features['searchDelay'] ); ?>
398 })
399 } );
400 </script>
401 <?php
402 }
403
404
405 /**
406 * Echo the column headers.
407 *
408 * @return void
409 */
410 public static function get_columns() {
411 return array(
412 'status_details' => esc_html__( 'Detail', 'mainwp' ),
413 );
414 }
415
416 /**
417 * Echo the column headers.
418 *
419 * @return void
420 */
421 public static function print_column_headers() {
422
423 $columns = static::get_columns();
424
425 foreach ( $columns as $column_event_key => $column_display_name ) {
426
427 $class = array( 'manage-' . $column_event_key . '-column' );
428 $attr = '';
429
430 $class[] = 'no-sort';
431
432 $tag = 'th';
433 $id = "id='$column_event_key'";
434
435 if ( ! empty( $class ) ) {
436 $class = "class='" . join( ' ', $class ) . "'";
437 }
438
439 echo "<$tag $id $class $attr style=\"display:none;\">$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput
440 }
441 }
442
443 /**
444 * The renders the connections status tab.
445 *
446 * @param string $current_tab The current tab.
447 */
448 public function prepare_items( $current_tab ) {
449
450 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
451
452 if ( ! in_array( $current_tab, array( 'all-sites', 'connected', 'disconnected' ), true ) ) {
453 wp_die( wp_json_encode( array( 'error' => __( 'The selected site\'s status is invalid. Please try again.', 'mainwp' ) ) ) );
454 }
455
456 $per_page = isset( $_POST['per_page'] ) ? intval( wp_unslash( $_POST['per_page'] ) ) : 25; // phpcs:ignore -- NOSONAR - ok.
457 $page = isset( $_POST['page'] ) ? intval( wp_unslash( $_POST['page'] ) ) : 1; // phpcs:ignore -- NOSONAR - ok.
458
459 $req_order = null;
460
461 if ( isset( $_REQUEST['order'] ) ) {
462 $order_values = MainWP_Utility::instance()->get_table_orders( $_REQUEST );
463 $req_order = $order_values['order'];
464 }
465
466 $perPage = isset( $_REQUEST['length'] ) ? intval( $_REQUEST['length'] ) : 25;
467 $start = isset( $_REQUEST['start'] ) ? intval( $_REQUEST['start'] ) : 0;
468
469 // phpcs:enable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
470
471 $status = $current_tab;
472
473 if ( 'all-sites' === $status ) {
474 $status = 'any';
475 }
476
477 $wpsite_fields = array( 'id', 'name', 'url', 'adminname' );
478 $sync_fields = array( 'sync_errors', 'dtsSync' );
479
480 $args = array(
481 'select_wp_fields' => $wpsite_fields,
482 'select_sync_fields' => $sync_fields,
483 'status' => $status,
484 'offset' => $start,
485 'rowcount' => $perPage,
486 'orderby' => 'wp.id ' . ( 'asc' === $req_order ? 'asc' : 'desc' ),
487 'view' => 'custom_view',
488 'others_fields' => array(),
489 );
490
491 $results = MainWP_DB::instance()->query(
492 MainWP_DB::instance()->get_sql_websites_for_current_user_by_params(
493 apply_filters(
494 'mainwp_connection_status_widget_get_sites_query_params',
495 $args
496 )
497 )
498 );
499
500 $items = array();
501
502 while ( $results && $website = MainWP_DB::fetch_object( $results ) ) {
503 $items[] = $website;
504 }
505 MainWP_DB::free_result( $results );
506
507 $args['count_sql'] = true;
508
509 $total_sql = MainWP_DB::instance()->get_sql_websites_for_current_user_by_params(
510 apply_filters(
511 'mainwp_connection_status_widget_get_sites_query_params',
512 $args
513 )
514 );
515
516 $total_items = MainWP_DB::instance()->get_var_field( $total_sql );
517
518 $this->items = $items;
519 $this->total_items = $total_items ? (int) $total_items : 0;
520 unset( $items );
521 }
522
523
524 /**
525 * Method ajax_display_rows()
526 *
527 * Display table rows.
528 */
529 public function ajax_display_rows() {
530 MainWP_Post_Handler::instance()->check_security( 'mainwp_widgets_connections_status_details_display_rows' );
531 $current_tab = isset( $_POST['current_tab'] ) ? sanitize_text_field( wp_unslash( $_POST['current_tab'] ) ) : ''; // phpcs:ignore -- NOSONAR - ok.
532 $this->prepare_items( $current_tab );
533 $output = $this->ajax_get_datatable_rows( $current_tab );
534 wp_send_json( $output );
535 }
536
537 /**
538 * Get table rows.
539 *
540 * @param string $current_tab The current tab.
541 *
542 * @return array Rows html.
543 */
544 public function ajax_get_datatable_rows( $current_tab ) {
545
546 $all_rows = array();
547 $info_rows = array();
548
549 $columns = static::get_columns();
550
551 if ( $this->items ) {
552 foreach ( $this->items as $site ) {
553 $rw_classes = 'mainwp-connect-status-item-' . intval( $site->id );
554
555 $info_item = array(
556 'rowClass' => esc_html( $rw_classes ),
557 'site_id' => $site->id,
558 );
559
560 $cols_data = array();
561 foreach ( $columns as $column_name => $column_display_name ) {
562 ob_start();
563 echo $this->column_default( $site, $column_name, $current_tab ); // phpcs:ignore WordPress.Security.EscapeOutput
564 $cols_data[ $column_name ] = ob_get_clean();
565 }
566 $all_rows[] = $cols_data;
567 $info_rows[] = $info_item;
568 }
569 }
570 return array(
571 'data' => $all_rows,
572 'recordsTotal' => (int) $this->total_items,
573 'recordsFiltered' => (int) $this->total_items,
574 'rowsInfo' => $info_rows,
575 );
576 }
577
578 /**
579 * Returns the column content for the provided item and column.
580 *
581 * @param object $website Website data.
582 * @param string $column_name Column name.
583 * @param string $current_tab The current tab.
584 *
585 * @return string $out Output.
586 */
587 public function column_default( $website, $column_name, $current_tab ) { //phpcs:ignore -- NOSONAR -complex.
588
589 $status = $current_tab;
590
591 if ( 'all-sites' === $current_tab ) {
592 $status = 'any';
593 }
594
595 $SYNCERRORS = 'disconnected';
596 $UP = 'connected';
597 $ALL = 'any';
598
599 $output = '';
600 if ( 'status_details' === $column_name ) {
601 $hasSyncErrors = ( '' !== $website->sync_errors );
602 $lastSyncTime = ! empty( $website->dtsSync ) ? MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $website->dtsSync ) ) : '';
603
604 ob_start();
605
606 if ( $status === $ALL ) {
607 static::render_all_item( $website, $lastSyncTime, $hasSyncErrors );
608 } elseif ( $status === $UP ) {
609 static::render_up_item( $website, $lastSyncTime );
610 } elseif ( $status === $SYNCERRORS ) {
611 static::render_down_item( $website, $lastSyncTime );
612 }
613
614 /**
615 * Action: mainwp_connection_status_widget_bottom
616 *
617 * Fires at the bottom of the Connection Status widget.
618 *
619 * @since 4.1
620 */
621 do_action( 'mainwp_connection_status_widget_bottom' );
622
623 $output = ob_get_clean();
624 }
625
626 if ( empty( $output ) ) {
627 return '';
628 }
629 return $output; //phpcs:ignore -- escaped.
630 }
631
632
633
634 /**
635 * Render connection status summary section.
636 *
637 * @param int $count_connected Connected Count.
638 * @param int $count_disconnected Disconnected Count.
639 */
640 public static function render_multi_status( $count_connected, $count_disconnected ) {
641 ?>
642 <div class="ui mainwp-cards small cards">
643 <div class="ui card">
644 <div class="content">
645 <div class="header">
646 <span class="ui large text"><i class="ui een check icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( $count_connected ) ); ?></span>
647 </div>
648 <div class="description"><strong><?php esc_html_e( 'Connected Sites', 'mainwp' ); ?></strong></div>
649 </div>
650 </div>
651 <div class="ui card">
652 <div class="content">
653 <div class="header">
654 <span class="ui large text"><i class="ui unlink icon"></i> <?php echo esc_html( MainWP_Utility::short_number_format( $count_disconnected ) ); ?></span>
655 </div>
656 <div class="description"><strong><?php esc_html_e( 'Disconnected Sites', 'mainwp' ); ?></strong></div>
657 </div>
658 </div>
659 </div>
660 <?php
661 }
662
663 /**
664 * Render all items list.
665 *
666 * @param mixed $website Website Info.
667 * @param mixed $lastSyncTime Last time the Child Site was synced to.
668 * @param mixed $hasSyncErrors Collected errors.
669 */
670 public static function render_all_item( $website, $lastSyncTime, $hasSyncErrors ) {
671 ?>
672 <div class="item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( $website->name ) ); ?>">
673 <div class="right floated">
674 <div class="ui right pointing dropdown">
675 <i class="ellipsis vertical icon"></i>
676 <div class="menu">
677 <?php if ( $hasSyncErrors ) : ?>
678 <a href="javascript:void(0)" class="mainwp-updates-overview-reconnect-site item" adminuser="<?php echo esc_attr( $website->adminname ); ?>" siteid="<?php echo intval( $website->id ); ?>"><?php esc_html_e( 'Reconnect Site', 'mainwp' ); ?></a>
679 <?php else : ?>
680 <a href="javascript:void(0)" class="item" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )"><?php esc_html_e( 'Sync Site', 'mainwp' ); ?></a>
681 <a href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); ?>" target="_blank" class="item"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
682 <?php endif; ?>
683 <a href="<?php echo esc_html( $website->url ); ?>" class="item" target="_blank"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
684 </div>
685 </div>
686 </div>
687 <?php if ( ! $hasSyncErrors ) : ?>
688 <a href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); ?>" target="_blank"><i class="sign in alternate icon"></i></a>
689 <?php endif; ?>
690 <a href="
691 <?php
692 /**
693 * Filter: mainwp_connection_status_list_item_title_url
694 *
695 * Filters the Connection Status widget list item title URL.
696 *
697 * @since 4.1
698 */
699 echo esc_url( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) );
700 ?>
701 ">
702 <?php
703 /**
704 * Filter: mainwp_connection_status_list_item_title
705 *
706 * Filters the Connection Status widget list item title text.
707 *
708 * @since 4.1
709 */
710 echo esc_html( stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ) );
711 ?>
712 </a>
713 <?php if ( $hasSyncErrors ) : ?>
714 <span class="ui mini red label"><?php esc_html_e( 'Disconnected', 'mainwp' ); ?></span>
715 <?php endif; ?>
716 <br/><span class="ui small text"><?php esc_html_e( 'Last synced: ', 'mainwp' ); ?> <?php echo esc_html( $lastSyncTime ); ?></span>
717 </div>
718
719 <?php
720 }
721
722 /**
723 * Render Connected Sites List.
724 *
725 * @param object $website Object containing the child site info.
726 * @param string $lastSyncTime Last time the Child Site was synced to.
727 */
728 public static function render_up_item( $website, $lastSyncTime ) {
729 ?>
730 <div class="item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( $website->name ) ); ?>">
731 <div class="right floated">
732 <div class="ui right pointing dropdown">
733 <i class="ellipsis vertical icon"></i>
734 <div class="menu">
735 <a href="javascript:void(0)" class="item" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )"><?php esc_html_e( 'Sync Site', 'mainwp' ); ?></a>
736 <a href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); ?>" target="_blank" class="item"><?php esc_html_e( 'Go to WP Admin', 'mainwp' ); ?></a>
737 <a href="<?php echo esc_html( $website->url ); ?>" class="item" target="_blank"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
738 </div>
739 </div>
740 </div>
741 <a href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); ?>" target="_blank"><i class="sign in alternate icon"></i></a>
742 <a href="
743 <?php
744 /**
745 * Filter: mainwp_connection_status_list_item_title_url
746 *
747 * Filters the Connection Status widget list item title URL.
748 *
749 * @since 4.1
750 */
751 echo esc_url( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) );
752 ?>
753 ">
754 <?php
755 /**
756 * Filter: mainwp_connection_status_list_item_title
757 *
758 * Filters the Connection Status widget list item title text.
759 *
760 * @since 4.1
761 */
762 echo esc_html( stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ) );
763 ?>
764 </a>
765 <br/><span class="ui small text"><?php esc_html_e( 'Last synced: ', 'mainwp' ); ?> <?php echo esc_html( $lastSyncTime ); ?></span>
766 </div>
767
768 <?php
769 }
770
771 /**
772 * Render Disconected Sites List.
773 *
774 * @param object $website Object containing the child site info.
775 * @param string $lastSyncTime Last time the Child Site was synced to.
776 */
777 public static function render_down_item( $website, $lastSyncTime ) {
778 ?>
779 <div class="red item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( $website->name ) ); ?>">
780 <div class="right floated">
781 <div class="ui right pointing dropdown">
782 <i class="ellipsis vertical icon"></i>
783 <div class="menu">
784 <a href="javascript:void(0)" class="mainwp-updates-overview-reconnect-site item" adminuser="<?php echo esc_attr( $website->adminname ); ?>" siteid="<?php echo intval( $website->id ); ?>"><?php esc_html_e( 'Reconnect Site', 'mainwp' ); ?></a>
785 <a href="<?php echo esc_html( $website->url ); ?>" class="item" target="_blank"><?php esc_html_e( 'Visit Site', 'mainwp' ); ?></a>
786 </div>
787 </div>
788 </div>
789 <a href="
790 <?php
791 /**
792 * Filter: mainwp_connection_status_list_item_title_url
793 *
794 * Filters the Connection Status widget list item title URL.
795 *
796 * @since 4.1
797 */
798 echo esc_url( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) );
799 ?>
800 ">
801 <?php
802 /**
803 * Filter: mainwp_connection_status_list_item_title
804 *
805 * Filters the Connection Status widget list item title text.
806 *
807 * @since 4.1
808 */
809 echo esc_html( stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ) );
810 ?>
811 </a>
812 <span class="ui mini red label"><?php esc_html_e( 'Disconnected', 'mainwp' ); ?></span>
813 <br/><span class="ui small text"><?php esc_html_e( 'Last synced: ', 'mainwp' ); ?> <?php echo esc_html( $lastSyncTime ); ?></span>
814 </div>
815
816 <?php
817 }
818 }
819