get_sql_website_by_id( $current_wpid ); } else { $sql = MainWP_DB::instance()->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 ) { if ( ! $hasSyncErrors ) { continue; } } if ( $j === $UP ) { if ( ! $isUp ) { continue; } } } $lastSyncTime = ! empty( $website->dtsSync ) ? MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $website->dtsSync ) ) : ''; ob_start(); if ( $j === $ALL ) { self::render_all_item( $website, $lastSyncTime, $hasSyncErrors ); } elseif ( $j === $UP ) { self::render_up_item( $website, $lastSyncTime ); } else { self::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 ); self::render_status( $current_wpid ); if ( empty( $current_wpid ) ) { self::render_multi_status( $count_connected, $count_disconnected ); } else { // Get site by ID $current_wpid. $site = MainWP_DB::instance()->get_website_by_id( $current_wpid ); self::render_current_status( $site, $count_connected ); } self::render_details( $html_all_sites, $html_online_sites, $html_other_sites ); } /** * The renders the MainWP Overview page Connection Status Widget Header and Drop down Box. * * @param mixed $current_wpid Current Website ID. */ public static function render_status( $current_wpid ) { ?>
0 ) : ?>