PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.3
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / pages / page-mainwp-updates.php

page-mainwp-updates.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.3, at pages/page-mainwp-updates.php

2,428 lines 129.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Updates Page.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_Updates
12 *
13 * @package MainWP\Dashboard
14 */
15 class MainWP_Updates { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16
17 /**
18 * User can ignore updates.
19 *
20 * @var bool $user_can_ignore_updates User can ignore updates.
21 */
22 public static $user_can_ignore_updates = null;
23
24 /**
25 * User can update translations.
26 *
27 * @var bool $user_can_update_trans User can update translations.
28 */
29 public static $user_can_update_trans = null;
30
31 /**
32 * User can update WordPress core files.
33 *
34 * @var bool $user_can_update_wp User can update WordPress core files.
35 */
36 public static $user_can_update_wp = null;
37
38 /**
39 * User can update themes.
40 *
41 * @var bool $user_can_update_themes User can update themes.
42 */
43 public static $user_can_update_themes = null;
44
45 /**
46 * User can update plugins.
47 *
48 * @var bool $user_can_update_plugins User can update plugins.
49 */
50 public static $user_can_update_plugins = null;
51
52 /**
53 * Placeholder for continue selector.
54 *
55 * @var string $continue_selector Placeholder for continue selector.
56 */
57 public static $continue_selector = '';
58
59 /**
60 * Placeholder for continue update.
61 *
62 * @var string $continue_update Placeholder for continue update.
63 */
64 public static $continue_update = '';
65
66 /**
67 * Placeholder for continue update slug.
68 *
69 * @var string $continue_update_slug Placeholder for continue update slug.
70 */
71 public static $continue_update_slug = '';
72
73 /**
74 * Public static varable to hold Subpages information.
75 *
76 * @var array $subPages
77 */
78 public static $subPages;
79
80 /**
81 * Current page.
82 *
83 * @static
84 * @var string $page Current page.
85 */
86 public static $page;
87
88 /**
89 * Gets Class Name.
90 *
91 * @return object
92 */
93 public static function get_class_name() {
94 return __CLASS__;
95 }
96
97 /**
98 * Instantiates MainWP Updates Page.
99 *
100 * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
101 */
102 public static function init() {
103 /**
104 * This hook allows you to render the Post page header via the 'mainwp-pageheader-updates' action.
105 *
106 * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
107 *
108 * @see \MainWP_Updates::render_header
109 */
110 add_action( 'mainwp-pageheader-updates', array( MainWP_Post::get_class_name(), 'render_header' ) );
111
112 /**
113 * This hook allows you to render the Updates page footer via the 'mainwp-pagefooter-updates' action.
114 *
115 * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
116 *
117 * @see \MainWP_Updates::render_footer
118 */
119 add_action( 'mainwp-pagefooter-updates', array( MainWP_Post::get_class_name(), 'render_footer' ) );
120
121 add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) );
122 }
123
124 /**
125 * Renders init updates menu.
126 *
127 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
128 */
129 public static function init_menu() {
130 static::init_left_menu( static::$subPages );
131 add_action( 'load-' . static::$page, array( static::get_class_name(), 'on_load_page' ) );
132 }
133
134 /**
135 * Initiates Updates menu.
136 *
137 * @param array $subPages Sub pages array.
138 *
139 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
140 * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
141 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
142 */
143 public static function init_left_menu( $subPages = array() ) {
144 static::$page = add_submenu_page(
145 'mainwp_tab',
146 __( 'Updates', 'mainwp' ),
147 '<span id="mainwp-Updates">' . esc_html__( 'Updates', 'mainwp' ) . '</span>',
148 'read',
149 'UpdatesManage',
150 array(
151 static::get_class_name(),
152 'render',
153 )
154 );
155
156 $updates_count = MainWP_Common_Handler::instance()->sites_available_updates_count();
157
158 $label_color_plugins = '';
159 $label_color_themes = '';
160 $label_color_wp = '';
161 $label_color_translations = '';
162 $label_color_total = '';
163
164 if ( isset( $updates_count['plugins'] ) && 0 < $updates_count['plugins'] ) {
165 $label_color_plugins = ' blue ';
166 }
167
168 if ( isset( $updates_count['wp'] ) && 0 < $updates_count['wp'] ) {
169 $label_color_wp = ' blue ';
170 }
171
172 if ( isset( $updates_count['themes'] ) && 0 < $updates_count['themes'] ) {
173 $label_color_themes = ' blue ';
174 }
175
176 if ( isset( $updates_count['translations'] ) && 0 < $updates_count['translations'] ) {
177 $label_color_translations = ' blue ';
178 }
179
180 if ( isset( $updates_count['total'] ) && 0 < $updates_count['total'] ) {
181 $label_color_total = ' blue ';
182 }
183
184 MainWP_Menu::add_left_menu(
185 array(
186 'title' => esc_html__( 'Updates', 'mainwp' ) . ' <span class="ui ' . $label_color_total . ' mini label">' . intval( $updates_count['total'] ) . '</span>',
187 'parent_key' => 'managesites',
188 'slug' => 'UpdatesManage',
189 'href' => 'admin.php?page=UpdatesManage',
190 'icon' => '<i class="sync icon"></i>',
191 'desc' => 'Manage updates on your child sites',
192 'leftsub_order' => 4,
193 ),
194 1
195 );
196
197 $init_sub_subleftmenu = array(
198 array(
199 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' label">' . intval( $updates_count['plugins'] ) . '</span>',
200 'parent_key' => 'UpdatesManage',
201 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates',
202 'slug' => 'UpdatesManage',
203 'right' => '',
204 ),
205 array(
206 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' label">' . intval( $updates_count['themes'] ) . '</span>',
207 'parent_key' => 'UpdatesManage',
208 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates',
209 'slug' => 'UpdatesManage',
210 'right' => '',
211 ),
212 array(
213 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' label">' . intval( $updates_count['wp'] ) . '</span>',
214 'parent_key' => 'UpdatesManage',
215 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates',
216 'slug' => 'UpdatesManage&tab=wordpress-updates',
217 'right' => '',
218 'active_params' => array( 'tab' => 'updates-ignore' ),
219 ),
220 array(
221 'title' => esc_html__( 'Updates Ignore', 'mainwp' ),
222 'parent_key' => 'UpdatesManage',
223 'slug' => 'UpdatesManage&tab=updates-ignore',
224 'href' => '', // fix warning.
225 'menu_hidden' => true,
226 ),
227 );
228
229 $show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
230 if ( $show_language_updates ) {
231 $init_sub_subleftmenu[] = array(
232 'title' => esc_html__( 'Translation', 'mainwp' ) . ' <span class="ui ' . $label_color_translations . ' label">' . intval( $updates_count['translations'] ) . '</span>',
233 'parent_key' => 'UpdatesManage',
234 'href' => 'admin.php?page=UpdatesManage&tab=translations-updates',
235 'slug' => 'UpdatesManage&tab=translations-updates',
236 'right' => '',
237 );
238 }
239
240 $init_sub_subleftmenu = apply_filters( 'mainwp_sub_leftmenu_updates', $init_sub_subleftmenu );
241
242 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'UpdatesManage', 'UpdatesManage' );
243
244 foreach ( $init_sub_subleftmenu as $item ) {
245 if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
246 continue;
247 }
248 MainWP_Menu::add_left_menu( $item, 2 );
249 }
250 }
251
252 /**
253 * Method on_load_page()
254 *
255 * Run on page load.
256 */
257 public static function on_load_page() {
258 add_filter( 'mainwp_header_actions_right', array( static::get_class_name(), 'screen_options' ), 10, 2 );
259 }
260
261 /**
262 * Method screen_options()
263 *
264 * Create Page Settings button.
265 *
266 * @param mixed $input Page Settings button HTML.
267 *
268 * @return mixed Page Settings button.
269 */
270 public static function screen_options( $input ) {
271 return $input .
272 '<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' ) . '">
273 <i class="cog icon"></i>
274 </a>';
275 }
276
277 /**
278 * Sets the MainWP Update page page title and pass it off to method MainWP_UI::render_top_header().
279 *
280 * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
281 */
282 public static function render_header() {
283
284 $params = array(
285 'title' => esc_html__( 'Available Updates', 'mainwp' ),
286 );
287
288 MainWP_UI::render_top_header( $params );
289 }
290
291 /**
292 * Closes the page container.
293 */
294 public static function render_footer() {
295 echo '</div>';
296 }
297
298 /**
299 * Generates individual site overview page link.
300 *
301 * @param object $website The site object.
302 * @param bool $echo_out Either echo or not.
303 *
304 * @return string Dashboard link.
305 */
306 public static function render_site_link_dashboard( $website, $echo_out = true ) {
307 $lnk = '<a href="' . esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ) . '" data-inverted="" data-tooltip="' . esc_html__( 'Visit this dashboard.', 'mainwp' ) . '">' . stripslashes( $website->name ) . '</a>';
308 if ( $echo_out ) {
309 echo $lnk; // phpcs:ignore WordPress.Security.EscapeOutput
310 } else {
311 return $lnk;
312 }
313 }
314
315 /**
316 * Checks if the current user has permission to uignore updates.
317 *
318 * @return bool Whether user can ignore updates or not.
319 */
320 public static function user_can_ignore_updates() {
321 if ( null === static::$user_can_ignore_updates ) {
322 static::$user_can_ignore_updates = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' );
323 }
324 return static::$user_can_ignore_updates;
325 }
326
327 /**
328 * Checks if the current user has permission to update translations.
329 *
330 * @return bool Whether user can update translations or not.
331 */
332 public static function user_can_update_trans() {
333 if ( null === static::$user_can_update_trans ) {
334 static::$user_can_update_trans = \mainwp_current_user_can( 'dashboard', 'update_translations' );
335 }
336 return static::$user_can_update_trans;
337 }
338
339 /**
340 * Checks if the current user has permission to update WordPress core files.
341 *
342 * @return bool Whether user can update WordPress or not.
343 */
344 public static function user_can_update_wp() {
345 if ( null === static::$user_can_update_wp ) {
346 static::$user_can_update_wp = \mainwp_current_user_can( 'dashboard', 'update_wordpress' );
347 }
348 return static::$user_can_update_wp;
349 }
350
351 /**
352 * Checks if the current user has permission to update themes.
353 *
354 * @return bool Whether user can update themes or not.
355 */
356 public static function user_can_update_themes() {
357 if ( null === static::$user_can_update_themes ) {
358 static::$user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' );
359 }
360 return static::$user_can_update_themes;
361 }
362
363 /**
364 * Checks if the current user has permission to update plugins.
365 *
366 * @return bool Whether user can update plugins or not.
367 */
368 public static function user_can_update_plugins() {
369 if ( null === static::$user_can_update_plugins ) {
370 static::$user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' );
371 }
372 return static::$user_can_update_plugins;
373 }
374
375 /**
376 * Renders updates page.
377 *
378 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
379 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_current_user()
380 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_group_id()
381 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
382 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
383 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
384 * @uses \MainWP\Dashboard\MainWP_Utility::array_sort()
385 */
386 public static function render() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity -- NOSONAR - current complexity is the only way to achieve desired results, pull request solutions appreciated.
387
388 static::handle_limit_sites();
389
390 $websites = static::get_sites_for_current_user();
391 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
392 $site_view = (int) $userExtension->site_view;
393
394 $site_offset_for_groups = array();
395 $all_groups = array();
396 $sites_in_groups = array();
397 $all_groups_sites = array();
398
399 if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
400 $groups = MainWP_DB_Common::instance()->get_groups_for_current_user();
401 foreach ( $groups as $group ) {
402 $all_groups[ $group->id ] = $group->name;
403 }
404 foreach ( $all_groups as $group_id => $group_name ) {
405 $all_groups_sites[ $group_id ] = array();
406 $group_sites = MainWP_DB::instance()->get_websites_by_group_id( $group_id );
407 foreach ( $group_sites as $site ) {
408 if ( ! isset( $sites_in_groups[ $site->id ] ) ) {
409 $sites_in_groups[ $site->id ] = 1;
410 }
411 $all_groups_sites[ $group_id ][] = $site->id;
412 }
413 unset( $group_sites );
414 }
415
416 $sites_not_in_groups = array();
417 $pos = 0;
418 MainWP_DB::data_seek( $websites, 0 );
419 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
420 $site_offset_for_groups[ $website->id ] = $pos;
421 ++$pos;
422 if ( ! isset( $sites_in_groups[ $website->id ] ) ) {
423 $sites_not_in_groups[] = $website->id;
424 }
425 }
426
427 if ( ! empty( $sites_not_in_groups ) ) {
428 $all_groups_sites[0] = $sites_not_in_groups;
429 $all_groups[0] = esc_html__( 'Others', 'mainwp' );
430 }
431 }
432
433 $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true );
434 $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true );
435 $decodedDismissedCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
436
437 $total_wp_upgrades = 0;
438 $total_plugin_upgrades = 0;
439 $total_translation_upgrades = 0;
440 $total_theme_upgrades = 0;
441 $total_sync_errors = 0;
442 $total_plugins_outdate = 0;
443 $total_themes_outdate = 0;
444
445 $allTranslations = array();
446 $translationsInfo = array();
447 $allPlugins = array();
448 $pluginsInfo = array();
449 $allThemes = array();
450 $themesInfo = array();
451
452 $allPluginsOutdate = array();
453 $allThemesOutdate = array();
454
455 MainWP_DB::data_seek( $websites, 0 );
456
457 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
458
459 $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array();
460 $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
461
462 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' ) ) {
463 $wp_upgrades = array();
464 }
465
466 if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
467 ++$total_wp_upgrades;
468 }
469
470 $translation_upgrades = json_decode( $website->translation_upgrades, true );
471
472 $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
473 if ( $website->is_ignorePluginUpdates ) {
474 $plugin_upgrades = array();
475 }
476
477 $theme_upgrades = json_decode( $website->theme_upgrades, true );
478 if ( $website->is_ignoreThemeUpdates ) {
479 $theme_upgrades = array();
480 }
481
482 $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
483 $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
484
485 if ( is_array( $decodedPremiumUpgrades ) ) {
486 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
487 $premiumUpgrade['premium'] = true;
488
489 if ( 'plugin' === $premiumUpgrade['type'] ) {
490 if ( ! is_array( $plugin_upgrades ) ) {
491 $plugin_upgrades = array();
492 }
493 if ( ! $website->is_ignorePluginUpdates ) {
494 $premiumUpgrade = array_filter( $premiumUpgrade );
495 if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
496 $plugin_upgrades[ $crrSlug ] = array();
497 }
498 $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
499 }
500 } elseif ( 'theme' === $premiumUpgrade['type'] ) {
501 if ( ! is_array( $theme_upgrades ) ) {
502 $theme_upgrades = array();
503 }
504 if ( ! $website->is_ignoreThemeUpdates ) {
505 $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
506 }
507 }
508 }
509 }
510
511 if ( is_array( $translation_upgrades ) ) {
512 $total_translation_upgrades += count( $translation_upgrades );
513 }
514
515 if ( is_array( $plugin_upgrades ) && ! $website->is_ignorePluginUpdates ) {
516 $_ignored_plugins = json_decode( $website->ignored_plugins, true );
517 if ( is_array( $_ignored_plugins ) ) {
518 $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins );
519 }
520
521 $_ignored_plugins = json_decode( $userExtension->ignored_plugins, true );
522 if ( is_array( $_ignored_plugins ) ) {
523 $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins );
524 }
525 $total_plugin_upgrades += count( $plugin_upgrades );
526 }
527
528 if ( is_array( $theme_upgrades ) ) {
529 $_ignored_themes = json_decode( $website->ignored_themes, true );
530 if ( is_array( $_ignored_themes ) ) {
531 $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes );
532 }
533
534 $_ignored_themes = json_decode( $userExtension->ignored_themes, true );
535 if ( is_array( $_ignored_themes ) ) {
536 $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes );
537 }
538
539 $total_theme_upgrades += count( $theme_upgrades );
540 }
541
542 $themesIgnoredAbandoned_perSites = array();
543 $ignoredAbandoned_themes = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
544 $ignoredAbandoned_themes = ! empty( $ignoredAbandoned_themes ) ? json_decode( $ignoredAbandoned_themes, true ) : array();
545
546 if ( is_array( $ignoredAbandoned_themes ) ) {
547 $ignoredAbandoned_themes = array_filter( $ignoredAbandoned_themes );
548 $themesIgnoredAbandoned_perSites = array_merge( $themesIgnoredAbandoned_perSites, $ignoredAbandoned_themes );
549 }
550
551 $ignoredAbandoned_plugins = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
552 $ignoredAbandoned_plugins = ! empty( $ignoredAbandoned_plugins ) ? json_decode( $ignoredAbandoned_plugins, true ) : array();
553
554 $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
555 $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
556
557 $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
558 $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
559
560 if ( is_array( $plugins_outdate ) ) {
561 if ( is_array( $ignoredAbandoned_plugins ) ) {
562 $plugins_outdate = array_diff_key( $plugins_outdate, $ignoredAbandoned_plugins );
563 }
564
565 if ( is_array( $decodedDismissedPlugins ) ) {
566 $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
567 }
568
569 $total_plugins_outdate += count( $plugins_outdate );
570 }
571
572 if ( is_array( $themes_outdate ) ) {
573 if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
574 $themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites );
575 }
576
577 if ( is_array( $decodedDismissedThemes ) ) {
578 $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
579 }
580
581 $total_themes_outdate += count( $themes_outdate );
582 }
583
584 if ( MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ) {
585 if ( is_array( $translation_upgrades ) ) {
586 foreach ( $translation_upgrades as $translation_upgrade ) {
587 $slug = esc_html( $translation_upgrade['slug'] );
588 if ( ! isset( $allTranslations[ $slug ] ) ) {
589 $allTranslations[ $slug ] = array(
590 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
591 'cnt' => 1,
592 );
593 } else {
594 ++$allTranslations[ $slug ]['cnt'];
595 }
596
597 $translationsInfo[ $slug ] = array(
598 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
599 'slug' => $slug,
600 'version' => esc_html( $translation_upgrade['version'] ),
601 );
602 }
603 }
604
605 if ( is_array( $plugin_upgrades ) ) {
606 foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) {
607 if ( ! isset( $allPlugins[ $slug ] ) ) {
608 $allPlugins[ $slug ] = array(
609 'name' => esc_html( $plugin_upgrade['Name'] ),
610 'cnt' => 1,
611 );
612 } else {
613 ++$allPlugins[ $slug ]['cnt'];
614 }
615
616 $pluginsInfo[ $slug ] = array(
617 'name' => esc_html( $plugin_upgrade['Name'] ),
618 'slug' => isset( $plugin_upgrade['update']['slug'] ) ? esc_html( $plugin_upgrade['update']['slug'] ) : '',
619 'premium' => ( isset( $plugin_upgrade['premium'] ) ? esc_html( $plugin_upgrade['premium'] ) : 0 ),
620 'PluginURI' => esc_html( $plugin_upgrade['PluginURI'] ),
621 'version' => esc_html( $plugin_upgrade['Version'] ),
622 );
623 }
624 }
625
626 if ( is_array( $theme_upgrades ) ) {
627 foreach ( $theme_upgrades as $slug => $theme_upgrade ) {
628 if ( ! isset( $allThemes[ $slug ] ) ) {
629 $allThemes[ $slug ] = array(
630 'name' => esc_html( $theme_upgrade['Name'] ),
631 'cnt' => 1,
632 );
633 } else {
634 ++$allThemes[ $slug ]['cnt'];
635 }
636
637 $up_th_name = isset( $theme_upgrade['Name'] ) ? esc_html( $theme_upgrade['Name'] ) : '';
638
639 if ( empty( $up_th_name ) ) {
640 $up_th_name = isset( $theme_upgrade['name'] ) ? esc_html( $theme_upgrade['name'] ) : 'N/A';
641 }
642
643 $themesInfo[ $slug ] = array(
644 'name' => $up_th_name,
645 'premium' => ( isset( $theme_upgrade['premium'] ) ? esc_html( $theme_upgrade['premium'] ) : 0 ),
646 );
647 }
648 }
649
650 if ( is_array( $plugins_outdate ) ) {
651 foreach ( $plugins_outdate as $slug => $plugin_outdate ) {
652 $slug = esc_html( $slug );
653 if ( ! isset( $allPluginsOutdate[ $slug ] ) ) {
654 $allPluginsOutdate[ $slug ] = array(
655 'name' => esc_html( $plugin_outdate['Name'] ),
656 'cnt' => 1,
657 'uri' => esc_html( $plugin_outdate['PluginURI'] ),
658 );
659 } else {
660 ++$allPluginsOutdate[ $slug ]['cnt'];
661 }
662 }
663 }
664
665 if ( is_array( $themes_outdate ) ) {
666 foreach ( $themes_outdate as $slug => $theme_outdate ) {
667 $slug = esc_html( $slug );
668 if ( ! isset( $allThemesOutdate[ $slug ] ) ) {
669 $allThemesOutdate[ $slug ] = array(
670 'name' => esc_html( $theme_outdate['Name'] ),
671 'cnt' => 1,
672 );
673 } else {
674 ++$allThemesOutdate[ $slug ]['cnt'];
675 }
676 }
677 }
678 }
679
680 if ( '' !== $website->sync_errors ) {
681 ++$total_sync_errors;
682 }
683 }
684
685 /**
686 * Filter: mainwp_updates_translation_sort_by
687 *
688 * Filters the default sorting option for Translation updates.
689 *
690 * @since 4.1
691 */
692 $allTranslationsSortBy = apply_filters( 'mainwp_updates_translation_sort_by', 'name' );
693
694 /**
695 * Filter: mainwp_updates_plugins_sort_by
696 *
697 * Filters the default sorting option for Plugin updates.
698 *
699 * @since 4.1
700 */
701 $allPluginsSortBy = apply_filters( 'mainwp_updates_plugins_sort_by', 'name' );
702
703 /**
704 * Filter: mainwp_updates_themes_sort_by
705 *
706 * Filters the default sorting option for Theme updates.
707 *
708 * @since 4.1
709 */
710 $allThemesSortBy = apply_filters( 'mainwp_updates_themes_sort_by', 'name' );
711
712 /**
713 * Filter: mainwp_updates_abandoned_plugins_sort_by
714 *
715 * Filters the default sorting option for Abandoned plugins.
716 *
717 * @since 4.1
718 */
719 $allPluginsOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_plugins_sort_by', 'name' );
720
721 /**
722 * Filter: mainwp_updates_abandoned_themes_sort_by
723 *
724 * Filters the default sorting option for Abandoned themes.
725 *
726 * @since 4.1
727 */
728 $allThemesOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_themes_sort_by', 'name' );
729
730 MainWP_Utility::array_sort( $allTranslations, $allTranslationsSortBy );
731 MainWP_Utility::array_sort( $allPlugins, $allPluginsSortBy );
732 MainWP_Utility::array_sort( $allThemes, $allThemesSortBy );
733 MainWP_Utility::array_sort( $allPluginsOutdate, $allPluginsOutdateSortBy );
734 MainWP_Utility::array_sort( $allThemesOutdate, $allThemesOutdateSortBy );
735
736 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
737
738 /**
739 * Limits number of updates to process.
740 *
741 * Limits the number of updates that will be processed in a single run on Update Everything action.
742 *
743 * @since 4.0
744 */
745 $limit_updates_all = apply_filters( 'mainwp_limit_updates_all', 0 );
746 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
747 if ( 0 < $limit_updates_all && isset( $_GET['continue_update'] ) && '' !== $_GET['continue_update'] ) {
748 static::$continue_update = sanitize_text_field( wp_unslash( $_GET['continue_update'] ) );
749 if ( ( 'plugins_upgrade_all' === static::$continue_update || 'themes_upgrade_all' === static::$continue_update || 'translations_upgrade_all' === static::$continue_update ) && isset( $_GET['slug'] ) && '' !== $_GET['slug'] ) {
750 static::$continue_update_slug = wp_unslash( $_GET['slug'] );
751 }
752 }
753
754 $current_tab = '';
755
756 if ( isset( $_GET['tab'] ) ) {
757 $current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) );
758 if ( ! in_array( $current_tab, array( 'wordpress-updates', 'updates-ignore', 'plugins-updates', 'themes-updates', 'translations-updates', 'abandoned-plugins', 'abandoned-themes', true ) ) ) {
759 $current_tab = 'plugins-updates';
760 }
761 } else {
762 $current_tab = 'plugins-updates';
763 }
764 // phpcs:enable
765 static::render_header( 'UpdatesManage' );
766
767 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 );
768
769 ?>
770 <div class="ui segment" id="mainwp-manage-updates">
771 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?>
772 <div class="ui info message">
773 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
774 <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>
775 <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>
776 </div>
777 <?php } ?>
778 <?php
779
780 $hooks_tabs = apply_filters( 'mainwp_pages_updates_render_tabs', false, $current_tab );
781
782 if ( false === $hooks_tabs ) {
783 if ( 'wordpress-updates' === $current_tab ) {
784 static::render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view );
785 } elseif ( 'updates-ignore' === $current_tab ) {
786 static::render_wp_ignore_update_tab( $websites, $userExtension );
787 } elseif ( 'plugins-updates' === $current_tab ) {
788 static::render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view );
789 } elseif ( 'themes-updates' === $current_tab ) {
790 static::render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view );
791 } elseif ( 'translations-updates' === $current_tab ) {
792 static::render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view );
793 } elseif ( 'abandoned-plugins' === $current_tab ) {
794 static::render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view );
795 } elseif ( 'abandoned-themes' === $current_tab ) {
796 static::render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view );
797 }
798 ?>
799 </div>
800 <?php
801 static::render_js_updates( $site_view );
802 }
803
804 static::render_updates_modal();
805
806 static::render_plugin_details_modal();
807 MainWP_UI::render_modal_upload_icon();
808 static::render_screen_options_modal();
809 static::render_footer();
810 ?>
811 <script type="text/javascript">
812 mainwp_manage_updates_screen_options = function () {
813 jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'show' );
814 jQuery( '#manage-updates-screen-options-form' ).submit( function() {
815 jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'hide' );
816 } );
817 return false;
818 };
819 </script>
820 <?php
821 }
822
823 /**
824 * Render WP updates tab.
825 *
826 * @param object $websites Object containing child sites info.
827 * @param object $userExtension User Extension object.
828 * @param int $total_wp_upgrades Number of available WP upates.
829 * @param array $all_groups_sites Array containing all groups and sites.
830 * @param array $all_groups Array containing all groups.
831 * @param int $site_offset_for_groups Offset value.
832 * @param string $site_view Current view.
833 *
834 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
835 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_wpcore_updates()
836 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_wpcore_updates()
837 */
838 public static function render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) {
839 ?>
840 <div class="ui active tab" data-tab="wordpress-updates">
841 <?php
842 /**
843 * Action: mainwp_updates_before_wp_updates
844 *
845 * Fires at the top of the WP updates tab.
846 *
847 * @param object $websites Object containing child sites info.
848 * @param int $total_wp_upgrades Number of available WP upates.
849 * @param array $all_groups_sites Array containing all groups and sites.
850 * @param array $all_groups Array containing all groups.
851 * @param int $site_offset_for_groups Offset value.
852 *
853 * @since 4.1
854 */
855 do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
856 if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
857 /**
858 * Action: mainwp_updates_pergroup_before_wp_updates
859 *
860 * Fires at the top of the WP updates tab, per Group view.
861 *
862 * @param object $websites Object containing child sites info.
863 * @param int $total_wp_upgrades Number of available WP upates.
864 * @param array $all_groups_sites Array containing all groups and sites.
865 * @param array $all_groups Array containing all groups.
866 * @param int $site_offset_for_groups Offset value.
867 *
868 * @since 4.1
869 */
870 do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
871 MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
872 /**
873 * Action: mainwp_updates_pergroup_after_wp_updates
874 *
875 * Fires at the bottom of the WP updates tab, per Group view.
876 *
877 * @param object $websites Object containing child sites info.
878 * @param int $total_wp_upgrades Number of available WP upates.
879 * @param array $all_groups_sites Array containing all groups and sites.
880 * @param array $all_groups Array containing all groups.
881 * @param int $site_offset_for_groups Offset value.
882 *
883 * @since 4.1
884 */
885 do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
886 } else {
887 /**
888 * Action: mainwp_updates_persite_before_wp_updates
889 *
890 * Fires at the top of the WP updates tab, per Site view.
891 *
892 * @param object $websites Object containing child sites info.
893 * @param int $total_wp_upgrades Number of available WP upates.
894 * @param array $all_groups_sites Array containing all groups and sites.
895 * @param array $all_groups Array containing all groups.
896 * @param int $site_offset_for_groups Offset value.
897 *
898 * @since 4.1
899 */
900 do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
901 MainWP_DB::data_seek( $websites, 0 );
902 MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades );
903 /**
904 * Action: mainwp_updates_persite_after_wp_updates
905 *
906 * Fires at the bottom of the WP updates tab, per Site view.
907 *
908 * @param object $websites Object containing child sites info.
909 * @param int $total_wp_upgrades Number of available WP upates.
910 * @param array $all_groups_sites Array containing all groups and sites.
911 * @param array $all_groups Array containing all groups.
912 * @param int $site_offset_for_groups Offset value.
913 *
914 * @since 4.1
915 */
916 do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
917 }
918 /**
919 * Action: mainwp_updates_after_wp_updates
920 *
921 * Fires at the top of the WP updates tab.
922 *
923 * @param object $websites Object containing child sites info.
924 * @param int $total_wp_upgrades Number of available WP upates.
925 * @param array $all_groups_sites Array containing all groups and sites.
926 * @param array $all_groups Array containing all groups.
927 * @param int $site_offset_for_groups Offset value.
928 *
929 * @since 4.1
930 */
931 do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
932 ?>
933 </div>
934 <?php
935 }
936
937
938 /**
939 * Renders WP updates tab.
940 *
941 * @param array $websites Object containing child sites info.
942 * @param object $userExtension User extension.
943 */
944 public static function render_wp_ignore_update_tab( $websites, $userExtension ) {
945 MainWP_WP_Updates::instance()->render_ignore( $websites, $userExtension );
946 }
947
948 /**
949 * Renders WP updates tab.
950 *
951 * @param object $websites Object containing child sites info.
952 * @param int $total_plugin_upgrades Number of available plugin updates.
953 * @param object $userExtension User extension.
954 * @param array $all_groups_sites Array of all groups and sites.
955 * @param array $all_groups Array of all groups.
956 * @param array $allPlugins Array of all plugins.
957 * @param array $pluginsInfo Array of all plugins info.
958 * @param int $site_offset_for_groups Offset value.
959 * @param string $site_view Current view.
960 *
961 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_plugins_updates()
962 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_plugins_updates()
963 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_plugins_updates()
964 */
965 public static function render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
966 $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
967 if ( ! is_array( $trustedPlugins ) ) {
968 $trustedPlugins = array();
969 }
970 ?>
971 <div class="ui active tab" data-tab="plugins-updates">
972 <?php
973 /**
974 * Action: mainwp_updates_before_plugin_updates
975 *
976 * Fires at the top of the Plugin updates tab.
977 *
978 * @param object $websites Object containing child sites info.
979 * @param int $total_plugin_upgrades Number of available plugin updates.
980 * @param object $userExtension User extension.
981 * @param array $all_groups_sites Array of all groups and sites.
982 * @param array $all_groups Array of all groups.
983 * @param array $allPlugins Array of all plugins.
984 * @param array $pluginsInfo Array of all plugins info.
985 * @param int $site_offset_for_groups Offset value.
986 *
987 * @since 4.1
988 */
989 do_action( 'mainwp_updates_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
990 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
991 /**
992 * Action: mainwp_updates_persite_before_plugin_updates
993 *
994 * Fires at the top of the Plugin updates tab, per Site view.
995 *
996 * @param object $websites Object containing child sites info.
997 * @param int $total_plugin_upgrades Number of available plugin updates.
998 * @param object $userExtension User extension.
999 * @param array $all_groups_sites Array of all groups and sites.
1000 * @param array $all_groups Array of all groups.
1001 * @param array $allPlugins Array of all plugins.
1002 * @param array $pluginsInfo Array of all plugins info.
1003 * @param int $site_offset_for_groups Offset value.
1004 *
1005 * @since 4.1
1006 */
1007 do_action( 'mainwp_updates_persite_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1008 MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins );
1009 /**
1010 * Action: mainwp_updates_persite_after_plugin_updates
1011 *
1012 * Fires at the bottom of the Plugin updates tab, per Site view.
1013 *
1014 * @param object $websites Object containing child sites info.
1015 * @param int $total_plugin_upgrades Number of available plugin updates.
1016 * @param object $userExtension User extension.
1017 * @param array $all_groups_sites Array of all groups and sites.
1018 * @param array $all_groups Array of all groups.
1019 * @param array $allPlugins Array of all plugins.
1020 * @param array $pluginsInfo Array of all plugins info.
1021 * @param int $site_offset_for_groups Offset value.
1022 *
1023 * @since 4.1
1024 */
1025 do_action( 'mainwp_updates_persite_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1026 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1027 /**
1028 * Action: mainwp_updates_pergroup_before_plugin_updates
1029 *
1030 * Fires at the top of the Plugin updates tab, per Group view.
1031 *
1032 * @param object $websites Object containing child sites info.
1033 * @param int $total_plugin_upgrades Number of available plugin updates.
1034 * @param object $userExtension User extension.
1035 * @param array $all_groups_sites Array of all groups and sites.
1036 * @param array $all_groups Array of all groups.
1037 * @param array $allPlugins Array of all plugins.
1038 * @param array $pluginsInfo Array of all plugins info.
1039 * @param int $site_offset_for_groups Offset value.
1040 *
1041 * @since 4.1
1042 */
1043 do_action( 'mainwp_updates_pergroup_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1044 MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins );
1045 /**
1046 * Action: mainwp_updates_pergroup_after_plugin_updates
1047 *
1048 * Fires at the bottom of the Plugin updates tab, per Group view.
1049 *
1050 * @param object $websites Object containing child sites info.
1051 * @param int $total_plugin_upgrades Number of available plugin updates.
1052 * @param object $userExtension User extension.
1053 * @param array $all_groups_sites Array of all groups and sites.
1054 * @param array $all_groups Array of all groups.
1055 * @param array $allPlugins Array of all plugins.
1056 * @param array $pluginsInfo Array of all plugins info.
1057 * @param int $site_offset_for_groups Offset value.
1058 *
1059 * @since 4.1
1060 */
1061 do_action( 'mainwp_updates_pergroup_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1062 } else {
1063 /**
1064 * Action: mainwp_updates_perplugin_before_plugin_updates
1065 *
1066 * Fires at the top of the Plugin updates tab, per Plugin view.
1067 *
1068 * @param object $websites Object containing child sites info.
1069 * @param int $total_plugin_upgrades Number of available plugin updates.
1070 * @param object $userExtension User extension.
1071 * @param array $all_groups_sites Array of all groups and sites.
1072 * @param array $all_groups Array of all groups.
1073 * @param array $allPlugins Array of all plugins.
1074 * @param array $pluginsInfo Array of all plugins info.
1075 * @param int $site_offset_for_groups Offset value.
1076 *
1077 * @since 4.1
1078 */
1079 do_action( 'mainwp_updates_perplugin_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1080 MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins );
1081 /**
1082 * Action: mainwp_updates_perplugin_after_plugin_updates
1083 *
1084 * Fires at the bottom of the Plugin updates tab, per Plugin view.
1085 *
1086 * @param object $websites Object containing child sites info.
1087 * @param int $total_plugin_upgrades Number of available plugin updates.
1088 * @param object $userExtension User extension.
1089 * @param array $all_groups_sites Array of all groups and sites.
1090 * @param array $all_groups Array of all groups.
1091 * @param array $allPlugins Array of all plugins.
1092 * @param array $pluginsInfo Array of all plugins info.
1093 * @param int $site_offset_for_groups Offset value.
1094 *
1095 * @since 4.1
1096 */
1097 do_action( 'mainwp_updates_perplugin_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1098 }
1099 /**
1100 * Action: mainwp_updates_after_plugin_updates
1101 *
1102 * Fires at the bottom of the Plugin updates tab.
1103 *
1104 * @param object $websites Object containing child sites info.
1105 * @param int $total_plugin_upgrades Number of available plugin updates.
1106 * @param object $userExtension User extension.
1107 * @param array $all_groups_sites Array of all groups and sites.
1108 * @param array $all_groups Array of all groups.
1109 * @param array $allPlugins Array of all plugins.
1110 * @param array $pluginsInfo Array of all plugins info.
1111 * @param int $site_offset_for_groups Offset value.
1112 *
1113 * @since 4.1
1114 */
1115 do_action( 'mainwp_updates_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1116 ?>
1117 </div>
1118 <?php
1119 }
1120
1121 /**
1122 * Renders theme update tab.
1123 *
1124 * @param object $websites Object containing child sites info.
1125 * @param int $total_theme_upgrades Number of available theme updates.
1126 * @param object $userExtension User extension.
1127 * @param array $all_groups_sites Array of all groups and sites.
1128 * @param array $all_groups Array of all groups.
1129 * @param array $allThemes Array of all themes.
1130 * @param array $themesInfo Array of all themes info.
1131 * @param int $site_offset_for_groups Offset value.
1132 * @param string $site_view Current view.
1133 *
1134 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_themes_updates()
1135 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_themes_updates()
1136 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_themes_updates()
1137 */
1138 public static function render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
1139 $trustedThemes = json_decode( $userExtension->trusted_themes, true );
1140 if ( ! is_array( $trustedThemes ) ) {
1141 $trustedThemes = array();
1142 }
1143 ?>
1144 <div class="ui active tab" data-tab="themes-updates">
1145 <?php
1146 /**
1147 * Action: mainwp_updates_before_theme_updates
1148 *
1149 * Fires at the top of the Theme updates tab.
1150 *
1151 * @param object $websites Object containing child sites info.
1152 * @param int $total_theme_upgrades Number of available theme updates.
1153 * @param object $userExtension User extension.
1154 * @param array $all_groups_sites Array of all groups and sites.
1155 * @param array $all_groups Array of all groups.
1156 * @param array $allThemes Array of all themes.
1157 * @param array $themesInfo Array of all themes info.
1158 * @param int $site_offset_for_groups Offset value.
1159 *
1160 * @since 4.1
1161 */
1162 do_action( 'mainwp_updates_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1163 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1164 /**
1165 * Action: mainwp_updates_persite_before_theme_updates
1166 *
1167 * Fires at the top of the Theme updates tab, per Site view.
1168 *
1169 * @param object $websites Object containing child sites info.
1170 * @param int $total_theme_upgrades Number of available theme updates.
1171 * @param object $userExtension User extension.
1172 * @param array $all_groups_sites Array of all groups and sites.
1173 * @param array $all_groups Array of all groups.
1174 * @param array $allThemes Array of all themes.
1175 * @param array $themesInfo Array of all themes info.
1176 * @param int $site_offset_for_groups Offset value.
1177 *
1178 * @since 4.1
1179 */
1180 do_action( 'mainwp_updates_persite_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1181 MainWP_Updates_Per_Site::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $trustedThemes );
1182 /**
1183 * Action: mainwp_updates_persite_after_theme_updates
1184 *
1185 * Fires at the bottom of the Theme updates tab, per Site view.
1186 *
1187 * @param object $websites Object containing child sites info.
1188 * @param int $total_theme_upgrades Number of available theme updates.
1189 * @param object $userExtension User extension.
1190 * @param array $all_groups_sites Array of all groups and sites.
1191 * @param array $all_groups Array of all groups.
1192 * @param array $allThemes Array of all themes.
1193 * @param array $themesInfo Array of all themes info.
1194 * @param int $site_offset_for_groups Offset value.
1195 *
1196 * @since 4.1
1197 */
1198 do_action( 'mainwp_updates_persite_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1199 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1200 /**
1201 * Action: mainwp_updates_pergroup_before_theme_updates
1202 *
1203 * Fires at the top of the Theme updates tab, per Group view.
1204 *
1205 * @param object $websites Object containing child sites info.
1206 * @param int $total_theme_upgrades Number of available theme updates.
1207 * @param object $userExtension User extension.
1208 * @param array $all_groups_sites Array of all groups and sites.
1209 * @param array $all_groups Array of all groups.
1210 * @param array $allThemes Array of all themes.
1211 * @param array $themesInfo Array of all themes info.
1212 * @param int $site_offset_for_groups Offset value.
1213 *
1214 * @since 4.1
1215 */
1216 do_action( 'mainwp_updates_pergroup_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1217 MainWP_Updates_Per_Group::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedThemes );
1218 /**
1219 * Action: mainwp_updates_pergroup_after_theme_updates
1220 *
1221 * Fires at the bottom of the Theme updates tab, per Group view.
1222 *
1223 * @param object $websites Object containing child sites info.
1224 * @param int $total_theme_upgrades Number of available theme updates.
1225 * @param object $userExtension User extension.
1226 * @param array $all_groups_sites Array of all groups and sites.
1227 * @param array $all_groups Array of all groups.
1228 * @param array $allThemes Array of all themes.
1229 * @param array $themesInfo Array of all themes info.
1230 * @param int $site_offset_for_groups Offset value.
1231 *
1232 * @since 4.1
1233 */
1234 do_action( 'mainwp_updates_pergroup_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1235 } else {
1236 /**
1237 * Action: mainwp_updates_pertheme_before_theme_updates
1238 *
1239 * Fires at the top of the Theme updates tab, per Theme view.
1240 *
1241 * @param object $websites Object containing child sites info.
1242 * @param int $total_theme_upgrades Number of available theme updates.
1243 * @param object $userExtension User extension.
1244 * @param array $all_groups_sites Array of all groups and sites.
1245 * @param array $all_groups Array of all groups.
1246 * @param array $allThemes Array of all themes.
1247 * @param array $themesInfo Array of all themes info.
1248 * @param int $site_offset_for_groups Offset value.
1249 *
1250 * @since 4.1
1251 */
1252 do_action( 'mainwp_updates_pertheme_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1253 MainWP_Updates_Per_Item::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes );
1254 /**
1255 * Action: mainwp_updates_pertheme_after_theme_updates
1256 *
1257 * Fires at the bottom of the Theme updates tab, per Theme view.
1258 *
1259 * @param object $websites Object containing child sites info.
1260 * @param int $total_theme_upgrades Number of available theme updates.
1261 * @param object $userExtension User extension.
1262 * @param array $all_groups_sites Array of all groups and sites.
1263 * @param array $all_groups Array of all groups.
1264 * @param array $allThemes Array of all themes.
1265 * @param array $themesInfo Array of all themes info.
1266 * @param int $site_offset_for_groups Offset value.
1267 *
1268 * @since 4.1
1269 */
1270 do_action( 'mainwp_updates_pertheme_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1271 }
1272 /**
1273 * Action: mainwp_updates_after_theme_updates
1274 *
1275 * Fires at the bottom of the Theme updates tab.
1276 *
1277 * @param object $websites Object containing child sites info.
1278 * @param int $total_theme_upgrades Number of available theme updates.
1279 * @param object $userExtension User extension.
1280 * @param array $all_groups_sites Array of all groups and sites.
1281 * @param array $all_groups Array of all groups.
1282 * @param array $allThemes Array of all themes.
1283 * @param array $themesInfo Array of all themes info.
1284 * @param int $site_offset_for_groups Offset value.
1285 *
1286 * @since 4.1
1287 */
1288 do_action( 'mainwp_updates_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1289 ?>
1290 </div>
1291 <?php
1292 }
1293
1294 /**
1295 * Renders translations update tab.
1296 *
1297 * @param object $websites Object containing child sites info.
1298 * @param int $total_translation_upgrades Number of available translation updates.
1299 * @param object $userExtension User extension.
1300 * @param array $all_groups_sites Array of all groups and sites.
1301 * @param array $all_groups Array of all groups.
1302 * @param array $allTranslations Array of all translations.
1303 * @param array $translationsInfo Array of all translations info.
1304 * @param bool $mainwp_show_language_updates Either or not show language updates.
1305 * @param int $site_offset_for_groups Offset value.
1306 * @param string $site_view Current Site view.
1307 *
1308 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_trans_update()
1309 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_trans_update()
1310 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_trans_update()
1311 */
1312 public static function render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
1313 if ( 1 === (int) $mainwp_show_language_updates ) {
1314 ?>
1315 <div class="ui active tab" data-tab="translations-updates">
1316 <?php
1317 /**
1318 * Action: mainwp_updates_before_translation_updates
1319 *
1320 * Fires at the top of the Translation updates tab.
1321 *
1322 * @param object $websites Object containing child sites info.
1323 * @param int $total_translation_upgrades Number of available translation updates.
1324 * @param object $userExtension User extension.
1325 * @param array $all_groups_sites Array of all groups and sites.
1326 * @param array $all_groups Array of all groups.
1327 * @param array $allTranslations Array of all translations.
1328 * @param array $translationsInfo Array of all translations info.
1329 * @param int $site_offset_for_groups Offset value.
1330 *
1331 * @since 4.1
1332 */
1333 do_action( 'mainwp_updates_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1334 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1335 /**
1336 * Action: mainwp_updates_persite_before_translation_updates
1337 *
1338 * Fires at the top of the Translation updates tab, per Site view.
1339 *
1340 * @param object $websites Object containing child sites info.
1341 * @param int $total_translation_upgrades Number of available translation updates.
1342 * @param object $userExtension User extension.
1343 * @param array $all_groups_sites Array of all groups and sites.
1344 * @param array $all_groups Array of all groups.
1345 * @param array $allTranslations Array of all translations.
1346 * @param array $translationsInfo Array of all translations info.
1347 * @param int $site_offset_for_groups Offset value.
1348 *
1349 * @since 4.1
1350 */
1351 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 );
1352 MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades );
1353 /**
1354 * Action: mainwp_updates_persite_after_translation_updates
1355 *
1356 * Fires at the bottom of the Translation updates tab, per Site view.
1357 *
1358 * @param object $websites Object containing child sites info.
1359 * @param int $total_translation_upgrades Number of available translation updates.
1360 * @param object $userExtension User extension.
1361 * @param array $all_groups_sites Array of all groups and sites.
1362 * @param array $all_groups Array of all groups.
1363 * @param array $allTranslations Array of all translations.
1364 * @param array $translationsInfo Array of all translations info.
1365 * @param int $site_offset_for_groups Offset value.
1366 *
1367 * @since 4.1
1368 */
1369 do_action( 'mainwp_updates_persite_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1370 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1371 /**
1372 * Action: mainwp_updates_pergroup_before_translation_updates
1373 *
1374 * Fires at the top of the Translation updates tab, per Group view.
1375 *
1376 * @param object $websites Object containing child sites info.
1377 * @param int $total_translation_upgrades Number of available translation updates.
1378 * @param object $userExtension User extension.
1379 * @param array $all_groups_sites Array of all groups and sites.
1380 * @param array $all_groups Array of all groups.
1381 * @param array $allTranslations Array of all translations.
1382 * @param array $translationsInfo Array of all translations info.
1383 * @param int $site_offset_for_groups Offset value.
1384 *
1385 * @since 4.1
1386 */
1387 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 );
1388 MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
1389 /**
1390 * Action: mainwp_updates_pergroup_after_translation_updates
1391 *
1392 * Fires at the bottom of the Translation updates tab, per Group view.
1393 *
1394 * @param object $websites Object containing child sites info.
1395 * @param int $total_translation_upgrades Number of available translation updates.
1396 * @param object $userExtension User extension.
1397 * @param array $all_groups_sites Array of all groups and sites.
1398 * @param array $all_groups Array of all groups.
1399 * @param array $allTranslations Array of all translations.
1400 * @param array $translationsInfo Array of all translations info.
1401 * @param int $site_offset_for_groups Offset value.
1402 *
1403 * @since 4.1
1404 */
1405 do_action( 'mainwp_updates_pergroup_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1406 } else {
1407 /**
1408 * Action: mainwp_updates_pertranslation_before_translation_updates
1409 *
1410 * Fires at the top of the Translation updates tab, per Translation view.
1411 *
1412 * @param object $websites Object containing child sites info.
1413 * @param int $total_translation_upgrades Number of available translation updates.
1414 * @param object $userExtension User extension.
1415 * @param array $all_groups_sites Array of all groups and sites.
1416 * @param array $all_groups Array of all groups.
1417 * @param array $allTranslations Array of all translations.
1418 * @param array $translationsInfo Array of all translations info.
1419 * @param int $site_offset_for_groups Offset value.
1420 *
1421 * @since 4.1
1422 */
1423 do_action( 'mainwp_updates_pertranslation_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1424 MainWP_Updates_Per_Item::render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo );
1425 /**
1426 * Action: mainwp_updates_pertranslation_after_translation_updates
1427 *
1428 * Fires at the bottom of the Translation updates tab, per Translation view.
1429 *
1430 * @param object $websites Object containing child sites info.
1431 * @param int $total_translation_upgrades Number of available translation updates.
1432 * @param object $userExtension User extension.
1433 * @param array $all_groups_sites Array of all groups and sites.
1434 * @param array $all_groups Array of all groups.
1435 * @param array $allTranslations Array of all translations.
1436 * @param array $translationsInfo Array of all translations info.
1437 * @param int $site_offset_for_groups Offset value.
1438 *
1439 * @since 4.1
1440 */
1441 do_action( 'mainwp_updates_pertranslation_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1442 }
1443 /**
1444 * Action: mainwp_updates_after_translation_updates
1445 *
1446 * Fires at the bottom of the Translation updates tab.
1447 *
1448 * @param object $websites Object containing child sites info.
1449 * @param int $total_translation_upgrades Number of available translation updates.
1450 * @param object $userExtension User extension.
1451 * @param array $all_groups_sites Array of all groups and sites.
1452 * @param array $all_groups Array of all groups.
1453 * @param array $allTranslations Array of all translations.
1454 * @param array $translationsInfo Array of all translations info.
1455 * @param int $site_offset_for_groups Offset value.
1456 *
1457 * @since 4.1
1458 */
1459 do_action( 'mainwp_updates_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1460 ?>
1461 </div>
1462 <?php
1463 }
1464 }
1465
1466 /**
1467 * Renders abandoned plugins tab.
1468 *
1469 * @param object $websites Object containing child sites info.
1470 * @param array $all_groups_sites Array of all groups and sites.
1471 * @param array $all_groups Array of all groups.
1472 * @param array $allPluginsOutdate Array of all abandoned plugins.
1473 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1474 * @param int $site_offset_for_groups Offset value.
1475 * @param string $site_view Current site view.
1476 *
1477 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_plugins()
1478 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_plugins()
1479 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_plugins()
1480 */
1481 public static function render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view ) {
1482 ?>
1483 <div class="ui active tab" data-tab="abandoned-plugins">
1484 <?php
1485 /**
1486 * Action: mainwp_updates_before_abandoned_plugins
1487 *
1488 * Fires at the top of the Abandoned plugins tab.
1489 *
1490 * @param object $websites Object containing child sites info.
1491 * @param array $all_groups_sites Array of all groups and sites.
1492 * @param array $all_groups Array of all groups.
1493 * @param array $allPluginsOutdate Array of all abandoned plugins.
1494 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1495 * @param int $site_offset_for_groups Offset value.
1496 *
1497 * @since 4.1
1498 */
1499 do_action( 'mainwp_updates_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1500 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1501 /**
1502 * Action: mainwp_updates_persite_before_abandoned_plugins
1503 *
1504 * Fires at the top of the Abandoned plugins tab, per Site view.
1505 *
1506 * @param object $websites Object containing child sites info.
1507 * @param array $all_groups_sites Array of all groups and sites.
1508 * @param array $all_groups Array of all groups.
1509 * @param array $allPluginsOutdate Array of all abandoned plugins.
1510 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1511 * @param int $site_offset_for_groups Offset value.
1512 *
1513 * @since 4.1
1514 */
1515 do_action( 'mainwp_updates_persite_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1516 MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $decodedDismissedPlugins );
1517 /**
1518 * Action: mainwp_updates_persite_after_abandoned_plugins
1519 *
1520 * Fires at the bottom of the Abandoned plugins tab, per Site view.
1521 *
1522 * @param object $websites Object containing child sites info.
1523 * @param array $all_groups_sites Array of all groups and sites.
1524 * @param array $all_groups Array of all groups.
1525 * @param array $allPluginsOutdate Array of all abandoned plugins.
1526 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1527 * @param int $site_offset_for_groups Offset value.
1528 *
1529 * @since 4.1
1530 */
1531 do_action( 'mainwp_updates_persite_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1532 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1533 /**
1534 * Action: mainwp_updates_pergroup_before_abandoned_plugins
1535 *
1536 * Fires at the top of the Abandoned plugins tab, per Group view.
1537 *
1538 * @param object $websites Object containing child sites info.
1539 * @param array $all_groups_sites Array of all groups and sites.
1540 * @param array $all_groups Array of all groups.
1541 * @param array $allPluginsOutdate Array of all abandoned plugins.
1542 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1543 * @param int $site_offset_for_groups Offset value.
1544 *
1545 * @since 4.1
1546 */
1547 do_action( 'mainwp_updates_pergroup_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1548 MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins );
1549 /**
1550 * Action: mainwp_updates_pergroup_after_abandoned_plugins
1551 *
1552 * Fires at the bottom of the Abandoned plugins tab, per Group view.
1553 *
1554 * @param object $websites Object containing child sites info.
1555 * @param array $all_groups_sites Array of all groups and sites.
1556 * @param array $all_groups Array of all groups.
1557 * @param array $allPluginsOutdate Array of all abandoned plugins.
1558 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1559 * @param int $site_offset_for_groups Offset value.
1560 *
1561 * @since 4.1
1562 */
1563 do_action( 'mainwp_updates_pergroup_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1564 } else {
1565 /**
1566 * Action: mainwp_updates_perplugin_before_abandoned_plugins
1567 *
1568 * Fires at the top of the Abandoned plugins tab, per Plugin view.
1569 *
1570 * @param object $websites Object containing child sites info.
1571 * @param array $all_groups_sites Array of all groups and sites.
1572 * @param array $all_groups Array of all groups.
1573 * @param array $allPluginsOutdate Array of all abandoned plugins.
1574 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1575 * @param int $site_offset_for_groups Offset value.
1576 *
1577 * @since 4.1
1578 */
1579 do_action( 'mainwp_updates_perplugin_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1580 MainWP_Updates_Per_Item::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins );
1581 /**
1582 * Action: mainwp_updates_perplugin_after_abandoned_plugins
1583 *
1584 * Fires at the bottom of the Abandoned plugins tab, per Plugin view.
1585 *
1586 * @param object $websites Object containing child sites info.
1587 * @param array $all_groups_sites Array of all groups and sites.
1588 * @param array $all_groups Array of all groups.
1589 * @param array $allPluginsOutdate Array of all abandoned plugins.
1590 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1591 * @param int $site_offset_for_groups Offset value.
1592 *
1593 * @since 4.1
1594 */
1595 do_action( 'mainwp_updates_perplugin_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1596 }
1597 /**
1598 * Action: mainwp_updates_after_abandoned_plugins
1599 *
1600 * Fires at the bottom of the Abandoned plugins tab.
1601 *
1602 * @param object $websites Object containing child sites info.
1603 * @param array $all_groups_sites Array of all groups and sites.
1604 * @param array $all_groups Array of all groups.
1605 * @param array $allPluginsOutdate Array of all abandoned plugins.
1606 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1607 * @param int $site_offset_for_groups Offset value.
1608 *
1609 * @since 4.1
1610 */
1611 do_action( 'mainwp_updates_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1612 ?>
1613 </div>
1614 <?php
1615 }
1616
1617 /**
1618 * Renders abandoned themes tab.
1619 *
1620 * @param object $websites Object containing child sites info.
1621 * @param array $all_groups_sites Array of all groups and sites.
1622 * @param array $all_groups Array of all groups.
1623 * @param array $allThemesOutdate Array of all abandoned plugins.
1624 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1625 * @param int $site_offset_for_groups Offset value.
1626 * @param string $site_view Current site view.
1627 *
1628 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_themes()
1629 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_themes()
1630 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_themes()
1631 */
1632 public static function render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view ) {
1633 ?>
1634 <div class="ui active tab" data-tab="abandoned-themes">
1635 <?php
1636 /**
1637 * Action: mainwp_updates_before_abandoned_themes
1638 *
1639 * Fires at the top of the Abandoned themes tab.
1640 *
1641 * @param object $websites Object containing child sites info.
1642 * @param array $all_groups_sites Array of all groups and sites.
1643 * @param array $all_groups Array of all groups.
1644 * @param array $allThemesOutdate Array of all abandoned plugins.
1645 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1646 * @param int $site_offset_for_groups Offset value.
1647 *
1648 * @since 4.1
1649 */
1650 do_action( 'mainwp_updates_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1651 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1652 /**
1653 * Action: mainwp_updates_persite_before_abandoned_themes
1654 *
1655 * Fires at the top of the Abandoned themes tab, per Site view.
1656 *
1657 * @param object $websites Object containing child sites info.
1658 * @param array $all_groups_sites Array of all groups and sites.
1659 * @param array $all_groups Array of all groups.
1660 * @param array $allThemesOutdate Array of all abandoned plugins.
1661 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1662 * @param int $site_offset_for_groups Offset value.
1663 *
1664 * @since 4.1
1665 */
1666 do_action( 'mainwp_updates_persite_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1667 MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $decodedDismissedThemes );
1668 /**
1669 * Action: mainwp_updates_persite_after_abandoned_themes
1670 *
1671 * Fires at the bottom of the Abandoned themes tab, per Site view.
1672 *
1673 * @param object $websites Object containing child sites info.
1674 * @param array $all_groups_sites Array of all groups and sites.
1675 * @param array $all_groups Array of all groups.
1676 * @param array $allThemesOutdate Array of all abandoned plugins.
1677 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1678 * @param int $site_offset_for_groups Offset value.
1679 *
1680 * @since 4.1
1681 */
1682 do_action( 'mainwp_updates_persite_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1683 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1684 /**
1685 * Action: mainwp_updates_pergroup_before_abandoned_themes
1686 *
1687 * Fires at the top of the Abandoned themes tab, per Group view.
1688 *
1689 * @param object $websites Object containing child sites info.
1690 * @param array $all_groups_sites Array of all groups and sites.
1691 * @param array $all_groups Array of all groups.
1692 * @param array $allThemesOutdate Array of all abandoned plugins.
1693 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1694 * @param int $site_offset_for_groups Offset value.
1695 *
1696 * @since 4.1
1697 */
1698 do_action( 'mainwp_updates_pergroup_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1699 MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes );
1700 /**
1701 * Action: mainwp_updates_pergroup_after_abandoned_themes
1702 *
1703 * Fires at the bottom of the Abandoned themes tab, per Group view.
1704 *
1705 * @param object $websites Object containing child sites info.
1706 * @param array $all_groups_sites Array of all groups and sites.
1707 * @param array $all_groups Array of all groups.
1708 * @param array $allThemesOutdate Array of all abandoned plugins.
1709 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1710 * @param int $site_offset_for_groups Offset value.
1711 *
1712 * @since 4.1
1713 */
1714 do_action( 'mainwp_updates_pergroup_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1715 } else {
1716 /**
1717 * Action: mainwp_updates_pertheme_before_abandoned_themes
1718 *
1719 * Fires at the top of the Abandoned themes tab, per Theme view.
1720 *
1721 * @param object $websites Object containing child sites info.
1722 * @param array $all_groups_sites Array of all groups and sites.
1723 * @param array $all_groups Array of all groups.
1724 * @param array $allThemesOutdate Array of all abandoned plugins.
1725 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1726 * @param int $site_offset_for_groups Offset value.
1727 *
1728 * @since 4.1
1729 */
1730 do_action( 'mainwp_updates_pertheme_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1731 MainWP_Updates_Per_Item::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes );
1732 /**
1733 * Action: mainwp_updates_pertheme_after_abandoned_themes
1734 *
1735 * Fires at the bottom of the Abandoned themes tab, per Theme view.
1736 *
1737 * @param object $websites Object containing child sites info.
1738 * @param array $all_groups_sites Array of all groups and sites.
1739 * @param array $all_groups Array of all groups.
1740 * @param array $allThemesOutdate Array of all abandoned plugins.
1741 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1742 * @param int $site_offset_for_groups Offset value.
1743 *
1744 * @since 4.1
1745 */
1746 do_action( 'mainwp_updates_pertheme_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1747 }
1748 /**
1749 * Action: mainwp_updates_after_abandoned_themes
1750 *
1751 * Fires at the bottom of the Abandoned themes tab.
1752 *
1753 * @param object $websites Object containing child sites info.
1754 * @param array $all_groups_sites Array of all groups and sites.
1755 * @param array $all_groups Array of all groups.
1756 * @param array $allThemesOutdate Array of all abandoned plugins.
1757 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1758 * @param int $site_offset_for_groups Offset value.
1759 *
1760 * @since 4.1
1761 */
1762 do_action( 'mainwp_updates_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1763 ?>
1764 </div>
1765 <?php
1766 }
1767
1768 /**
1769 * Renders JavaScript for update page.
1770 *
1771 * @param string $site_view current site view.
1772 */
1773 public static function render_js_updates( $site_view ) {
1774 $table_features = array(
1775 'searching' => 'false',
1776 'paging' => 'false',
1777 'stateSave' => 'true',
1778 'info' => 'false',
1779 'exclusive' => 'false',
1780 'duration' => '200',
1781 );
1782 /**
1783 * Filter: mainwp_updates_table_features
1784 *
1785 * Filters the Updates table features.
1786 *
1787 * @since 4.1
1788 */
1789 $table_features = apply_filters( 'mainwp_updates_table_features', $table_features );
1790 ?>
1791 <script type="text/javascript">
1792 jQuery( document ).ready( function () {
1793 jQuery( '#mainwp-manage-updates .ui.accordion' ).accordion( {
1794 "exclusive": <?php echo esc_html( $table_features['exclusive'] ); ?>,
1795 "duration": <?php echo esc_html( $table_features['duration'] ); ?>,
1796 onOpen: function(){
1797 //mainwp_datatable_init_and_fix_recalc('table.mainwp-manage-updates-item-table');
1798 }
1799 } );
1800 } );
1801
1802 mainwp_datatable_init_and_fix_recalc = function(selector){
1803 jQuery(selector).each( function(e) {
1804 if(jQuery(this).is(":visible")){
1805 console.log('visible ' + jQuery(this).attr('id'));
1806 jQuery(this).css( 'display', 'table' );
1807 jQuery(this).DataTable().destroy();
1808 let tb = jQuery(this).DataTable({
1809 "paging":false,
1810 "info": false,
1811 "searching": false,
1812 "ordering" : false,
1813 "responsive": true
1814 });
1815 tb.columns.adjust();
1816 tb.responsive.recalc();
1817 }
1818 });
1819 }
1820
1821 jQuery( document ).on( 'click', '.trigger-all-accordion', function() {
1822 if ( jQuery( this ).hasClass( 'active' ) ) {
1823 jQuery( this ).removeClass( 'active' );
1824 jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1825 if ( jQuery( this ).hasClass( 'active' ) ) {
1826 jQuery( this ).trigger( 'click' );
1827 }
1828 } );
1829 } else {
1830 jQuery( this ).addClass( 'active' );
1831 jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1832 if ( !jQuery( this ).hasClass( 'active' ) ) {
1833 jQuery( this ).trigger( 'click' );
1834 }
1835 } );
1836 }
1837 } );
1838
1839 </script>
1840 <?php
1841
1842 if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1843 ?>
1844 <script type="text/javascript">
1845 jQuery( document ).ready( function () {
1846 updatesoverview_updates_init_group_view();
1847 } );
1848 </script>
1849 <?php
1850 }
1851 }
1852
1853
1854 /**
1855 * Gets sites for updates
1856 *
1857 * @return object Object containing websites info.
1858 *
1859 * @uses \MainWP\Dashboard\MainWP_DB::query()
1860 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id()
1861 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1862 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1863 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1864 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1865 */
1866 public static function get_sites_for_current_user() {
1867 /**
1868 * Current user global.
1869 *
1870 * @global string
1871 */
1872 global $current_user;
1873
1874 $current_wpid = MainWP_System_Utility::get_current_wpid();
1875 if ( $current_wpid ) {
1876 $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' ) );
1877 } else {
1878 $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
1879 $is_staging = 'no';
1880 if ( $staging_enabled ) {
1881 $staging_updates_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users();
1882 if ( 'staging' === $staging_updates_view ) {
1883 $is_staging = 'yes';
1884 }
1885 }
1886 $params = array(
1887 'connected' => 'yes',
1888 );
1889
1890 $limit_sites = get_option( 'mainwp_manage_updates_limit_sites' );
1891 if ( ! empty( $limit_sites ) ) {
1892 $params['limit_sites'] = $limit_sites;
1893 }
1894 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging, $params );
1895 }
1896 return MainWP_DB::instance()->query( $sql );
1897 }
1898
1899 /**
1900 * Renders header tabs
1901 *
1902 * @param bool $show_language_updates show language update.
1903 * @param string $current_tab current tab.
1904 * @param int $total_wp_upgrades total WP update.
1905 * @param int $total_plugin_upgrades total plugins update.
1906 * @param int $total_theme_upgrades total themes update.
1907 * @param int $total_translation_upgrades total translation update.
1908 * @param int $total_plugins_outdate total plugins outdate.
1909 * @param int $total_themes_outdate total theme outdate.
1910 * @param string $site_view current site view.
1911 */
1912 public static function render_header_tabs( $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 ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1913
1914 /**
1915 * Action: mainwp_updates_before_nav_tabs
1916 *
1917 * Fires before the navigation tabs on the Updates page.
1918 *
1919 * @since 4.1
1920 */
1921 do_action( 'mainwp_updates_before_nav_tabs' );
1922
1923 $header_tabs = array(
1924 'plugins-updates' => array(
1925 'slug' => 'plugins-updates',
1926 'title' => esc_html__( 'Plugin Updates', 'mainwp' ),
1927 'total_upgrades' => $total_plugin_upgrades,
1928 ),
1929 'themes-updates' => array(
1930 'slug' => 'themes-updates',
1931 'title' => esc_html__( 'Theme Updates', 'mainwp' ),
1932 'total_upgrades' => $total_theme_upgrades,
1933 ),
1934 'wordpress-updates' => array(
1935 'slug' => 'wordpress-updates',
1936 'title' => esc_html__( 'WordPress Updates', 'mainwp' ),
1937 'total_upgrades' => $total_wp_upgrades,
1938 ),
1939 );
1940
1941 if ( $show_language_updates ) {
1942 $header_tabs['translations-updates'] = array(
1943 'slug' => 'translations-updates',
1944 'title' => esc_html__( 'Translations Updates', 'mainwp' ),
1945 'total_upgrades' => $total_translation_upgrades,
1946 );
1947 }
1948
1949 $header_tabs['abandoned-plugins'] = array(
1950 'slug' => 'abandoned-plugins',
1951 'title' => esc_html__( 'Abandoned Plugins', 'mainwp' ),
1952 'total_upgrades' => $total_plugins_outdate,
1953 );
1954
1955 $header_tabs['abandoned-themes'] = array(
1956 'slug' => 'abandoned-themes',
1957 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ),
1958 'total_upgrades' => $total_themes_outdate,
1959 );
1960
1961 $header_tabs = apply_filters( 'mainwp_page_hearder_tabs_updates', $header_tabs );
1962
1963 ?>
1964 <div id="mainwp-page-navigation-wrapper">
1965 <div class="ui vertical menu mainwp-page-navigation">
1966 <?php
1967 foreach ( $header_tabs as $slug => $tab ) {
1968 if ( empty( $tab['title'] ) ) {
1969 continue;
1970 }
1971 ?>
1972 <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>
1973 <?php
1974 }
1975 ?>
1976 </div>
1977 </div>
1978 <?php
1979
1980 $hide_show_updates_per = 'updates-ignore' === $current_tab ? true : false;
1981
1982 $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', $hide_show_updates_per, $current_tab );
1983
1984 /**
1985 * Action: mainwp_updates_after_nav_tabs
1986 *
1987 * Fires after the navigation tabs on the Updates page.
1988 *
1989 * @since 4.1
1990 */
1991 do_action( 'mainwp_updates_after_nav_tabs' );
1992
1993 /**
1994 * Action: mainwp_updates_before_actions_bar
1995 *
1996 * Fires before the actions bar on the Updates page.
1997 *
1998 * @since 4.1
1999 */
2000 do_action( 'mainwp_updates_before_actions_bar' );
2001
2002 if ( ! $hide_show_updates_per ) {
2003 $is_demo = MainWP_Demo_Handle::is_demo_mode();
2004 ?>
2005 <div class="mainwp-sub-header">
2006 <div class="ui grid">
2007 <div class="equal width row">
2008 <div class="middle aligned column">
2009 <form method="post" action="" class="ui mini form">
2010 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2011 <div class="inline field">
2012 <select class="ui dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview">
2013 <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option>
2014 <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>
2015 <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option>
2016 </select>
2017 </div>
2018 </form>
2019 </div>
2020 <div class="middle aligned right aligned column">
2021 <?php
2022 /**
2023 * Filter: mainwp_widgetupdates_actions_top
2024 *
2025 * Filters the udpates actions top content.
2026 *
2027 * @since Unknown
2028 */
2029 echo apply_filters( 'mainwp_widgetupdates_actions_top', '' ); // phpcs:ignore WordPress.Security.EscapeOutput
2030 if ( 'abandoned-plugins' === $current_tab ) {
2031 if ( $is_demo ) {
2032 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>' );
2033 } else {
2034 ?>
2035 <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>
2036 <?php
2037 }
2038 } elseif ( 'abandoned-themes' === $current_tab ) {
2039 if ( $is_demo ) {
2040 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>' );
2041 } else {
2042 ?>
2043 <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>
2044 <?php
2045 }
2046 }
2047 ?>
2048 </div>
2049 </div>
2050 </div>
2051 </div>
2052 <?php
2053 static::render_button_view_ignored_updates( $current_tab );
2054 }
2055
2056 /**
2057 * Action: mainwp_updates_after_actions_bar
2058 *
2059 * Fires after the actions bar on the Updates page.
2060 *
2061 * @since 4.1
2062 */
2063 do_action( 'mainwp_updates_after_actions_bar' );
2064 }
2065
2066
2067 /**
2068 * Method render_button_view_ignored_updates().
2069 *
2070 * @param string $current_tab current tab.
2071 *
2072 * @return null
2073 */
2074 public static function render_button_view_ignored_updates( $current_tab = '' ) {
2075 if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ) ) ) {
2076 return;
2077 }
2078 ?>
2079 <div class="mainwp-sub-header">
2080 <div class="ui grid">
2081 <div class="equal width row">
2082 <div class="middle aligned column">
2083 </div>
2084 <div class="middle aligned right aligned column">
2085 <?php
2086 if ( 'wordpress-updates' === $current_tab ) {
2087 ?>
2088 <a class="ui mini basic button" href="admin.php?page=UpdatesManage&tab=updates-ignore" data-position="top 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 Core Updates', 'mainwp' ); ?></a>
2089 <?php
2090 } elseif ( 'plugins-updates' === $current_tab ) {
2091 ?>
2092 <a class="ui mini basic button" href="admin.php?page=PluginsIgnore" data-position="top right" data-tooltip="<?php esc_attr_e( 'Click here to see the list of ignored plugin updates.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'View Ignored Plugin Updates', 'mainwp' ); ?></a>
2093 <?php
2094 } elseif ( 'themes-updates' === $current_tab ) {
2095 ?>
2096 <a class="ui mini basic button" href="admin.php?page=ThemesIgnore" data-position="top right" data-tooltip="<?php esc_attr_e( 'Click here to see the list of ignored theme updates.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'View Ignored Theme Updates', 'mainwp' ); ?></a>
2097 <?php
2098 }
2099 ?>
2100 </div>
2101 </div>
2102 </div>
2103 </div>
2104 <?php
2105 }
2106
2107 /**
2108 * Method handle_limit_sites().
2109 */
2110 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.
2111 // put hook here before loading sites.
2112 $limit_number = apply_filters( 'mainwp_manage_updates_limit_loading', false, 'updates' );
2113 $current_limit = get_option( 'mainwp_manage_updates_limit_sites' );
2114
2115 if ( (int) $limit_number !== (int) $current_limit ) {
2116 update_option( 'mainwp_manage_updates_limit_sites', $limit_number );
2117 update_option( 'mainwp_manage_updates_limit_current_page', 1 );
2118 }
2119
2120 if ( ! empty( $limit_number ) ) {
2121
2122 $count = MainWP_DB::instance()->get_websites_count( null, true );
2123
2124 $current_page = 1;
2125 if ( isset( $_GET['current_page'] ) && isset( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) ) {
2126 $current_page = intval( $_GET['current_page'] );
2127 }
2128
2129 if ( 0 >= $current_page ) {
2130 $current_page = 1;
2131 }
2132
2133 $total_page = ceil( $count / $limit_number );
2134
2135 if ( $current_page > $total_page ) {
2136 $current_page = $total_page;
2137 }
2138 update_option( 'mainwp_manage_updates_limit_current_page', $current_page );
2139 }
2140 }
2141
2142 /**
2143 * Method render_limit_load_sites().
2144 *
2145 * @param int $limit_number limit loading sites.
2146 */
2147 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.
2148
2149 $count = MainWP_DB::instance()->get_websites_count( null, true );
2150 $total_page = ceil( $count / $limit_number );
2151
2152 $current_page = (int) get_option( 'mainwp_manage_updates_limit_current_page' );
2153
2154 $first = 1 === $current_page;
2155 $last = $total_page <= $current_page;
2156
2157 ?>
2158 <div class="dt-paging paging_full_numbers">
2159 <div class="ui stackable pagination menu"><menu>
2160 <?php if ( $first ) { ?>
2161 <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>
2162 <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>
2163 <?php } else { ?>
2164 <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>
2165 <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_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>
2166 <?php } ?>
2167 <?php
2168 for ( $i = 1; $i <= $total_page;$i++ ) {
2169 ?>
2170 <li class="dt-paging-button item <?php echo $current_page === $i ? 'active' : ''; ?>"><a href="admin.php?page=UpdatesManage&current_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>
2171 <?php
2172 }
2173 ?>
2174 <?php if ( $last ) { ?>
2175 <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>
2176 <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>
2177 <?php } else { ?>
2178 <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_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>
2179 <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_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>
2180 <?php } ?>
2181 </menu></div>
2182 </div>
2183 <br/>
2184 <?php
2185 }
2186
2187 /**
2188 * Cheks which primary backup plugin is being used.
2189 *
2190 * @param mixed $what Which backup plugin is being use.
2191 * @param object $website Website array of information.
2192 *
2193 * @return boolean True|False.
2194 */
2195 public static function activated_primary_backup_plugin( $what, $website ) {
2196 $plugins = json_decode( $website->plugins, 1 );
2197 if ( ! is_array( $plugins ) || empty( $plugins ) ) {
2198 return false;
2199 }
2200
2201 $checks = array(
2202 'backupbuddy' => 'backupbuddy/backupbuddy.php',
2203 'backupwp' => array( 'backwpup/backwpup.php', 'backwpup-pro/backwpup.php' ),
2204 'updraftplus' => 'updraftplus/updraftplus.php',
2205
2206 );
2207
2208 $slug = isset( $checks[ $what ] ) ? $checks[ $what ] : '';
2209
2210 if ( empty( $slug ) ) {
2211 return false;
2212 }
2213
2214 $installed = false;
2215
2216 foreach ( $plugins as $plugin ) {
2217 if ( ( is_string( $slug ) && strtolower( $plugin['slug'] ) === $slug ) || ( is_array( $slug ) && in_array( $plugin['slug'], $slug ) ) ) {
2218 if ( $plugin['active'] ) {
2219 $installed = true;
2220 }
2221 break;
2222 }
2223 }
2224
2225 return $installed;
2226 }
2227
2228 /**
2229 * Sets the HTML selector to continue updates.
2230 *
2231 * @param string $current_update current update string.
2232 * @param bool $slug Whether to update slug.
2233 */
2234 public static function set_continue_update_html_selector( $current_update, $slug = false ) {
2235
2236 $check_slug = true;
2237 if ( ! empty( $slug ) ) {
2238 $check_slug = ( $slug === static::$continue_update_slug ) ? true : false;
2239 }
2240
2241 if ( $check_slug && $current_update === static::$continue_update ) {
2242 static::$continue_selector = 'updatesoverview_continue_update_me';
2243 } else {
2244 static::$continue_selector = '';
2245 }
2246 }
2247
2248 /**
2249 * Gets the HTML selector to continue updates.
2250 *
2251 * @return void.
2252 */
2253 public static function get_continue_update_selector() {
2254 echo esc_attr( static::$continue_selector );
2255 }
2256
2257 /**
2258 * Displays the updates modal window during updates.
2259 */
2260 public static function render_updates_modal() {
2261 ?>
2262 <div class="ui modal" id="updatesoverview-backup-box">
2263 <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
2264 <div class="scrolling content mainwp-modal-content"></div>
2265 <div class="actions mainwp-modal-actions">
2266 <input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/>
2267 <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>&nbsp;
2268 <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
2269 </div>
2270 </div>
2271 <?php
2272 }
2273
2274 /**
2275 * Displays the plugin details modal window.
2276 */
2277 public static function render_plugin_details_modal() {
2278 ?>
2279 <div class="ui modal" id="mainwp-plugin-details-modal">
2280 <i class="close icon"></i>
2281 <div class="header"><?php echo esc_html__( 'Plugin Details', 'mainwp' ); ?></div>
2282 <div class="content">
2283 <div class="ui embed"></div>
2284 </div>
2285 <div class="actions">
2286 </div>
2287 </div>
2288 <?php
2289 }
2290
2291 /**
2292 * Method render_screen_options_modal()
2293 *
2294 * Renders Page Settings Modal.
2295 */
2296 public static function render_screen_options_modal() { // phpcs:ignore -- NOSONAR - complex method.
2297
2298 $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' );
2299 $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' );
2300 $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' );
2301 $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 );
2302 $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
2303 $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
2304 ?>
2305 <div class="ui modal" id="mainwp-manage-updates-screen-options-modal">
2306 <i class="close icon"></i>
2307 <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
2308 <div class="scrolling content ui form">
2309 <form method="POST" action="" id="manage-updates-screen-options-form" name="manage-updates-screen-options-form">
2310 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2311 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdatesScrOptions' ) ); ?>" />
2312 <div class="ui grid field">
2313 <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label>
2314 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugin updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2315 <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
2316 <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2317 <option value="0" <?php echo ( false !== $snPluginAutomaticDailyUpdate && empty( $snPluginAutomaticDailyUpdate ) ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2318 </select>
2319 </div>
2320 </div>
2321 <div class="ui grid field">
2322 <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label>
2323 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic theme updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2324 <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
2325 <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2326 <option value="0" <?php echo ( false !== $snThemeAutomaticDailyUpdate && 0 === $snThemeAutomaticDailyUpdate ) || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2327 </select>
2328 </div>
2329 </div>
2330 <div class="ui grid field">
2331 <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label>
2332 <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">
2333 <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
2334 <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2335 <option value="0" <?php echo ( false !== $snAutomaticDailyUpdate && 0 === $snAutomaticDailyUpdate ) || 2 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2336 </select>
2337 </div>
2338 </div>
2339 <div class="ui grid field">
2340 <label class="six wide column middle aligned"><?php esc_html_e( 'Advanced automatic updates delay', 'mainwp' ); ?></label>
2341 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'Set the number of days to delay automatic updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2342 <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
2343 <option value="0" <?php echo 0 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
2344 <option value="1" <?php echo 1 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
2345 <option value="2" <?php echo 2 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
2346 <option value="3" <?php echo 3 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
2347 <option value="4" <?php echo 4 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
2348 <option value="5" <?php echo 5 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
2349 <option value="6" <?php echo 6 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
2350 <option value="7" <?php echo 7 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
2351 <option value="14" <?php echo 14 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
2352 <option value="30" <?php echo 30 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
2353 </select>
2354 </div>
2355 </div>
2356 <div class="ui grid field">
2357 <label class="six wide column middle aligned"><?php esc_html_e( 'Show WordPress language updates', 'mainwp' ); ?></label>
2358 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to manage Translation updates', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2359 <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo 1 === $mainwp_show_language_updates ? 'checked="true"' : ''; ?>/>
2360 </div>
2361 </div>
2362 <div class="ui grid field">
2363 <label class="six wide column middle aligned"><?php esc_html_e( 'Update confirmations', 'mainwp' ); ?></label>
2364 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Choose if you want to disable the popup confirmations when performing updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2365 <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
2366 <option value="0" <?php echo 0 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
2367 <option value="2" <?php echo 2 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
2368 <option value="1" <?php echo 1 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
2369 </select>
2370 </div>
2371 </div>
2372 <div class="ui hidden divider"></div>
2373 <div class="ui hidden divider"></div>
2374 </div>
2375 <div class="actions">
2376 <div class="ui two columns grid">
2377 <div class="left aligned column"></div>
2378 <div class="ui right aligned column">
2379 <input type="submit" class="ui green button" name="btnSubmit" id="submit-manage-updates-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2380 </div>
2381 </div>
2382 </div>
2383 </form>
2384 </div>
2385 <?php
2386 }
2387
2388
2389 /**
2390 * Method mainwp_help_content()
2391 *
2392 * Creates the MainWP Help Documentation List for the help component in the sidebar.
2393 */
2394 public static function mainwp_help_content() {
2395 if ( isset( $_GET['page'] ) && 'UpdatesManage' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2396 ?>
2397 <p><?php esc_html_e( 'If you need help with managing updates, please review following help documents', 'mainwp' ); ?></p>
2398 <div class="ui list">
2399 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#update-plugins" target="_blank">Update Plugins</a></div>
2400 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#plugins-auto-updates" target="_blank">Plugins Auto Updates</a></div>
2401 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#ignore-plugin-updates" target="_blank">Ignore Plugin Updates</a></div>
2402 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#update-themes" target="_blank">Update Themes</a></div>
2403 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#themes-auto-updates" target="_blank">Themes Auto Updates</a></div>
2404 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#ignore-theme-updates" target="_blank">Ignore Theme Updates</a></div>
2405 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#update-wordpress-core" target="_blank">Update WordPress Core</a></div>
2406 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#auto-update-wordpress-core" target="_blank">Auto Update WordPress Core</a></div>
2407 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#ignore-wordpress-core-update" target="_blank">Ignore WordPress Core Update</a></div>
2408 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-updates/#safe-updates---updates-rollback" target="_blank">Safe Updates/Updates Rollback</a></div>
2409 <?php
2410 /**
2411 * Action: mainwp_updates_help_item
2412 *
2413 * Fires at the bottom of the help articles list in the Help sidebar on the Updates page.
2414 *
2415 * Suggested HTML markup:
2416 *
2417 * <div class="item"><a href="Your custom URL">Your custom text</a></div>
2418 *
2419 * @since 4.1
2420 */
2421 do_action( 'mainwp_updates_help_item' );
2422 ?>
2423 </div>
2424 <?php
2425 }
2426 }
2427 }
2428