| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Manage Screenshots. |
| 4 |
* |
| 5 |
* @package MainWP/Dashboard |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace MainWP\Dashboard; |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Class MainWP_Manage_Screenshots |
| 17 |
* |
| 18 |
* @package MainWP\Dashboard |
| 19 |
*/ |
| 20 |
class MainWP_Manage_Screenshots { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| 21 |
|
| 22 |
/** |
| 23 |
* Get Class Name |
| 24 |
* |
| 25 |
* @return string __CLASS__ |
| 26 |
*/ |
| 27 |
public static function get_class_name() { |
| 28 |
return __CLASS__; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* MainWP_Manage_Screenshots constructor. |
| 33 |
* |
| 34 |
* Run each time the class is called. |
| 35 |
* Add action to generate tabletop. |
| 36 |
*/ |
| 37 |
public function __construct() { |
| 38 |
add_action( 'mainwp_managesites_tabletop', array( &$this, 'generate_tabletop' ) ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Method get_instance(). |
| 43 |
*/ |
| 44 |
public static function get_instance() { |
| 45 |
return new self(); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Method generate_tabletop() |
| 50 |
* |
| 51 |
* Run the render_manage_sites_table_top menthod. |
| 52 |
*/ |
| 53 |
public function generate_tabletop() { |
| 54 |
$this->render_manage_sites_table_top(); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Render manage sites table top. |
| 59 |
*/ |
| 60 |
public function render_manage_sites_table_top() { |
| 61 |
$filters_row_style = 'display:none'; |
| 62 |
|
| 63 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 64 |
$selected_status = isset( $_REQUEST['status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ) : ''; |
| 65 |
$selected_group = isset( $_REQUEST['g'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['g'] ) ) : ''; |
| 66 |
$selected_client = isset( $_REQUEST['client'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['client'] ) ) : ''; |
| 67 |
$is_not = isset( $_REQUEST['isnot'] ) && ( 'yes' === $_REQUEST['isnot'] ) ? true : false; |
| 68 |
|
| 69 |
$reset_filter = isset( $_REQUEST['reset'] ) && ( 'yes' === $_REQUEST['reset'] ) ? true : false; |
| 70 |
|
| 71 |
if ( ! isset( $_REQUEST['g'] ) && ! $reset_filter ) { |
| 72 |
$selected_status = get_user_option( 'mainwp_screenshots_filter_status' ); |
| 73 |
$selected_group = get_user_option( 'mainwp_screenshots_filter_group' ); |
| 74 |
$selected_client = get_user_option( 'mainwp_screenshots_filter_client' ); |
| 75 |
$is_not = get_user_option( 'mainwp_screenshots_filter_is_not' ); |
| 76 |
} |
| 77 |
// phpcs:enable |
| 78 |
|
| 79 |
if ( ! empty( $selected_status ) || ! empty( $selected_group ) || ! empty( $selected_client ) ) { |
| 80 |
$filters_row_style = 'display:flex'; |
| 81 |
} |
| 82 |
|
| 83 |
?> |
| 84 |
<div class="ui stackable three column grid"> |
| 85 |
|
| 86 |
<div class="row ui mini form"> |
| 87 |
<div class="middle aligned column"> |
| 88 |
<input type="text" id="mainwp-screenshots-sites-filter" value="" placeholder="<?php esc_attr_e( 'Type to filter your sites', 'mainwp' ); ?>"> |
| 89 |
</div> |
| 90 |
<div class="middle aligned column"></div> |
| 91 |
<div class="right aligned middle aligned column"> |
| 92 |
<?php MainWP_Manage_Sites_List_Table::render_page_navigation_left_items(); ?> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
|
| 96 |
<div class="row ui mini form manage-sites-screenshots-filter-top" id="mainwp-sites-filters-row" style="<?php echo esc_attr( $filters_row_style ); ?>"> |
| 97 |
<div class="twelve wide middle aligned column ui grid"> |
| 98 |
<div class="ui selection dropdown seg_is_not" id="mainwp_is_not_site"> |
| 99 |
<input type="hidden" value="<?php echo $is_not ? 'yes' : ''; ?>"> |
| 100 |
<i class="dropdown icon"></i> |
| 101 |
<div class="default text"><?php esc_html_e( 'Is', 'mainwp' ); ?></div> |
| 102 |
<div class="menu"> |
| 103 |
<div class="item" data-value=""><?php esc_html_e( 'Is', 'mainwp' ); ?></div> |
| 104 |
<div class="item" data-value="yes"><?php esc_html_e( 'Is not', 'mainwp' ); ?></div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
<div id="mainwp-filter-sites-group" class="ui multiple selection dropdown seg_site_tags"> |
| 108 |
<input type="hidden" value="<?php echo esc_html( $selected_group ); ?>"> |
| 109 |
<i class="dropdown icon"></i> |
| 110 |
<div class="default text"><?php esc_html_e( 'All tags', 'mainwp' ); ?></div> |
| 111 |
<div class="menu"> |
| 112 |
<?php |
| 113 |
$groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites(); |
| 114 |
foreach ( $groups as $group ) { |
| 115 |
?> |
| 116 |
<div class="item" data-value="<?php echo intval( $group->id ); ?>"><?php echo esc_html( stripslashes( $group->name ) ); ?></div> |
| 117 |
<?php |
| 118 |
} |
| 119 |
?> |
| 120 |
<div class="item" data-value="nogroups"><?php esc_html_e( 'No Tags', 'mainwp' ); ?></div> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
<div class="ui selection dropdown seg_site_status" id="mainwp-filter-sites-status"> |
| 124 |
<input type="hidden" value="<?php echo esc_html( $selected_status ); ?>"> |
| 125 |
<div class="default text"><?php esc_html_e( 'All statuses', 'mainwp' ); ?></div> |
| 126 |
<i class="dropdown icon"></i> |
| 127 |
<div class="menu"> |
| 128 |
<div class="item" data-value="all" ><?php esc_html_e( 'All statuses', 'mainwp' ); ?></div> |
| 129 |
<div class="item" data-value="connected"><?php esc_html_e( 'Connected', 'mainwp' ); ?></div> |
| 130 |
<div class="item" data-value="disconnected"><?php esc_html_e( 'Disconnected', 'mainwp' ); ?></div> |
| 131 |
<div class="item" data-value="suspended"><?php esc_html_e( 'Suspended', 'mainwp' ); ?></div> |
| 132 |
<div class="item" data-value="update"><?php esc_html_e( 'Available update', 'mainwp' ); ?></div> |
| 133 |
<div class="item" data-value="sitehealthnotgood"><?php esc_html_e( 'Site Health Not Good', 'mainwp' ); ?></div> |
| 134 |
<div class="item" data-value="phpver8"><?php esc_html_e( 'PHP < 8.0', 'mainwp' ); ?></div> |
| 135 |
<div class="item" data-value="phpver81"><?php esc_html_e( 'PHP < 8.1', 'mainwp' ); ?></div> |
| 136 |
<div class="item" data-value="phpver82"><?php esc_html_e( 'PHP < 8.2', 'mainwp' ); ?></div> |
| 137 |
<div class="item" data-value="phpver83"><?php esc_html_e( 'PHP < 8.3', 'mainwp' ); ?></div> |
| 138 |
<div class="item" data-value="phpver84"><?php esc_html_e( 'PHP < 8.4', 'mainwp' ); ?></div> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
<div id="mainwp-filter-clients" class="ui selection multiple dropdown seg_site_clients"> |
| 142 |
<input type="hidden" value="<?php echo esc_html( $selected_client ); ?>"> |
| 143 |
<i class="dropdown icon"></i> |
| 144 |
<div class="default text"><?php esc_html_e( 'All clients', 'mainwp' ); ?></div> |
| 145 |
<div class="menu"> |
| 146 |
<?php |
| 147 |
$clients = MainWP_DB_Client::instance()->get_wp_client_by( 'all' ); |
| 148 |
foreach ( $clients as $client ) { |
| 149 |
?> |
| 150 |
<div class="item" data-value="<?php echo intval( $client->client_id ); ?>"><?php echo esc_html( stripslashes( $client->name ) ); ?></div> |
| 151 |
<?php |
| 152 |
} |
| 153 |
?> |
| 154 |
<div class="item" data-value="noclients"><?php esc_html_e( 'No Client', 'mainwp' ); ?></div> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
<button onclick="mainwp_screenshots_sites_filter()" class="ui mini green basic button"><i class="filter icon"></i> <?php esc_html_e( 'Filter', 'mainwp' ); ?></button> |
| 158 |
<button onclick="mainwp_screenshots_sites_reset_filters()" class="ui mini button"><i class="times icon"></i> <?php esc_html_e( 'Reset', 'mainwp' ); ?></button> |
| 159 |
</div> |
| 160 |
<?php |
| 161 |
MainWP_Manage_Sites_Filter_Segment::get_instance()->render_filters_segment(); |
| 162 |
?> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
<script type="text/javascript"> |
| 166 |
mainwp_screenshots_sites_filter = function() { |
| 167 |
let group = jQuery( "#mainwp-filter-sites-group" ).dropdown( "get value" ); |
| 168 |
let status = jQuery( "#mainwp-filter-sites-status" ).dropdown( "get value" ); |
| 169 |
let isNot = jQuery("#mainwp_is_not_site").dropdown("get value"); |
| 170 |
let client = jQuery("#mainwp-filter-clients").dropdown("get value"); |
| 171 |
let params = ''; |
| 172 |
params += '&g=' + group; |
| 173 |
params += '&client=' + client; |
| 174 |
if ( status != '' ) { |
| 175 |
params += '&status=' + status; |
| 176 |
} |
| 177 |
if ( 'yes' == isNot ){ |
| 178 |
params += '&isnot=yes'; |
| 179 |
} |
| 180 |
window.location = 'admin.php?page=managesites' + params; |
| 181 |
return false; |
| 182 |
}; |
| 183 |
|
| 184 |
mainwp_screenshots_sites_reset_filters = function() { |
| 185 |
window.location = 'admin.php?page=managesites&reset=yes' |
| 186 |
return false; |
| 187 |
}; |
| 188 |
|
| 189 |
jQuery( document ).on( 'keyup', '#mainwp-screenshots-sites-filter', function () { |
| 190 |
let filter = jQuery(this).val().toLowerCase(); |
| 191 |
let siteItems = jQuery('#mainwp-sites-previews').find( '.card' ); |
| 192 |
for ( let i = 0; i < siteItems.length; i++ ) { |
| 193 |
let currentElement = jQuery( siteItems[i] ); |
| 194 |
let valueurl = jQuery(currentElement).attr('site-url').toLowerCase(); |
| 195 |
let valuename = currentElement.find('.ui.header').text().toLowerCase(); |
| 196 |
if ( valueurl.indexOf( filter ) > -1 || valuename.indexOf( filter ) > -1 ) { |
| 197 |
currentElement.show(); |
| 198 |
} else { |
| 199 |
currentElement.hide(); |
| 200 |
} |
| 201 |
} |
| 202 |
} ); |
| 203 |
|
| 204 |
jQuery(document).ready(function(){ |
| 205 |
jQuery('#mainwp-sites-previews .image img').visibility({ |
| 206 |
type : 'image', |
| 207 |
transition : 'fade in', |
| 208 |
duration : 1000 |
| 209 |
}); |
| 210 |
}); |
| 211 |
|
| 212 |
</script> |
| 213 |
<?php |
| 214 |
MainWP_UI::render_modal_save_segment(); |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Method render_all_sites() |
| 219 |
* |
| 220 |
* Render Screenshots. |
| 221 |
*/ |
| 222 |
public static function render_all_sites() { // phpcs:ignore -- NOSONAR - comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 223 |
/** |
| 224 |
* Sites Page header |
| 225 |
* |
| 226 |
* Renders the tabs on the Sites screen. |
| 227 |
* |
| 228 |
* @since Unknown |
| 229 |
*/ |
| 230 |
do_action( 'mainwp_pageheader_sites', 'managesites' ); |
| 231 |
|
| 232 |
$count = MainWP_DB::instance()->get_websites_count( null, true ); |
| 233 |
|
| 234 |
if ( empty( $count ) ) { |
| 235 |
/** |
| 236 |
* Action: mainwp_before_empty_manage_sites_placeholder |
| 237 |
* |
| 238 |
* Fires before the placeholder on the empty Manage Sites page. |
| 239 |
* |
| 240 |
* @since 6.0 |
| 241 |
*/ |
| 242 |
do_action( 'mainwp_before_empty_manage_sites_placeholder' ); |
| 243 |
?> |
| 244 |
<div id="mainwp-manage-sites-empty" class="ui padded center aligned segment"> |
| 245 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'No sites connected yet.', 'mainwp' ), __( 'Connect your first WordPress site and start managing updates, security, and backups from one command center.', 'mainwp' ), '<em data-emoji=":globe_with_meridians:" class="big"></em>' ); ?> |
| 246 |
<div class="ui hidden divider"></div> |
| 247 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>" class="ui big green button"><i class="plus icon"></i> <?php esc_html_e( 'Connect Your First Sites', 'mainwp' ); ?></a> |
| 248 |
<div class="ui hidden divider"></div> |
| 249 |
<a class="ui grey text" href="https://docs.mainwp.com/getting-started/get-started-with-mainwp#add-a-site-to-your-dashboard"><?php esc_html_e( 'or learn how it works →', 'mainwp' ); ?></a> |
| 250 |
</div> |
| 251 |
<?php |
| 252 |
/** |
| 253 |
* Action: mainwp_after_empty_manage_sites_placeholder |
| 254 |
* |
| 255 |
* Fires after the placeholder on the empty Manage Sites page. |
| 256 |
* |
| 257 |
* @since 6.0 |
| 258 |
*/ |
| 259 |
do_action( 'mainwp_after_empty_manage_sites_placeholder' ); |
| 260 |
|
| 261 |
/** |
| 262 |
* Sites Page footer |
| 263 |
* |
| 264 |
* Renders the footer on the Sites screen. |
| 265 |
* |
| 266 |
* @since Unknown |
| 267 |
*/ |
| 268 |
do_action( 'mainwp_pagefooter_sites' ); |
| 269 |
|
| 270 |
return; |
| 271 |
} |
| 272 |
|
| 273 |
$websites = static::prepare_items(); |
| 274 |
|
| 275 |
MainWP_DB::data_seek( $websites, 0 ); |
| 276 |
|
| 277 |
$userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 278 |
|
| 279 |
$decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array(); |
| 280 |
if ( ! is_array( $decodedIgnoredCores ) ) { |
| 281 |
$decodedIgnoredCores = array(); |
| 282 |
} |
| 283 |
|
| 284 |
$nonce = wp_create_nonce( 'viewmode' ); |
| 285 |
|
| 286 |
?> |
| 287 |
|
| 288 |
<div id="mainwp-screenshots-sites" class="ui padded segment"> |
| 289 |
<?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-grid-view-mode-info-message' ) ) : ?> |
| 290 |
<div class="ui info message"> |
| 291 |
<i class="close icon mainwp-notice-dismiss" notice-id="mainwp-grid-view-mode-info-message"></i> |
| 292 |
<div><?php /* translators: 1: opening anchor tag, 2: closing anchor tag */ printf( esc_html__( 'In the Grid mode, sites options are limited in comparison to the %1$sTable mode%2$s.', 'mainwp' ), '<a href="admin.php?page=managesites&viewmode=table&modenonce=' . esc_html( $nonce ) . '">', '</a>' ); ?></div> |
| 293 |
</div> |
| 294 |
<?php endif; ?> |
| 295 |
<?php |
| 296 |
/** |
| 297 |
* Filter: mainwp_cards_per_row |
| 298 |
* |
| 299 |
* Filters the number of cards per row in MainWP Screenshots page. |
| 300 |
* |
| 301 |
* @since 4.1.8 |
| 302 |
*/ |
| 303 |
$cards_per_row = apply_filters( 'mainwp_cards_per_row', 'five' ); |
| 304 |
?> |
| 305 |
<div id="mainwp-sites-previews"> |
| 306 |
<div id="mainwp-message-zone" class="ui message" style="display:none;"></div> |
| 307 |
<div class="ui <?php echo esc_attr( $cards_per_row ); ?> mainwp-cards cards" > |
| 308 |
<?php |
| 309 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 310 |
$hasSyncErrors = ( '' !== $website->sync_errors ); |
| 311 |
$suspendedSite = ( '0' !== $website->suspended ); |
| 312 |
|
| 313 |
$status_color = ''; |
| 314 |
$status_icon = ''; |
| 315 |
$status_tooltip = ''; |
| 316 |
|
| 317 |
if ( $hasSyncErrors ) { |
| 318 |
$status_color = 'red'; |
| 319 |
$status_icon = 'unlink'; |
| 320 |
$status_tooltip = esc_html__( 'Disconnected', 'mainwp' ); |
| 321 |
} elseif ( $suspendedSite ) { |
| 322 |
$status_color = 'yellow'; |
| 323 |
$status_icon = 'pause'; |
| 324 |
$status_tooltip = esc_html__( 'Suspended', 'mainwp' ); |
| 325 |
} else { |
| 326 |
$status_color = 'green'; |
| 327 |
$status_icon = 'check'; |
| 328 |
$status_tooltip = esc_html__( 'Connected', 'mainwp' ); |
| 329 |
} |
| 330 |
|
| 331 |
$total_wp_upgrades = 0; |
| 332 |
$total_plugin_upgrades = 0; |
| 333 |
$total_theme_upgrades = 0; |
| 334 |
|
| 335 |
$wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array(); |
| 336 |
$ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array(); |
| 337 |
|
| 338 |
if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) { |
| 339 |
$wp_upgrades = array(); |
| 340 |
} |
| 341 |
|
| 342 |
if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) { |
| 343 |
++$total_wp_upgrades; |
| 344 |
} |
| 345 |
|
| 346 |
$plugin_upgrades = json_decode( $website->plugin_upgrades, true ); |
| 347 |
|
| 348 |
if ( $website->is_ignorePluginUpdates ) { |
| 349 |
$plugin_upgrades = array(); |
| 350 |
} |
| 351 |
|
| 352 |
$theme_upgrades = json_decode( $website->theme_upgrades, true ); |
| 353 |
|
| 354 |
if ( $website->is_ignoreThemeUpdates ) { |
| 355 |
$theme_upgrades = array(); |
| 356 |
} |
| 357 |
|
| 358 |
$decodedPremiumUpgrades = ! empty( $website->premium_upgrades ) ? json_decode( $website->premium_upgrades, true ) : array(); |
| 359 |
|
| 360 |
if ( is_array( $decodedPremiumUpgrades ) ) { |
| 361 |
foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { |
| 362 |
$premiumUpgrade['premium'] = true; |
| 363 |
|
| 364 |
if ( 'plugin' === $premiumUpgrade['type'] ) { |
| 365 |
if ( ! is_array( $plugin_upgrades ) ) { |
| 366 |
$plugin_upgrades = array(); |
| 367 |
} |
| 368 |
if ( ! $website->is_ignorePluginUpdates ) { |
| 369 |
$plugin_upgrades[ $crrSlug ] = $premiumUpgrade; |
| 370 |
} |
| 371 |
} elseif ( 'theme' === $premiumUpgrade['type'] ) { |
| 372 |
if ( ! is_array( $theme_upgrades ) ) { |
| 373 |
$theme_upgrades = array(); |
| 374 |
} |
| 375 |
if ( ! $website->is_ignoreThemeUpdates ) { |
| 376 |
$theme_upgrades[ $crrSlug ] = $premiumUpgrade; |
| 377 |
} |
| 378 |
} |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
if ( is_array( $plugin_upgrades ) ) { |
| 383 |
|
| 384 |
$ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 385 |
if ( is_array( $ignored_plugins ) ) { |
| 386 |
$plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); |
| 387 |
|
| 388 |
} |
| 389 |
|
| 390 |
$ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 391 |
if ( is_array( $ignored_plugins ) ) { |
| 392 |
$plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); |
| 393 |
|
| 394 |
} |
| 395 |
|
| 396 |
$total_plugin_upgrades += count( $plugin_upgrades ); |
| 397 |
} |
| 398 |
|
| 399 |
if ( is_array( $theme_upgrades ) ) { |
| 400 |
|
| 401 |
$ignored_themes = json_decode( $website->ignored_themes, true ); |
| 402 |
if ( is_array( $ignored_themes ) ) { |
| 403 |
$theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); |
| 404 |
} |
| 405 |
|
| 406 |
$ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 407 |
if ( is_array( $ignored_themes ) ) { |
| 408 |
$theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); |
| 409 |
} |
| 410 |
|
| 411 |
$total_theme_upgrades += count( $theme_upgrades ); |
| 412 |
} |
| 413 |
|
| 414 |
$total_updates = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades; |
| 415 |
|
| 416 |
$client_image = ''; |
| 417 |
if ( $website->client_id > 0 ) { |
| 418 |
$client = MainWP_DB_Client::instance()->get_wp_client_by( 'client_id', $website->client_id, true ); |
| 419 |
$client_image = MainWP_Client_Handler::get_client_avatar( $client ); |
| 420 |
} else { |
| 421 |
$client_image = '<i class="user circle grey big icon"></i>'; |
| 422 |
} |
| 423 |
|
| 424 |
$website_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' ); |
| 425 |
$website_info = ! empty( $website_info ) ? json_decode( $website_info, true ) : array(); |
| 426 |
$site_mshot = MainWP_UI::get_mshots_image_sources( $website->url, 900 ); |
| 427 |
|
| 428 |
?> |
| 429 |
|
| 430 |
<div class="card" site-url="<?php echo esc_url( $website->url ); ?>"> |
| 431 |
<div class="image" data-tooltip="<?php echo esc_attr( $status_tooltip ); ?>" data-position="top center" data-inverted=""> |
| 432 |
<img alt="<?php esc_attr_e( 'Website preview', 'mainwp' ); ?>" data-src="<?php echo esc_url( $site_mshot['src'] ); ?>" data-mainwp-mshot-src="<?php echo esc_url( $site_mshot['src'] ); ?>" data-mainwp-mshot-requeue-src="<?php echo esc_url( $site_mshot['requeue_src'] ); ?>"> |
| 433 |
</div> |
| 434 |
<div class="ui <?php echo esc_attr( $status_color ); ?> corner label"> |
| 435 |
<i class="<?php echo esc_attr( $status_icon ); ?> icon"></i> |
| 436 |
</div> |
| 437 |
<div class="content"> |
| 438 |
<h2 class="ui small header"> |
| 439 |
<a href="<?php MainWP_Site_Open::get_open_site_admin_link( $website->id, true ); //phpcs:ignore -- ok. ?>" target="_blank" data-tooltip="<?php esc_attr_e( 'Go to WP Admin', 'mainwp' ); ?>" data-position="top left" data-inverted=""><i class="sign in icon"></i></a> <a href="admin.php?page=managesites&dashboard=<?php echo intval( $website->id ); ?>"><?php echo esc_html( stripslashes( $website->name ) ); ?></a> |
| 440 |
<br/><?php MainWP_Utility::get_site_index_option_icon( $website_info['site_public'] ); ?> <span class="ui small text"><a href="<?php echo esc_url( $website->url ); ?>" class="ui grey text" target="_blank"><?php echo esc_html( $website->url ); ?></a></span> |
| 441 |
</h2> |
| 442 |
<?php if ( isset( $website->wpgroups ) && '' !== $website->wpgroups ) : ?> |
| 443 |
<div><?php echo MainWP_System_Utility::get_site_tags( (array) $website ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div> |
| 444 |
<?php endif; ?> |
| 445 |
</div> |
| 446 |
<div class="extra content"> |
| 447 |
<a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" class="ui grey text"> |
| 448 |
<?php echo $client_image; //phpcs:ignore -- NOSONAR - ok.?> <?php echo esc_html( $website->client_name ); ?> |
| 449 |
</a> |
| 450 |
</div> |
| 451 |
|
| 452 |
<div class="extra content"> |
| 453 |
<?php if ( $hasSyncErrors ) : ?> |
| 454 |
<a class="ui mini green basic icon button mainwp_site_card_reconnect" site-id="<?php echo intval( $website->id ); ?>" href="#"><i class="sync alternate icon"></i></a> |
| 455 |
<?php else : ?> |
| 456 |
<a href="javascript:void(0)" class="ui mini green icon button mainwp-sync-this-site" site-id="<?php echo intval( $website->id ); ?>"><i class="sync alternate icon"></i></a> |
| 457 |
<?php endif; ?> |
| 458 |
<a href="admin.php?page=managesites&id=<?php echo intval( $website->id ); ?>"class="ui mini grey icon button"><i class="cog icon"></i></a> |
| 459 |
<a data-tooltip="<?php echo ! empty( $website->dtsSync ) ? esc_attr__( 'Last sync: ', 'mainwp' ) . MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $website->dtsSync ) ) : ''; ?> " data-position="left center" data-inverted="" class="ui mini grey button" href="admin.php?page=managesites&updateid=<?php echo intval( $website->id ); //phpcs:ignore -- NOSONAR -ok. ?>"> |
| 460 |
<i class="sync alternate icon"></i> <?php echo intval( $total_updates ); ?> |
| 461 |
</a> |
| 462 |
<span class="right floated"><?php MainWP_Utility::get_language_code_as_flag( $website_info['site_lang'] ); ?></span> |
| 463 |
</div> |
| 464 |
</div> |
| 465 |
<?php |
| 466 |
} |
| 467 |
?> |
| 468 |
</div> |
| 469 |
</div> |
| 470 |
</div> |
| 471 |
<script type="text/javascript"> |
| 472 |
jQuery(document).ready(function(){ |
| 473 |
jQuery('#mainwp-sites-previews .image img').visibility( { |
| 474 |
type : 'image', |
| 475 |
transition : 'fade in', |
| 476 |
duration : 1000 |
| 477 |
}); |
| 478 |
}); |
| 479 |
|
| 480 |
mainwp_manage_sites_screen_options = function () { |
| 481 |
jQuery( '#mainwp-manage-sites-screen-options-modal' ).modal( { |
| 482 |
allowMultiple: true, |
| 483 |
onHide: function () { |
| 484 |
//ok. |
| 485 |
} |
| 486 |
} ).modal( 'show' ); |
| 487 |
|
| 488 |
jQuery( '#manage-sites-screen-options-form' ).submit( function() { |
| 489 |
jQuery( '#mainwp-manage-sites-screen-options-modal' ).modal( 'hide' ); |
| 490 |
} ); |
| 491 |
return false; |
| 492 |
}; |
| 493 |
|
| 494 |
</script> |
| 495 |
<?php |
| 496 |
MainWP_DB::free_result( $websites ); |
| 497 |
static::render_screen_options(); |
| 498 |
/** |
| 499 |
* Sites Page Footer |
| 500 |
* |
| 501 |
* Renders the footer on the Sites screen. |
| 502 |
* |
| 503 |
* @since Unknown |
| 504 |
*/ |
| 505 |
do_action( 'mainwp_pagefooter_sites', 'managesites' ); |
| 506 |
} |
| 507 |
|
| 508 |
/** |
| 509 |
* Method render_screen_options() |
| 510 |
* |
| 511 |
* Render Page Settings Modal. |
| 512 |
*/ |
| 513 |
public static function render_screen_options() { |
| 514 |
$siteViewMode = MainWP_Utility::get_siteview_mode(); |
| 515 |
$is_demo = MainWP_Demo_Handle::is_demo_mode(); |
| 516 |
?> |
| 517 |
<div class="ui modal" id="mainwp-manage-sites-screen-options-modal"> |
| 518 |
<i class="close icon"></i> |
| 519 |
<div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| 520 |
<div class="scrolling content ui form"> |
| 521 |
<form method="POST" action="" id="manage-sites-screen-options-form" name="manage_sites_screen_options_form"> |
| 522 |
<?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?> |
| 523 |
<input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SreenshotsSitesScrOptions' ) ); ?>" /> |
| 524 |
<div class="ui grid field"> |
| 525 |
<label class="top aligned six wide column" tabindex="0"><?php esc_html_e( 'Sites view mode', 'mainwp' ); ?></label> |
| 526 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Sites view mode.', 'mainwp' ); ?>" data-inverted="" data-position="left center"> |
| 527 |
<div class="ui info message"> |
| 528 |
<div><strong><?php echo esc_html__( 'Sites view mode is an experimental feature.', 'mainwp' ); ?></strong></div> |
| 529 |
<div><?php echo esc_html__( 'In the Grid mode, sites options are limited in comparison to the Table mode.', 'mainwp' ); ?></div> |
| 530 |
<div><?php echo esc_html__( 'Grid mode queries WordPress.com servers to capture a screenshot of your site the same way comments show you a preview of URLs.', 'mainwp' ); ?></div> |
| 531 |
</div> |
| 532 |
<select name="mainwp_sitesviewmode" id="mainwp_sitesviewmode" class="ui dropdown"> |
| 533 |
<option value="table" <?php echo 'table' === $siteViewMode ? 'selected' : ''; ?>><?php esc_html_e( 'Table', 'mainwp' ); ?></option> |
| 534 |
<option value="grid" <?php echo 'grid' === $siteViewMode ? 'selected' : ''; ?>><?php esc_html_e( 'Grid', 'mainwp' ); ?></option> |
| 535 |
</select> |
| 536 |
</div> |
| 537 |
</div> |
| 538 |
<div class="ui grid field"> |
| 539 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Export child sites to CSV file', 'mainwp' ); ?></label> |
| 540 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to export all connected sites to a CSV file.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><a href="admin.php?page=MainWPTools&doExportSites=yes&_wpnonce=<?php echo esc_html( wp_create_nonce( 'export_sites' ) ); ?>" class="ui button green basic"><?php esc_html_e( 'Export Child Sites', 'mainwp' ); ?></a></div> |
| 541 |
</div> |
| 542 |
<div class="ui grid field"> |
| 543 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label> |
| 544 |
<div class="ten wide column" id="mainwp-disconnect-sites-tool" data-tooltip="<?php esc_attr_e( 'This will function will break the connection and leave the MainWP Child plugin active.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left"> |
| 545 |
<?php |
| 546 |
if ( $is_demo ) { |
| 547 |
MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="#" disabled="disabled" class="ui button green basic disabled">' . esc_html__( 'Disconnect Websites.', 'mainwp' ) . '</a>' ); |
| 548 |
} else { |
| 549 |
?> |
| 550 |
<a href="admin.php?page=MainWPTools&disconnectSites=yes&_wpnonce=<?php echo esc_html( wp_create_nonce( 'disconnect_sites' ) ); ?>" onclick="mainwp_tool_disconnect_sites(); return false;" class="ui button green basic"><?php esc_html_e( 'Disconnect Websites.', 'mainwp' ); ?></a> |
| 551 |
<?php } ?> |
| 552 |
</div> |
| 553 |
</div> |
| 554 |
<div class="ui hidden divider"></div> |
| 555 |
<div class="ui hidden divider"></div> |
| 556 |
</div> |
| 557 |
<div class="actions"> |
| 558 |
<div class="ui two columns grid"> |
| 559 |
<div class="left aligned column"> |
| 560 |
<span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated columns.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><input type="button" class="ui button" name="reset" id="reset-managersites-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span> |
| 561 |
</div> |
| 562 |
<div class="ui right aligned column"> |
| 563 |
<input type="submit" class="ui green button" name="btnSubmit" id="submit-managersites-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" /> |
| 564 |
</div> |
| 565 |
</div> |
| 566 |
</div> |
| 567 |
<input type="hidden" name="reset_managersites_columns_order" value="0"> |
| 568 |
</form> |
| 569 |
</div> |
| 570 |
<div class="ui small modal" id="mainwp-manage-sites-site-preview-screen-options-modal"> |
| 571 |
<div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| 572 |
<div class="scrolling content ui form"> |
| 573 |
<span><?php esc_html_e( 'Would you like to turn on home screen previews? This function queries WordPress.com servers to capture a screenshot of your site the same way comments shows you preview of URLs.', 'mainwp' ); ?> |
| 574 |
</div> |
| 575 |
<div class="actions"> |
| 576 |
<div class="ui ok button"><?php esc_html_e( 'Yes', 'mainwp' ); ?></div> |
| 577 |
<div class="ui cancel button"><?php esc_html_e( 'No', 'mainwp' ); ?></div> |
| 578 |
</div> |
| 579 |
</div> |
| 580 |
<script type="text/javascript"> |
| 581 |
jQuery( document ).ready( function () { |
| 582 |
jQuery('#reset-managersites-settings').on( 'click', function () { |
| 583 |
mainwp_confirm(__( 'Are you sure?' ), function(){ |
| 584 |
jQuery('#mainwp_sitesviewmode').dropdown( 'set selected', 'grid' ); |
| 585 |
jQuery('#submit-managersites-settings').click(); |
| 586 |
}, false, false, true ); |
| 587 |
return false; |
| 588 |
}); |
| 589 |
} ); |
| 590 |
</script> |
| 591 |
<?php |
| 592 |
} |
| 593 |
|
| 594 |
/** |
| 595 |
* Prepare the items to be listed. |
| 596 |
*/ |
| 597 |
public static function prepare_items() { // phpcs:ignore -- NOSONAR - comlex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 598 |
|
| 599 |
$orderby = 'wp.url'; |
| 600 |
|
| 601 |
$perPage = 9999; |
| 602 |
$start = 0; |
| 603 |
|
| 604 |
$reset_filter = isset( $_REQUEST['reset'] ) && ( 'yes' === $_REQUEST['reset'] ) ? true : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 605 |
|
| 606 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 607 |
$get_saved_state = ! isset( $_REQUEST['g'] ) && ! isset( $_REQUEST['status'] ) && ! isset( $_REQUEST['client'] ) && ! $reset_filter; |
| 608 |
$get_all = ( isset( $_REQUEST['status'] ) && 'all' === $_REQUEST['status'] ) && empty( $_REQUEST['g'] ) && empty( $_REQUEST['client'] ) ? true : false; |
| 609 |
$is_not = ( isset( $_REQUEST['isnot'] ) && 'yes' === $_REQUEST['isnot'] ) ? true : false; |
| 610 |
|
| 611 |
if ( $reset_filter ) { |
| 612 |
$get_all = true; |
| 613 |
} |
| 614 |
|
| 615 |
$site_status = ''; |
| 616 |
|
| 617 |
if ( ! isset( $_REQUEST['status'] ) ) { |
| 618 |
if ( $get_saved_state ) { |
| 619 |
$site_status = get_user_option( 'mainwp_screenshots_filter_status' ); |
| 620 |
} else { |
| 621 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_status', '' ); |
| 622 |
} |
| 623 |
} else { |
| 624 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_status', sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ) ); |
| 625 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_is_not', $is_not ); |
| 626 |
$site_status = sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ); |
| 627 |
} |
| 628 |
|
| 629 |
if ( $get_all ) { |
| 630 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_group', '' ); |
| 631 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_client', '' ); |
| 632 |
} |
| 633 |
|
| 634 |
$group_ids = false; |
| 635 |
$client_ids = false; |
| 636 |
|
| 637 |
if ( ! $get_all ) { |
| 638 |
if ( ! isset( $_REQUEST['g'] ) ) { |
| 639 |
if ( $get_saved_state ) { |
| 640 |
$group_ids = get_user_option( 'mainwp_screenshots_filter_group' ); |
| 641 |
} else { |
| 642 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_group', '' ); |
| 643 |
} |
| 644 |
} else { |
| 645 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_group', sanitize_text_field( wp_unslash( $_REQUEST['g'] ) ) ); |
| 646 |
$group_ids = sanitize_text_field( wp_unslash( $_REQUEST['g'] ) ); // may be multi groups. |
| 647 |
} |
| 648 |
|
| 649 |
if ( ! isset( $_REQUEST['client'] ) ) { |
| 650 |
if ( $get_saved_state ) { |
| 651 |
$client_ids = get_user_option( 'mainwp_screenshots_filter_client' ); |
| 652 |
} else { |
| 653 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_client', '' ); |
| 654 |
} |
| 655 |
} else { |
| 656 |
MainWP_Utility::update_user_option( 'mainwp_screenshots_filter_client', sanitize_text_field( wp_unslash( $_REQUEST['client'] ) ) ); |
| 657 |
$client_ids = sanitize_text_field( wp_unslash( $_REQUEST['client'] ) ); // may be multi groups. |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
$where = null; |
| 662 |
|
| 663 |
if ( '' !== $site_status && 'all' !== $site_status ) { |
| 664 |
if ( 'connected' === $site_status ) { |
| 665 |
$where = 'wp_sync.sync_errors = ""'; |
| 666 |
if ( $is_not ) { |
| 667 |
$where = 'wp_sync.sync_errors <> ""'; |
| 668 |
} |
| 669 |
} elseif ( 'disconnected' === $site_status ) { |
| 670 |
$where = 'wp_sync.sync_errors <> ""'; |
| 671 |
if ( $is_not ) { |
| 672 |
$where = 'wp_sync.sync_errors = ""'; |
| 673 |
} |
| 674 |
} elseif ( 'update' === $site_status ) { |
| 675 |
$available_update_ids = MainWP_Common_Functions::instance()->get_available_update_siteids(); |
| 676 |
if ( empty( $available_update_ids ) ) { |
| 677 |
$where = 'wp.id = -1'; |
| 678 |
if ( $is_not ) { |
| 679 |
$where = 'wp.id != -1'; |
| 680 |
} |
| 681 |
} else { |
| 682 |
$where = 'wp.id IN (' . implode( ',', $available_update_ids ) . ') '; |
| 683 |
if ( $is_not ) { |
| 684 |
$where = 'wp.id NOT IN (' . implode( ',', $available_update_ids ) . ') '; |
| 685 |
} |
| 686 |
} |
| 687 |
} elseif ( 'sitehealthnotgood' === $site_status ) { |
| 688 |
$where = ' wp_sync.health_status = 1 '; |
| 689 |
if ( $is_not ) { |
| 690 |
$where = 'wp_sync.health_status = 0'; |
| 691 |
} |
| 692 |
} elseif ( 'phpver8' === $site_status ) { |
| 693 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '<', '8.0.0.0' ); // NOSONAR - no IP. |
| 694 |
if ( $is_not ) { |
| 695 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '>=', '8.0.0.0' ); // NOSONAR - no IP. |
| 696 |
} |
| 697 |
} elseif ( 'phpver81' === $site_status ) { |
| 698 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '<', '8.1.0.0' ); // NOSONAR - no IP. |
| 699 |
if ( $is_not ) { |
| 700 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '>=', '8.1.0.0' ); // NOSONAR - no IP. |
| 701 |
} |
| 702 |
} elseif ( 'phpver82' === $site_status ) { |
| 703 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '<', '8.2.0.0' ); // NOSONAR - no IP. |
| 704 |
if ( $is_not ) { |
| 705 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '>=', '8.2.0.0' ); // NOSONAR - no IP. |
| 706 |
} |
| 707 |
} elseif ( 'phpver83' === $site_status ) { |
| 708 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '<', '8.3.0.0' ); // NOSONAR - no IP. |
| 709 |
if ( $is_not ) { |
| 710 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '>=', '8.3.0.0' ); // NOSONAR - no IP. |
| 711 |
} |
| 712 |
} elseif ( 'phpver84' === $site_status ) { |
| 713 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '<', '8.4.0.0' ); // NOSONAR - no IP. |
| 714 |
if ( $is_not ) { |
| 715 |
$where = MainWP_DB_Common::instance()->get_sql_where_wpopt_phpversion( 'phpversion', '>=', '8.4.0.0' ); // NOSONAR - no IP. |
| 716 |
} |
| 717 |
} elseif ( 'suspended' === $site_status ) { |
| 718 |
$where = 'wp.suspended = 1'; |
| 719 |
if ( $is_not ) { |
| 720 |
$where = 'wp.suspended = 0'; |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
// phpcs:enable |
| 725 |
|
| 726 |
$params = array( |
| 727 |
'selectgroups' => true, |
| 728 |
'orderby' => $orderby, |
| 729 |
'offset' => $start, |
| 730 |
'rowcount' => $perPage, |
| 731 |
); |
| 732 |
|
| 733 |
$params['isnot'] = $is_not; |
| 734 |
|
| 735 |
$qry_group_ids = array(); |
| 736 |
if ( ! empty( $group_ids ) ) { |
| 737 |
$group_ids = explode( ',', $group_ids ); // convert to array. |
| 738 |
// to fix query deleted groups. |
| 739 |
$groups = MainWP_DB_Common::instance()->get_groups_for_manage_sites(); |
| 740 |
foreach ( $groups as $gr ) { |
| 741 |
if ( in_array( $gr->id, $group_ids ) ) { |
| 742 |
$qry_group_ids[] = $gr->id; |
| 743 |
} |
| 744 |
} |
| 745 |
// to fix. |
| 746 |
if ( in_array( 'nogroups', $group_ids ) ) { |
| 747 |
$qry_group_ids[] = 'nogroups'; |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
if ( ! empty( $qry_group_ids ) ) { |
| 752 |
$params['group_id'] = $qry_group_ids; |
| 753 |
} |
| 754 |
|
| 755 |
$qry_client_ids = array(); |
| 756 |
if ( ! empty( $client_ids ) ) { |
| 757 |
$client_ids = explode( ',', $client_ids ); // convert to array. |
| 758 |
// to fix query deleted client. |
| 759 |
$clients = MainWP_DB_Client::instance()->get_wp_client_by( 'all' ); |
| 760 |
foreach ( $clients as $cl ) { |
| 761 |
if ( in_array( $cl->client_id, $client_ids ) ) { |
| 762 |
$qry_client_ids[] = $cl->client_id; |
| 763 |
} |
| 764 |
} |
| 765 |
// to fix. |
| 766 |
if ( in_array( 'noclients', $client_ids ) ) { |
| 767 |
$qry_client_ids[] = 'noclients'; |
| 768 |
} |
| 769 |
} |
| 770 |
|
| 771 |
if ( ! empty( $qry_client_ids ) ) { |
| 772 |
$params['client_id'] = $qry_client_ids; |
| 773 |
} |
| 774 |
|
| 775 |
if ( ! empty( $where ) ) { |
| 776 |
$params['extra_where'] = $where; |
| 777 |
} |
| 778 |
|
| 779 |
$params['extra_view'] = array( |
| 780 |
'wp_upgrades', |
| 781 |
'ignored_wp_upgrades', |
| 782 |
); |
| 783 |
|
| 784 |
$cache_group = MainWP_Cache_Helper::CGR_SITES; |
| 785 |
|
| 786 |
$cache_key = MainWP_Cache_Helper::get_cache_key( 'sites_ids', $cache_group, $params ); |
| 787 |
|
| 788 |
$cache_ids = MainWP_Cache_Helper::instance()->get_cache( |
| 789 |
$cache_key, |
| 790 |
$cache_group |
| 791 |
); |
| 792 |
|
| 793 |
if ( '_get_cache_false' !== $cache_ids ) { |
| 794 |
if ( empty( $cache_ids ) ) { |
| 795 |
$params['_included_cache_ids'] = array( 0 ); // not found if get cached success but empty. |
| 796 |
} else { |
| 797 |
$params['_included_cache_ids'] = $cache_ids; |
| 798 |
} |
| 799 |
} |
| 800 |
|
| 801 |
$websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_search_websites_for_current_user( $params ) ); |
| 802 |
|
| 803 |
$site_ids = array(); |
| 804 |
while ( $websites && ( $site = MainWP_DB::fetch_object( $websites ) ) ) { |
| 805 |
$site_ids[] = $site->id; |
| 806 |
} |
| 807 |
|
| 808 |
// Set manage sites ids cache. |
| 809 |
MainWP_Cache_Helper::add_cache( $cache_key, $cache_group, $site_ids ); |
| 810 |
|
| 811 |
return $websites; |
| 812 |
} |
| 813 |
} |
| 814 |
|