get_sql_websites_for_current_user(); $websites = MainWP_DB::instance()->query( $sql ); $count_connected = 0; $count_disconnected = 0; // Loop 3 times. $SYNCERRORS = 0; $UP = 1; $ALL = 2; $html_online_sites = ''; $html_other_sites = ''; $html_all_sites = ''; $disconnect_site_ids = array(); for ( $j = 0; $j < 3; $j++ ) { MainWP_DB::data_seek( $websites, 0 ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( empty( $website ) ) { continue; } $hasSyncErrors = ( '' !== $website->sync_errors ); $isUp = ! $hasSyncErrors; if ( $j !== $ALL ) { if ( $j === $SYNCERRORS && ! $hasSyncErrors ) { continue; } if ( $j === $UP && ! $isUp ) { continue; } } $lastSyncTime = ! empty( $website->dtsSync ) ? MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $website->dtsSync ) ) : ''; ob_start(); if ( $j === $ALL ) { static::render_all_item( $website, $lastSyncTime, $hasSyncErrors ); } elseif ( $j === $UP ) { static::render_up_item( $website, $lastSyncTime ); } else { static::render_down_item( $website, $lastSyncTime ); } /** * Action: mainwp_connection_status_widget_bottom * * Fires at the bottom of the Connection Status widget. * * @since 4.1 */ do_action( 'mainwp_connection_status_widget_bottom' ); $output = ob_get_clean(); if ( $j === $ALL ) { $html_all_sites .= $output; } elseif ( $j === $UP ) { $html_online_sites .= $output; ++$count_connected; } elseif ( ! in_array( $website->id, $disconnect_site_ids ) ) { $disconnect_site_ids[] = $website->id; $html_other_sites .= $output; ++$count_disconnected; } } } MainWP_DB::free_result( $websites ); static::render_status( $count_connected, $count_disconnected ); static::render_details( $html_all_sites, $html_online_sites, $html_other_sites ); MainWP_UI::render_modal_reconnect(); } /** * The renders the MainWP Overview page Connection Status Widget Header and Drop down Box. * * @param int $count_connected Number of connected sites. * @param int $count_disconnected Number of disconnected sites. */ public static function render_status( $count_connected, $count_disconnected ) { ?>