| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Updates Overview Widget |
| 4 |
* |
| 5 |
* Grab Child Sites update status & build widget. |
| 6 |
* |
| 7 |
* @package MainWP/Updates_Overview |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace MainWP\Dashboard; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class MainWP_Updates_Overview |
| 14 |
* |
| 15 |
* @package MainWP\Dashboard |
| 16 |
*/ |
| 17 |
class MainWP_Updates_Overview { |
| 18 |
|
| 19 |
/** |
| 20 |
* Method get_class_name() |
| 21 |
* |
| 22 |
* Get Class Name |
| 23 |
* |
| 24 |
* @return string __CLASS__ Class Name. |
| 25 |
*/ |
| 26 |
public static function get_class_name() { |
| 27 |
return __CLASS__; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Method init() |
| 32 |
* |
| 33 |
* Add plugins api filter. |
| 34 |
*/ |
| 35 |
public static function init() { |
| 36 |
add_filter( 'plugins_api', array( __CLASS__, 'plugins_api' ), 10, 3 ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Method plugins_api() |
| 41 |
* |
| 42 |
* Grab Child Sites update status & build widget. |
| 43 |
* |
| 44 |
* @param mixed $default Default. |
| 45 |
* @param mixed $action Action. |
| 46 |
* @param mixed $args Slug. |
| 47 |
* |
| 48 |
* @return mixed $default|$res |
| 49 |
*/ |
| 50 |
public static function plugins_api( $default, $action, $args ) { |
| 51 |
if ( property_exists( $args, 'slug' ) && ( 'mainwp' === $args->slug ) ) { |
| 52 |
return $default; |
| 53 |
} |
| 54 |
|
| 55 |
$url = 'http://api.wordpress.org/plugins/info/1.0/'; |
| 56 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
| 57 |
if ( $ssl ) { |
| 58 |
$url = set_url_scheme( $url, 'https' ); |
| 59 |
} |
| 60 |
|
| 61 |
$args = array( |
| 62 |
'timeout' => 15, |
| 63 |
'body' => array( |
| 64 |
'action' => $action, |
| 65 |
'request' => serialize( $args ), // phpcs:ignore -- WP.org API params. |
| 66 |
), |
| 67 |
); |
| 68 |
$request = wp_remote_post( $url, $args ); |
| 69 |
|
| 70 |
if ( is_wp_error( $request ) ) { |
| 71 |
$url = isset( $_REQUEST['url'] ) ? esc_url_raw( wp_unslash( $_REQUEST['url'] ) ) : ''; |
| 72 |
$name = isset( $_REQUEST['name'] ) ? wp_unslash( $_REQUEST['name'] ) : ''; |
| 73 |
$res = new \WP_Error( 'plugins_api_failed', __( '<h3>No plugin information found.</h3> This may be a premium plugin and no other details are available from WordPress.', 'mainwp' ) . ' ' . ( '' == $url ? __( 'Please visit the plugin website for more information.', 'mainwp' ) : __( 'Please visit the plugin website for more information: ', 'mainwp' ) . '<a href="' . esc_html( rawurldecode( $url ) ) . '" target="_blank">' . esc_html( rawurldecode( $name ) ) . '</a>' ), $request->get_error_message() ); |
| 74 |
|
| 75 |
return $res; |
| 76 |
} |
| 77 |
|
| 78 |
return $default; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Method get_name() |
| 83 |
* |
| 84 |
* Define Widget Title. |
| 85 |
*/ |
| 86 |
public static function get_name() { |
| 87 |
return __( 'Update Overview', 'mainwp' ); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Method render() |
| 92 |
* |
| 93 |
* Check if $_GET['dashboard'] then run render_sites(). |
| 94 |
*/ |
| 95 |
public static function render() { |
| 96 |
self::render_sites(); |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Method sync_site() |
| 101 |
* |
| 102 |
* Sync Child Site. |
| 103 |
* |
| 104 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 105 |
* @uses \MainWP\Dashboard\MainWP_DB::update_website_sync_values() |
| 106 |
* @uses \MainWP\Dashboard\MainWP_Sync::sync_website() |
| 107 |
*/ |
| 108 |
public static function sync_site() { |
| 109 |
$website = null; |
| 110 |
$wp_id = isset( $_POST['wp_id'] ) ? intval( $_POST['wp_id'] ) : false; |
| 111 |
if ( $wp_id ) { |
| 112 |
$website = MainWP_DB::instance()->get_website_by_id( $wp_id ); |
| 113 |
} |
| 114 |
|
| 115 |
if ( null == $website ) { |
| 116 |
die( wp_json_encode( array( 'error' => __( 'Site ID not found. Please reload the page and try again.', 'mainwp' ) ) ) ); |
| 117 |
} |
| 118 |
|
| 119 |
if ( MainWP_Sync::sync_website( $website ) ) { |
| 120 |
die( wp_json_encode( array( 'result' => 'SUCCESS' ) ) ); |
| 121 |
} |
| 122 |
|
| 123 |
$website = MainWP_DB::instance()->get_website_by_id( $website->id ); |
| 124 |
|
| 125 |
die( wp_json_encode( array( 'error' => $website->sync_errors ) ) ); |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* Method render_sites() |
| 130 |
* |
| 131 |
* Grab available Child Sites updates a build Widget. |
| 132 |
* |
| 133 |
* @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() |
| 134 |
* @uses \MainWP\Dashboard\MainWP_DB_Common::get_last_sync_status() |
| 135 |
* @uses \MainWP\Dashboard\MainWP_DB::query() |
| 136 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 137 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 138 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek()::fetch_object() |
| 139 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 140 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid() |
| 141 |
* @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp() |
| 142 |
*/ |
| 143 |
public static function render_sites() { // phpcs:ignore -- current complexity required to achieve desired results. Pull request solutions appreciated. |
| 144 |
|
| 145 |
$globalView = true; |
| 146 |
|
| 147 |
/** |
| 148 |
* Current user global. |
| 149 |
* |
| 150 |
* @global string |
| 151 |
*/ |
| 152 |
global $current_user; |
| 153 |
|
| 154 |
$current_wpid = MainWP_System_Utility::get_current_wpid(); |
| 155 |
|
| 156 |
if ( $current_wpid ) { |
| 157 |
$sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) ); |
| 158 |
$globalView = false; |
| 159 |
} else { |
| 160 |
$staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' ); |
| 161 |
// To support staging extension. |
| 162 |
$is_staging = 'no'; |
| 163 |
if ( $staging_enabled ) { |
| 164 |
$staging_updates_view = get_user_option( 'mainwp_staging_options_updates_view', $current_user->ID ); |
| 165 |
if ( 'staging' == $staging_updates_view ) { |
| 166 |
$is_staging = 'yes'; |
| 167 |
} |
| 168 |
} |
| 169 |
// end support. |
| 170 |
|
| 171 |
$sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging ); |
| 172 |
} |
| 173 |
|
| 174 |
$userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 175 |
$websites = MainWP_DB::instance()->query( $sql ); |
| 176 |
|
| 177 |
$mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 ); |
| 178 |
|
| 179 |
$decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); |
| 180 |
$decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); |
| 181 |
|
| 182 |
$total_wp_upgrades = 0; |
| 183 |
$total_plugin_upgrades = 0; |
| 184 |
$total_translation_upgrades = 0; |
| 185 |
$total_theme_upgrades = 0; |
| 186 |
|
| 187 |
$total_plugins_outdate = 0; |
| 188 |
$total_themes_outdate = 0; |
| 189 |
|
| 190 |
$all_wp_updates = array(); |
| 191 |
$all_plugins_updates = array(); |
| 192 |
$all_themes_updates = array(); |
| 193 |
$all_translations_updates = array(); |
| 194 |
|
| 195 |
MainWP_DB::data_seek( $websites, 0 ); |
| 196 |
|
| 197 |
$currentSite = null; |
| 198 |
|
| 199 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 200 |
if ( ! $globalView ) { |
| 201 |
$currentSite = $website; |
| 202 |
} |
| 203 |
|
| 204 |
$pluginsIgnoredAbandoned_perSites = array(); |
| 205 |
$themesIgnoredAbandoned_perSites = array(); |
| 206 |
|
| 207 |
$wp_upgrades = json_decode( MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ), true ); |
| 208 |
if ( $website->is_ignoreCoreUpdates ) { |
| 209 |
$wp_upgrades = array(); |
| 210 |
} |
| 211 |
|
| 212 |
if ( is_array( $wp_upgrades ) && count( $wp_upgrades ) > 0 ) { |
| 213 |
$total_wp_upgrades ++; |
| 214 |
$all_wp_updates[] = array( |
| 215 |
'id' => $website->id, |
| 216 |
'name' => $website->name, |
| 217 |
); |
| 218 |
} |
| 219 |
|
| 220 |
$translation_upgrades = json_decode( $website->translation_upgrades, true ); |
| 221 |
|
| 222 |
$plugin_upgrades = json_decode( $website->plugin_upgrades, true ); |
| 223 |
if ( $website->is_ignorePluginUpdates ) { |
| 224 |
$plugin_upgrades = array(); |
| 225 |
} |
| 226 |
|
| 227 |
$theme_upgrades = json_decode( $website->theme_upgrades, true ); |
| 228 |
if ( $website->is_ignoreThemeUpdates ) { |
| 229 |
$theme_upgrades = array(); |
| 230 |
} |
| 231 |
|
| 232 |
$decodedPremiumUpgrades = json_decode( MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' ), true ); |
| 233 |
if ( is_array( $decodedPremiumUpgrades ) ) { |
| 234 |
foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { |
| 235 |
$premiumUpgrade['premium'] = true; |
| 236 |
|
| 237 |
if ( 'plugin' == $premiumUpgrade['type'] ) { |
| 238 |
if ( ! is_array( $plugin_upgrades ) ) { |
| 239 |
$plugin_upgrades = array(); |
| 240 |
} |
| 241 |
if ( ! $website->is_ignorePluginUpdates ) { |
| 242 |
|
| 243 |
$premiumUpgrade = array_filter( $premiumUpgrade ); |
| 244 |
if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { |
| 245 |
$plugin_upgrades[ $crrSlug ] = array(); |
| 246 |
} |
| 247 |
|
| 248 |
$plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); |
| 249 |
} |
| 250 |
} elseif ( 'theme' == $premiumUpgrade['type'] ) { |
| 251 |
if ( ! is_array( $theme_upgrades ) ) { |
| 252 |
$theme_upgrades = array(); |
| 253 |
} |
| 254 |
if ( ! $website->is_ignoreThemeUpdates ) { |
| 255 |
$theme_upgrades[ $crrSlug ] = $premiumUpgrade; |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
if ( is_array( $translation_upgrades ) ) { |
| 262 |
|
| 263 |
$total_translation_upgrades += count( $translation_upgrades ); |
| 264 |
|
| 265 |
if ( count( $translation_upgrades ) > 0 ) { |
| 266 |
foreach ( $translation_upgrades as $trans_upgrade ) { |
| 267 |
$slug = $trans_upgrade['slug']; |
| 268 |
$all_translations_updates[] = array( |
| 269 |
'id' => $website->id, |
| 270 |
'name' => $website->name, |
| 271 |
'translation_slug' => $slug, |
| 272 |
); |
| 273 |
} |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
if ( is_array( $plugin_upgrades ) ) { |
| 278 |
$ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 279 |
if ( is_array( $ignored_plugins ) ) { |
| 280 |
$plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); |
| 281 |
} |
| 282 |
|
| 283 |
$ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 284 |
if ( is_array( $ignored_plugins ) ) { |
| 285 |
$plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); |
| 286 |
} |
| 287 |
|
| 288 |
$total_plugin_upgrades += count( $plugin_upgrades ); |
| 289 |
|
| 290 |
if ( count( $plugin_upgrades ) > 0 ) { |
| 291 |
foreach ( $plugin_upgrades as $slug => $value ) { |
| 292 |
$all_plugins_updates[] = array( |
| 293 |
'id' => $website->id, |
| 294 |
'name' => $website->name, |
| 295 |
'plugin_slug' => $slug, |
| 296 |
); |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
if ( is_array( $theme_upgrades ) ) { |
| 302 |
$ignored_themes = json_decode( $website->ignored_themes, true ); |
| 303 |
if ( is_array( $ignored_themes ) ) { |
| 304 |
$theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); |
| 305 |
} |
| 306 |
|
| 307 |
$ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 308 |
if ( is_array( $ignored_themes ) ) { |
| 309 |
$theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); |
| 310 |
} |
| 311 |
|
| 312 |
$total_theme_upgrades += count( $theme_upgrades ); |
| 313 |
|
| 314 |
if ( count( $theme_upgrades ) > 0 ) { |
| 315 |
foreach ( $theme_upgrades as $slug => $value ) { |
| 316 |
$all_themes_updates[] = array( |
| 317 |
'id' => $website->id, |
| 318 |
'name' => $website->name, |
| 319 |
'theme_slug' => $slug, |
| 320 |
); |
| 321 |
} |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
$pluginsIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); |
| 326 |
$pluginsIgnoredAbandoned_perSites = ! empty( $pluginsIgnoredAbandoned_perSites ) ? json_decode( $pluginsIgnoredAbandoned_perSites, true ) : array(); |
| 327 |
if ( is_array( $pluginsIgnoredAbandoned_perSites ) ) { |
| 328 |
$pluginsIgnoredAbandoned_perSites = array_filter( $pluginsIgnoredAbandoned_perSites ); |
| 329 |
} |
| 330 |
|
| 331 |
$themesIgnoredAbandoned_perSites = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); |
| 332 |
$themesIgnoredAbandoned_perSites = ! empty( $themesIgnoredAbandoned_perSites ) ? json_decode( $themesIgnoredAbandoned_perSites, true ) : array(); |
| 333 |
if ( is_array( $themesIgnoredAbandoned_perSites ) ) { |
| 334 |
$themesIgnoredAbandoned_perSites = array_filter( $themesIgnoredAbandoned_perSites ); |
| 335 |
} |
| 336 |
|
| 337 |
$plugins_outdate = json_decode( MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ), true ); |
| 338 |
$themes_outdate = json_decode( MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ), true ); |
| 339 |
|
| 340 |
if ( is_array( $plugins_outdate ) ) { |
| 341 |
if ( is_array( $pluginsIgnoredAbandoned_perSites ) ) { |
| 342 |
$plugins_outdate = array_diff_key( $plugins_outdate, $pluginsIgnoredAbandoned_perSites ); |
| 343 |
} |
| 344 |
|
| 345 |
if ( is_array( $decodedDismissedPlugins ) ) { |
| 346 |
$plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); |
| 347 |
} |
| 348 |
|
| 349 |
$total_plugins_outdate += count( $plugins_outdate ); |
| 350 |
} |
| 351 |
|
| 352 |
if ( is_array( $themes_outdate ) ) { |
| 353 |
if ( is_array( $themesIgnoredAbandoned_perSites ) ) { |
| 354 |
$themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites ); |
| 355 |
} |
| 356 |
|
| 357 |
if ( is_array( $decodedDismissedThemes ) ) { |
| 358 |
$themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); |
| 359 |
} |
| 360 |
|
| 361 |
$total_themes_outdate += count( $themes_outdate ); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
// WP Upgrades part. |
| 366 |
$total_upgrades = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades; |
| 367 |
|
| 368 |
// to fix incorrect total updates. |
| 369 |
if ( $mainwp_show_language_updates ) { |
| 370 |
$total_upgrades += $total_translation_upgrades; |
| 371 |
} |
| 372 |
|
| 373 |
$trustedPlugins = json_decode( $userExtension->trusted_plugins, true ); |
| 374 |
if ( ! is_array( $trustedPlugins ) ) { |
| 375 |
$trustedPlugins = array(); |
| 376 |
} |
| 377 |
$trustedThemes = json_decode( $userExtension->trusted_themes, true ); |
| 378 |
if ( ! is_array( $trustedThemes ) ) { |
| 379 |
$trustedThemes = array(); |
| 380 |
} |
| 381 |
|
| 382 |
/** |
| 383 |
* Filter: mainwp_limit_updates_all |
| 384 |
* |
| 385 |
* Limits the number of updates that will be processed in a single run on Update Everything action. |
| 386 |
* |
| 387 |
* @since 4.0 |
| 388 |
*/ |
| 389 |
$limit_updates_all = apply_filters( 'mainwp_limit_updates_all', 0 ); |
| 390 |
$continue_update = ''; |
| 391 |
if ( $limit_updates_all > 0 ) { |
| 392 |
if ( isset( $_GET['continue_update'] ) && '' != $_GET['continue_update'] ) { |
| 393 |
$continue_update = sanitize_text_field( wp_unslash( $_GET['continue_update'] ) ); |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
if ( ! $globalView ) { |
| 398 |
$last_dtsSync = $currentSite->dtsSync; |
| 399 |
} else { |
| 400 |
$result = MainWP_DB_Common::instance()->get_last_sync_status(); |
| 401 |
$sync_status = $result['sync_status']; |
| 402 |
$last_sync = $result['last_sync']; |
| 403 |
$last_dtsSync = $result['last_sync']; |
| 404 |
|
| 405 |
if ( 'all_synced' === $sync_status ) { |
| 406 |
$now = time(); |
| 407 |
$last_sync_all = get_option( 'mainwp_last_synced_all_sites', 0 ); |
| 408 |
if ( 0 == $last_sync_all ) { |
| 409 |
$last_sync_all = $last_sync; |
| 410 |
} |
| 411 |
$last_dtsSync = $last_sync_all; |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
$lastSyncMsg = ''; |
| 416 |
if ( $last_dtsSync ) { |
| 417 |
$lastSyncMsg = __( 'Last successfully completed synchronization: ', 'mainwp' ) . MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $last_dtsSync ) ); |
| 418 |
} |
| 419 |
|
| 420 |
$user_can_update_translation = mainwp_current_user_have_right( 'dashboard', 'update_translations' ); |
| 421 |
$user_can_update_wordpress = mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ); |
| 422 |
$user_can_update_themes = mainwp_current_user_have_right( 'dashboard', 'update_themes' ); |
| 423 |
$user_can_update_plugins = mainwp_current_user_have_right( 'dashboard', 'update_plugins' ); |
| 424 |
|
| 425 |
$can_total_update = ( $user_can_update_wordpress && $user_can_update_plugins && $user_can_update_themes && $user_can_update_translation ) ? true : false; |
| 426 |
|
| 427 |
self::render_total_update( $total_upgrades, $lastSyncMsg, $can_total_update, $limit_updates_all ); |
| 428 |
self::render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $continue_update ); |
| 429 |
self::render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $continue_update ); |
| 430 |
self::render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $continue_update ); |
| 431 |
if ( 1 == $mainwp_show_language_updates ) { |
| 432 |
self::render_language_update( $user_can_update_translation, $total_translation_upgrades, $globalView, $current_wpid, $continue_update ); |
| 433 |
} |
| 434 |
self::render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid ); |
| 435 |
self::render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid ); |
| 436 |
self::render_global_update( |
| 437 |
$user_can_update_wordpress, |
| 438 |
$total_wp_upgrades, |
| 439 |
$all_wp_updates, |
| 440 |
$user_can_update_plugins, |
| 441 |
$total_plugin_upgrades, |
| 442 |
$all_plugins_updates, |
| 443 |
$user_can_update_themes, |
| 444 |
$total_theme_upgrades, |
| 445 |
$all_themes_updates, |
| 446 |
$mainwp_show_language_updates, |
| 447 |
$user_can_update_translation, |
| 448 |
$total_translation_upgrades, |
| 449 |
$all_translations_updates |
| 450 |
); |
| 451 |
self::render_bottom( $websites, $globalView ); |
| 452 |
} |
| 453 |
|
| 454 |
/** |
| 455 |
* Render total update. |
| 456 |
* |
| 457 |
* @param int $total_upgrades number of update. |
| 458 |
* @param string $lastSyncMsg last sync info. |
| 459 |
* @param bool true|false $can_total_update permission to update all. |
| 460 |
* @param int $limit_updates_all limit number of update per request, 0 is no limit. |
| 461 |
*/ |
| 462 |
public static function render_total_update( $total_upgrades, $lastSyncMsg, $can_total_update, $limit_updates_all ) { |
| 463 |
?> |
| 464 |
<div class="ui grid"> |
| 465 |
<div class="sixteen wide column"> |
| 466 |
<h3 class="ui header handle-drag"> |
| 467 |
<?php |
| 468 |
/** |
| 469 |
* Filter: mainwp_updates_overview_widget_title |
| 470 |
* |
| 471 |
* Filters the Updates Overview widget title text. |
| 472 |
* |
| 473 |
* @since 4.1 |
| 474 |
*/ |
| 475 |
echo esc_html( apply_filters( 'mainwp_updates_overview_widget_title', __( 'Updates Overview', 'mainwp' ) ) ); |
| 476 |
?> |
| 477 |
<div class="sub header"><?php echo $lastSyncMsg; ?></div> |
| 478 |
</h3> |
| 479 |
</div> |
| 480 |
</div> |
| 481 |
<input type="hidden" name="updatesoverview_limit_updates_all" id="updatesoverview_limit_updates_all" value="<?php echo intval( $limit_updates_all ); ?>"> |
| 482 |
<?php |
| 483 |
/** |
| 484 |
* Action: mainwp_updates_overview_before_total_updates |
| 485 |
* |
| 486 |
* Fires before the total updates section in the Updates Overview widget. |
| 487 |
* |
| 488 |
* @since 4.1 |
| 489 |
*/ |
| 490 |
do_action( 'mainwp_updates_overview_before_total_updates' ); |
| 491 |
?> |
| 492 |
<div class="ui two column stackable grid"> |
| 493 |
<div class="column"> |
| 494 |
<div class="ui large statistic horizontal"> |
| 495 |
<div class="value"> |
| 496 |
<?php echo $total_upgrades; ?> |
| 497 |
</div> |
| 498 |
<div class="label"> |
| 499 |
<?php esc_html_e( 'Total Updates', 'mainwp' ); ?> |
| 500 |
</div> |
| 501 |
</div> |
| 502 |
</div> |
| 503 |
<div class="column middle aligned"> |
| 504 |
<?php |
| 505 |
/** |
| 506 |
* Filter: mainwp_update_everything_button_text |
| 507 |
* |
| 508 |
* Filters the Update Everything button text. |
| 509 |
* |
| 510 |
* @since 4.1 |
| 511 |
*/ |
| 512 |
if ( $can_total_update ) : |
| 513 |
?> |
| 514 |
<?php if ( ! get_option( 'mainwp_hide_update_everything', false ) ) : ?> |
| 515 |
<a href="#" <?php echo 0 == $total_upgrades ? 'disabled' : 'onClick="return updatesoverview_global_upgrade_all( \'all\' );"'; ?> class="ui big button fluid green" data-tooltip="<?php esc_attr_e( 'Clicking this button will update all Plugins, Themes, WP Core files and translations on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php echo esc_html( apply_filters( 'mainwp_update_everything_button_text', __( 'Update Everything', 'mainwp' ) ) ); ?></a> |
| 516 |
<?php endif; ?> |
| 517 |
<?php endif; ?> |
| 518 |
</div> |
| 519 |
</div> |
| 520 |
<?php |
| 521 |
/** |
| 522 |
* Action: mainwp_updates_overview_after_total_updates |
| 523 |
* |
| 524 |
* Fires after the total updates section in the Updates Overview widget. |
| 525 |
* |
| 526 |
* @since 4.1 |
| 527 |
*/ |
| 528 |
do_action( 'mainwp_updates_overview_after_total_updates' ); |
| 529 |
?> |
| 530 |
<?php |
| 531 |
} |
| 532 |
|
| 533 |
/** |
| 534 |
* Render WordPress update details. |
| 535 |
* |
| 536 |
* @param bool $user_can_update_wordpress Permission to update WordPress. |
| 537 |
* @param int $total_wp_upgrades Total number of WordPress update. |
| 538 |
* @param bool $globalView Global view or not. |
| 539 |
* @param int $current_wpid Current site ID. |
| 540 |
* @param string $continue_update String of continue update. |
| 541 |
* |
| 542 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 543 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 544 |
*/ |
| 545 |
public static function render_wordpress_update( $user_can_update_wordpress, $total_wp_upgrades, $globalView, $current_wpid, $continue_update ) { |
| 546 |
?> |
| 547 |
<div class="ui hidden divider"></div> |
| 548 |
<div class="ui horizontal divider"> |
| 549 |
<?php |
| 550 |
/** |
| 551 |
* Filter: mainwp_updates_overview_update_details_divider |
| 552 |
* |
| 553 |
* Filters the Update Details divider text in the Updates Overview widget. |
| 554 |
* |
| 555 |
* @since 4.1 |
| 556 |
*/ |
| 557 |
echo esc_html( apply_filters( 'mainwp_updates_overview_update_details_divider', __( 'Update Details', 'mainwp' ) ) ); |
| 558 |
?> |
| 559 |
</div> |
| 560 |
<div class="ui hidden divider"></div> |
| 561 |
<?php |
| 562 |
/** |
| 563 |
* Action: mainwp_updates_overview_before_update_details |
| 564 |
* |
| 565 |
* Fires at the top of the Update Details section in the Updates Overview widget. |
| 566 |
* |
| 567 |
* @since 4.1 |
| 568 |
*/ |
| 569 |
do_action( 'mainwp_updates_overview_before_update_details' ); |
| 570 |
|
| 571 |
/** |
| 572 |
* Action: mainwp_updates_overview_before_wordpress_updates |
| 573 |
* |
| 574 |
* Fires before the WordPress updates section in the Updates Overview widget. |
| 575 |
* |
| 576 |
* @since 4.1 |
| 577 |
*/ |
| 578 |
do_action( 'mainwp_updates_overview_before_wordpress_updates' ); |
| 579 |
?> |
| 580 |
<div class="ui grid"> |
| 581 |
<div class="two column row"> |
| 582 |
<div class="column"> |
| 583 |
<div class="ui horizontal statistic"> |
| 584 |
<div class="value"> |
| 585 |
<?php echo $total_wp_upgrades; ?> |
| 586 |
</div> |
| 587 |
<div class="label"> |
| 588 |
<?php esc_html_e( 'WordPress Updates', 'mainwp' ); ?> |
| 589 |
</div> |
| 590 |
</div> |
| 591 |
</div> |
| 592 |
<div class="right aligned column"> |
| 593 |
<?php |
| 594 |
if ( $user_can_update_wordpress ) : |
| 595 |
if ( $globalView ) { |
| 596 |
$detail_wp_up = 'admin.php?page=UpdatesManage&tab=wordpress-updates'; |
| 597 |
} else { |
| 598 |
$detail_wp_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=wordpress-updates'; |
| 599 |
} |
| 600 |
?> |
| 601 |
<?php if ( 0 < $total_wp_upgrades ) : ?> |
| 602 |
<?php MainWP_Updates::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); ?> |
| 603 |
<a href="<?php echo $detail_wp_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 604 |
<a href="#" onClick="return updatesoverview_global_upgrade_all('wp');" class="ui green basic button <?php echo MainWP_Updates::get_continue_update_selector(); ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update WP Core files on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 605 |
<?php else : ?> |
| 606 |
<a href="<?php echo $detail_wp_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 607 |
<a href="#" class="ui disabled green basic button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 608 |
<?php endif; ?> |
| 609 |
<?php endif; ?> |
| 610 |
</div> |
| 611 |
</div> |
| 612 |
</div> |
| 613 |
<?php |
| 614 |
/** |
| 615 |
* Action: mainwp_updates_overview_after_wordpress_updates |
| 616 |
* |
| 617 |
* Fires after the WordPress updates section in the Updates Overview widget. |
| 618 |
* |
| 619 |
* @since 4.1 |
| 620 |
*/ |
| 621 |
do_action( 'mainwp_updates_overview_after_wordpress_updates' ); |
| 622 |
} |
| 623 |
|
| 624 |
/** |
| 625 |
* Render Plugins update detail. |
| 626 |
* |
| 627 |
* @param bool true|false $user_can_update_plugins permission to update. |
| 628 |
* @param int $total_plugin_upgrades total number of update. |
| 629 |
* @param bool true|false $globalView global view or not. |
| 630 |
* @param int $current_wpid current site id. |
| 631 |
* @param string $continue_update string of continue update. |
| 632 |
* |
| 633 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 634 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 635 |
*/ |
| 636 |
public static function render_plugins_update( $user_can_update_plugins, $total_plugin_upgrades, $globalView, $current_wpid, $continue_update ) { |
| 637 |
/** |
| 638 |
* Action: mainwp_updates_overview_before_plugin_updates |
| 639 |
* |
| 640 |
* Fires before the Plugin updates section in the Updates Overview widget. |
| 641 |
* |
| 642 |
* @since 4.1 |
| 643 |
*/ |
| 644 |
do_action( 'mainwp_updates_overview_before_plugin_updates' ); |
| 645 |
?> |
| 646 |
<div class="ui grid"> |
| 647 |
<div class="two column row"> |
| 648 |
<div class="column"> |
| 649 |
<div class="ui horizontal statistic"> |
| 650 |
<div class="value"> |
| 651 |
<?php echo $total_plugin_upgrades; ?> |
| 652 |
</div> |
| 653 |
<div class="label"> |
| 654 |
<?php esc_html_e( 'Plugin Updates', 'mainwp' ); ?> |
| 655 |
</div> |
| 656 |
</div> |
| 657 |
</div> |
| 658 |
<div class="right aligned column"> |
| 659 |
<?php |
| 660 |
if ( $user_can_update_plugins ) { |
| 661 |
MainWP_Updates::set_continue_update_html_selector( 'plugins_global_upgrade_all' ); |
| 662 |
if ( $globalView ) { |
| 663 |
$detail_plugins_up = 'admin.php?page=UpdatesManage&tab=plugins-updates'; |
| 664 |
} else { |
| 665 |
$detail_plugins_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=plugins-updates'; |
| 666 |
} |
| 667 |
|
| 668 |
if ( 0 == $total_plugin_upgrades ) { |
| 669 |
?> |
| 670 |
<a href="<?php echo $detail_plugins_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 671 |
<a href="#" class="ui disabled green basic button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 672 |
<?php |
| 673 |
} else { |
| 674 |
?> |
| 675 |
<a href="<?php echo $detail_plugins_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 676 |
<a href="#" onClick="return updatesoverview_global_upgrade_all('plugin');" class="ui basic green button <?php echo MainWP_Updates::get_continue_update_selector(); ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update all Plugins on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 677 |
<?php |
| 678 |
} |
| 679 |
}; |
| 680 |
?> |
| 681 |
</div> |
| 682 |
</div> |
| 683 |
</div> |
| 684 |
<?php |
| 685 |
/** |
| 686 |
* Action: mainwp_updates_overview_after_plugin_updates |
| 687 |
* |
| 688 |
* Fires after the Plugin updates section in the Updates Overview widget. |
| 689 |
* |
| 690 |
* @since 4.1 |
| 691 |
*/ |
| 692 |
do_action( 'mainwp_updates_overview_after_plugin_updates' ); |
| 693 |
} |
| 694 |
|
| 695 |
/** |
| 696 |
* Render Themes update detail. |
| 697 |
* |
| 698 |
* @param bool true|false $user_can_update_themes permission to update. |
| 699 |
* @param int $total_theme_upgrades total number of update. |
| 700 |
* @param bool true|false $globalView global view or not. |
| 701 |
* @param int $current_wpid current site id. |
| 702 |
* @param string $continue_update string of continue update. |
| 703 |
* |
| 704 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 705 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 706 |
*/ |
| 707 |
public static function render_themes_update( $user_can_update_themes, $total_theme_upgrades, $globalView, $current_wpid, $continue_update ) { |
| 708 |
/** |
| 709 |
* Action: mainwp_updates_overview_before_theme_updates |
| 710 |
* |
| 711 |
* Fires before the Theme updates section in the Updates Overview widget. |
| 712 |
* |
| 713 |
* @since 4.1 |
| 714 |
*/ |
| 715 |
do_action( 'mainwp_updates_overview_before_theme_updates' ); |
| 716 |
?> |
| 717 |
<div class="ui grid"> |
| 718 |
<div class="two column row"> |
| 719 |
<div class="column"> |
| 720 |
<div class="ui horizontal statistic"> |
| 721 |
<div class="value"> |
| 722 |
<?php echo $total_theme_upgrades; ?> |
| 723 |
</div> |
| 724 |
<div class="label"> |
| 725 |
<?php esc_html_e( 'Theme Updates', 'mainwp' ); ?> |
| 726 |
</div> |
| 727 |
</div> |
| 728 |
</div> |
| 729 |
<div class="right aligned column"> |
| 730 |
<?php |
| 731 |
if ( $user_can_update_themes ) { |
| 732 |
MainWP_Updates::set_continue_update_html_selector( 'themes_global_upgrade_all' ); |
| 733 |
if ( $globalView ) { |
| 734 |
$detail_themes_up = 'admin.php?page=UpdatesManage&tab=themes-updates'; |
| 735 |
} else { |
| 736 |
$detail_themes_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=themes-updates'; |
| 737 |
} |
| 738 |
if ( 0 == $total_theme_upgrades ) { |
| 739 |
?> |
| 740 |
<a href="<?php echo $detail_themes_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 741 |
<a href="#" class="ui disabled green basic button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 742 |
<?php |
| 743 |
} else { |
| 744 |
?> |
| 745 |
<a href="<?php echo $detail_themes_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 746 |
<a href="#" onClick="return updatesoverview_global_upgrade_all('theme');" class="ui basic green button <?php echo MainWP_Updates::get_continue_update_selector(); ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update all Themes on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 747 |
<?php |
| 748 |
} |
| 749 |
}; |
| 750 |
?> |
| 751 |
</div> |
| 752 |
</div> |
| 753 |
</div> |
| 754 |
<?php |
| 755 |
/** |
| 756 |
* Action: mainwp_updates_overview_after_theme_updates |
| 757 |
* |
| 758 |
* Fires after the Theme updates section in the Updates Overview widget. |
| 759 |
* |
| 760 |
* @since 4.1 |
| 761 |
*/ |
| 762 |
do_action( 'mainwp_updates_overview_after_theme_updates' ); |
| 763 |
} |
| 764 |
/** |
| 765 |
* Render language update details. |
| 766 |
* |
| 767 |
* @param bool $user_can_update_translation Permission to update. |
| 768 |
* @param int $total_translation_upgrades Total number of update. |
| 769 |
* @param bool $globalView Global view or not. |
| 770 |
* @param int $current_wpid Current site id. |
| 771 |
* @param string $continue_update String of continue update. |
| 772 |
* |
| 773 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 774 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 775 |
*/ |
| 776 |
public static function render_language_update( $user_can_update_translation, $total_translation_upgrades, $globalView, $current_wpid, $continue_update ) { |
| 777 |
/** |
| 778 |
* Action: mainwp_updates_overview_before_translation_updates |
| 779 |
* |
| 780 |
* Fires before the Translation updates section in the Updates Overview widget. |
| 781 |
* |
| 782 |
* @since 4.1 |
| 783 |
*/ |
| 784 |
do_action( 'mainwp_updates_overview_before_translation_updates' ); |
| 785 |
?> |
| 786 |
<div class="ui grid"> |
| 787 |
<div class="two column row"> |
| 788 |
<div class="column"> |
| 789 |
<div class="ui horizontal statistic"> |
| 790 |
<div class="value"> |
| 791 |
<?php echo $total_translation_upgrades; ?> |
| 792 |
</div> |
| 793 |
<div class="label"> |
| 794 |
<?php esc_html_e( 'Translation Updates', 'mainwp' ); ?> |
| 795 |
</div> |
| 796 |
</div> |
| 797 |
</div> |
| 798 |
<div class="right aligned column"> |
| 799 |
<?php |
| 800 |
if ( $user_can_update_translation ) { |
| 801 |
MainWP_Updates::set_continue_update_html_selector( 'translations_global_upgrade_all' ); |
| 802 |
if ( $globalView ) { |
| 803 |
$detail_trans_up = 'admin.php?page=UpdatesManage&tab=translations-updates'; |
| 804 |
} else { |
| 805 |
$detail_trans_up = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=translations-updates'; |
| 806 |
} |
| 807 |
if ( 0 == $total_translation_upgrades ) { |
| 808 |
?> |
| 809 |
<a href="<?php echo $detail_trans_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 810 |
<a href="#" class="ui disabled green basic button"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 811 |
<?php |
| 812 |
} else { |
| 813 |
?> |
| 814 |
<a href="<?php echo $detail_trans_up; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 815 |
<a href="#" onClick="return updatesoverview_global_upgrade_all('translation');" class="ui basic green button <?php echo MainWP_Updates::get_continue_update_selector(); ?>" data-tooltip="<?php esc_html_e( 'Clicking this button will update all Translations on All your websites.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a> |
| 816 |
<?php |
| 817 |
} |
| 818 |
}; |
| 819 |
?> |
| 820 |
</div> |
| 821 |
</div> |
| 822 |
</div> |
| 823 |
<?php |
| 824 |
/** |
| 825 |
* Action: mainwp_updates_overview_after_translation_updates |
| 826 |
* |
| 827 |
* Fires after the Translation updates section in the Updates Overview widget. |
| 828 |
* |
| 829 |
* @since 4.1 |
| 830 |
*/ |
| 831 |
do_action( 'mainwp_updates_overview_after_translation_updates' ); |
| 832 |
|
| 833 |
/** |
| 834 |
* Action: mainwp_updates_overview_after_update_details |
| 835 |
* |
| 836 |
* Fires at the bottom of the Update Details section in the Updates Overview widget. |
| 837 |
* |
| 838 |
* @since 4.1 |
| 839 |
*/ |
| 840 |
do_action( 'mainwp_updates_overview_after_update_details' ); |
| 841 |
} |
| 842 |
|
| 843 |
/** |
| 844 |
* Render abandoned plugins detail. |
| 845 |
* |
| 846 |
* @param int $total_plugins_outdate total number of update. |
| 847 |
* @param bool $globalView global view or not. |
| 848 |
* @param int $current_wpid current site id. |
| 849 |
*/ |
| 850 |
public static function render_abandoned_plugins( $total_plugins_outdate, $globalView, $current_wpid ) { |
| 851 |
?> |
| 852 |
<div class="ui hidden divider"></div> |
| 853 |
<div class="ui horizontal divider"> |
| 854 |
<?php |
| 855 |
/** |
| 856 |
* Filter: mainwp_updates_overview_abandoned_plugins_themes_divider |
| 857 |
* |
| 858 |
* Filters the Abandoned Plugins & Themes divider text in the Updates Overview widget. |
| 859 |
* |
| 860 |
* @since 4.1 |
| 861 |
*/ |
| 862 |
echo esc_html( apply_filters( 'mainwp_updates_overview_abandoned_plugins_themes_divider', __( 'Abandoned Plugins & Themes', 'mainwp' ) ) ); |
| 863 |
?> |
| 864 |
</div> |
| 865 |
<div class="ui hidden divider"></div> |
| 866 |
<?php |
| 867 |
/** |
| 868 |
* Action: mainwp_updates_overview_before_abandoned_plugins_themes |
| 869 |
* |
| 870 |
* Fires at the top of the Abandoned Plugins & Themes section in the Updates Overview widget. |
| 871 |
* |
| 872 |
* @since 4.1 |
| 873 |
*/ |
| 874 |
do_action( 'mainwp_updates_overview_before_abandoned_plugins_themes' ); |
| 875 |
?> |
| 876 |
<div class="ui grid"> |
| 877 |
<div class="two column row"> |
| 878 |
<div class="column"> |
| 879 |
<div class="ui horizontal statistic"> |
| 880 |
<?php |
| 881 |
if ( $globalView ) { |
| 882 |
$detail_aban_plugins = 'admin.php?page=UpdatesManage&tab=abandoned-plugins'; |
| 883 |
} else { |
| 884 |
$detail_aban_plugins = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-plugins'; |
| 885 |
} |
| 886 |
?> |
| 887 |
<div class="value"> |
| 888 |
<?php echo $total_plugins_outdate; ?> |
| 889 |
</div> |
| 890 |
<div class="label"> |
| 891 |
<?php esc_html_e( 'Abandoned Plugins', 'mainwp' ); ?> |
| 892 |
</div> |
| 893 |
</div> |
| 894 |
</div> |
| 895 |
<div class="right aligned column"> |
| 896 |
<a href="<?php echo $detail_aban_plugins; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 897 |
</div> |
| 898 |
</div> |
| 899 |
</div> |
| 900 |
<?php |
| 901 |
} |
| 902 |
|
| 903 |
/** |
| 904 |
* Render abandoned themes detail. |
| 905 |
* |
| 906 |
* @param int $total_themes_outdate Total number of update. |
| 907 |
* @param bool $globalView global View or not. |
| 908 |
* @param int $current_wpid Current site ID. |
| 909 |
*/ |
| 910 |
public static function render_abandoned_themes( $total_themes_outdate, $globalView, $current_wpid ) { |
| 911 |
?> |
| 912 |
<div class="ui grid"> |
| 913 |
<div class="two column row"> |
| 914 |
<div class="column"> |
| 915 |
<div class="ui horizontal statistic"> |
| 916 |
<?php |
| 917 |
if ( $globalView ) { |
| 918 |
$detail_aban_themes = 'admin.php?page=UpdatesManage&tab=abandoned-themes'; |
| 919 |
} else { |
| 920 |
$detail_aban_themes = 'admin.php?page=managesites&updateid=' . $current_wpid . '&tab=abandoned-themes'; |
| 921 |
} |
| 922 |
?> |
| 923 |
<div class="value"> |
| 924 |
<?php echo $total_themes_outdate; ?> |
| 925 |
</div> |
| 926 |
<div class="label"> |
| 927 |
<?php esc_html_e( 'Abandoned Themes', 'mainwp' ); ?> |
| 928 |
</div> |
| 929 |
</div> |
| 930 |
</div> |
| 931 |
<div class="right aligned column"> |
| 932 |
<a href="<?php echo $detail_aban_themes; ?>" class="ui button"><?php esc_html_e( 'See Details', 'mainwp' ); ?></a> |
| 933 |
</div> |
| 934 |
</div> |
| 935 |
</div> |
| 936 |
<?php |
| 937 |
/** |
| 938 |
* Action: mainwp_updates_overview_after_abandoned_plugins_themes |
| 939 |
* |
| 940 |
* Fires at the bottom of the Abandoned Plugins & Themes section in the Updates Overview widget. |
| 941 |
* |
| 942 |
* @since 4.1 |
| 943 |
*/ |
| 944 |
do_action( 'mainwp_updates_overview_after_abandoned_plugins_themes' ); |
| 945 |
} |
| 946 |
|
| 947 |
/** |
| 948 |
* Method render_global_update() |
| 949 |
* |
| 950 |
* Render global updates. |
| 951 |
* |
| 952 |
* @param bool $user_can_update_wordpress Permission to update WordPress. |
| 953 |
* @param int $total_wp_upgrades Total WordPress update. |
| 954 |
* @param array $all_wp_updates All WordPress update list. |
| 955 |
* |
| 956 |
* @param bool $user_can_update_plugins permission to update plugings. |
| 957 |
* @param int $total_plugin_upgrades total WordPress update. |
| 958 |
* @param array $all_plugins_updates all WordPress update list. |
| 959 |
* |
| 960 |
* @param bool $user_can_update_themes permission to update themes. |
| 961 |
* @param int $total_theme_upgrades total themes update. |
| 962 |
* @param mixed $all_themes_updates all themes update list. |
| 963 |
* |
| 964 |
* @param mixed $mainwp_show_language_updates MainWP Language Updates. |
| 965 |
* @param bool $user_can_update_translation permission to update languages. |
| 966 |
* @param int $total_translation_upgrades total WordPress update. |
| 967 |
* @param mixed $all_translations_updates all transations update list. |
| 968 |
*/ |
| 969 |
public static function render_global_update( |
| 970 |
$user_can_update_wordpress, |
| 971 |
$total_wp_upgrades, |
| 972 |
$all_wp_updates, |
| 973 |
|
| 974 |
$user_can_update_plugins, |
| 975 |
$total_plugin_upgrades, |
| 976 |
$all_plugins_updates, |
| 977 |
|
| 978 |
$user_can_update_themes, |
| 979 |
$total_theme_upgrades, |
| 980 |
$all_themes_updates, |
| 981 |
|
| 982 |
$mainwp_show_language_updates, |
| 983 |
$user_can_update_translation, |
| 984 |
$total_translation_upgrades, |
| 985 |
$all_translations_updates |
| 986 |
) { |
| 987 |
?> |
| 988 |
<div style="display: none"> |
| 989 |
|
| 990 |
<div id="wp_upgrades"> |
| 991 |
<?php |
| 992 |
if ( $user_can_update_wordpress && $total_wp_upgrades > 0 ) { |
| 993 |
foreach ( $all_wp_updates as $item ) { |
| 994 |
?> |
| 995 |
<div updated="0" site_id="<?php echo $item['id']; ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" ></div> |
| 996 |
<?php |
| 997 |
} |
| 998 |
} |
| 999 |
?> |
| 1000 |
</div> |
| 1001 |
|
| 1002 |
<div id="wp_plugin_upgrades"> |
| 1003 |
<?php |
| 1004 |
if ( $user_can_update_plugins && $total_plugin_upgrades > 0 ) { |
| 1005 |
foreach ( $all_plugins_updates as $item ) { |
| 1006 |
?> |
| 1007 |
<div updated="0" site_id="<?php echo $item['id']; ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" plugin_slug="<?php echo esc_attr( $item['plugin_slug'] ); ?>" ></div> |
| 1008 |
<?php |
| 1009 |
} |
| 1010 |
} |
| 1011 |
?> |
| 1012 |
</div> |
| 1013 |
<div id="wp_theme_upgrades"> |
| 1014 |
|
| 1015 |
<?php |
| 1016 |
if ( $user_can_update_themes && $total_theme_upgrades > 0 ) { |
| 1017 |
foreach ( $all_themes_updates as $item ) { |
| 1018 |
?> |
| 1019 |
<div updated="0" site_id="<?php echo $item['id']; ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" theme_slug="<?php echo esc_attr( $item['theme_slug'] ); ?>" ></div> |
| 1020 |
<?php |
| 1021 |
} |
| 1022 |
} |
| 1023 |
?> |
| 1024 |
|
| 1025 |
</div> |
| 1026 |
<?php if ( 1 == $mainwp_show_language_updates ) : ?> |
| 1027 |
<div id="wp_translation_upgrades"> |
| 1028 |
|
| 1029 |
<?php |
| 1030 |
if ( $user_can_update_translation && $total_translation_upgrades > 0 ) { |
| 1031 |
foreach ( $all_translations_updates as $item ) { |
| 1032 |
?> |
| 1033 |
<div updated="0" site_id="<?php echo $item['id']; ?>" site_name="<?php echo esc_attr( $item['name'] ); ?>" translation_slug="<?php echo esc_attr( $item['translation_slug'] ); ?>" ></div> |
| 1034 |
<?php |
| 1035 |
} |
| 1036 |
} |
| 1037 |
?> |
| 1038 |
</div> |
| 1039 |
<?php endif; ?> |
| 1040 |
</div> |
| 1041 |
<?php |
| 1042 |
} |
| 1043 |
|
| 1044 |
/** |
| 1045 |
* Render bottom of widget. |
| 1046 |
* |
| 1047 |
* @param object $websites Object containing child sites info. |
| 1048 |
* @param bool $globalView Whether it's global or individual site view. |
| 1049 |
* |
| 1050 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 1051 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 1052 |
* @uses \MainWP\Dashboard\MainWP_DB::free_result() |
| 1053 |
*/ |
| 1054 |
public static function render_bottom( $websites, $globalView ) { |
| 1055 |
|
| 1056 |
MainWP_DB::data_seek( $websites, 0 ); |
| 1057 |
|
| 1058 |
$site_ids = array(); |
| 1059 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 1060 |
$site_ids[] = $website->id; |
| 1061 |
} |
| 1062 |
|
| 1063 |
/** |
| 1064 |
* Action: mainwp_updatesoverview_widget_bottom |
| 1065 |
* |
| 1066 |
* Fires at the bottom of the Updates Overview widgets. |
| 1067 |
* |
| 1068 |
* @param array $side_ids Array of sites IDs. |
| 1069 |
* @param bool $globalView Whether it's global or individual site view. |
| 1070 |
* |
| 1071 |
* @since 4.0 |
| 1072 |
*/ |
| 1073 |
do_action( 'mainwp_updatesoverview_widget_bottom', $site_ids, $globalView ); |
| 1074 |
?> |
| 1075 |
<div class="ui modal" id="updatesoverview-backup-box" tabindex="0"> |
| 1076 |
<div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div> |
| 1077 |
<div class="scrolling content mainwp-modal-content"></div> |
| 1078 |
<div class="actions mainwp-modal-actions"> |
| 1079 |
<input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/> |
| 1080 |
<a id="updatesoverview-backup-now" href="#" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a> |
| 1081 |
<input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/> |
| 1082 |
</div> |
| 1083 |
</div> |
| 1084 |
|
| 1085 |
<?php |
| 1086 |
MainWP_DB::free_result( $websites ); |
| 1087 |
} |
| 1088 |
|
| 1089 |
/** |
| 1090 |
* Method dismiss_sync_errors() |
| 1091 |
* |
| 1092 |
* @param bool $dismiss true|false. |
| 1093 |
* |
| 1094 |
* @return bool true |
| 1095 |
*/ |
| 1096 |
public static function dismiss_sync_errors( $dismiss = true ) { |
| 1097 |
global $current_user; |
| 1098 |
update_user_option( $current_user->ID, 'mainwp_syncerrors_dismissed', $dismiss ); |
| 1099 |
|
| 1100 |
return true; |
| 1101 |
} |
| 1102 |
|
| 1103 |
/** |
| 1104 |
* Method checkbackups() |
| 1105 |
* |
| 1106 |
* Check if Child Site needs to be backed up before updates. |
| 1107 |
* |
| 1108 |
* @return mixed $output |
| 1109 |
* |
| 1110 |
* @uses \MainWP\Dashboard\MainWP_Backup_Handler::is_archive() |
| 1111 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1112 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 1113 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_primary_backup() |
| 1114 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_specific_dir() |
| 1115 |
*/ |
| 1116 |
public static function check_backups() { |
| 1117 |
if ( empty( $_POST['sites'] ) || ! is_array( $_POST['sites'] ) ) { |
| 1118 |
return true; |
| 1119 |
} |
| 1120 |
|
| 1121 |
$primaryBackup = MainWP_System_Utility::get_primary_backup(); |
| 1122 |
$global_backup_before_upgrade = get_option( 'mainwp_backup_before_upgrade' ); |
| 1123 |
|
| 1124 |
$mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' ); |
| 1125 |
if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) { |
| 1126 |
$mainwp_backup_before_upgrade_days = 7; |
| 1127 |
} |
| 1128 |
|
| 1129 |
$output = array(); |
| 1130 |
if ( isset( $_POST['sites'] ) ) { |
| 1131 |
foreach ( array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) as $siteId ) { |
| 1132 |
$website = MainWP_DB::instance()->get_website_by_id( $siteId ); |
| 1133 |
if ( ( 0 == $website->backup_before_upgrade ) || ( ( 2 == $website->backup_before_upgrade ) && ( 0 == $global_backup_before_upgrade ) ) ) { |
| 1134 |
continue; |
| 1135 |
} |
| 1136 |
|
| 1137 |
if ( ! empty( $primaryBackup ) ) { |
| 1138 |
$lastBackup = MainWP_DB::instance()->get_website_option( $website, 'primary_lasttime_backup' ); |
| 1139 |
|
| 1140 |
if ( -1 != $lastBackup ) { // installed backup plugin. |
| 1141 |
$output['sites'][ $siteId ] = ( $lastBackup < ( time() - ( $mainwp_backup_before_upgrade_days * 24 * 60 * 60 ) ) ? false : true ); |
| 1142 |
} |
| 1143 |
$output['primary_backup'] = $primaryBackup; |
| 1144 |
} else { |
| 1145 |
$dir = MainWP_System_Utility::get_mainwp_specific_dir( $siteId ); |
| 1146 |
// Check if backup ok. |
| 1147 |
$lastBackup = - 1; |
| 1148 |
if ( file_exists( $dir ) ) { |
| 1149 |
$dh = opendir( $dir ); |
| 1150 |
if ( $dh ) { |
| 1151 |
while ( false !== ( $file = readdir( $dh ) ) ) { |
| 1152 |
if ( '.' != $file && '..' != $file ) { |
| 1153 |
$theFile = $dir . $file; |
| 1154 |
if ( MainWP_Backup_Handler::is_archive( $file ) && ! MainWP_Backup_Handler::is_sql_archive( $file ) && ( filemtime( $theFile ) > $lastBackup ) ) { |
| 1155 |
$lastBackup = filemtime( $theFile ); |
| 1156 |
} |
| 1157 |
} |
| 1158 |
} |
| 1159 |
closedir( $dh ); |
| 1160 |
} |
| 1161 |
} |
| 1162 |
|
| 1163 |
$output['sites'][ $siteId ] = ( $lastBackup < ( time() - ( $mainwp_backup_before_upgrade_days * 24 * 60 * 60 ) ) ? false : true ); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
} |
| 1167 |
|
| 1168 |
return $output; |
| 1169 |
} |
| 1170 |
|
| 1171 |
} |
| 1172 |
|