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