| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Connection Status |
| 4 |
* |
| 5 |
* Build the MainWP Overview page Connection Status Widget. |
| 6 |
* |
| 7 |
* @package MainWP/Dashboard |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class MainWP_Connection_Status |
| 14 |
* |
| 15 |
* Build the Connection Status Widget. |
| 16 |
*/ |
| 17 |
class MainWP_Connection_Status { |
| 18 |
|
| 19 |
/** |
| 20 |
* Method get_class_name() |
| 21 |
* |
| 22 |
* @return string __CLASS__ Class Name |
| 23 |
*/ |
| 24 |
public static function get_class_name() { |
| 25 |
return __CLASS__; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Method render() |
| 30 |
* |
| 31 |
* @return mixed render_sites() |
| 32 |
*/ |
| 33 |
public static function render() { |
| 34 |
self::render_sites(); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Method render_sites() |
| 39 |
* |
| 40 |
* Build the Connection Status Widget |
| 41 |
* Displays $SYNCERRORS|$UP|$ALL. |
| 42 |
* |
| 43 |
* @uses \MainWP\Dashboard\MainWP_DB::query() |
| 44 |
* @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_by_id() |
| 45 |
* @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_id() |
| 46 |
* @uses \MainWP\Dashboard\MainWP_DB::get_sql_search_websites_for_current_user() |
| 47 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 48 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 49 |
* @uses \MainWP\Dashboard\MainWP_DB::free_result() |
| 50 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid() |
| 51 |
* @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() |
| 52 |
* @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp() |
| 53 |
*/ |
| 54 |
public static function render_sites() { // phpcs:ignore -- current complexity required to achieve desired results. Pull request solutions appreciated. |
| 55 |
$current_wpid = MainWP_System_Utility::get_current_wpid(); |
| 56 |
|
| 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 |
} |
| 62 |
|
| 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 |
$md5Connection = ( 1 == $website->nossl ); |
| 89 |
|
| 90 |
if ( $j != $ALL ) { |
| 91 |
if ( $j == $SYNCERRORS ) { |
| 92 |
if ( ! $hasSyncErrors ) { |
| 93 |
continue; |
| 94 |
} |
| 95 |
} |
| 96 |
if ( $j == $UP ) { |
| 97 |
if ( ! $isUp ) { |
| 98 |
continue; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
$output_md5 = ''; |
| 104 |
if ( $md5Connection ) { |
| 105 |
$output_md5 = '<div>' . __( 'MD5 Connection' ) . '<br /><a href="https://kb.mainwp.com/docs/md5-connection-issue/" class="ui button mini green basic" target="_blank" data-tooltip="MD5 Connection" data-inverted="">' . __( 'Read More', 'mainwp' ) . '</a></div>'; |
| 106 |
} |
| 107 |
|
| 108 |
$lastSyncTime = ! empty( $website->dtsSync ) ? MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $website->dtsSync ) ) : ''; |
| 109 |
|
| 110 |
ob_start(); |
| 111 |
|
| 112 |
if ( $j == $ALL ) { |
| 113 |
self::render_all_item( $website, $lastSyncTime, $md5Connection, $output_md5, $hasSyncErrors ); |
| 114 |
} elseif ( $j == $UP ) { |
| 115 |
self::render_up_item( $website, $lastSyncTime, $md5Connection, $output_md5 ); |
| 116 |
} else { |
| 117 |
self::render_down_item( $website, $lastSyncTime, $md5Connection, $output_md5 ); |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Action: mainwp_connection_status_widget_bottom |
| 122 |
* |
| 123 |
* Fires at the bottom of the Connection Status widget. |
| 124 |
* |
| 125 |
* @since 4.1 |
| 126 |
*/ |
| 127 |
do_action( 'mainwp_connection_status_widget_bottom' ); |
| 128 |
|
| 129 |
$output = ob_get_clean(); |
| 130 |
|
| 131 |
if ( $j == $ALL ) { |
| 132 |
$html_all_sites .= $output; |
| 133 |
} elseif ( $j == $UP ) { |
| 134 |
$html_online_sites .= $output; |
| 135 |
$count_connected++; |
| 136 |
} elseif ( ! in_array( $website->id, $disconnect_site_ids ) ) { |
| 137 |
$disconnect_site_ids[] = $website->id; |
| 138 |
$html_other_sites .= $output; |
| 139 |
$count_disconnected++; |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
MainWP_DB::free_result( $websites ); |
| 145 |
|
| 146 |
self::render_status( $current_wpid ); |
| 147 |
|
| 148 |
if ( empty( $current_wpid ) ) { |
| 149 |
self::render_multi_status( $count_connected, $count_disconnected ); |
| 150 |
} else { |
| 151 |
// Get site by ID $current_wpid. |
| 152 |
$site = MainWP_DB::instance()->get_website_by_id( $current_wpid ); |
| 153 |
self::render_current_status( $site, $count_connected ); |
| 154 |
} |
| 155 |
|
| 156 |
self::render_details( $html_all_sites, $html_online_sites, $html_other_sites ); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* The renders the MainWP Overview page Connection Status Widget Header and Drop down Box. |
| 161 |
* |
| 162 |
* @param mixed $current_wpid Current Website ID. |
| 163 |
*/ |
| 164 |
public static function render_status( $current_wpid ) { |
| 165 |
?> |
| 166 |
<div class="ui grid"> |
| 167 |
<div class="twelve wide column"> |
| 168 |
<h3 class="ui header handle-drag"> |
| 169 |
<?php |
| 170 |
/** |
| 171 |
* Filter: mainwp_connection_status_widget_title |
| 172 |
* |
| 173 |
* Filters the Connection Status widget title text. |
| 174 |
* |
| 175 |
* @since 4.1 |
| 176 |
*/ |
| 177 |
echo esc_html( apply_filters( 'mainwp_connection_status_widget_title', __( 'Connection Status', 'mainwp' ) ) ); |
| 178 |
?> |
| 179 |
<div class="sub header"><?php esc_html_e( 'Child sites connection status', 'mainwp' ); ?></div> |
| 180 |
</h3> |
| 181 |
</div> |
| 182 |
<?php if ( empty( $current_wpid ) ) { ?> |
| 183 |
<div class="four wide column right aligned"> |
| 184 |
<div id="widget-connect-status-dropdown-selector" class="ui dropdown top right pointing not-auto-init mainwp-dropdown-tab"> |
| 185 |
<div class="text"><?php esc_html_e( 'All Sites', 'mainwp' ); ?></div> |
| 186 |
<i class="dropdown icon"></i> |
| 187 |
<div class="menu"> |
| 188 |
<a class="active item" data-tab="no-sites" data-value="" 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> |
| 189 |
<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( 'See All Sites', 'mainwp' ); ?></a> |
| 190 |
<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( 'See All Connected', 'mainwp' ); ?></a> |
| 191 |
<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( 'See All Disconnected', 'mainwp' ); ?></a> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
|
| 196 |
<script type="text/javascript"> |
| 197 |
jQuery( document ).ready( function () { |
| 198 |
jQuery( '#widget-connect-status-dropdown-selector' ).dropdown( { |
| 199 |
onChange: function( val ) { |
| 200 |
if ( typeof( Storage ) !== 'undefined' ) { |
| 201 |
localStorage.setItem( 'lsWidgetConnectStatusDropdownVal', val ); |
| 202 |
} |
| 203 |
} |
| 204 |
} ); |
| 205 |
if ( typeof( Storage ) !== "undefined" ) { |
| 206 |
if ( val = localStorage.getItem( 'lsWidgetConnectStatusDropdownVal' ) ) { |
| 207 |
jQuery( '#widget-connect-status-dropdown-selector' ).dropdown( 'set selected',val ); |
| 208 |
jQuery( '#widget-connect-status-dropdown-selector' ).closest( '.mainwp-widget' ).find( 'div[data-tab="' + val + '"]' ).addClass( 'active' ); |
| 209 |
} |
| 210 |
} |
| 211 |
} ); |
| 212 |
</script> |
| 213 |
|
| 214 |
<?php } ?> |
| 215 |
</div> |
| 216 |
<div class="ui hidden divider"></div> |
| 217 |
<?php |
| 218 |
/** |
| 219 |
* Action: mainwp_connection_status_widget_top |
| 220 |
* |
| 221 |
* Fires at the top of the Connection Status widget. |
| 222 |
* |
| 223 |
* @since 4.1 |
| 224 |
*/ |
| 225 |
do_action( 'mainwp_connection_status_widget_top' ); |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 229 |
* Render the MainWP Overview page Conection Status Widget Content. |
| 230 |
* |
| 231 |
* @param mixed $site Site list. |
| 232 |
* @param mixed $count_connected Connection Count. |
| 233 |
*/ |
| 234 |
public static function render_current_status( $site, $count_connected ) { |
| 235 |
/** |
| 236 |
* Action: mainwp_connection_status_widget_single_top |
| 237 |
* |
| 238 |
* Fires at the top of the Connection Status widget. |
| 239 |
* |
| 240 |
* @param object $site Object containing the child site info. |
| 241 |
* |
| 242 |
* @since 4.1 |
| 243 |
*/ |
| 244 |
do_action( 'mainwp_connection_status_widget_single_top', $site ); |
| 245 |
if ( $count_connected > 0 ) : |
| 246 |
?> |
| 247 |
<div class="ui two column stackable grid"> |
| 248 |
<div class="column left aligned"> |
| 249 |
<h2 class="ui header"> |
| 250 |
<i class="green check icon"></i> |
| 251 |
<div class="content"><?php esc_html_e( 'Connected', 'mainwp' ); ?></div> |
| 252 |
</h2> |
| 253 |
</div> |
| 254 |
<div class="column right aligned"> |
| 255 |
<a href="<?php echo $site->url; ?>" class="ui icon mini button" target="_blank" data-tooltip="<?php esc_html_e( 'Go to the site front page', 'mainwp' ); ?>" data-inverted=""><i class="external alternate icon"></i></a> |
| 256 |
<a href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $site->id; ?>" class="ui icon mini button" target="_blank" data-tooltip="<?php esc_html_e( 'Go to the site WP Admin', 'mainwp' ); ?>" data-inverted=""><i class="sign in alternate icon"></i></a> |
| 257 |
<a href="javascript:void(0)" class="ui button mini green" siteid="<?php echo $site->id; ?>" onClick="updatesoverview_wp_sync( '<?php echo $site->id; ?>' )" data-tooltip="Sync <?php echo stripslashes( $site->name ); ?> data." data-inverted=""><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a> |
| 258 |
</div> |
| 259 |
</div> |
| 260 |
<?php else : ?> |
| 261 |
<div class="ui two column stackable grid mainwp_wp_sync" site_id="<?php echo $site->id; ?>"> |
| 262 |
<div class="column left aligned"> |
| 263 |
<h2 class="ui header"> |
| 264 |
<i class="red unlink icon"></i> |
| 265 |
<div class="content"><?php esc_html_e( 'Disconnected', 'mainwp' ); ?></div> |
| 266 |
</h2> |
| 267 |
</div> |
| 268 |
<div class="column right aligned"> |
| 269 |
<a href="<?php echo $site->url; ?>" class="ui icon mini button" target="_blank" data-tooltip="<?php esc_html_e( 'Go to the site front page', 'mainwp' ); ?>" data-inverted=""><i class="external alternate icon"></i></a> |
| 270 |
<a href="#" class="mainwp-updates-overview-reconnect-site ui mini green basic button" siteid="<?php echo $site->id; ?>" data-tooltip="Reconnect <?php echo stripslashes( $site->name ); ?>" data-inverted=""><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a> |
| 271 |
</div> |
| 272 |
</div> |
| 273 |
<?php |
| 274 |
endif; |
| 275 |
/** |
| 276 |
* Action: mainwp_connection_status_widget_single_bottom |
| 277 |
* |
| 278 |
* Fires at the bottom of the Connection Status widget. |
| 279 |
* |
| 280 |
* @param object $site Object containing the child site info. |
| 281 |
* |
| 282 |
* @since 4.1 |
| 283 |
*/ |
| 284 |
do_action( 'mainwp_connection_status_widget_single_bottom', $site ); |
| 285 |
} |
| 286 |
|
| 287 |
/** |
| 288 |
* Render connection status summary section. |
| 289 |
* |
| 290 |
* @param int $count_connected Connected Count. |
| 291 |
* @param int $count_disconnected Disconnected Count. |
| 292 |
*/ |
| 293 |
public static function render_multi_status( $count_connected, $count_disconnected ) { |
| 294 |
?> |
| 295 |
<div class="ui two column stackable grid"> |
| 296 |
<div class="column center aligned"> |
| 297 |
<div class="ui horizontal statistics large"> |
| 298 |
<div class="green statistic"> |
| 299 |
<div class="value"> |
| 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 ); ?></a> |
| 301 |
</div> |
| 302 |
<div class="label"> |
| 303 |
<?php esc_html_e( 'Connected', 'mainwp' ); ?> |
| 304 |
</div> |
| 305 |
</div> |
| 306 |
</div> |
| 307 |
</div> |
| 308 |
<div class="column center aligned"> |
| 309 |
<div class="ui horizontal statistics large"> |
| 310 |
<div class="<?php echo ( 0 < $count_disconnected ) ? 'red' : 'green'; ?> statistic"> |
| 311 |
<div class="value"> |
| 312 |
<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 ); ?></a> |
| 313 |
</div> |
| 314 |
<div class="label"> |
| 315 |
<?php esc_html_e( 'Disconnected', 'mainwp' ); ?> |
| 316 |
</div> |
| 317 |
</div> |
| 318 |
</div> |
| 319 |
</div> |
| 320 |
</div> |
| 321 |
<?php |
| 322 |
} |
| 323 |
|
| 324 |
/** |
| 325 |
* Render See All Sites List. |
| 326 |
* |
| 327 |
* @param mixed $html_all_sites All sites html. |
| 328 |
* @param mixed $html_online_sites Online sites html. |
| 329 |
* @param mixed $html_other_sites Other sites html. |
| 330 |
*/ |
| 331 |
public static function render_details( $html_all_sites, $html_online_sites, $html_other_sites ) { |
| 332 |
?> |
| 333 |
<div class="ui hidden divider"></div> |
| 334 |
|
| 335 |
<div class="ui active tab" data-tab="no-sites"></div> |
| 336 |
|
| 337 |
<div class="ui tab" data-tab="all-sites"> |
| 338 |
<?php |
| 339 |
/** |
| 340 |
* Action: mainwp_connection_status_before_all_sites_list |
| 341 |
* |
| 342 |
* Fires before the list of all sites in the connection status widgets |
| 343 |
* |
| 344 |
* @since 4.1 |
| 345 |
*/ |
| 346 |
do_action( 'mainwp_connection_status_before_all_sites_list' ) |
| 347 |
?> |
| 348 |
<div class="ui middle aligned divided selection list"> |
| 349 |
<?php echo $html_all_sites; ?> |
| 350 |
</div> |
| 351 |
<?php |
| 352 |
/** |
| 353 |
* Action: mainwp_connection_status_after_all_sites_list |
| 354 |
* |
| 355 |
* Fires after the list of all sites in the connection status widgets |
| 356 |
* |
| 357 |
* @since 4.1 |
| 358 |
*/ |
| 359 |
do_action( 'mainwp_connection_status_after_all_sites_list' ) |
| 360 |
?> |
| 361 |
</div> |
| 362 |
|
| 363 |
<div class="ui tab" data-tab="connected"> |
| 364 |
<?php |
| 365 |
/** |
| 366 |
* Action: mainwp_connection_status_before_connected_sites_list |
| 367 |
* |
| 368 |
* Fires before the list of connected sites in the connection status widgets |
| 369 |
* |
| 370 |
* @since 4.1 |
| 371 |
*/ |
| 372 |
do_action( 'mainwp_connection_status_before_connected_sites_list' ) |
| 373 |
?> |
| 374 |
<div class="ui middle aligned divided selection list"> |
| 375 |
<?php echo $html_online_sites; ?> |
| 376 |
</div> |
| 377 |
<?php |
| 378 |
/** |
| 379 |
* Action: mainwp_connection_status_after_connected_sites_list |
| 380 |
* |
| 381 |
* Fires after the list of connected sites in the connection status widgets |
| 382 |
* |
| 383 |
* @since 4.1 |
| 384 |
*/ |
| 385 |
do_action( 'mainwp_connection_status_after_connected_sites_list' ) |
| 386 |
?> |
| 387 |
</div> |
| 388 |
|
| 389 |
<div class="ui tab" data-tab="disconnected"> |
| 390 |
<?php |
| 391 |
/** |
| 392 |
* Action: mainwp_connection_status_before_disconnected_sites_list |
| 393 |
* |
| 394 |
* Fires before the list of disconnected sites in the connection status widgets |
| 395 |
* |
| 396 |
* @since 4.1 |
| 397 |
*/ |
| 398 |
do_action( 'mainwp_connection_status_before_disconnected_sites_list' ) |
| 399 |
?> |
| 400 |
<div class="ui middle aligned divided selection list"> |
| 401 |
<?php echo $html_other_sites; ?> |
| 402 |
</div> |
| 403 |
<?php |
| 404 |
/** |
| 405 |
* Action: mainwp_connection_status_after_disconnected_sites_list |
| 406 |
* |
| 407 |
* Fires after the list of disconnected sites in the connection status widgets |
| 408 |
* |
| 409 |
* @since 4.1 |
| 410 |
*/ |
| 411 |
do_action( 'mainwp_connection_status_after_disconnected_sites_list' ) |
| 412 |
?> |
| 413 |
</div> |
| 414 |
<?php |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
/** |
| 419 |
* Render all items list. |
| 420 |
* |
| 421 |
* @param mixed $website Website Info. |
| 422 |
* @param mixed $lastSyncTime Last time the Child Site was synced to. |
| 423 |
* @param mixed $md5Connection md5 Connection. |
| 424 |
* @param mixed $output_md5 md5 decoded output. |
| 425 |
* @param mixed $hasSyncErrors Collected errors. |
| 426 |
*/ |
| 427 |
public static function render_all_item( $website, $lastSyncTime, $md5Connection, $output_md5, $hasSyncErrors ) { |
| 428 |
?> |
| 429 |
<div class="item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo rawurlencode( $website->name ); ?>"> |
| 430 |
<div class="ui grid"> |
| 431 |
<div class="six wide column middle aligned"> |
| 432 |
<a href=" |
| 433 |
<?php |
| 434 |
/** |
| 435 |
* Filter: mainwp_connection_status_list_item_title_url |
| 436 |
* |
| 437 |
* Filters the Connection Status widget list item title URL. |
| 438 |
* |
| 439 |
* @since 4.1 |
| 440 |
*/ |
| 441 |
echo esc_attr( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) ); |
| 442 |
?> |
| 443 |
"> |
| 444 |
<?php |
| 445 |
/** |
| 446 |
* Filter: mainwp_connection_status_list_item_title |
| 447 |
* |
| 448 |
* Filters the Connection Status widget list item title text. |
| 449 |
* |
| 450 |
* @since 4.1 |
| 451 |
*/ |
| 452 |
echo stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ); |
| 453 |
?> |
| 454 |
</a> |
| 455 |
</div> |
| 456 |
<div class="one wide column middle aligned"> |
| 457 |
<a href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website->id; ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site WP Admin', 'mainwp' ); ?>" data-inverted=""><i class="sign in alternate icon"></i></a> |
| 458 |
</div> |
| 459 |
<div class="one wide column middle aligned"> |
| 460 |
<a href="<?php echo esc_html( $website->url ); ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site front page', 'mainwp' ); ?>" data-inverted=""><i class="external alternate icon"></i></a> |
| 461 |
</div> |
| 462 |
<div class="four wide column middle aligned"> |
| 463 |
<span><?php echo esc_attr( $lastSyncTime ); ?></span> |
| 464 |
</div> |
| 465 |
<div class="four wide column middle aligned right aligned reconnect-wrapper"> |
| 466 |
<?php |
| 467 |
if ( $md5Connection ) { |
| 468 |
echo $output_md5; |
| 469 |
} elseif ( $hasSyncErrors ) { |
| 470 |
?> |
| 471 |
<a href="javascript:void(0)" class="mainwp-updates-overview-reconnect-site ui button mini green basic" siteid="<?php echo intval( $website->id ); ?>" data-tooltip="Reconnect <?php echo stripslashes( $website->name ); ?>." data-inverted=""><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a> |
| 472 |
<?php |
| 473 |
} else { |
| 474 |
?> |
| 475 |
<a href="javascript:void(0)" class="ui button mini green" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )" data-tooltip="Sync <?php echo stripslashes( $website->name ); ?> data." data-inverted=""><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a> |
| 476 |
<?php |
| 477 |
} |
| 478 |
?> |
| 479 |
</div> |
| 480 |
</div> |
| 481 |
</div> |
| 482 |
<?php |
| 483 |
} |
| 484 |
|
| 485 |
/** |
| 486 |
* Render Connected Sites List. |
| 487 |
* |
| 488 |
* @param object $website Object containing the child site info. |
| 489 |
* @param string $lastSyncTime Last time the Child Site was synced to. |
| 490 |
* @param bool $md5Connection MD5 connection. |
| 491 |
* @param string $output_md5 MD5 decoded output. |
| 492 |
*/ |
| 493 |
public static function render_up_item( $website, $lastSyncTime, $md5Connection, $output_md5 ) { |
| 494 |
?> |
| 495 |
<div class="item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo rawurlencode( $website->name ); ?>"> |
| 496 |
<div class="ui grid"> |
| 497 |
<div class="six wide column middle aligned"> |
| 498 |
<a href=" |
| 499 |
<?php |
| 500 |
/** |
| 501 |
* Filter: mainwp_connection_status_list_item_title_url |
| 502 |
* |
| 503 |
* Filters the Connection Status widget list item title URL. |
| 504 |
* |
| 505 |
* @since 4.1 |
| 506 |
*/ |
| 507 |
echo esc_attr( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) ); |
| 508 |
?> |
| 509 |
"> |
| 510 |
<?php |
| 511 |
/** |
| 512 |
* Filter: mainwp_connection_status_list_item_title |
| 513 |
* |
| 514 |
* Filters the Connection Status widget list item title text. |
| 515 |
* |
| 516 |
* @since 4.1 |
| 517 |
*/ |
| 518 |
echo stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ); |
| 519 |
?> |
| 520 |
</a> |
| 521 |
</div> |
| 522 |
<div class="one wide column middle aligned"> |
| 523 |
<a href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website->id; ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site WP Admin', 'mainwp' ); ?>" data-inverted=""><i class="sign in alternate icon"></i></a> |
| 524 |
</div> |
| 525 |
<div class="one wide column middle aligned"> |
| 526 |
<a href="<?php echo esc_html( $website->url ); ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site front page', 'mainwp' ); ?>" data-inverted=""><i class="external alternate icon"></i></a> |
| 527 |
</div> |
| 528 |
<div class="four wide column middle aligned"> |
| 529 |
<span><?php echo esc_attr( $lastSyncTime ); ?></span> |
| 530 |
</div> |
| 531 |
<div class="four wide column middle aligned right aligned"> |
| 532 |
<?php |
| 533 |
if ( $md5Connection ) { |
| 534 |
echo $output_md5; |
| 535 |
} else { |
| 536 |
?> |
| 537 |
<a href="javascript:void(0)" class="ui button mini green" siteid="<?php echo intval( $website->id ); ?>" onClick="updatesoverview_wp_sync( '<?php echo intval( $website->id ); ?>' )" data-tooltip="Sync <?php echo stripslashes( $website->name ); ?> data." data-inverted=""><?php esc_html_e( 'Sync Data', 'mainwp' ); ?></a> |
| 538 |
<?php |
| 539 |
} |
| 540 |
?> |
| 541 |
</div> |
| 542 |
</div> |
| 543 |
</div> |
| 544 |
<?php |
| 545 |
} |
| 546 |
|
| 547 |
/** |
| 548 |
* Render Disconected Sites List. |
| 549 |
* |
| 550 |
* @param object $website Object containing the child site info. |
| 551 |
* @param string $lastSyncTime Last time the Child Site was synced to. |
| 552 |
* @param bool $md5Connection MD5 connection. |
| 553 |
* @param string $output_md5 MD5 decoded output. |
| 554 |
*/ |
| 555 |
public static function render_down_item( $website, $lastSyncTime, $md5Connection, $output_md5 ) { |
| 556 |
?> |
| 557 |
<div class="item mainwp_wp_sync" site_id="<?php echo intval( $website->id ); ?>" site_name="<?php echo rawurlencode( $website->name ); ?>"> |
| 558 |
<div class="ui grid"> |
| 559 |
<div class="six wide column middle aligned"> |
| 560 |
<a href=" |
| 561 |
<?php |
| 562 |
/** |
| 563 |
* Filter: mainwp_connection_status_list_item_title_url |
| 564 |
* |
| 565 |
* Filters the Connection Status widget list item title URL. |
| 566 |
* |
| 567 |
* @since 4.1 |
| 568 |
*/ |
| 569 |
echo esc_attr( apply_filters( 'mainwp_connection_status_list_item_title_url', 'admin.php?page=managesites&dashboard=' . $website->id, $website ) ); |
| 570 |
?> |
| 571 |
"> |
| 572 |
<?php |
| 573 |
/** |
| 574 |
* Filter: mainwp_connection_status_list_item_title |
| 575 |
* |
| 576 |
* Filters the Connection Status widget list item title text. |
| 577 |
* |
| 578 |
* @since 4.1 |
| 579 |
*/ |
| 580 |
echo stripslashes( apply_filters( 'mainwp_connection_status_list_item_title', $website->name, $website ) ); |
| 581 |
?> |
| 582 |
</a> |
| 583 |
</div> |
| 584 |
<div class="one wide column middle aligned"> |
| 585 |
<a href="<?php echo 'admin.php?page=SiteOpen&newWindow=yes&websiteid=' . $website->id; ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site WP Admin', 'mainwp' ); ?>" data-inverted=""><i class="sign in alternate icon"></i></a> |
| 586 |
</div> |
| 587 |
<div class="one wide column middle aligned"> |
| 588 |
<a href="<?php echo esc_html( $website->url ); ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to the site front page', 'mainwp' ); ?>" data-inverted=""><i class="external alternate icon"></i></a> |
| 589 |
</div> |
| 590 |
<div class="four wide column middle aligned"> |
| 591 |
<span><?php echo esc_attr( $lastSyncTime ); ?></span> |
| 592 |
</div> |
| 593 |
<div class="four wide column middle aligned right aligned reconnect-wrapper"> |
| 594 |
<?php |
| 595 |
if ( $md5Connection ) { |
| 596 |
echo $output_md5; |
| 597 |
} else { |
| 598 |
?> |
| 599 |
<a href="#" class="mainwp-updates-overview-reconnect-site" siteid="<?php echo intval( $website->id ); ?>" data-tooltip="Reconnect <?php echo stripslashes( $website->name ); ?>" data-inverted=""><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a> |
| 600 |
<?php |
| 601 |
} |
| 602 |
?> |
| 603 |
</div> |
| 604 |
</div> |
| 605 |
</div> |
| 606 |
<?php |
| 607 |
} |
| 608 |
|
| 609 |
} |
| 610 |
|