| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | /** |
| 11 | 16 | * Class MainWP_Updates |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -70,8 +75,15 @@ | ||
| 70 | 75 | */ |
| 71 | 76 | public static $continue_update_slug = ''; |
| 72 | 77 | |
| 73 | 78 | /** |
| 79 | + * Cached ignored updates counts. | |
| 80 | + * | |
| 81 | + * @var array $ignored_updates_counts Cached ignored updates counts. | |
| 82 | + */ | |
| 83 | + public static $ignored_updates_counts = array(); | |
| 84 | + | |
| 85 | + /** | |
| 74 | 86 | * Public static varable to hold Subpages information. |
| 75 | 87 | * |
| 76 | 88 | * @var array $subPages |
| 77 | 89 | */ |
| @@ -103,11 +115,11 @@ | ||
| 103 | 115 | /** |
| 104 | 116 | * This hook allows you to render the Post page header via the 'mainwp-pageheader-updates' action. |
| 105 | 117 | * |
| 106 | 118 | * This hook is normally used in the same context of 'mainwp-getsubpages-updates' |
| 107 | - * | |
| 108 | - * @see \MainWP_Updates::render_header | |
| 109 | - */ | |
| 119 | + * | |
| 120 | + * @see \MainWP_Updates::render_header | |
| 121 | + */ | |
| 110 | 122 | add_action( 'mainwp-pageheader-updates', array( MainWP_Post::get_class_name(), 'render_header' ) ); |
| 111 | 123 | |
| 112 | 124 | /** |
| 113 | 125 | * This hook allows you to render the Updates page footer via the 'mainwp-pagefooter-updates' action. |
| @@ -118,11 +130,19 @@ | ||
| 118 | 130 | */ |
| 119 | 131 | add_action( 'mainwp-pagefooter-updates', array( MainWP_Post::get_class_name(), 'render_footer' ) ); |
| 120 | 132 | |
| 121 | 133 | add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) ); |
| 134 | + add_action( 'admin_init', array( static::get_class_name(), 'admin_init' ) ); | |
| 122 | 135 | } |
| 123 | 136 | |
| 124 | 137 | /** |
| 138 | + * Init method. | |
| 139 | + */ | |
| 140 | + public static function admin_init() { | |
| 141 | + static::handle_post_staging_sites_view(); | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 125 | 145 | * Renders init updates menu. |
| 126 | 146 | * |
| 127 | 147 | * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu() |
| 128 | 148 | */ |
| @@ -161,25 +181,25 @@ | ||
| 161 | 181 | $label_color_translations = ''; |
| 162 | 182 | $label_color_total = ''; |
| 163 | 183 | |
| 164 | 184 | if ( isset( $updates_count['plugins'] ) && 0 < $updates_count['plugins'] ) { |
| 165 | - $label_color_plugins = ' blue '; | |
| 185 | + $label_color_plugins = 'green'; | |
| 166 | 186 | } |
| 167 | 187 | |
| 168 | 188 | if ( isset( $updates_count['wp'] ) && 0 < $updates_count['wp'] ) { |
| 169 | - $label_color_wp = ' blue '; | |
| 189 | + $label_color_wp = 'green'; | |
| 170 | 190 | } |
| 171 | 191 | |
| 172 | 192 | if ( isset( $updates_count['themes'] ) && 0 < $updates_count['themes'] ) { |
| 173 | - $label_color_themes = ' blue '; | |
| 193 | + $label_color_themes = 'green'; | |
| 174 | 194 | } |
| 175 | 195 | |
| 176 | 196 | if ( isset( $updates_count['translations'] ) && 0 < $updates_count['translations'] ) { |
| 177 | - $label_color_translations = ' blue '; | |
| 197 | + $label_color_translations = 'green'; | |
| 178 | 198 | } |
| 179 | 199 | |
| 180 | 200 | if ( isset( $updates_count['total'] ) && 0 < $updates_count['total'] ) { |
| 181 | - $label_color_total = ' blue '; | |
| 201 | + $label_color_total = 'green'; | |
| 182 | 202 | } |
| 183 | 203 | |
| 184 | 204 | MainWP_Menu::add_left_menu( |
| 185 | 205 | array( |
| @@ -193,67 +213,49 @@ | ||
| 193 | 213 | ), |
| 194 | 214 | 1 |
| 195 | 215 | ); |
| 196 | 216 | |
| 217 | + $init_sub_subleftmenu = array( | |
| 218 | + array( | |
| 219 | + 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' tiny label">' . intval( $updates_count['plugins'] ) . '</span>', | |
| 220 | + 'parent_key' => 'UpdatesManage', | |
| 221 | + 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates', | |
| 222 | + 'slug' => 'UpdatesManage', | |
| 223 | + 'right' => '', | |
| 224 | + ), | |
| 225 | + array( | |
| 226 | + 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' tiny label">' . intval( $updates_count['themes'] ) . '</span>', | |
| 227 | + 'parent_key' => 'UpdatesManage', | |
| 228 | + 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates', | |
| 229 | + 'slug' => 'UpdatesManage', | |
| 230 | + 'right' => '', | |
| 231 | + ), | |
| 232 | + array( | |
| 233 | + 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' tiny label">' . intval( $updates_count['wp'] ) . '</span>', | |
| 234 | + 'parent_key' => 'UpdatesManage', | |
| 235 | + 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates', | |
| 236 | + 'slug' => 'UpdatesManage&tab=wordpress-updates', | |
| 237 | + 'right' => '', | |
| 238 | + 'active_params' => array( 'tab' => 'updates-ignore' ), | |
| 239 | + ), | |
| 240 | + array( | |
| 241 | + 'title' => esc_html__( 'Updates Ignore', 'mainwp' ), | |
| 242 | + 'parent_key' => 'UpdatesManage', | |
| 243 | + 'slug' => 'UpdatesManage&tab=updates-ignore', | |
| 244 | + 'href' => '', // fix warning. | |
| 245 | + 'menu_hidden' => true, | |
| 246 | + ), | |
| 247 | + ); | |
| 248 | + | |
| 197 | 249 | $show_language_updates = get_option( 'mainwp_show_language_updates', 1 ); |
| 198 | - | |
| 199 | 250 | if ( $show_language_updates ) { |
| 200 | - | |
| 201 | - $init_sub_subleftmenu = array( | |
| 202 | - array( | |
| 203 | - 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' label">' . intval( $updates_count['plugins'] ) . '</span>', | |
| 204 | - 'parent_key' => 'UpdatesManage', | |
| 205 | - 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates', | |
| 206 | - 'slug' => 'UpdatesManage', | |
| 207 | - 'right' => '', | |
| 208 | - ), | |
| 209 | - array( | |
| 210 | - 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' label">' . intval( $updates_count['themes'] ) . '</span>', | |
| 211 | - 'parent_key' => 'UpdatesManage', | |
| 212 | - 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates', | |
| 213 | - 'slug' => 'UpdatesManage', | |
| 214 | - 'right' => '', | |
| 215 | - ), | |
| 216 | - array( | |
| 217 | - 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' label">' . intval( $updates_count['wp'] ) . '</span>', | |
| 218 | - 'parent_key' => 'UpdatesManage', | |
| 219 | - 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates', | |
| 220 | - 'slug' => 'UpdatesManage&tab=wordpress-updates', | |
| 221 | - 'right' => '', | |
| 222 | - ), | |
| 223 | - array( | |
| 224 | - 'title' => esc_html__( 'Translation', 'mainwp' ) . ' <span class="ui ' . $label_color_translations . ' label">' . intval( $updates_count['translations'] ) . '</span>', | |
| 225 | - 'parent_key' => 'UpdatesManage', | |
| 226 | - 'href' => 'admin.php?page=UpdatesManage&tab=translations-updates', | |
| 227 | - 'slug' => 'UpdatesManage&tab=translations-updates', | |
| 228 | - 'right' => '', | |
| 229 | - ), | |
| 230 | - | |
| 251 | + $init_sub_subleftmenu[] = array( | |
| 252 | + 'title' => esc_html__( 'Translation', 'mainwp' ) . ' <span class="ui ' . $label_color_translations . ' tiny label">' . intval( $updates_count['translations'] ) . '</span>', | |
| 253 | + 'parent_key' => 'UpdatesManage', | |
| 254 | + 'href' => 'admin.php?page=UpdatesManage&tab=translations-updates', | |
| 255 | + 'slug' => 'UpdatesManage&tab=translations-updates', | |
| 256 | + 'right' => '', | |
| 231 | 257 | ); |
| 232 | - } else { | |
| 233 | - $init_sub_subleftmenu = array( | |
| 234 | - array( | |
| 235 | - 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' label">' . intval( $updates_count['plugins'] ) . '</span>', | |
| 236 | - 'parent_key' => 'UpdatesManage', | |
| 237 | - 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates', | |
| 238 | - 'slug' => 'UpdatesManage', | |
| 239 | - 'right' => '', | |
| 240 | - ), | |
| 241 | - array( | |
| 242 | - 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' label">' . intval( $updates_count['themes'] ) . '</span>', | |
| 243 | - 'parent_key' => 'UpdatesManage', | |
| 244 | - 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates', | |
| 245 | - 'slug' => 'UpdatesManage', | |
| 246 | - 'right' => '', | |
| 247 | - ), | |
| 248 | - array( | |
| 249 | - 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' label">' . intval( $updates_count['wp'] ) . '1</span>', | |
| 250 | - 'parent_key' => 'UpdatesManage', | |
| 251 | - 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates', | |
| 252 | - 'slug' => 'UpdatesManage&tab=wordpress-updates', | |
| 253 | - 'right' => '', | |
| 254 | - ), | |
| 255 | - ); | |
| 256 | 258 | } |
| 257 | 259 | |
| 258 | 260 | $init_sub_subleftmenu = apply_filters( 'mainwp_sub_leftmenu_updates', $init_sub_subleftmenu ); |
| 259 | 261 | |
| @@ -286,9 +288,9 @@ | ||
| 286 | 288 | * @return mixed Page Settings button. |
| 287 | 289 | */ |
| 288 | 290 | public static function screen_options( $input ) { |
| 289 | 291 | return $input . |
| 290 | - '<a class="ui button basic icon" onclick="mainwp_manage_updates_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '"> | |
| 292 | + '<a class="ui button basic icon" onclick="mainwp_manage_updates_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '"> | |
| 291 | 293 | <i class="cog icon"></i> |
| 292 | 294 | </a>'; |
| 293 | 295 | } |
| 294 | 296 | |
| @@ -296,12 +298,20 @@ | ||
| 296 | 298 | * Sets the MainWP Update page page title and pass it off to method MainWP_UI::render_top_header(). |
| 297 | 299 | * |
| 298 | 300 | * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() |
| 299 | 301 | */ |
| 300 | - public static function render_header() { | |
| 302 | + public static function render_header( $current_tab = '' ) { | |
| 301 | 303 | |
| 304 | + $title = esc_html__( 'Available Updates', 'mainwp' ); | |
| 305 | + | |
| 306 | + if ( 'abandoned-plugins' === $current_tab ) { | |
| 307 | + $title = esc_html__( 'Abandoned Plugins', 'mainwp' ); | |
| 308 | + } elseif ( 'abandoned-themes' === $current_tab ) { | |
| 309 | + $title = esc_html__( 'Abandoned Themes', 'mainwp' ); | |
| 310 | + } | |
| 311 | + | |
| 302 | 312 | $params = array( |
| 303 | - 'title' => esc_html__( 'Available Updates', 'mainwp' ), | |
| 313 | + 'title' => $title, | |
| 304 | 314 | ); |
| 305 | 315 | |
| 306 | 316 | MainWP_UI::render_top_header( $params ); |
| 307 | 317 | } |
| @@ -336,9 +346,9 @@ | ||
| 336 | 346 | * @return bool Whether user can ignore updates or not. |
| 337 | 347 | */ |
| 338 | 348 | public static function user_can_ignore_updates() { |
| 339 | 349 | if ( null === static::$user_can_ignore_updates ) { |
| 340 | - static::$user_can_ignore_updates = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ); | |
| 350 | + static::$user_can_ignore_updates = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ); | |
| 341 | 351 | } |
| 342 | 352 | return static::$user_can_ignore_updates; |
| 343 | 353 | } |
| 344 | 354 | |
| @@ -348,9 +358,9 @@ | ||
| 348 | 358 | * @return bool Whether user can update translations or not. |
| 349 | 359 | */ |
| 350 | 360 | public static function user_can_update_trans() { |
| 351 | 361 | if ( null === static::$user_can_update_trans ) { |
| 352 | - static::$user_can_update_trans = mainwp_current_user_have_right( 'dashboard', 'update_translations' ); | |
| 362 | + static::$user_can_update_trans = \mainwp_current_user_can( 'dashboard', 'update_translations' ); | |
| 353 | 363 | } |
| 354 | 364 | return static::$user_can_update_trans; |
| 355 | 365 | } |
| 356 | 366 | |
| @@ -360,9 +370,9 @@ | ||
| 360 | 370 | * @return bool Whether user can update WordPress or not. |
| 361 | 371 | */ |
| 362 | 372 | public static function user_can_update_wp() { |
| 363 | 373 | if ( null === static::$user_can_update_wp ) { |
| 364 | - static::$user_can_update_wp = mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ); | |
| 374 | + static::$user_can_update_wp = \mainwp_current_user_can( 'dashboard', 'update_wordpress' ); | |
| 365 | 375 | } |
| 366 | 376 | return static::$user_can_update_wp; |
| 367 | 377 | } |
| 368 | 378 | |
| @@ -372,9 +382,9 @@ | ||
| 372 | 382 | * @return bool Whether user can update themes or not. |
| 373 | 383 | */ |
| 374 | 384 | public static function user_can_update_themes() { |
| 375 | 385 | if ( null === static::$user_can_update_themes ) { |
| 376 | - static::$user_can_update_themes = mainwp_current_user_have_right( 'dashboard', 'update_themes' ); | |
| 386 | + static::$user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' ); | |
| 377 | 387 | } |
| 378 | 388 | return static::$user_can_update_themes; |
| 379 | 389 | } |
| 380 | 390 | |
| @@ -384,9 +394,9 @@ | ||
| 384 | 394 | * @return bool Whether user can update plugins or not. |
| 385 | 395 | */ |
| 386 | 396 | public static function user_can_update_plugins() { |
| 387 | 397 | if ( null === static::$user_can_update_plugins ) { |
| 388 | - static::$user_can_update_plugins = mainwp_current_user_have_right( 'dashboard', 'update_plugins' ); | |
| 398 | + static::$user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' ); | |
| 389 | 399 | } |
| 390 | 400 | return static::$user_can_update_plugins; |
| 391 | 401 | } |
| 392 | 402 | |
| @@ -392,8 +402,10 @@ | ||
| 392 | 402 | |
| 393 | 403 | /** |
| 394 | 404 | * Renders updates page. |
| 395 | 405 | * |
| 406 | + * @param string $abandoned_tab Render abandoned plugins|themes tab, abandoned_plugins|abandoned_themes. | |
| 407 | + * | |
| 396 | 408 | * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() |
| 397 | 409 | * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_current_user() |
| 398 | 410 | * @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_group_id() |
| 399 | 411 | * @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| @@ -400,9 +412,12 @@ | ||
| 400 | 412 | * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 401 | 413 | * @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 402 | 414 | * @uses \MainWP\Dashboard\MainWP_Utility::array_sort() |
| 403 | 415 | */ |
| 404 | - public static function render() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity -- NOSONAR - current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 416 | + public static function render( $abandoned_tab = '' ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity -- NOSONAR - current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 417 | + | |
| 418 | + static::handle_limit_sites(); | |
| 419 | + | |
| 405 | 420 | $websites = static::get_sites_for_current_user(); |
| 406 | 421 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 407 | 422 | $site_view = (int) $userExtension->site_view; |
| 408 | 423 | |
| @@ -444,10 +459,11 @@ | ||
| 444 | 459 | $all_groups[0] = esc_html__( 'Others', 'mainwp' ); |
| 445 | 460 | } |
| 446 | 461 | } |
| 447 | 462 | |
| 448 | - $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true ); | |
| 449 | - $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true ); | |
| 463 | + $decodedDismissedPlugins = ! empty( $userExtension->dismissed_plugins ) ? json_decode( $userExtension->dismissed_plugins, true ) : array(); | |
| 464 | + $decodedDismissedThemes = ! empty( $userExtension->dismissed_themes ) ? json_decode( $userExtension->dismissed_themes, true ) : array(); | |
| 465 | + $decodedDismissedCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array(); | |
| 450 | 466 | |
| 451 | 467 | $total_wp_upgrades = 0; |
| 452 | 468 | $total_plugin_upgrades = 0; |
| 453 | 469 | $total_translation_upgrades = 0; |
| @@ -469,12 +485,12 @@ | ||
| 469 | 485 | MainWP_DB::data_seek( $websites, 0 ); |
| 470 | 486 | |
| 471 | 487 | while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 472 | 488 | |
| 473 | - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ); | |
| 474 | - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array(); | |
| 489 | + $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array(); | |
| 490 | + $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array(); | |
| 475 | 491 | |
| 476 | - if ( $website->is_ignoreCoreUpdates ) { | |
| 492 | + 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, $decodedDismissedCores, 'core' ) ) { | |
| 477 | 493 | $wp_upgrades = array(); |
| 478 | 494 | } |
| 479 | 495 | |
| 480 | 496 | if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) { |
| @@ -482,8 +498,12 @@ | ||
| 482 | 498 | } |
| 483 | 499 | |
| 484 | 500 | $translation_upgrades = json_decode( $website->translation_upgrades, true ); |
| 485 | 501 | |
| 502 | + if ( ! empty( $website->ignored_trans_updates ) ) { | |
| 503 | + $translation_upgrades = array(); | |
| 504 | + } | |
| 505 | + | |
| 486 | 506 | $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); |
| 487 | 507 | if ( $website->is_ignorePluginUpdates ) { |
| 488 | 508 | $plugin_upgrades = array(); |
| 489 | 509 | } |
| @@ -506,9 +526,9 @@ | ||
| 506 | 526 | } |
| 507 | 527 | if ( ! $website->is_ignorePluginUpdates ) { |
| 508 | 528 | $premiumUpgrade = array_filter( $premiumUpgrade ); |
| 509 | 529 | if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) { |
| 510 | - $plugin_upgrades[ $crrSlug ] = array(); | |
| 530 | + continue; // to fix missing update name. | |
| 511 | 531 | } |
| 512 | 532 | $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade ); |
| 513 | 533 | } |
| 514 | 534 | } elseif ( 'theme' === $premiumUpgrade['type'] ) { |
| @@ -528,16 +548,15 @@ | ||
| 528 | 548 | |
| 529 | 549 | if ( is_array( $plugin_upgrades ) && ! $website->is_ignorePluginUpdates ) { |
| 530 | 550 | $_ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 531 | 551 | if ( is_array( $_ignored_plugins ) ) { |
| 532 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $_ignored_plugins ); | |
| 552 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins ); | |
| 533 | 553 | } |
| 534 | 554 | |
| 535 | 555 | $_ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 536 | 556 | if ( is_array( $_ignored_plugins ) ) { |
| 537 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $_ignored_plugins ); | |
| 557 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins ); | |
| 538 | 558 | } |
| 539 | - | |
| 540 | 559 | $total_plugin_upgrades += count( $plugin_upgrades ); |
| 541 | 560 | } |
| 542 | 561 | |
| 543 | 562 | if ( is_array( $theme_upgrades ) ) { |
| @@ -542,14 +561,14 @@ | ||
| 542 | 561 | |
| 543 | 562 | if ( is_array( $theme_upgrades ) ) { |
| 544 | 563 | $_ignored_themes = json_decode( $website->ignored_themes, true ); |
| 545 | 564 | if ( is_array( $_ignored_themes ) ) { |
| 546 | - $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes ); | |
| 565 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $_ignored_themes ); | |
| 547 | 566 | } |
| 548 | 567 | |
| 549 | 568 | $_ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 550 | 569 | if ( is_array( $_ignored_themes ) ) { |
| 551 | - $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes ); | |
| 570 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $_ignored_themes ); | |
| 552 | 571 | } |
| 553 | 572 | |
| 554 | 573 | $total_theme_upgrades += count( $theme_upgrades ); |
| 555 | 574 | } |
| @@ -595,8 +614,38 @@ | ||
| 595 | 614 | |
| 596 | 615 | $total_themes_outdate += count( $themes_outdate ); |
| 597 | 616 | } |
| 598 | 617 | |
| 618 | + // to fix displaying per sites/tags. | |
| 619 | + if ( is_array( $plugins_outdate ) ) { | |
| 620 | + foreach ( $plugins_outdate as $slug => $plugin_outdate ) { | |
| 621 | + $slug = esc_html( $slug ); | |
| 622 | + if ( ! isset( $allPluginsOutdate[ $slug ] ) ) { | |
| 623 | + $allPluginsOutdate[ $slug ] = array( | |
| 624 | + 'name' => esc_html( $plugin_outdate['Name'] ), | |
| 625 | + 'cnt' => 1, | |
| 626 | + 'uri' => esc_html( $plugin_outdate['PluginURI'] ), | |
| 627 | + ); | |
| 628 | + } else { | |
| 629 | + ++$allPluginsOutdate[ $slug ]['cnt']; | |
| 630 | + } | |
| 631 | + } | |
| 632 | + } | |
| 633 | + | |
| 634 | + if ( is_array( $themes_outdate ) ) { | |
| 635 | + foreach ( $themes_outdate as $slug => $theme_outdate ) { | |
| 636 | + $slug = esc_html( $slug ); | |
| 637 | + if ( ! isset( $allThemesOutdate[ $slug ] ) ) { | |
| 638 | + $allThemesOutdate[ $slug ] = array( | |
| 639 | + 'name' => esc_html( $theme_outdate['Name'] ), | |
| 640 | + 'cnt' => 1, | |
| 641 | + ); | |
| 642 | + } else { | |
| 643 | + ++$allThemesOutdate[ $slug ]['cnt']; | |
| 644 | + } | |
| 645 | + } | |
| 646 | + } | |
| 647 | + | |
| 599 | 648 | if ( MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ) { |
| 600 | 649 | if ( is_array( $translation_upgrades ) ) { |
| 601 | 650 | foreach ( $translation_upgrades as $translation_upgrade ) { |
| 602 | 651 | $slug = esc_html( $translation_upgrade['slug'] ); |
| @@ -632,8 +681,9 @@ | ||
| 632 | 681 | 'name' => esc_html( $plugin_upgrade['Name'] ), |
| 633 | 682 | 'slug' => isset( $plugin_upgrade['update']['slug'] ) ? esc_html( $plugin_upgrade['update']['slug'] ) : '', |
| 634 | 683 | 'premium' => ( isset( $plugin_upgrade['premium'] ) ? esc_html( $plugin_upgrade['premium'] ) : 0 ), |
| 635 | 684 | 'PluginURI' => esc_html( $plugin_upgrade['PluginURI'] ), |
| 685 | + 'version' => esc_html( $plugin_upgrade['Version'] ), | |
| 636 | 686 | ); |
| 637 | 687 | } |
| 638 | 688 | } |
| 639 | 689 | |
| @@ -647,43 +697,20 @@ | ||
| 647 | 697 | } else { |
| 648 | 698 | ++$allThemes[ $slug ]['cnt']; |
| 649 | 699 | } |
| 650 | 700 | |
| 701 | + $up_th_name = isset( $theme_upgrade['Name'] ) ? esc_html( $theme_upgrade['Name'] ) : ''; | |
| 702 | + | |
| 703 | + if ( empty( $up_th_name ) ) { | |
| 704 | + $up_th_name = isset( $theme_upgrade['name'] ) ? esc_html( $theme_upgrade['name'] ) : 'N/A'; | |
| 705 | + } | |
| 706 | + | |
| 651 | 707 | $themesInfo[ $slug ] = array( |
| 652 | - 'name' => esc_html( $theme_upgrade['Name'] ), | |
| 708 | + 'name' => $up_th_name, | |
| 653 | 709 | 'premium' => ( isset( $theme_upgrade['premium'] ) ? esc_html( $theme_upgrade['premium'] ) : 0 ), |
| 654 | 710 | ); |
| 655 | 711 | } |
| 656 | 712 | } |
| 657 | - | |
| 658 | - if ( is_array( $plugins_outdate ) ) { | |
| 659 | - foreach ( $plugins_outdate as $slug => $plugin_outdate ) { | |
| 660 | - $slug = esc_html( $slug ); | |
| 661 | - if ( ! isset( $allPluginsOutdate[ $slug ] ) ) { | |
| 662 | - $allPluginsOutdate[ $slug ] = array( | |
| 663 | - 'name' => esc_html( $plugin_outdate['Name'] ), | |
| 664 | - 'cnt' => 1, | |
| 665 | - 'uri' => esc_html( $plugin_outdate['PluginURI'] ), | |
| 666 | - ); | |
| 667 | - } else { | |
| 668 | - ++$allPluginsOutdate[ $slug ]['cnt']; | |
| 669 | - } | |
| 670 | - } | |
| 671 | - } | |
| 672 | - | |
| 673 | - if ( is_array( $themes_outdate ) ) { | |
| 674 | - foreach ( $themes_outdate as $slug => $theme_outdate ) { | |
| 675 | - $slug = esc_html( $slug ); | |
| 676 | - if ( ! isset( $allThemesOutdate[ $slug ] ) ) { | |
| 677 | - $allThemesOutdate[ $slug ] = array( | |
| 678 | - 'name' => esc_html( $theme_outdate['Name'] ), | |
| 679 | - 'cnt' => 1, | |
| 680 | - ); | |
| 681 | - } else { | |
| 682 | - ++$allThemesOutdate[ $slug ]['cnt']; | |
| 683 | - } | |
| 684 | - } | |
| 685 | - } | |
| 686 | 713 | } |
| 687 | 714 | |
| 688 | 715 | if ( '' !== $website->sync_errors ) { |
| 689 | 716 | ++$total_sync_errors; |
| @@ -762,26 +789,33 @@ | ||
| 762 | 789 | $current_tab = ''; |
| 763 | 790 | |
| 764 | 791 | if ( isset( $_GET['tab'] ) ) { |
| 765 | 792 | $current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); |
| 766 | - if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates', 'translations-updates', 'abandoned-plugins', 'abandoned-themes', true ) ) ) { | |
| 793 | + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'updates-ignore', 'plugins-updates', 'themes-updates', 'translations-updates', true ) ) ) { | |
| 767 | 794 | $current_tab = 'plugins-updates'; |
| 768 | 795 | } |
| 769 | - } else { | |
| 796 | + } elseif ( 'abandoned_plugins' === $abandoned_tab ) { | |
| 797 | + $current_tab = 'abandoned-plugins'; | |
| 798 | + } elseif ( 'abandoned_themes' === $abandoned_tab ) { | |
| 799 | + $current_tab = 'abandoned-themes'; | |
| 800 | + } | |
| 801 | + | |
| 802 | + if ( empty( $current_tab ) ) { | |
| 770 | 803 | $current_tab = 'plugins-updates'; |
| 771 | 804 | } |
| 805 | + | |
| 772 | 806 | // phpcs:enable |
| 773 | - static::render_header( 'UpdatesManage' ); | |
| 807 | + static::render_header( $current_tab ); | |
| 774 | 808 | |
| 775 | 809 | static::render_header_tabs( $mainwp_show_language_updates, $current_tab, $total_wp_upgrades, $total_plugin_upgrades, $total_theme_upgrades, $total_translation_upgrades, $total_plugins_outdate, $total_themes_outdate, $site_view ); |
| 776 | 810 | |
| 777 | 811 | ?> |
| 778 | - <div class="ui segment" id="mainwp-manage-updates"> | |
| 779 | - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?> | |
| 812 | + <div class="ui padded segment" id="mainwp-manage-updates"> | |
| 813 | + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?> | |
| 780 | 814 | <div class="ui info message"> |
| 781 | 815 | <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i> |
| 782 | - <div><?php printf( esc_html__( 'Manage available updates for all your child sites. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">', '</a>', '<a href="https://kb.mainwp.com/docs/update-themes/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/update-wordpress-core/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 783 | - <div><?php printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/ignore-wordpress-core-update/" target="_blank">', '</a>', '<a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/ignore-theme-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 816 | + <div><?php /* translators: 1: opening anchor tag for plugins, 2: closing anchor tag, 3: opening anchor tag for themes, 4: closing anchor tag with icon, 5: opening anchor tag for WordPress core, 6: closing anchor tag with icon */ printf( esc_html__( 'Manage available updates for all your child sites. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-updates" target="_blank">', '</a>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 817 | + <div><?php /* translators: 1: opening anchor tag for WordPress core, 2: closing anchor tag with icon, 3: opening anchor tag for plugins, 4: closing anchor tag with icon, 5: opening anchor tag for themes, 6: closing anchor tag with icon */ printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div> | |
| 784 | 818 | </div> |
| 785 | 819 | <?php } ?> |
| 786 | 820 | <?php |
| 787 | 821 | |
| @@ -788,9 +822,11 @@ | ||
| 788 | 822 | $hooks_tabs = apply_filters( 'mainwp_pages_updates_render_tabs', false, $current_tab ); |
| 789 | 823 | |
| 790 | 824 | if ( false === $hooks_tabs ) { |
| 791 | 825 | if ( 'wordpress-updates' === $current_tab ) { |
| 792 | - static::render_wp_update_tab( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ); | |
| 826 | + static::render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ); | |
| 827 | + } elseif ( 'updates-ignore' === $current_tab ) { | |
| 828 | + static::render_wp_ignore_update_tab( $websites, $userExtension ); | |
| 793 | 829 | } elseif ( 'plugins-updates' === $current_tab ) { |
| 794 | 830 | static::render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view ); |
| 795 | 831 | } elseif ( 'themes-updates' === $current_tab ) { |
| 796 | 832 | static::render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view ); |
| @@ -811,8 +847,9 @@ | ||
| 811 | 847 | |
| 812 | 848 | static::render_plugin_details_modal(); |
| 813 | 849 | MainWP_UI::render_modal_upload_icon(); |
| 814 | 850 | static::render_screen_options_modal(); |
| 851 | + static::render_changes_history_modal(); | |
| 815 | 852 | static::render_footer(); |
| 816 | 853 | ?> |
| 817 | 854 | <script type="text/javascript"> |
| 818 | 855 | mainwp_manage_updates_screen_options = function () { |
| @@ -829,8 +866,9 @@ | ||
| 829 | 866 | /** |
| 830 | 867 | * Render WP updates tab. |
| 831 | 868 | * |
| 832 | 869 | * @param object $websites Object containing child sites info. |
| 870 | + * @param object $userExtension User Extension object. | |
| 833 | 871 | * @param int $total_wp_upgrades Number of available WP upates. |
| 834 | 872 | * @param array $all_groups_sites Array containing all groups and sites. |
| 835 | 873 | * @param array $all_groups Array containing all groups. |
| 836 | 874 | * @param int $site_offset_for_groups Offset value. |
| @@ -839,16 +877,31 @@ | ||
| 839 | 877 | * @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 840 | 878 | * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_wpcore_updates() |
| 841 | 879 | * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_wpcore_updates() |
| 842 | 880 | */ |
| 843 | - public static function render_wp_update_tab( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) { | |
| 881 | + public static function render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) { | |
| 844 | 882 | ?> |
| 845 | 883 | <div class="ui active tab" data-tab="wordpress-updates"> |
| 846 | - <?php | |
| 884 | + <?php | |
| 885 | + /** | |
| 886 | + * Action: mainwp_updates_before_wp_updates | |
| 887 | + * | |
| 888 | + * Fires at the top of the WP updates tab. | |
| 889 | + * | |
| 890 | + * @param object $websites Object containing child sites info. | |
| 891 | + * @param int $total_wp_upgrades Number of available WP upates. | |
| 892 | + * @param array $all_groups_sites Array containing all groups and sites. | |
| 893 | + * @param array $all_groups Array containing all groups. | |
| 894 | + * @param int $site_offset_for_groups Offset value. | |
| 895 | + * | |
| 896 | + * @since 4.1 | |
| 897 | + */ | |
| 898 | + do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 899 | + if ( MAINWP_VIEW_PER_GROUP === $site_view ) { | |
| 847 | 900 | /** |
| 848 | - * Action: mainwp_updates_before_wp_updates | |
| 901 | + * Action: mainwp_updates_pergroup_before_wp_updates | |
| 849 | 902 | * |
| 850 | - * Fires at the top of the WP updates tab. | |
| 903 | + * Fires at the top of the WP updates tab, per Group view. | |
| 851 | 904 | * |
| 852 | 905 | * @param object $websites Object containing child sites info. |
| 853 | 906 | * @param int $total_wp_upgrades Number of available WP upates. |
| 854 | 907 | * @param array $all_groups_sites Array containing all groups and sites. |
| @@ -856,75 +909,14 @@ | ||
| 856 | 909 | * @param int $site_offset_for_groups Offset value. |
| 857 | 910 | * |
| 858 | 911 | * @since 4.1 |
| 859 | 912 | */ |
| 860 | - do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 861 | - if ( MAINWP_VIEW_PER_GROUP === $site_view ) { | |
| 862 | - /** | |
| 863 | - * Action: mainwp_updates_pergroup_before_wp_updates | |
| 864 | - * | |
| 865 | - * Fires at the top of the WP updates tab, per Group view. | |
| 866 | - * | |
| 867 | - * @param object $websites Object containing child sites info. | |
| 868 | - * @param int $total_wp_upgrades Number of available WP upates. | |
| 869 | - * @param array $all_groups_sites Array containing all groups and sites. | |
| 870 | - * @param array $all_groups Array containing all groups. | |
| 871 | - * @param int $site_offset_for_groups Offset value. | |
| 872 | - * | |
| 873 | - * @since 4.1 | |
| 874 | - */ | |
| 875 | - do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 876 | - MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 877 | - /** | |
| 878 | - * Action: mainwp_updates_pergroup_after_wp_updates | |
| 879 | - * | |
| 880 | - * Fires at the bottom of the WP updates tab, per Group view. | |
| 881 | - * | |
| 882 | - * @param object $websites Object containing child sites info. | |
| 883 | - * @param int $total_wp_upgrades Number of available WP upates. | |
| 884 | - * @param array $all_groups_sites Array containing all groups and sites. | |
| 885 | - * @param array $all_groups Array containing all groups. | |
| 886 | - * @param int $site_offset_for_groups Offset value. | |
| 887 | - * | |
| 888 | - * @since 4.1 | |
| 889 | - */ | |
| 890 | - do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 891 | - } else { | |
| 892 | - /** | |
| 893 | - * Action: mainwp_updates_persite_before_wp_updates | |
| 894 | - * | |
| 895 | - * Fires at the top of the WP updates tab, per Site view. | |
| 896 | - * | |
| 897 | - * @param object $websites Object containing child sites info. | |
| 898 | - * @param int $total_wp_upgrades Number of available WP upates. | |
| 899 | - * @param array $all_groups_sites Array containing all groups and sites. | |
| 900 | - * @param array $all_groups Array containing all groups. | |
| 901 | - * @param int $site_offset_for_groups Offset value. | |
| 902 | - * | |
| 903 | - * @since 4.1 | |
| 904 | - */ | |
| 905 | - do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 906 | - MainWP_DB::data_seek( $websites, 0 ); | |
| 907 | - MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $total_wp_upgrades ); | |
| 908 | - /** | |
| 909 | - * Action: mainwp_updates_persite_after_wp_updates | |
| 910 | - * | |
| 911 | - * Fires at the bottom of the WP updates tab, per Site view. | |
| 912 | - * | |
| 913 | - * @param object $websites Object containing child sites info. | |
| 914 | - * @param int $total_wp_upgrades Number of available WP upates. | |
| 915 | - * @param array $all_groups_sites Array containing all groups and sites. | |
| 916 | - * @param array $all_groups Array containing all groups. | |
| 917 | - * @param int $site_offset_for_groups Offset value. | |
| 918 | - * | |
| 919 | - * @since 4.1 | |
| 920 | - */ | |
| 921 | - do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 922 | - } | |
| 913 | + do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 914 | + MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 923 | 915 | /** |
| 924 | - * Action: mainwp_updates_after_wp_updates | |
| 916 | + * Action: mainwp_updates_pergroup_after_wp_updates | |
| 925 | 917 | * |
| 926 | - * Fires at the top of the WP updates tab. | |
| 918 | + * Fires at the bottom of the WP updates tab, per Group view. | |
| 927 | 919 | * |
| 928 | 920 | * @param object $websites Object containing child sites info. |
| 929 | 921 | * @param int $total_wp_upgrades Number of available WP upates. |
| 930 | 922 | * @param array $all_groups_sites Array containing all groups and sites. |
| @@ -932,17 +924,74 @@ | ||
| 932 | 924 | * @param int $site_offset_for_groups Offset value. |
| 933 | 925 | * |
| 934 | 926 | * @since 4.1 |
| 935 | 927 | */ |
| 936 | - do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 937 | - ?> | |
| 928 | + do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 929 | + } else { | |
| 930 | + /** | |
| 931 | + * Action: mainwp_updates_persite_before_wp_updates | |
| 932 | + * | |
| 933 | + * Fires at the top of the WP updates tab, per Site view. | |
| 934 | + * | |
| 935 | + * @param object $websites Object containing child sites info. | |
| 936 | + * @param int $total_wp_upgrades Number of available WP upates. | |
| 937 | + * @param array $all_groups_sites Array containing all groups and sites. | |
| 938 | + * @param array $all_groups Array containing all groups. | |
| 939 | + * @param int $site_offset_for_groups Offset value. | |
| 940 | + * | |
| 941 | + * @since 4.1 | |
| 942 | + */ | |
| 943 | + do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 944 | + MainWP_DB::data_seek( $websites, 0 ); | |
| 945 | + MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades ); | |
| 946 | + /** | |
| 947 | + * Action: mainwp_updates_persite_after_wp_updates | |
| 948 | + * | |
| 949 | + * Fires at the bottom of the WP updates tab, per Site view. | |
| 950 | + * | |
| 951 | + * @param object $websites Object containing child sites info. | |
| 952 | + * @param int $total_wp_upgrades Number of available WP upates. | |
| 953 | + * @param array $all_groups_sites Array containing all groups and sites. | |
| 954 | + * @param array $all_groups Array containing all groups. | |
| 955 | + * @param int $site_offset_for_groups Offset value. | |
| 956 | + * | |
| 957 | + * @since 4.1 | |
| 958 | + */ | |
| 959 | + do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 960 | + } | |
| 961 | + /** | |
| 962 | + * Action: mainwp_updates_after_wp_updates | |
| 963 | + * | |
| 964 | + * Fires at the top of the WP updates tab. | |
| 965 | + * | |
| 966 | + * @param object $websites Object containing child sites info. | |
| 967 | + * @param int $total_wp_upgrades Number of available WP upates. | |
| 968 | + * @param array $all_groups_sites Array containing all groups and sites. | |
| 969 | + * @param array $all_groups Array containing all groups. | |
| 970 | + * @param int $site_offset_for_groups Offset value. | |
| 971 | + * | |
| 972 | + * @since 4.1 | |
| 973 | + */ | |
| 974 | + do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 975 | + ?> | |
| 938 | 976 | </div> |
| 939 | 977 | <?php |
| 940 | 978 | } |
| 941 | 979 | |
| 980 | + | |
| 942 | 981 | /** |
| 943 | 982 | * Renders WP updates tab. |
| 944 | 983 | * |
| 984 | + * @param array $websites Object containing child sites info. | |
| 985 | + * @param object $userExtension User extension. | |
| 986 | + */ | |
| 987 | + public static function render_wp_ignore_update_tab( $websites, $userExtension ) { | |
| 988 | + MainWP_WP_Updates::instance()->render_ignore( $websites, $userExtension ); | |
| 989 | + } | |
| 990 | + | |
| 991 | + /** | |
| 992 | + * Renders WP updates tab. | |
| 993 | + * | |
| 945 | 994 | * @param object $websites Object containing child sites info. |
| 946 | 995 | * @param int $total_plugin_upgrades Number of available plugin updates. |
| 947 | 996 | * @param object $userExtension User extension. |
| 948 | 997 | * @param array $all_groups_sites Array of all groups and sites. |
| @@ -998,9 +1047,9 @@ | ||
| 998 | 1047 | * |
| 999 | 1048 | * @since 4.1 |
| 1000 | 1049 | */ |
| 1001 | 1050 | do_action( 'mainwp_updates_persite_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups ); |
| 1002 | - MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins ); | |
| 1051 | + MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins ); | |
| 1003 | 1052 | /** |
| 1004 | 1053 | * Action: mainwp_updates_persite_after_plugin_updates |
| 1005 | 1054 | * |
| 1006 | 1055 | * Fires at the bottom of the Plugin updates tab, per Site view. |
| @@ -1034,9 +1083,9 @@ | ||
| 1034 | 1083 | * |
| 1035 | 1084 | * @since 4.1 |
| 1036 | 1085 | */ |
| 1037 | 1086 | do_action( 'mainwp_updates_pergroup_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups ); |
| 1038 | - MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins ); | |
| 1087 | + MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins ); | |
| 1039 | 1088 | /** |
| 1040 | 1089 | * Action: mainwp_updates_pergroup_after_plugin_updates |
| 1041 | 1090 | * |
| 1042 | 1091 | * Fires at the bottom of the Plugin updates tab, per Group view. |
| @@ -1070,9 +1119,9 @@ | ||
| 1070 | 1119 | * |
| 1071 | 1120 | * @since 4.1 |
| 1072 | 1121 | */ |
| 1073 | 1122 | do_action( 'mainwp_updates_perplugin_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups ); |
| 1074 | - MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins ); | |
| 1123 | + MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins ); | |
| 1075 | 1124 | /** |
| 1076 | 1125 | * Action: mainwp_updates_perplugin_after_plugin_updates |
| 1077 | 1126 | * |
| 1078 | 1127 | * Fires at the bottom of the Plugin updates tab, per Plugin view. |
| @@ -1342,9 +1391,9 @@ | ||
| 1342 | 1391 | * |
| 1343 | 1392 | * @since 4.1 |
| 1344 | 1393 | */ |
| 1345 | 1394 | do_action( 'mainwp_updates_persite_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups ); |
| 1346 | - MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades ); | |
| 1395 | + MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades, $userExtension ); | |
| 1347 | 1396 | /** |
| 1348 | 1397 | * Action: mainwp_updates_persite_after_translation_updates |
| 1349 | 1398 | * |
| 1350 | 1399 | * Fires at the bottom of the Translation updates tab, per Site view. |
| @@ -1378,9 +1427,9 @@ | ||
| 1378 | 1427 | * |
| 1379 | 1428 | * @since 4.1 |
| 1380 | 1429 | */ |
| 1381 | 1430 | do_action( 'mainwp_updates_pergroup_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups ); |
| 1382 | - MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ); | |
| 1431 | + MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $userExtension ); | |
| 1383 | 1432 | /** |
| 1384 | 1433 | * Action: mainwp_updates_pergroup_after_translation_updates |
| 1385 | 1434 | * |
| 1386 | 1435 | * Fires at the bottom of the Translation updates tab, per Group view. |
| @@ -1506,9 +1555,9 @@ | ||
| 1506 | 1555 | * |
| 1507 | 1556 | * @since 4.1 |
| 1508 | 1557 | */ |
| 1509 | 1558 | do_action( 'mainwp_updates_persite_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups ); |
| 1510 | - MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $decodedDismissedPlugins ); | |
| 1559 | + MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins ); | |
| 1511 | 1560 | /** |
| 1512 | 1561 | * Action: mainwp_updates_persite_after_abandoned_plugins |
| 1513 | 1562 | * |
| 1514 | 1563 | * Fires at the bottom of the Abandoned plugins tab, per Site view. |
| @@ -1538,9 +1587,9 @@ | ||
| 1538 | 1587 | * |
| 1539 | 1588 | * @since 4.1 |
| 1540 | 1589 | */ |
| 1541 | 1590 | do_action( 'mainwp_updates_pergroup_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups ); |
| 1542 | - MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins ); | |
| 1591 | + MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $allPluginsOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins ); | |
| 1543 | 1592 | /** |
| 1544 | 1593 | * Action: mainwp_updates_pergroup_after_abandoned_plugins |
| 1545 | 1594 | * |
| 1546 | 1595 | * Fires at the bottom of the Abandoned plugins tab, per Group view. |
| @@ -1657,9 +1706,9 @@ | ||
| 1657 | 1706 | * |
| 1658 | 1707 | * @since 4.1 |
| 1659 | 1708 | */ |
| 1660 | 1709 | do_action( 'mainwp_updates_persite_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups ); |
| 1661 | - MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $decodedDismissedThemes ); | |
| 1710 | + MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes ); | |
| 1662 | 1711 | /** |
| 1663 | 1712 | * Action: mainwp_updates_persite_after_abandoned_themes |
| 1664 | 1713 | * |
| 1665 | 1714 | * Fires at the bottom of the Abandoned themes tab, per Site view. |
| @@ -1689,9 +1738,9 @@ | ||
| 1689 | 1738 | * |
| 1690 | 1739 | * @since 4.1 |
| 1691 | 1740 | */ |
| 1692 | 1741 | do_action( 'mainwp_updates_pergroup_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups ); |
| 1693 | - MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes ); | |
| 1742 | + MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $allThemesOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes ); | |
| 1694 | 1743 | /** |
| 1695 | 1744 | * Action: mainwp_updates_pergroup_after_abandoned_themes |
| 1696 | 1745 | * |
| 1697 | 1746 | * Fires at the bottom of the Abandoned themes tab, per Group view. |
| @@ -1782,9 +1831,9 @@ | ||
| 1782 | 1831 | */ |
| 1783 | 1832 | $table_features = apply_filters( 'mainwp_updates_table_features', $table_features ); |
| 1784 | 1833 | ?> |
| 1785 | 1834 | <script type="text/javascript"> |
| 1786 | - jQuery( document ).ready( function () { | |
| 1835 | + jQuery( document ).ready( function ($) { | |
| 1787 | 1836 | jQuery( '#mainwp-manage-updates .ui.accordion' ).accordion( { |
| 1788 | 1837 | "exclusive": <?php echo esc_html( $table_features['exclusive'] ); ?>, |
| 1789 | 1838 | "duration": <?php echo esc_html( $table_features['duration'] ); ?>, |
| 1790 | 1839 | onOpen: function(){ |
| @@ -1790,14 +1839,35 @@ | ||
| 1790 | 1839 | onOpen: function(){ |
| 1791 | 1840 | //mainwp_datatable_init_and_fix_recalc('table.mainwp-manage-updates-item-table'); |
| 1792 | 1841 | } |
| 1793 | 1842 | } ); |
| 1843 | + | |
| 1844 | + $('table.mainwp-js-persistent-table').each(function () { | |
| 1845 | + const table = this; // DOM element | |
| 1846 | + new TablePersistentState(table, { | |
| 1847 | + headerSelector: '.handle-accordion-sorting', | |
| 1848 | + onPersist:function( { table, column, direction, isrestore } ){ | |
| 1849 | + if(isrestore){ | |
| 1850 | + const $th = $(table).find( | |
| 1851 | + `.handle-accordion-sorting[data-key="${column}"]` // header column must have data-key property. | |
| 1852 | + ); | |
| 1853 | + if (!$th) return; | |
| 1854 | + setTimeout(function () {// to fix binding delay issue. | |
| 1855 | + $($th).trigger('click'); | |
| 1856 | + if(direction === 'desc'){ | |
| 1857 | + $($th).trigger('click'); | |
| 1858 | + } | |
| 1859 | + }, 500); | |
| 1860 | + } | |
| 1861 | + } | |
| 1862 | + }); | |
| 1863 | + }); | |
| 1864 | + | |
| 1794 | 1865 | } ); |
| 1795 | 1866 | |
| 1796 | 1867 | mainwp_datatable_init_and_fix_recalc = function(selector){ |
| 1797 | 1868 | jQuery(selector).each( function(e) { |
| 1798 | 1869 | if(jQuery(this).is(":visible")){ |
| 1799 | - console.log('visible ' + jQuery(this).attr('id')); | |
| 1800 | 1870 | jQuery(this).css( 'display', 'table' ); |
| 1801 | 1871 | jQuery(this).DataTable().destroy(); |
| 1802 | 1872 | let tb = jQuery(this).DataTable({ |
| 1803 | 1873 | "paging":false, |
| @@ -1811,8 +1881,10 @@ | ||
| 1811 | 1881 | } |
| 1812 | 1882 | }); |
| 1813 | 1883 | } |
| 1814 | 1884 | |
| 1885 | + | |
| 1886 | + | |
| 1815 | 1887 | jQuery( document ).on( 'click', '.trigger-all-accordion', function() { |
| 1816 | 1888 | if ( jQuery( this ).hasClass( 'active' ) ) { |
| 1817 | 1889 | jQuery( this ).removeClass( 'active' ); |
| 1818 | 1890 | jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) { |
| @@ -1866,22 +1938,28 @@ | ||
| 1866 | 1938 | global $current_user; |
| 1867 | 1939 | |
| 1868 | 1940 | $current_wpid = MainWP_System_Utility::get_current_wpid(); |
| 1869 | 1941 | if ( $current_wpid ) { |
| 1870 | - $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' ) ); | |
| 1942 | + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'ignored_wp_upgrades', 'ignored_trans_updates', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon', 'site_info' ) ); | |
| 1871 | 1943 | } else { |
| 1872 | 1944 | $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' ); |
| 1873 | 1945 | $is_staging = 'no'; |
| 1874 | 1946 | if ( $staging_enabled ) { |
| 1875 | - $staging_updates_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users(); | |
| 1947 | + $staging_updates_view = MainWP_System_Utility::get_select_staging_view_sites(); | |
| 1876 | 1948 | if ( 'staging' === $staging_updates_view ) { |
| 1877 | 1949 | $is_staging = 'yes'; |
| 1878 | 1950 | } |
| 1879 | 1951 | } |
| 1880 | 1952 | $params = array( |
| 1881 | - 'connected' => 'yes', | |
| 1953 | + 'connected' => 'yes', | |
| 1954 | + 'maybe_cache' => true, | |
| 1882 | 1955 | ); |
| 1883 | - $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, $params ); | |
| 1956 | + | |
| 1957 | + $limit_sites = get_option( 'mainwp_manage_updates_limit_sites' ); | |
| 1958 | + if ( ! empty( $limit_sites ) ) { | |
| 1959 | + $params['limit_sites'] = $limit_sites; | |
| 1960 | + } | |
| 1961 | + $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'rollback_updates_data', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon', 'site_info' ), $is_staging, $params ); | |
| 1884 | 1962 | } |
| 1885 | 1963 | return MainWP_DB::instance()->query( $sql ); |
| 1886 | 1964 | } |
| 1887 | 1965 | |
| @@ -1911,14 +1989,14 @@ | ||
| 1911 | 1989 | |
| 1912 | 1990 | $header_tabs = array( |
| 1913 | 1991 | 'plugins-updates' => array( |
| 1914 | 1992 | 'slug' => 'plugins-updates', |
| 1915 | - 'title' => esc_html__( 'Plugins Updates', 'mainwp' ), | |
| 1993 | + 'title' => esc_html__( 'Plugin Updates', 'mainwp' ), | |
| 1916 | 1994 | 'total_upgrades' => $total_plugin_upgrades, |
| 1917 | 1995 | ), |
| 1918 | 1996 | 'themes-updates' => array( |
| 1919 | 1997 | 'slug' => 'themes-updates', |
| 1920 | - 'title' => esc_html__( 'Themes Updates', 'mainwp' ), | |
| 1998 | + 'title' => esc_html__( 'Theme Updates', 'mainwp' ), | |
| 1921 | 1999 | 'total_upgrades' => $total_theme_upgrades, |
| 1922 | 2000 | ), |
| 1923 | 2001 | 'wordpress-updates' => array( |
| 1924 | 2002 | 'slug' => 'wordpress-updates', |
| @@ -1951,24 +2029,51 @@ | ||
| 1951 | 2029 | |
| 1952 | 2030 | ?> |
| 1953 | 2031 | <div id="mainwp-page-navigation-wrapper"> |
| 1954 | 2032 | <div class="ui vertical menu mainwp-page-navigation"> |
| 1955 | - <?php | |
| 1956 | - foreach ( $header_tabs as $slug => $tab ) { | |
| 1957 | - if ( empty( $tab['title'] ) ) { | |
| 1958 | - continue; | |
| 1959 | - } | |
| 1960 | - ?> | |
| 2033 | + <?php | |
| 2034 | + foreach ( $header_tabs as $slug => $tab ) { | |
| 2035 | + if ( empty( $tab['title'] ) ) { | |
| 2036 | + continue; | |
| 2037 | + } | |
| 2038 | + ?> | |
| 1961 | 2039 | <a class="<?php echo $slug === $current_tab ? 'active' : ''; ?> item" data-tab="<?php echo esc_html( $slug ); ?>" href="admin.php?page=UpdatesManage&tab=<?php echo esc_html( $slug ); ?>"><?php echo esc_html( $tab['title'] ); ?><div class="ui small <?php echo empty( $tab['total_upgrades'] ) ? 'green' : 'red'; ?> label" timestamp="<?php echo esc_html( time() ); ?>"><?php echo intval( $tab['total_upgrades'] ); ?></div></a> |
| 1962 | 2040 | <?php |
| 1963 | - } | |
| 1964 | - ?> | |
| 2041 | + } | |
| 2042 | + ?> | |
| 1965 | 2043 | </div> |
| 1966 | 2044 | </div> |
| 1967 | 2045 | <?php |
| 1968 | 2046 | |
| 1969 | - $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', false, $current_tab ); | |
| 2047 | + $hide_show_updates_per = 'updates-ignore' === $current_tab ? true : false; | |
| 1970 | 2048 | |
| 2049 | + $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', $hide_show_updates_per, $current_tab ); | |
| 2050 | + | |
| 2051 | + $show_select_staging_sites = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ); | |
| 2052 | + $has_ignored_updates = in_array( | |
| 2053 | + $current_tab, | |
| 2054 | + array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ), | |
| 2055 | + true | |
| 2056 | + ) && 0 < static::get_ignored_updates_count( $current_tab ); | |
| 2057 | + $show_updates_actions_bar = $has_ignored_updates | |
| 2058 | + || ( 'plugins-updates' === $current_tab && 0 < $total_plugin_upgrades ) | |
| 2059 | + || ( 'themes-updates' === $current_tab && 0 < $total_theme_upgrades ) | |
| 2060 | + || ( 'wordpress-updates' === $current_tab && 0 < $total_wp_upgrades ) | |
| 2061 | + || ( 'translations-updates' === $current_tab && 0 < $total_translation_upgrades ) | |
| 2062 | + || 'abandoned-plugins' === $current_tab | |
| 2063 | + || 'abandoned-themes' === $current_tab; | |
| 2064 | + $current_tab_updates_count = 0; | |
| 2065 | + | |
| 2066 | + if ( 'plugins-updates' === $current_tab ) { | |
| 2067 | + $current_tab_updates_count = $total_plugin_upgrades; | |
| 2068 | + } elseif ( 'themes-updates' === $current_tab ) { | |
| 2069 | + $current_tab_updates_count = $total_theme_upgrades; | |
| 2070 | + } elseif ( 'wordpress-updates' === $current_tab ) { | |
| 2071 | + $current_tab_updates_count = $total_wp_upgrades; | |
| 2072 | + } elseif ( 'translations-updates' === $current_tab ) { | |
| 2073 | + $current_tab_updates_count = $total_translation_upgrades; | |
| 2074 | + } | |
| 2075 | + | |
| 1971 | 2076 | /** |
| 1972 | 2077 | * Action: mainwp_updates_after_nav_tabs |
| 1973 | 2078 | * |
| 1974 | 2079 | * Fires after the navigation tabs on the Updates page. |
| @@ -1984,230 +2089,433 @@ | ||
| 1984 | 2089 | * |
| 1985 | 2090 | * @since 4.1 |
| 1986 | 2091 | */ |
| 1987 | 2092 | do_action( 'mainwp_updates_before_actions_bar' ); |
| 2093 | + ?> | |
| 1988 | 2094 | |
| 1989 | - if ( ! $hide_show_updates_per ) { | |
| 1990 | - $is_demo = MainWP_Demo_Handle::is_demo_mode(); | |
| 1991 | - ?> | |
| 1992 | - <div class="mainwp-sub-header"> | |
| 1993 | - <div class="ui grid"> | |
| 1994 | - <div class="equal width row"> | |
| 1995 | - <div class="middle aligned column"> | |
| 1996 | - <form method="post" action="" class="ui mini form"> | |
| 1997 | - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> | |
| 1998 | - <div class="inline field"> | |
| 1999 | - <select class="ui dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview"> | |
| 2000 | - <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option> | |
| 2001 | - <option value="0" class="item" <?php echo MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Item', 'mainwp' ); ?></option> | |
| 2002 | - <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option> | |
| 2003 | - </select> | |
| 2004 | - </div> | |
| 2005 | - </form> | |
| 2095 | + <?php if ( ! $hide_show_updates_per || $show_select_staging_sites ) : ?> | |
| 2096 | + <?php if ( $show_updates_actions_bar ) : ?> | |
| 2097 | + <div class="mainwp-sub-header"> | |
| 2098 | + <div class="ui three column grid"> | |
| 2099 | + <div class="left aligned middle aligned column"> | |
| 2100 | + <?php static::render_updates_view_options( $site_view ); ?> | |
| 2101 | + <?php | |
| 2102 | + if ( $show_select_staging_sites ) { | |
| 2103 | + static::render_select_staging_sites_view(); | |
| 2104 | + } | |
| 2105 | + ?> | |
| 2106 | + </div> | |
| 2107 | + <div class="center aligned middle aligned column"></div> | |
| 2108 | + <div class="right aligned middle aligned column"> | |
| 2109 | + <?php | |
| 2110 | + /** | |
| 2111 | + * Action: mainwp_widget_updates_actions_top | |
| 2112 | + * | |
| 2113 | + * Updates actions top content. | |
| 2114 | + * | |
| 2115 | + * @since 5.5 | |
| 2116 | + */ | |
| 2117 | + do_action( 'mainwp_widget_updates_actions_top', $current_tab ); | |
| 2118 | + ?> | |
| 2119 | + <?php static::render_updates_actions_buttons( $current_tab, $current_tab_updates_count ); ?> | |
| 2120 | + <?php static::render_button_view_ignored_updates( $current_tab ); ?> | |
| 2121 | + <?php static::render_abandoned_plugins_themes_buttons( $current_tab ); ?> | |
| 2122 | + </div> | |
| 2006 | 2123 | </div> |
| 2007 | - <div class="middle aligned right aligned column"> | |
| 2008 | - <?php | |
| 2009 | - /** | |
| 2010 | - * Filter: mainwp_widgetupdates_actions_top | |
| 2011 | - * | |
| 2012 | - * Filters the udpates actions top content. | |
| 2013 | - * | |
| 2014 | - * @since Unknown | |
| 2015 | - */ | |
| 2016 | - echo apply_filters( 'mainwp_widgetupdates_actions_top', '' ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 2017 | - if ( 'abandoned-plugins' === $current_tab ) { | |
| 2018 | - if ( $is_demo ) { | |
| 2019 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini basic button disabled" disabled="disabled">' . esc_html__( 'Check for Abandoned Plugins', 'mainwp' ) . '</a>' ); | |
| 2020 | - } else { | |
| 2021 | - ?> | |
| 2022 | - <a href="#" onClick="updatesoverview_bulk_check_abandoned('plugin'); return false;" class="ui green mini basic button" data-tooltip="<?php esc_html_e( 'Check for Abandoned Plugins.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Check for Abandoned Plugins', 'mainwp' ); ?></a> | |
| 2023 | - <?php | |
| 2024 | - } | |
| 2025 | - } elseif ( 'abandoned-themes' === $current_tab ) { | |
| 2026 | - if ( $is_demo ) { | |
| 2027 | - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini basic button disabled" disabled="disabled">' . esc_html__( 'Check for Abandoned Themes', 'mainwp' ) . '</a>' ); | |
| 2028 | - } else { | |
| 2029 | - ?> | |
| 2030 | - <a href="#" onClick="updatesoverview_bulk_check_abandoned('theme'); return false;" class="ui green mini basic button" data-tooltip="<?php esc_html_e( 'Check for Abandoned Themes.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Check for Abandoned Themes', 'mainwp' ); ?></a> | |
| 2031 | - <?php | |
| 2032 | - } | |
| 2033 | - } | |
| 2034 | - ?> | |
| 2124 | + </div> | |
| 2125 | + <?php elseif ( $show_select_staging_sites ) : ?> | |
| 2126 | + <div class="mainwp-sub-header"> | |
| 2127 | + <div class="ui three column grid"> | |
| 2128 | + <div class="left aligned middle aligned column"> | |
| 2129 | + <?php static::render_select_staging_sites_view(); ?> | |
| 2130 | + </div> | |
| 2131 | + <div class="center aligned middle aligned column"></div> | |
| 2132 | + <div class="right aligned middle aligned column"> | |
| 2133 | + </div> | |
| 2035 | 2134 | </div> |
| 2036 | - </div> | |
| 2037 | - </div> | |
| 2038 | - </div> | |
| 2135 | + </div> | |
| 2136 | + <?php endif; ?> | |
| 2137 | + <?php endif; ?> | |
| 2039 | 2138 | <?php |
| 2139 | + /** | |
| 2140 | + * Action: mainwp_updates_after_actions_bar | |
| 2141 | + * | |
| 2142 | + * Fires after the actions bar on the Updates page. | |
| 2143 | + * | |
| 2144 | + * @since 4.1 | |
| 2145 | + */ | |
| 2146 | + do_action( 'mainwp_updates_after_actions_bar' ); | |
| 2147 | + } | |
| 2148 | + | |
| 2149 | + /** | |
| 2150 | + * Method handle_post_staging_sites_view. | |
| 2151 | + * | |
| 2152 | + * @return void | |
| 2153 | + */ | |
| 2154 | + public static function handle_post_staging_sites_view() { | |
| 2155 | + //phpcs:disable WordPress.Security.NonceVerification.Missing | |
| 2156 | + if ( isset( $_POST['mainwpStagingNonceView'] ) && wp_verify_nonce( sanitize_key( $_POST['mainwpStagingNonceView'] ), 'mainwpStagingNonceView' ) ) { | |
| 2157 | + global $current_user; | |
| 2158 | + if ( isset( $_POST['select_staging_options_siteview'] ) && in_array( $_POST['select_staging_options_siteview'], array( 'live', 'staging' ), true ) ) { | |
| 2159 | + update_user_option( $current_user->ID, 'mainwp_staging_options_updates_view', $_POST['select_staging_options_siteview'] ); | |
| 2160 | + } | |
| 2040 | 2161 | } |
| 2162 | + //phpcs:enable WordPress.Security.NonceVerification.Missing | |
| 2163 | + } | |
| 2041 | 2164 | |
| 2042 | 2165 | /** |
| 2043 | - * Action: mainwp_updates_after_actions_bar | |
| 2166 | + * Method render_select_staging_sites_view. | |
| 2044 | 2167 | * |
| 2045 | - * Fires after the actions bar on the Updates page. | |
| 2046 | - * | |
| 2047 | - * @since 4.1 | |
| 2168 | + * @return void | |
| 2048 | 2169 | */ |
| 2049 | - do_action( 'mainwp_updates_after_actions_bar' ); | |
| 2170 | + public static function render_select_staging_sites_view() { | |
| 2171 | + $view = MainWP_System_Utility::get_select_staging_view_sites(); | |
| 2172 | + $view_stagings = 'staging' === (string) $view ? true : false; | |
| 2173 | + | |
| 2174 | + ?> | |
| 2175 | + <form method="post" action="" style="display:inline"> | |
| 2176 | + <select class="ui dropdown mini" id="mainwp_staging_select_options_siteview" name="select_staging_options_siteview"> | |
| 2177 | + <option value="live" <?php echo $view_stagings ? '' : 'selected'; ?>><?php esc_html_e( 'Production sites', 'mainwp' ); ?></option> | |
| 2178 | + <option value="staging" <?php echo $view_stagings ? 'selected' : ''; ?>><?php esc_html_e( 'Staging sites', 'mainwp' ); ?></option> | |
| 2179 | + </select> | |
| 2180 | + <?php wp_nonce_field( 'mainwpStagingNonceView', 'mainwpStagingNonceView' ); ?> | |
| 2181 | + </form> | |
| 2182 | + <script type="text/javascript"> | |
| 2183 | + jQuery(document).ready(function ($) { | |
| 2184 | + jQuery("#mainwp_staging_select_options_siteview").change(function() { | |
| 2185 | + jQuery(this).closest("form").submit(); | |
| 2186 | + }); | |
| 2187 | + }) | |
| 2188 | + </script> | |
| 2189 | + <?php | |
| 2050 | 2190 | } |
| 2051 | 2191 | |
| 2192 | + | |
| 2052 | 2193 | /** |
| 2053 | - * Renders the HTTP Check html content. | |
| 2194 | + * Method render_updates_view_options(). | |
| 2054 | 2195 | * |
| 2055 | - * @param object $websites Child Sites. | |
| 2056 | - * | |
| 2057 | - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 2058 | - * @uses \MainWP\Dashboard\MainWP_DB::data_seek() | |
| 2196 | + * @param mixed $site_view Site view. | |
| 2197 | + * @return void | |
| 2059 | 2198 | */ |
| 2060 | - public static function render_http_checks( $websites ) { //phpcs:ignore -- NOSONAR - complex. | |
| 2199 | + public static function render_updates_view_options( $site_view = '' ) { | |
| 2200 | + ?> | |
| 2201 | + <form method="post" action="" class="ui mini form" style="display:inline flow-root"> | |
| 2202 | + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?> | |
| 2203 | + <select class="ui mini dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview"> | |
| 2204 | + <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option> | |
| 2205 | + <option value="0" class="item" <?php echo MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Item', 'mainwp' ); ?></option> | |
| 2206 | + <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option> | |
| 2207 | + </select> | |
| 2208 | + </form> | |
| 2209 | + <?php | |
| 2210 | + } | |
| 2061 | 2211 | |
| 2062 | - $enable_legacy_backup = get_option( 'mainwp_enableLegacyBackupFeature' ); | |
| 2063 | - $mainwp_primaryBackup = get_option( 'mainwp_primaryBackup' ); | |
| 2212 | + /** | |
| 2213 | + * Method render_abandoned_plugins_themes_buttons(). | |
| 2214 | + * | |
| 2215 | + * @param mixed $current_tab Current tab. | |
| 2216 | + * @return void | |
| 2217 | + */ | |
| 2218 | + public static function render_abandoned_plugins_themes_buttons( $current_tab = '' ) { | |
| 2219 | + if ( 'abandoned-plugins' === $current_tab ) { | |
| 2220 | + ?> | |
| 2221 | + <a href="#" onClick="updatesoverview_bulk_check_abandoned('plugin'); return false;" class="ui green mini basic button"><?php esc_html_e( 'Check for Abandoned Plugins', 'mainwp' ); ?></a> | |
| 2222 | + <?php } elseif ( 'abandoned-themes' === $current_tab ) { ?> | |
| 2223 | + <a href="#" onClick="updatesoverview_bulk_check_abandoned('theme'); return false;" class="ui green mini basic button"><?php esc_html_e( 'Check for Abandoned Themes', 'mainwp' ); ?></a> | |
| 2224 | + <?php | |
| 2225 | + } | |
| 2226 | + } | |
| 2064 | 2227 | |
| 2065 | 2228 | /** |
| 2066 | - * Custom backup pages | |
| 2229 | + * Method get_ignored_core_versions(). | |
| 2067 | 2230 | * |
| 2068 | - * Filters backup options to set correct page for restore options. | |
| 2231 | + * @param array $decodedIgnoredCores Decoded ignored cores. | |
| 2069 | 2232 | * |
| 2070 | - * @since 4.0 | |
| 2233 | + * @return array Ignored core versions. | |
| 2071 | 2234 | */ |
| 2072 | - $customPage = apply_filters_deprecated( 'mainwp-getcustompage-backups', array( false ), '4.0.7.2', 'mainwp_getcustompage_backups' ); // @deprecated Use 'mainwp_getcustompage_backups' instead. NOSONAR - not IP. | |
| 2073 | - $customPage = apply_filters( 'mainwp_getcustompage_backups', $customPage ); | |
| 2235 | + public static function get_ignored_core_versions( $decodedIgnoredCores ) { | |
| 2236 | + if ( | |
| 2237 | + ! is_array( $decodedIgnoredCores ) | |
| 2238 | + || empty( $decodedIgnoredCores['ignored_versions'] ) | |
| 2239 | + || ! is_array( $decodedIgnoredCores['ignored_versions'] ) | |
| 2240 | + ) { | |
| 2241 | + return array(); | |
| 2242 | + } | |
| 2074 | 2243 | |
| 2075 | - $restorePageSlug = ''; | |
| 2076 | - if ( empty( $enable_legacy_backup ) && ! empty( $mainwp_primaryBackup ) && is_array( $customPage ) && isset( $customPage['managesites_slug'] ) ) { | |
| 2077 | - $restorePageSlug = 'admin.php?page=ManageSites' . $customPage['managesites_slug']; | |
| 2078 | - } elseif ( $enable_legacy_backup ) { | |
| 2079 | - $restorePageSlug = 'admin.php?page=managesites'; | |
| 2244 | + return array_filter( $decodedIgnoredCores['ignored_versions'] ); | |
| 2245 | + } | |
| 2246 | + | |
| 2247 | + /** | |
| 2248 | + * Method get_ignored_updates_count(). | |
| 2249 | + * | |
| 2250 | + * @param string $current_tab Current tab. | |
| 2251 | + * | |
| 2252 | + * @return int Ignored updates count. | |
| 2253 | + */ | |
| 2254 | + public static function get_ignored_updates_count( $current_tab = '' ) { //phpcs:ignore -- NOSONAR - complex. | |
| 2255 | + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ), true ) ) { | |
| 2256 | + return 0; | |
| 2080 | 2257 | } |
| 2081 | - ?> | |
| 2082 | - <div class="" id="mainwp-http-response-issues"> | |
| 2083 | - <?php | |
| 2084 | - /** | |
| 2085 | - * Action: mainwp_updates_before_http_response_table | |
| 2086 | - * | |
| 2087 | - * Fires before the HTTP responses table on the Updates pages | |
| 2088 | - * | |
| 2089 | - * @since 4.1 | |
| 2090 | - */ | |
| 2091 | - do_action( 'mainwp_updates_before_http_response_table' ); | |
| 2092 | - ?> | |
| 2093 | - <table class="ui single line inverted unstackable table" id="mainwp-http-response-issues-table"> | |
| 2094 | - <thead> | |
| 2095 | - <tr> | |
| 2096 | - <th scope="col" class="no-sort" colspan="3"><?php esc_html_e( 'HTTP Response Check Results', 'mainwp' ); ?></th> | |
| 2097 | - </tr> | |
| 2098 | - <tr> | |
| 2099 | - <th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> | |
| 2100 | - <th scope="col"><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th> | |
| 2101 | - <th scope="col" class="collapsing no-sort"></th> | |
| 2102 | - </tr> | |
| 2103 | - </thead> | |
| 2104 | - <tbody> | |
| 2105 | - <?php | |
| 2106 | - MainWP_DB::data_seek( $websites, 0 ); | |
| 2107 | - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 2108 | - if ( 1 === (int) $website->offline_check_result || '-1' === $website->http_response_code ) { | |
| 2109 | - continue; | |
| 2110 | - } | |
| 2111 | 2258 | |
| 2112 | - $restoreSlug = ''; | |
| 2259 | + if ( isset( static::$ignored_updates_counts[ $current_tab ] ) ) { | |
| 2260 | + return static::$ignored_updates_counts[ $current_tab ]; | |
| 2261 | + } | |
| 2113 | 2262 | |
| 2114 | - if ( ! empty( $restorePageSlug ) ) { | |
| 2115 | - if ( $enable_legacy_backup ) { | |
| 2116 | - $restoreSlug = $restorePageSlug . '&backupid=' . intval( $website->id ); | |
| 2117 | - } elseif ( static::activated_primary_backup_plugin( $mainwp_primaryBackup, $website ) ) { | |
| 2118 | - $restoreSlug = $restorePageSlug . '&id=' . intval( $website->id ); | |
| 2119 | - } | |
| 2120 | - } | |
| 2263 | + $count = 0; | |
| 2264 | + $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 2265 | + | |
| 2266 | + if ( 'plugins-updates' === $current_tab ) { | |
| 2267 | + $decodedIgnoredPlugins = is_object( $userExtension ) && ! empty( $userExtension->ignored_plugins ) ? json_decode( $userExtension->ignored_plugins, true ) : array(); | |
| 2268 | + $count = is_array( $decodedIgnoredPlugins ) ? count( $decodedIgnoredPlugins ) : 0; | |
| 2269 | + } elseif ( 'themes-updates' === $current_tab ) { | |
| 2270 | + $decodedIgnoredThemes = is_object( $userExtension ) && ! empty( $userExtension->ignored_themes ) ? json_decode( $userExtension->ignored_themes, true ) : array(); | |
| 2271 | + $count = is_array( $decodedIgnoredThemes ) ? count( $decodedIgnoredThemes ) : 0; | |
| 2272 | + } elseif ( 'wordpress-updates' === $current_tab ) { | |
| 2273 | + $decodedIgnoredCores = is_object( $userExtension ) && ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array(); | |
| 2274 | + $count = count( static::get_ignored_core_versions( $decodedIgnoredCores ) ); | |
| 2275 | + } | |
| 2276 | + | |
| 2277 | + $websites = MainWP_DB::instance()->query( | |
| 2278 | + MainWP_DB::instance()->get_sql_websites_for_current_user( | |
| 2279 | + false, | |
| 2280 | + null, | |
| 2281 | + 'wp.url', | |
| 2282 | + false, | |
| 2283 | + false, | |
| 2284 | + null, | |
| 2285 | + false, | |
| 2286 | + array( 'ignored_wp_upgrades' ) | |
| 2287 | + ) | |
| 2288 | + ); | |
| 2289 | + | |
| 2290 | + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { | |
| 2291 | + if ( 'plugins-updates' === $current_tab ) { | |
| 2292 | + $decodedIgnoredPlugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array(); | |
| 2293 | + if ( ! empty( $decodedIgnoredPlugins ) && is_array( $decodedIgnoredPlugins ) ) { | |
| 2294 | + ++$count; | |
| 2295 | + } | |
| 2296 | + } elseif ( 'themes-updates' === $current_tab ) { | |
| 2297 | + $decodedIgnoredThemes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array(); | |
| 2298 | + if ( ! empty( $decodedIgnoredThemes ) && is_array( $decodedIgnoredThemes ) ) { | |
| 2299 | + ++$count; | |
| 2300 | + } | |
| 2301 | + } elseif ( 'wordpress-updates' === $current_tab && empty( $website->is_ignoreCoreUpdates ) ) { | |
| 2302 | + $decodedIgnoredCores = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array(); | |
| 2303 | + if ( ! empty( static::get_ignored_core_versions( $decodedIgnoredCores ) ) ) { | |
| 2304 | + ++$count; | |
| 2305 | + } | |
| 2306 | + } | |
| 2307 | + } | |
| 2308 | + | |
| 2309 | + if ( $websites ) { | |
| 2310 | + MainWP_DB::free_result( $websites ); | |
| 2311 | + } | |
| 2312 | + | |
| 2313 | + static::$ignored_updates_counts[ $current_tab ] = $count; | |
| 2314 | + | |
| 2315 | + return $count; | |
| 2316 | + } | |
| 2317 | + | |
| 2318 | + /** | |
| 2319 | + * Method render_updates_actions_buttons(). | |
| 2320 | + * | |
| 2321 | + * @param mixed $current_tab Current tab. | |
| 2322 | + * @param int $updates_count Available updates count. | |
| 2323 | + * @return void | |
| 2324 | + */ | |
| 2325 | + public static function render_updates_actions_buttons( $current_tab, $updates_count = 0 ) { | |
| 2326 | + $has_updates = 0 < intval( $updates_count ); | |
| 2327 | + | |
| 2328 | + if ( 'plugins-updates' === $current_tab ) { | |
| 2329 | + if ( static::user_can_update_plugins() ) { | |
| 2330 | + if ( $has_updates ) { | |
| 2331 | + static::set_continue_update_html_selector( 'plugins_global_upgrade_all' ); | |
| 2121 | 2332 | ?> |
| 2122 | - <tr id="child-site-<?php echo intval( $website->id ); ?>" class="child-site mainwp-child-site-<?php echo intval( $website->id ); ?>" siteid="<?php echo intval( $website->id ); ?>" site-url="<?php echo esc_url( $website->url ); ?>"> | |
| 2123 | - <td> | |
| 2124 | - <?php static::render_site_link_dashboard( $website ); ?> | |
| 2125 | - </td> | |
| 2126 | - <td id="wp_http_response_code_<?php echo esc_attr( $website->id ); ?>"> | |
| 2127 | - <label class="ui red label http-code"><?php echo 'HTTP ' . esc_html( $website->http_response_code ); ?></label> | |
| 2128 | - </td> | |
| 2129 | - <td class="right aligned"> | |
| 2130 | - <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $website->id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="ui mini button" target="_blank"><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></a> | |
| 2131 | - <a href="javascript:void(0)" onclick="return updatesoverview_recheck_http( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini green button"><?php esc_html_e( 'Recheck', 'mainwp' ); ?></a> | |
| 2132 | - <?php if ( ! empty( $website->sync_errors ) ) { ?> | |
| 2133 | - <a href="#" class="mainwp_site_reconnect ui green mini button"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a> | |
| 2134 | - <?php } ?> | |
| 2135 | - <a href="javascript:void(0)" onClick="return updatesoverview_ignore_http_response( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?></a> | |
| 2136 | - <?php if ( ! empty( $restoreSlug ) ) { ?> | |
| 2137 | - <a href="<?php echo esc_url( $restoreSlug ); ?>" class="ui green mini basic button"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a> | |
| 2138 | - <?php } ?> | |
| 2139 | - </td> | |
| 2140 | - </tr> | |
| 2333 | + <a href="javascript:void(0)" onClick="updatesoverview_plugins_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui mini green basic button"><?php esc_html_e( 'Update Selected Plugins', 'mainwp' ); ?></a> | |
| 2334 | + <a href="javascript:void(0)" onClick="updatesoverview_plugins_global_upgrade_all(); return false;" class="mainwp-update-all-button ui mini green button"><?php esc_html_e( 'Update All Plugins', 'mainwp' ); ?></a> | |
| 2141 | 2335 | <?php |
| 2336 | + } else { | |
| 2337 | + ?> | |
| 2338 | + <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini green basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected Plugins', 'mainwp' ); ?></a> | |
| 2339 | + <a href="javascript:void(0)" class="mainwp-update-all-button ui mini green disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All Plugins', 'mainwp' ); ?></a> | |
| 2340 | + <?php | |
| 2142 | 2341 | } |
| 2342 | + } | |
| 2343 | + } elseif ( 'themes-updates' === $current_tab ) { | |
| 2344 | + if ( static::user_can_update_themes() ) { | |
| 2345 | + if ( $has_updates ) { | |
| 2346 | + static::set_continue_update_html_selector( 'themes_global_upgrade_all' ); | |
| 2347 | + ?> | |
| 2348 | + <a href="javascript:void(0)" onClick="updatesoverview_themes_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui mini green basic button"><?php esc_html_e( 'Update Selected Themes', 'mainwp' ); ?></a> | |
| 2349 | + <a href="javascript:void(0)" onClick="updatesoverview_themes_global_upgrade_all(); return false;" class="mainwp-update-all-button ui mini green button"><?php esc_html_e( 'Update All Themes', 'mainwp' ); ?></a> | |
| 2350 | + <?php | |
| 2351 | + } else { | |
| 2352 | + ?> | |
| 2353 | + <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini green basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected Themes', 'mainwp' ); ?></a> | |
| 2354 | + <a href="javascript:void(0)" class="mainwp-update-all-button ui mini green disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All Themes', 'mainwp' ); ?></a> | |
| 2355 | + <?php | |
| 2356 | + } | |
| 2357 | + } | |
| 2358 | + } elseif ( 'wordpress-updates' === $current_tab ) { | |
| 2359 | + if ( static::user_can_update_wp() ) { | |
| 2360 | + if ( $has_updates ) { | |
| 2361 | + static::set_continue_update_html_selector( 'wpcore_global_upgrade_all' ); | |
| 2362 | + ?> | |
| 2363 | + <a href="javascript:void(0)" class="mainwp-update-selected-button ui green mini basic button" onclick="event.stopPropagation(); updatesoverview_wordpress_global_upgrade_all( false, true ); return false;"><?php esc_html_e( 'Update Selected WP Cores', 'mainwp' ); ?></a> | |
| 2364 | + <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini button" onclick="updatesoverview_wordpress_global_upgrade_all(); return false;"><?php esc_html_e( 'Update All WP Cores', 'mainwp' ); ?></a> | |
| 2365 | + <?php | |
| 2366 | + } else { | |
| 2367 | + ?> | |
| 2368 | + <a href="javascript:void(0)" class="mainwp-update-selected-button ui green mini basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected WP Cores', 'mainwp' ); ?></a> | |
| 2369 | + <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All WP Cores', 'mainwp' ); ?></a> | |
| 2370 | + <?php | |
| 2371 | + } | |
| 2372 | + } | |
| 2373 | + } elseif ( 'translations-updates' === $current_tab ) { | |
| 2374 | + if ( static::user_can_update_trans() ) { | |
| 2143 | 2375 | ?> |
| 2144 | - </tbody> | |
| 2145 | - <tfoot> | |
| 2146 | - <tr> | |
| 2147 | - <th scope="col" ><?php esc_html_e( 'Website', 'mainwp' ); ?></th> | |
| 2148 | - <th scope="col" ><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th> | |
| 2149 | - <th scope="col" class="collapsing no-sort"></th> | |
| 2150 | - </tr> | |
| 2151 | - </tfoot> | |
| 2152 | - </table> | |
| 2376 | + <a href="javascript:void(0)" onClick="updatesoverview_translations_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui button mini basic green"><?php esc_html_e( 'Update Selected Translations', 'mainwp' ); ?></a> | |
| 2377 | + <a href="javascript:void(0)" onClick="updatesoverview_translations_global_upgrade_all(); return false;" class="mainwp-update-all-button ui button mini green"><?php esc_html_e( 'Update All Translations', 'mainwp' ); ?></a> | |
| 2378 | + <?php | |
| 2379 | + } | |
| 2380 | + } | |
| 2381 | + } | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + /** | |
| 2385 | + * Method render_button_view_ignored_updates(). | |
| 2386 | + * | |
| 2387 | + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() | |
| 2388 | + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user() | |
| 2389 | + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() | |
| 2390 | + * | |
| 2391 | + * @param string $current_tab current tab. | |
| 2392 | + * | |
| 2393 | + * @return null | |
| 2394 | + */ | |
| 2395 | + public static function render_button_view_ignored_updates( $current_tab = '' ) { //phpcs:ignore -- NOSONAR - complex. | |
| 2396 | + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ) ) ) { | |
| 2397 | + return; | |
| 2398 | + } | |
| 2399 | + $count_ignored_updates = static::get_ignored_updates_count( $current_tab ); | |
| 2400 | + $ignored_core_url = add_query_arg( | |
| 2401 | + array( | |
| 2402 | + 'page' => 'UpdatesManage', | |
| 2403 | + 'tab' => 'updates-ignore', | |
| 2404 | + ), | |
| 2405 | + admin_url( 'admin.php' ) | |
| 2406 | + ); | |
| 2407 | + $ignored_plugins_url = add_query_arg( | |
| 2408 | + array( | |
| 2409 | + 'page' => 'PluginsIgnore', | |
| 2410 | + ), | |
| 2411 | + admin_url( 'admin.php' ) | |
| 2412 | + ); | |
| 2413 | + $ignored_themes_url = add_query_arg( | |
| 2414 | + array( | |
| 2415 | + 'page' => 'ThemesIgnore', | |
| 2416 | + ), | |
| 2417 | + admin_url( 'admin.php' ) | |
| 2418 | + ); | |
| 2419 | + ?> | |
| 2420 | + <?php if ( 'wordpress-updates' === $current_tab && 0 < $count_ignored_updates ) : ?> | |
| 2421 | + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_core_url ); ?>" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Click here to see the list of ignored WordPress core updates.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a> | |
| 2422 | + <?php elseif ( 'plugins-updates' === $current_tab && 0 < $count_ignored_updates ) : ?> | |
| 2423 | + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_plugins_url ); ?>"><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a> | |
| 2424 | + <?php elseif ( 'themes-updates' === $current_tab && 0 < $count_ignored_updates ) : ?> | |
| 2425 | + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_themes_url ); ?>" ><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a> | |
| 2426 | + <?php endif; ?> | |
| 2153 | 2427 | <?php |
| 2154 | - /** | |
| 2155 | - * Action: mainwp_updates_after_http_response_table | |
| 2156 | - * | |
| 2157 | - * Fires after the HTTP responses table on the Updates pages. | |
| 2158 | - * | |
| 2159 | - * @since 4.1 | |
| 2160 | - */ | |
| 2161 | - do_action( 'mainwp_updates_after_http_response_table' ); | |
| 2428 | + } | |
| 2162 | 2429 | |
| 2163 | - $table_features = array( | |
| 2164 | - 'searching' => 'false', | |
| 2165 | - 'paging' => 'false', | |
| 2166 | - 'stateSave' => 'true', | |
| 2167 | - 'info' => 'false', | |
| 2168 | - 'responsive' => 'true', | |
| 2169 | - ); | |
| 2430 | + /** | |
| 2431 | + * Method handle_limit_sites(). | |
| 2432 | + */ | |
| 2433 | + public static function handle_limit_sites(){ // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 2434 | + // put hook here before loading sites. | |
| 2435 | + $limit_number = apply_filters( 'mainwp_manage_updates_limit_loading', false, 'updates' ); | |
| 2436 | + $current_limit = get_option( 'mainwp_manage_updates_limit_sites' ); | |
| 2170 | 2437 | |
| 2171 | - /** | |
| 2172 | - * Filter: mainwp_updates_http_responses_datatable_features | |
| 2173 | - * | |
| 2174 | - * Filters the DataTable options for the HTTP Responses table on the Updates page. | |
| 2175 | - * | |
| 2176 | - * @since 4.1 | |
| 2177 | - */ | |
| 2178 | - $table_features = apply_filters( 'mainwp_updates_http_responses_datatable_features', $table_features ); | |
| 2179 | - ?> | |
| 2180 | - <script> | |
| 2181 | - jQuery( document ).ready( function() { | |
| 2182 | - let responsive = <?php echo esc_html( $table_features['responsive'] ); ?>; | |
| 2183 | - if( jQuery( window ).width() > 1140 ) { | |
| 2184 | - responsive = false; | |
| 2185 | - } | |
| 2186 | - jQuery( '#mainwp-http-response-issues-table' ).DataTable( { | |
| 2187 | - "responsive": responsive, | |
| 2188 | - "searching": <?php echo esc_html( $table_features['searching'] ); ?>, | |
| 2189 | - "paging" : <?php echo esc_html( $table_features['paging'] ); ?>, | |
| 2190 | - "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>, | |
| 2191 | - "info" : <?php echo esc_html( $table_features['info'] ); ?>, | |
| 2192 | - "columnDefs" : [ { "orderable": false, "targets": "no-sort" } ], | |
| 2193 | - "language" : { "emptyTable": "No HTTP issues detected." }, | |
| 2194 | - } ); | |
| 2195 | - } ); | |
| 2196 | - </script> | |
| 2438 | + if ( (int) $limit_number !== (int) $current_limit ) { | |
| 2439 | + update_option( 'mainwp_manage_updates_limit_sites', $limit_number ); | |
| 2440 | + update_option( 'mainwp_manage_updates_limit_current_page', 1 ); | |
| 2441 | + } | |
| 2442 | + | |
| 2443 | + if ( ! empty( $limit_number ) ) { | |
| 2444 | + | |
| 2445 | + $count = MainWP_DB::instance()->get_websites_count( null, true ); | |
| 2446 | + | |
| 2447 | + $current_page = 1; | |
| 2448 | + if ( isset( $_GET['current_page'] ) && isset( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) ) { | |
| 2449 | + $current_page = intval( $_GET['current_page'] ); | |
| 2450 | + } | |
| 2451 | + | |
| 2452 | + if ( 0 >= $current_page ) { | |
| 2453 | + $current_page = 1; | |
| 2454 | + } | |
| 2455 | + | |
| 2456 | + $total_page = ceil( $count / $limit_number ); | |
| 2457 | + | |
| 2458 | + if ( $current_page > $total_page ) { | |
| 2459 | + $current_page = $total_page; | |
| 2460 | + } | |
| 2461 | + update_option( 'mainwp_manage_updates_limit_current_page', $current_page ); | |
| 2462 | + } | |
| 2463 | + } | |
| 2464 | + | |
| 2465 | + /** | |
| 2466 | + * Method render_limit_load_sites(). | |
| 2467 | + * | |
| 2468 | + * @param int $limit_number limit loading sites. | |
| 2469 | + */ | |
| 2470 | + public static function render_limit_load_sites( $limit_number) { // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 2471 | + | |
| 2472 | + $count = MainWP_DB::instance()->get_websites_count( null, true ); | |
| 2473 | + $total_page = ceil( $count / $limit_number ); | |
| 2474 | + | |
| 2475 | + $current_page = (int) get_option( 'mainwp_manage_updates_limit_current_page' ); | |
| 2476 | + | |
| 2477 | + $first = 1 === $current_page; | |
| 2478 | + $last = $total_page <= $current_page; | |
| 2479 | + | |
| 2480 | + ?> | |
| 2481 | + <div class="dt-paging paging_full_numbers"> | |
| 2482 | + <div class="ui stackable pagination menu"><menu> | |
| 2483 | + <?php if ( $first ) { ?> | |
| 2484 | + <li class="dt-paging-button item disabled"><div class="page-link first" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="First" data-dt-idx="first" tabindex="-1">First</div></li> | |
| 2485 | + <li class="dt-paging-button item disabled"><div class="page-link previous" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Previous" data-dt-idx="previous" tabindex="-1">Previous</div></li> | |
| 2486 | + <?php } else { ?> | |
| 2487 | + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage" class="page-link first" aria-controls="mainwp-manage-sites-table" aria-label="First" data-dt-idx="first" tabindex="0">First</a></li> | |
| 2488 | + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage¤t_page=<?php echo intval( $current_page - 1 ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link previous" aria-controls="mainwp-manage-sites-table" aria-label="Previous" data-dt-idx="previous" tabindex="0">Previous</a></li> | |
| 2489 | + <?php } ?> | |
| 2490 | + <?php | |
| 2491 | + for ( $i = 1; $i <= $total_page;$i++ ) { | |
| 2492 | + ?> | |
| 2493 | + <li class="dt-paging-button item <?php echo $current_page === $i ? 'active' : ''; ?>"><a href="admin.php?page=UpdatesManage¤t_page=<?php echo intval( $i ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link" aria-controls="mainwp-manage-sites-table" aria-current="page" data-dt-idx="1" tabindex="0"><?php echo intval( $i ); ?></a></li> | |
| 2494 | + <?php | |
| 2495 | + } | |
| 2496 | + ?> | |
| 2497 | + <?php if ( $last ) { ?> | |
| 2498 | + <li class="dt-paging-button item disabled"><div class="page-link next" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Next" data-dt-idx="next" tabindex="-1">Next</div></li> | |
| 2499 | + <li class="dt-paging-button item disabled"><div class="page-link last" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Last" data-dt-idx="last" tabindex="-1">Last</div></li> | |
| 2500 | + <?php } else { ?> | |
| 2501 | + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage¤t_page=<?php echo $current_page === $last ? intval( $last ) : intval( $current_page + 1 ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link next" aria-controls="mainwp-manage-sites-table" aria-label="Next" data-dt-idx="next" tabindex="0">Next</a></li> | |
| 2502 | + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage¤t_page=<?php echo intval( $total_page ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link last" aria-controls="mainwp-manage-sites-table" aria-label="Last" data-dt-idx="last" tabindex="0">Last</a></li> | |
| 2503 | + <?php } ?> | |
| 2504 | + </menu></div> | |
| 2197 | 2505 | </div> |
| 2198 | - <div class="ui hidden clearing divider"></div> | |
| 2199 | - <?php | |
| 2506 | + <br/> | |
| 2507 | + <?php | |
| 2200 | 2508 | } |
| 2201 | 2509 | |
| 2202 | - /** | |
| 2203 | - * Cheks which primary backup plugin is being used. | |
| 2204 | - * | |
| 2205 | - * @param mixed $what Which backup plugin is being use. | |
| 2206 | - * @param object $website Website array of information. | |
| 2207 | - * | |
| 2208 | - * @return boolean True|False. | |
| 2209 | - */ | |
| 2510 | + /** | |
| 2511 | + * Cheks which primary backup plugin is being used. | |
| 2512 | + * | |
| 2513 | + * @param mixed $what Which backup plugin is being use. | |
| 2514 | + * @param object $website Website array of information. | |
| 2515 | + * | |
| 2516 | + * @return boolean True|False. | |
| 2517 | + */ | |
| 2210 | 2518 | public static function activated_primary_backup_plugin( $what, $website ) { |
| 2211 | 2519 | $plugins = json_decode( $website->plugins, 1 ); |
| 2212 | 2520 | if ( ! is_array( $plugins ) || empty( $plugins ) ) { |
| 2213 | 2521 | return false; |
| @@ -2239,14 +2547,14 @@ | ||
| 2239 | 2547 | |
| 2240 | 2548 | return $installed; |
| 2241 | 2549 | } |
| 2242 | 2550 | |
| 2243 | - /** | |
| 2244 | - * Sets the HTML selector to continue updates. | |
| 2245 | - * | |
| 2246 | - * @param string $current_update current update string. | |
| 2247 | - * @param bool $slug Whether to update slug. | |
| 2248 | - */ | |
| 2551 | + /** | |
| 2552 | + * Sets the HTML selector to continue updates. | |
| 2553 | + * | |
| 2554 | + * @param string $current_update current update string. | |
| 2555 | + * @param bool $slug Whether to update slug. | |
| 2556 | + */ | |
| 2249 | 2557 | public static function set_continue_update_html_selector( $current_update, $slug = false ) { |
| 2250 | 2558 | |
| 2251 | 2559 | $check_slug = true; |
| 2252 | 2560 | if ( ! empty( $slug ) ) { |
| @@ -2259,20 +2567,20 @@ | ||
| 2259 | 2567 | static::$continue_selector = ''; |
| 2260 | 2568 | } |
| 2261 | 2569 | } |
| 2262 | 2570 | |
| 2263 | - /** | |
| 2264 | - * Gets the HTML selector to continue updates. | |
| 2265 | - * | |
| 2266 | - * @return void. | |
| 2267 | - */ | |
| 2571 | + /** | |
| 2572 | + * Gets the HTML selector to continue updates. | |
| 2573 | + * | |
| 2574 | + * @return void. | |
| 2575 | + */ | |
| 2268 | 2576 | public static function get_continue_update_selector() { |
| 2269 | 2577 | echo esc_attr( static::$continue_selector ); |
| 2270 | 2578 | } |
| 2271 | 2579 | |
| 2272 | - /** | |
| 2273 | - * Displays the updates modal window during updates. | |
| 2274 | - */ | |
| 2580 | + /** | |
| 2581 | + * Displays the updates modal window during updates. | |
| 2582 | + */ | |
| 2275 | 2583 | public static function render_updates_modal() { |
| 2276 | 2584 | ?> |
| 2277 | 2585 | <div class="ui modal" id="updatesoverview-backup-box"> |
| 2278 | 2586 | <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div> |
| @@ -2282,14 +2590,14 @@ | ||
| 2282 | 2590 | <a id="updatesoverview-backup-now" href="javascript:void(0)" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a> |
| 2283 | 2591 | <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/> |
| 2284 | 2592 | </div> |
| 2285 | 2593 | </div> |
| 2286 | - <?php | |
| 2594 | + <?php | |
| 2287 | 2595 | } |
| 2288 | 2596 | |
| 2289 | - /** | |
| 2290 | - * Displays the plugin details modal window. | |
| 2291 | - */ | |
| 2597 | + /** | |
| 2598 | + * Displays the plugin details modal window. | |
| 2599 | + */ | |
| 2292 | 2600 | public static function render_plugin_details_modal() { |
| 2293 | 2601 | ?> |
| 2294 | 2602 | <div class="ui modal" id="mainwp-plugin-details-modal"> |
| 2295 | 2603 | <i class="close icon"></i> |
| @@ -2299,8 +2607,50 @@ | ||
| 2299 | 2607 | </div> |
| 2300 | 2608 | <div class="actions"> |
| 2301 | 2609 | </div> |
| 2302 | 2610 | </div> |
| 2611 | + <?php | |
| 2612 | + } | |
| 2613 | + | |
| 2614 | + /** | |
| 2615 | + * Method get_site_tz_info(). | |
| 2616 | + * | |
| 2617 | + * @param object $website Website. | |
| 2618 | + * | |
| 2619 | + * @return string Timezone site info. | |
| 2620 | + */ | |
| 2621 | + public static function get_site_tz_info( $website ) { | |
| 2622 | + if ( is_object( $website ) && ! empty( $website->site_info ) ) { | |
| 2623 | + $wp_info = ! empty( $website->site_info ) ? json_decode( $website->site_info, true ) : array(); | |
| 2624 | + if ( ! is_array( $wp_info ) ) { | |
| 2625 | + $wp_info = array(); | |
| 2626 | + } | |
| 2627 | + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array(); | |
| 2628 | + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0; | |
| 2629 | + return esc_html__( '- Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs ); | |
| 2630 | + } | |
| 2631 | + return ''; | |
| 2632 | + } | |
| 2633 | + | |
| 2634 | + /** | |
| 2635 | + * Method render_changes_history_modal() | |
| 2636 | + */ | |
| 2637 | + public static function render_changes_history_modal() { | |
| 2638 | + ?> | |
| 2639 | + <div class="ui modal" id="mainwp-plugin-theme-history-changes-modal"> | |
| 2640 | + <i class="close icon"></i> | |
| 2641 | + <div class="ui header"> | |
| 2642 | + <div class="main-text"><?php esc_html_e( 'History', 'mainwp' ); ?></div> | |
| 2643 | + <div class="sub header" style="display:none;"></div> | |
| 2644 | + </div> | |
| 2645 | + <div class="scrolling content"></div> | |
| 2646 | + <div class="actions"> | |
| 2647 | + <div class="ui two columns stackable grid"> | |
| 2648 | + <div class="left aligned column col-left"></div> | |
| 2649 | + <div class="right aligned column col-right"></div> | |
| 2650 | + </div> | |
| 2651 | + </div> | |
| 2652 | + </div> | |
| 2303 | 2653 | <?php |
| 2304 | 2654 | } |
| 2305 | 2655 | |
| 2306 | 2656 | /** |
| @@ -2309,14 +2659,16 @@ | ||
| 2309 | 2659 | * Renders Page Settings Modal. |
| 2310 | 2660 | */ |
| 2311 | 2661 | public static function render_screen_options_modal() { // phpcs:ignore -- NOSONAR - complex method. |
| 2312 | 2662 | |
| 2313 | - $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' ); | |
| 2314 | - $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' ); | |
| 2315 | - $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' ); | |
| 2316 | - $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 ); | |
| 2317 | - $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 ); | |
| 2318 | - $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 ); | |
| 2663 | + $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' ); | |
| 2664 | + $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' ); | |
| 2665 | + $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' ); | |
| 2666 | + $snTransAutomaticUpdate = (int) get_option( 'mainwp_transAutomaticDailyUpdate' ); | |
| 2667 | + | |
| 2668 | + $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 ); | |
| 2669 | + $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 ); | |
| 2670 | + $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 ); | |
| 2319 | 2671 | ?> |
| 2320 | 2672 | <div class="ui modal" id="mainwp-manage-updates-screen-options-modal"> |
| 2321 | 2673 | <i class="close icon"></i> |
| 2322 | 2674 | <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| @@ -2321,13 +2673,13 @@ | ||
| 2321 | 2673 | <i class="close icon"></i> |
| 2322 | 2674 | <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| 2323 | 2675 | <div class="scrolling content ui form"> |
| 2324 | 2676 | <form method="POST" action="" id="manage-updates-screen-options-form" name="manage-updates-screen-options-form"> |
| 2325 | - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> | |
| 2677 | + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?> | |
| 2326 | 2678 | <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdatesScrOptions' ) ); ?>" /> |
| 2327 | 2679 | <div class="ui grid field"> |
| 2328 | 2680 | <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label> |
| 2329 | - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugins updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left"> | |
| 2681 | + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugin updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left"> | |
| 2330 | 2682 | <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown"> |
| 2331 | 2683 | <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option> |
| 2332 | 2684 | <option value="0" <?php echo ( false !== $snPluginAutomaticDailyUpdate && empty( $snPluginAutomaticDailyUpdate ) ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option> |
| 2333 | 2685 | </select> |
| @@ -2334,9 +2686,9 @@ | ||
| 2334 | 2686 | </div> |
| 2335 | 2687 | </div> |
| 2336 | 2688 | <div class="ui grid field"> |
| 2337 | 2689 | <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label> |
| 2338 | - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic themes updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 2690 | + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic theme updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 2339 | 2691 | <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown"> |
| 2340 | 2692 | <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option> |
| 2341 | 2693 | <option value="0" <?php echo ( false !== $snThemeAutomaticDailyUpdate && 0 === $snThemeAutomaticDailyUpdate ) || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option> |
| 2342 | 2694 | </select> |
| @@ -2342,8 +2694,17 @@ | ||
| 2342 | 2694 | </select> |
| 2343 | 2695 | </div> |
| 2344 | 2696 | </div> |
| 2345 | 2697 | <div class="ui grid field"> |
| 2698 | + <label class="six wide column middle aligned"><?php esc_html_e( 'Translation advanced automatic updates', 'mainwp' ); ?></label> | |
| 2699 | + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic translation updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 2700 | + <select name="mainwp_transAutomaticDailyUpdate" id="mainwp_transAutomaticDailyUpdate" class="ui dropdown"> | |
| 2701 | + <option value="1" <?php echo 1 === $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option> | |
| 2702 | + <option value="0" <?php echo ( false !== $snTransAutomaticUpdate && 0 === $snTransAutomaticUpdate ) || 2 === $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option> | |
| 2703 | + </select> | |
| 2704 | + </div> | |
| 2705 | + </div> | |
| 2706 | + <div class="ui grid field"> | |
| 2346 | 2707 | <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label> |
| 2347 | 2708 | <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic WordPress core updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 2348 | 2709 | <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown"> |
| 2349 | 2710 | <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option> |
| @@ -2396,29 +2757,32 @@ | ||
| 2396 | 2757 | </div> |
| 2397 | 2758 | </div> |
| 2398 | 2759 | </form> |
| 2399 | 2760 | </div> |
| 2400 | - <?php | |
| 2761 | + <?php | |
| 2401 | 2762 | } |
| 2402 | 2763 | |
| 2403 | 2764 | |
| 2404 | - /** | |
| 2405 | - * MainWP Help Box content. Hook the section help content to the Help Sidebar element. | |
| 2406 | - */ | |
| 2765 | + /** | |
| 2766 | + * Method mainwp_help_content() | |
| 2767 | + * | |
| 2768 | + * Creates the MainWP Help Documentation List for the help component in the sidebar. | |
| 2769 | + */ | |
| 2407 | 2770 | public static function mainwp_help_content() { |
| 2408 | 2771 | if ( isset( $_GET['page'] ) && 'UpdatesManage' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 2409 | 2772 | ?> |
| 2410 | 2773 | <p><?php esc_html_e( 'If you need help with managing updates, please review following help documents', 'mainwp' ); ?></p> |
| 2411 | - <div class="ui relaxed bulleted list"> | |
| 2412 | - <div class="item"><a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">Update Plugins</a> <i class="external alternate icon"></i></div> | |
| 2413 | - <div class="item"><a href="https://kb.mainwp.com/docs/plugins-auto-updates/" target="_blank">Plugins Auto Updates</a> <i class="external alternate icon"></i></div> | |
| 2414 | - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">Ignore Plugin Updates</a> <i class="external alternate icon"></i></div> | |
| 2415 | - <div class="item"><a href="https://kb.mainwp.com/docs/update-themes/" target="_blank">Update Themes</a> <i class="external alternate icon"></i></div> | |
| 2416 | - <div class="item"><a href="https://kb.mainwp.com/docs/themes-auto-updates/" target="_blank">Themes Auto Updates</a> <i class="external alternate icon"></i></div> | |
| 2417 | - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-theme-updates/" target="_blank">Ignore Theme Updates</a> <i class="external alternate icon"></i></div> | |
| 2418 | - <div class="item"><a href="https://kb.mainwp.com/docs/update-wordpress-core/" target="_blank">Update WordPress Core</a> <i class="external alternate icon"></i></div> | |
| 2419 | - <div class="item"><a href="https://kb.mainwp.com/docs/auto-update-wordpress-core/" target="_blank">Auto Update WordPress Core</a> <i class="external alternate icon"></i></div> | |
| 2420 | - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-wordpress-core-update/" target="_blank">Ignore WordPress Core Update</a> <i class="external alternate icon"></i></div> | |
| 2774 | + <div class="ui list"> | |
| 2775 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-updates" target="_blank">Update Plugins</a></div> | |
| 2776 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-auto-updates" target="_blank">Plugins Auto Updates</a></div> | |
| 2777 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">Ignore Plugin Updates</a></div> | |
| 2778 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">Update Themes</a></div> | |
| 2779 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#theme-auto-updates" target="_blank">Themes Auto Updates</a></div> | |
| 2780 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">Ignore Theme Updates</a></div> | |
| 2781 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">Update WordPress Core</a></div> | |
| 2782 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#auto-update-wordpress-core" target="_blank">Auto Update WordPress Core</a></div> | |
| 2783 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-wordpress-core-updates" target="_blank">Ignore WordPress Core Update</a></div> | |
| 2784 | + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#safe-updates-%2F-rollback" target="_blank">Safe Updates/Updates Rollback</a></div> | |
| 2421 | 2785 | <?php |
| 2422 | 2786 | /** |
| 2423 | 2787 | * Action: mainwp_updates_help_item |
| 2424 | 2788 | * |
| @@ -2432,8 +2796,8 @@ | ||
| 2432 | 2796 | */ |
| 2433 | 2797 | do_action( 'mainwp_updates_help_item' ); |
| 2434 | 2798 | ?> |
| 2435 | 2799 | </div> |
| 2436 | - <?php | |
| 2800 | + <?php | |
| 2437 | 2801 | } |
| 2438 | 2802 | } |
| 2439 | 2803 | } |