PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.2
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.2.2, at pages/page-mainwp-updates.php

2,572 lines 136.5 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_have_right( '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_have_right( '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_have_right( '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_have_right( '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_have_right( '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 $themesInfo[ $slug ] = array(
638 'name' => esc_html( $theme_upgrade['Name'] ),
639 'premium' => ( isset( $theme_upgrade['premium'] ) ? esc_html( $theme_upgrade['premium'] ) : 0 ),
640 );
641 }
642 }
643
644 if ( is_array( $plugins_outdate ) ) {
645 foreach ( $plugins_outdate as $slug => $plugin_outdate ) {
646 $slug = esc_html( $slug );
647 if ( ! isset( $allPluginsOutdate[ $slug ] ) ) {
648 $allPluginsOutdate[ $slug ] = array(
649 'name' => esc_html( $plugin_outdate['Name'] ),
650 'cnt' => 1,
651 'uri' => esc_html( $plugin_outdate['PluginURI'] ),
652 );
653 } else {
654 ++$allPluginsOutdate[ $slug ]['cnt'];
655 }
656 }
657 }
658
659 if ( is_array( $themes_outdate ) ) {
660 foreach ( $themes_outdate as $slug => $theme_outdate ) {
661 $slug = esc_html( $slug );
662 if ( ! isset( $allThemesOutdate[ $slug ] ) ) {
663 $allThemesOutdate[ $slug ] = array(
664 'name' => esc_html( $theme_outdate['Name'] ),
665 'cnt' => 1,
666 );
667 } else {
668 ++$allThemesOutdate[ $slug ]['cnt'];
669 }
670 }
671 }
672 }
673
674 if ( '' !== $website->sync_errors ) {
675 ++$total_sync_errors;
676 }
677 }
678
679 /**
680 * Filter: mainwp_updates_translation_sort_by
681 *
682 * Filters the default sorting option for Translation updates.
683 *
684 * @since 4.1
685 */
686 $allTranslationsSortBy = apply_filters( 'mainwp_updates_translation_sort_by', 'name' );
687
688 /**
689 * Filter: mainwp_updates_plugins_sort_by
690 *
691 * Filters the default sorting option for Plugin updates.
692 *
693 * @since 4.1
694 */
695 $allPluginsSortBy = apply_filters( 'mainwp_updates_plugins_sort_by', 'name' );
696
697 /**
698 * Filter: mainwp_updates_themes_sort_by
699 *
700 * Filters the default sorting option for Theme updates.
701 *
702 * @since 4.1
703 */
704 $allThemesSortBy = apply_filters( 'mainwp_updates_themes_sort_by', 'name' );
705
706 /**
707 * Filter: mainwp_updates_abandoned_plugins_sort_by
708 *
709 * Filters the default sorting option for Abandoned plugins.
710 *
711 * @since 4.1
712 */
713 $allPluginsOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_plugins_sort_by', 'name' );
714
715 /**
716 * Filter: mainwp_updates_abandoned_themes_sort_by
717 *
718 * Filters the default sorting option for Abandoned themes.
719 *
720 * @since 4.1
721 */
722 $allThemesOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_themes_sort_by', 'name' );
723
724 MainWP_Utility::array_sort( $allTranslations, $allTranslationsSortBy );
725 MainWP_Utility::array_sort( $allPlugins, $allPluginsSortBy );
726 MainWP_Utility::array_sort( $allThemes, $allThemesSortBy );
727 MainWP_Utility::array_sort( $allPluginsOutdate, $allPluginsOutdateSortBy );
728 MainWP_Utility::array_sort( $allThemesOutdate, $allThemesOutdateSortBy );
729
730 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
731
732 /**
733 * Limits number of updates to process.
734 *
735 * Limits the number of updates that will be processed in a single run on Update Everything action.
736 *
737 * @since 4.0
738 */
739 $limit_updates_all = apply_filters( 'mainwp_limit_updates_all', 0 );
740 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
741 if ( 0 < $limit_updates_all && isset( $_GET['continue_update'] ) && '' !== $_GET['continue_update'] ) {
742 static::$continue_update = sanitize_text_field( wp_unslash( $_GET['continue_update'] ) );
743 if ( ( 'plugins_upgrade_all' === static::$continue_update || 'themes_upgrade_all' === static::$continue_update || 'translations_upgrade_all' === static::$continue_update ) && isset( $_GET['slug'] ) && '' !== $_GET['slug'] ) {
744 static::$continue_update_slug = wp_unslash( $_GET['slug'] );
745 }
746 }
747
748 $current_tab = '';
749
750 if ( isset( $_GET['tab'] ) ) {
751 $current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) );
752 if ( ! in_array( $current_tab, array( 'wordpress-updates', 'updates-ignore', 'plugins-updates', 'themes-updates', 'translations-updates', 'abandoned-plugins', 'abandoned-themes', true ) ) ) {
753 $current_tab = 'plugins-updates';
754 }
755 } else {
756 $current_tab = 'plugins-updates';
757 }
758 // phpcs:enable
759 static::render_header( 'UpdatesManage' );
760
761 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 );
762
763 ?>
764 <div class="ui segment" id="mainwp-manage-updates">
765 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?>
766 <div class="ui info message">
767 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
768 <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>
769 <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>
770 </div>
771 <?php } ?>
772 <?php
773
774 $hooks_tabs = apply_filters( 'mainwp_pages_updates_render_tabs', false, $current_tab );
775
776 if ( false === $hooks_tabs ) {
777 if ( 'wordpress-updates' === $current_tab ) {
778 static::render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view );
779 } elseif ( 'updates-ignore' === $current_tab ) {
780 static::render_wp_ignore_update_tab( $websites, $userExtension );
781 } elseif ( 'plugins-updates' === $current_tab ) {
782 static::render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view );
783 } elseif ( 'themes-updates' === $current_tab ) {
784 static::render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view );
785 } elseif ( 'translations-updates' === $current_tab ) {
786 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 );
787 } elseif ( 'abandoned-plugins' === $current_tab ) {
788 static::render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view );
789 } elseif ( 'abandoned-themes' === $current_tab ) {
790 static::render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view );
791 }
792 ?>
793 </div>
794 <?php
795 static::render_js_updates( $site_view );
796 }
797
798 static::render_updates_modal();
799
800 static::render_plugin_details_modal();
801 MainWP_UI::render_modal_upload_icon();
802 static::render_screen_options_modal();
803 static::render_footer();
804 ?>
805 <script type="text/javascript">
806 mainwp_manage_updates_screen_options = function () {
807 jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'show' );
808 jQuery( '#manage-updates-screen-options-form' ).submit( function() {
809 jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'hide' );
810 } );
811 return false;
812 };
813 </script>
814 <?php
815 }
816
817 /**
818 * Render WP updates tab.
819 *
820 * @param object $websites Object containing child sites info.
821 * @param object $userExtension User Extension object.
822 * @param int $total_wp_upgrades Number of available WP upates.
823 * @param array $all_groups_sites Array containing all groups and sites.
824 * @param array $all_groups Array containing all groups.
825 * @param int $site_offset_for_groups Offset value.
826 * @param string $site_view Current view.
827 *
828 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
829 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_wpcore_updates()
830 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_wpcore_updates()
831 */
832 public static function render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) {
833 ?>
834 <div class="ui active tab" data-tab="wordpress-updates">
835 <?php
836 /**
837 * Action: mainwp_updates_before_wp_updates
838 *
839 * Fires at the top of the WP updates tab.
840 *
841 * @param object $websites Object containing child sites info.
842 * @param int $total_wp_upgrades Number of available WP upates.
843 * @param array $all_groups_sites Array containing all groups and sites.
844 * @param array $all_groups Array containing all groups.
845 * @param int $site_offset_for_groups Offset value.
846 *
847 * @since 4.1
848 */
849 do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
850 if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
851 /**
852 * Action: mainwp_updates_pergroup_before_wp_updates
853 *
854 * Fires at the top of the WP updates tab, per Group view.
855 *
856 * @param object $websites Object containing child sites info.
857 * @param int $total_wp_upgrades Number of available WP upates.
858 * @param array $all_groups_sites Array containing all groups and sites.
859 * @param array $all_groups Array containing all groups.
860 * @param int $site_offset_for_groups Offset value.
861 *
862 * @since 4.1
863 */
864 do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
865 MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
866 /**
867 * Action: mainwp_updates_pergroup_after_wp_updates
868 *
869 * Fires at the bottom of the WP updates tab, per Group view.
870 *
871 * @param object $websites Object containing child sites info.
872 * @param int $total_wp_upgrades Number of available WP upates.
873 * @param array $all_groups_sites Array containing all groups and sites.
874 * @param array $all_groups Array containing all groups.
875 * @param int $site_offset_for_groups Offset value.
876 *
877 * @since 4.1
878 */
879 do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
880 } else {
881 /**
882 * Action: mainwp_updates_persite_before_wp_updates
883 *
884 * Fires at the top of the WP updates tab, per Site view.
885 *
886 * @param object $websites Object containing child sites info.
887 * @param int $total_wp_upgrades Number of available WP upates.
888 * @param array $all_groups_sites Array containing all groups and sites.
889 * @param array $all_groups Array containing all groups.
890 * @param int $site_offset_for_groups Offset value.
891 *
892 * @since 4.1
893 */
894 do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
895 MainWP_DB::data_seek( $websites, 0 );
896 MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades );
897 /**
898 * Action: mainwp_updates_persite_after_wp_updates
899 *
900 * Fires at the bottom of the WP updates tab, per Site view.
901 *
902 * @param object $websites Object containing child sites info.
903 * @param int $total_wp_upgrades Number of available WP upates.
904 * @param array $all_groups_sites Array containing all groups and sites.
905 * @param array $all_groups Array containing all groups.
906 * @param int $site_offset_for_groups Offset value.
907 *
908 * @since 4.1
909 */
910 do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
911 }
912 /**
913 * Action: mainwp_updates_after_wp_updates
914 *
915 * Fires at the top of the WP updates tab.
916 *
917 * @param object $websites Object containing child sites info.
918 * @param int $total_wp_upgrades Number of available WP upates.
919 * @param array $all_groups_sites Array containing all groups and sites.
920 * @param array $all_groups Array containing all groups.
921 * @param int $site_offset_for_groups Offset value.
922 *
923 * @since 4.1
924 */
925 do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
926 ?>
927 </div>
928 <?php
929 }
930
931
932 /**
933 * Renders WP updates tab.
934 *
935 * @param array $websites Object containing child sites info.
936 * @param object $userExtension User extension.
937 */
938 public static function render_wp_ignore_update_tab( $websites, $userExtension ) {
939 MainWP_WP_Updates::instance()->render_ignore( $websites, $userExtension );
940 }
941
942 /**
943 * Renders WP updates tab.
944 *
945 * @param object $websites Object containing child sites info.
946 * @param int $total_plugin_upgrades Number of available plugin updates.
947 * @param object $userExtension User extension.
948 * @param array $all_groups_sites Array of all groups and sites.
949 * @param array $all_groups Array of all groups.
950 * @param array $allPlugins Array of all plugins.
951 * @param array $pluginsInfo Array of all plugins info.
952 * @param int $site_offset_for_groups Offset value.
953 * @param string $site_view Current view.
954 *
955 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_plugins_updates()
956 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_plugins_updates()
957 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_plugins_updates()
958 */
959 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.
960 $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
961 if ( ! is_array( $trustedPlugins ) ) {
962 $trustedPlugins = array();
963 }
964 ?>
965 <div class="ui active tab" data-tab="plugins-updates">
966 <?php
967 /**
968 * Action: mainwp_updates_before_plugin_updates
969 *
970 * Fires at the top of the Plugin updates tab.
971 *
972 * @param object $websites Object containing child sites info.
973 * @param int $total_plugin_upgrades Number of available plugin updates.
974 * @param object $userExtension User extension.
975 * @param array $all_groups_sites Array of all groups and sites.
976 * @param array $all_groups Array of all groups.
977 * @param array $allPlugins Array of all plugins.
978 * @param array $pluginsInfo Array of all plugins info.
979 * @param int $site_offset_for_groups Offset value.
980 *
981 * @since 4.1
982 */
983 do_action( 'mainwp_updates_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
984 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
985 /**
986 * Action: mainwp_updates_persite_before_plugin_updates
987 *
988 * Fires at the top of the Plugin updates tab, per Site view.
989 *
990 * @param object $websites Object containing child sites info.
991 * @param int $total_plugin_upgrades Number of available plugin updates.
992 * @param object $userExtension User extension.
993 * @param array $all_groups_sites Array of all groups and sites.
994 * @param array $all_groups Array of all groups.
995 * @param array $allPlugins Array of all plugins.
996 * @param array $pluginsInfo Array of all plugins info.
997 * @param int $site_offset_for_groups Offset value.
998 *
999 * @since 4.1
1000 */
1001 do_action( 'mainwp_updates_persite_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1002 MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins );
1003 /**
1004 * Action: mainwp_updates_persite_after_plugin_updates
1005 *
1006 * Fires at the bottom of the Plugin updates tab, per Site view.
1007 *
1008 * @param object $websites Object containing child sites info.
1009 * @param int $total_plugin_upgrades Number of available plugin updates.
1010 * @param object $userExtension User extension.
1011 * @param array $all_groups_sites Array of all groups and sites.
1012 * @param array $all_groups Array of all groups.
1013 * @param array $allPlugins Array of all plugins.
1014 * @param array $pluginsInfo Array of all plugins info.
1015 * @param int $site_offset_for_groups Offset value.
1016 *
1017 * @since 4.1
1018 */
1019 do_action( 'mainwp_updates_persite_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1020 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1021 /**
1022 * Action: mainwp_updates_pergroup_before_plugin_updates
1023 *
1024 * Fires at the top of the Plugin updates tab, per Group view.
1025 *
1026 * @param object $websites Object containing child sites info.
1027 * @param int $total_plugin_upgrades Number of available plugin updates.
1028 * @param object $userExtension User extension.
1029 * @param array $all_groups_sites Array of all groups and sites.
1030 * @param array $all_groups Array of all groups.
1031 * @param array $allPlugins Array of all plugins.
1032 * @param array $pluginsInfo Array of all plugins info.
1033 * @param int $site_offset_for_groups Offset value.
1034 *
1035 * @since 4.1
1036 */
1037 do_action( 'mainwp_updates_pergroup_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1038 MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins );
1039 /**
1040 * Action: mainwp_updates_pergroup_after_plugin_updates
1041 *
1042 * Fires at the bottom of the Plugin updates tab, per Group view.
1043 *
1044 * @param object $websites Object containing child sites info.
1045 * @param int $total_plugin_upgrades Number of available plugin updates.
1046 * @param object $userExtension User extension.
1047 * @param array $all_groups_sites Array of all groups and sites.
1048 * @param array $all_groups Array of all groups.
1049 * @param array $allPlugins Array of all plugins.
1050 * @param array $pluginsInfo Array of all plugins info.
1051 * @param int $site_offset_for_groups Offset value.
1052 *
1053 * @since 4.1
1054 */
1055 do_action( 'mainwp_updates_pergroup_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1056 } else {
1057 /**
1058 * Action: mainwp_updates_perplugin_before_plugin_updates
1059 *
1060 * Fires at the top of the Plugin updates tab, per Plugin view.
1061 *
1062 * @param object $websites Object containing child sites info.
1063 * @param int $total_plugin_upgrades Number of available plugin updates.
1064 * @param object $userExtension User extension.
1065 * @param array $all_groups_sites Array of all groups and sites.
1066 * @param array $all_groups Array of all groups.
1067 * @param array $allPlugins Array of all plugins.
1068 * @param array $pluginsInfo Array of all plugins info.
1069 * @param int $site_offset_for_groups Offset value.
1070 *
1071 * @since 4.1
1072 */
1073 do_action( 'mainwp_updates_perplugin_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1074 MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins );
1075 /**
1076 * Action: mainwp_updates_perplugin_after_plugin_updates
1077 *
1078 * Fires at the bottom of the Plugin updates tab, per Plugin view.
1079 *
1080 * @param object $websites Object containing child sites info.
1081 * @param int $total_plugin_upgrades Number of available plugin updates.
1082 * @param object $userExtension User extension.
1083 * @param array $all_groups_sites Array of all groups and sites.
1084 * @param array $all_groups Array of all groups.
1085 * @param array $allPlugins Array of all plugins.
1086 * @param array $pluginsInfo Array of all plugins info.
1087 * @param int $site_offset_for_groups Offset value.
1088 *
1089 * @since 4.1
1090 */
1091 do_action( 'mainwp_updates_perplugin_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1092 }
1093 /**
1094 * Action: mainwp_updates_after_plugin_updates
1095 *
1096 * Fires at the bottom of the Plugin updates tab.
1097 *
1098 * @param object $websites Object containing child sites info.
1099 * @param int $total_plugin_upgrades Number of available plugin updates.
1100 * @param object $userExtension User extension.
1101 * @param array $all_groups_sites Array of all groups and sites.
1102 * @param array $all_groups Array of all groups.
1103 * @param array $allPlugins Array of all plugins.
1104 * @param array $pluginsInfo Array of all plugins info.
1105 * @param int $site_offset_for_groups Offset value.
1106 *
1107 * @since 4.1
1108 */
1109 do_action( 'mainwp_updates_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1110 ?>
1111 </div>
1112 <?php
1113 }
1114
1115 /**
1116 * Renders theme update tab.
1117 *
1118 * @param object $websites Object containing child sites info.
1119 * @param int $total_theme_upgrades Number of available theme updates.
1120 * @param object $userExtension User extension.
1121 * @param array $all_groups_sites Array of all groups and sites.
1122 * @param array $all_groups Array of all groups.
1123 * @param array $allThemes Array of all themes.
1124 * @param array $themesInfo Array of all themes info.
1125 * @param int $site_offset_for_groups Offset value.
1126 * @param string $site_view Current view.
1127 *
1128 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_themes_updates()
1129 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_themes_updates()
1130 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_themes_updates()
1131 */
1132 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.
1133 $trustedThemes = json_decode( $userExtension->trusted_themes, true );
1134 if ( ! is_array( $trustedThemes ) ) {
1135 $trustedThemes = array();
1136 }
1137 ?>
1138 <div class="ui active tab" data-tab="themes-updates">
1139 <?php
1140 /**
1141 * Action: mainwp_updates_before_theme_updates
1142 *
1143 * Fires at the top of the Theme updates tab.
1144 *
1145 * @param object $websites Object containing child sites info.
1146 * @param int $total_theme_upgrades Number of available theme updates.
1147 * @param object $userExtension User extension.
1148 * @param array $all_groups_sites Array of all groups and sites.
1149 * @param array $all_groups Array of all groups.
1150 * @param array $allThemes Array of all themes.
1151 * @param array $themesInfo Array of all themes info.
1152 * @param int $site_offset_for_groups Offset value.
1153 *
1154 * @since 4.1
1155 */
1156 do_action( 'mainwp_updates_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1157 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1158 /**
1159 * Action: mainwp_updates_persite_before_theme_updates
1160 *
1161 * Fires at the top of the Theme updates tab, per Site view.
1162 *
1163 * @param object $websites Object containing child sites info.
1164 * @param int $total_theme_upgrades Number of available theme updates.
1165 * @param object $userExtension User extension.
1166 * @param array $all_groups_sites Array of all groups and sites.
1167 * @param array $all_groups Array of all groups.
1168 * @param array $allThemes Array of all themes.
1169 * @param array $themesInfo Array of all themes info.
1170 * @param int $site_offset_for_groups Offset value.
1171 *
1172 * @since 4.1
1173 */
1174 do_action( 'mainwp_updates_persite_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1175 MainWP_Updates_Per_Site::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $trustedThemes );
1176 /**
1177 * Action: mainwp_updates_persite_after_theme_updates
1178 *
1179 * Fires at the bottom of the Theme updates tab, per Site view.
1180 *
1181 * @param object $websites Object containing child sites info.
1182 * @param int $total_theme_upgrades Number of available theme updates.
1183 * @param object $userExtension User extension.
1184 * @param array $all_groups_sites Array of all groups and sites.
1185 * @param array $all_groups Array of all groups.
1186 * @param array $allThemes Array of all themes.
1187 * @param array $themesInfo Array of all themes info.
1188 * @param int $site_offset_for_groups Offset value.
1189 *
1190 * @since 4.1
1191 */
1192 do_action( 'mainwp_updates_persite_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1193 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1194 /**
1195 * Action: mainwp_updates_pergroup_before_theme_updates
1196 *
1197 * Fires at the top of the Theme updates tab, per Group view.
1198 *
1199 * @param object $websites Object containing child sites info.
1200 * @param int $total_theme_upgrades Number of available theme updates.
1201 * @param object $userExtension User extension.
1202 * @param array $all_groups_sites Array of all groups and sites.
1203 * @param array $all_groups Array of all groups.
1204 * @param array $allThemes Array of all themes.
1205 * @param array $themesInfo Array of all themes info.
1206 * @param int $site_offset_for_groups Offset value.
1207 *
1208 * @since 4.1
1209 */
1210 do_action( 'mainwp_updates_pergroup_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1211 MainWP_Updates_Per_Group::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedThemes );
1212 /**
1213 * Action: mainwp_updates_pergroup_after_theme_updates
1214 *
1215 * Fires at the bottom of the Theme updates tab, per Group view.
1216 *
1217 * @param object $websites Object containing child sites info.
1218 * @param int $total_theme_upgrades Number of available theme updates.
1219 * @param object $userExtension User extension.
1220 * @param array $all_groups_sites Array of all groups and sites.
1221 * @param array $all_groups Array of all groups.
1222 * @param array $allThemes Array of all themes.
1223 * @param array $themesInfo Array of all themes info.
1224 * @param int $site_offset_for_groups Offset value.
1225 *
1226 * @since 4.1
1227 */
1228 do_action( 'mainwp_updates_pergroup_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1229 } else {
1230 /**
1231 * Action: mainwp_updates_pertheme_before_theme_updates
1232 *
1233 * Fires at the top of the Theme updates tab, per Theme view.
1234 *
1235 * @param object $websites Object containing child sites info.
1236 * @param int $total_theme_upgrades Number of available theme updates.
1237 * @param object $userExtension User extension.
1238 * @param array $all_groups_sites Array of all groups and sites.
1239 * @param array $all_groups Array of all groups.
1240 * @param array $allThemes Array of all themes.
1241 * @param array $themesInfo Array of all themes info.
1242 * @param int $site_offset_for_groups Offset value.
1243 *
1244 * @since 4.1
1245 */
1246 do_action( 'mainwp_updates_pertheme_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1247 MainWP_Updates_Per_Item::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes );
1248 /**
1249 * Action: mainwp_updates_pertheme_after_theme_updates
1250 *
1251 * Fires at the bottom of the Theme updates tab, per Theme view.
1252 *
1253 * @param object $websites Object containing child sites info.
1254 * @param int $total_theme_upgrades Number of available theme updates.
1255 * @param object $userExtension User extension.
1256 * @param array $all_groups_sites Array of all groups and sites.
1257 * @param array $all_groups Array of all groups.
1258 * @param array $allThemes Array of all themes.
1259 * @param array $themesInfo Array of all themes info.
1260 * @param int $site_offset_for_groups Offset value.
1261 *
1262 * @since 4.1
1263 */
1264 do_action( 'mainwp_updates_pertheme_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1265 }
1266 /**
1267 * Action: mainwp_updates_after_theme_updates
1268 *
1269 * Fires at the bottom of the Theme updates tab.
1270 *
1271 * @param object $websites Object containing child sites info.
1272 * @param int $total_theme_upgrades Number of available theme updates.
1273 * @param object $userExtension User extension.
1274 * @param array $all_groups_sites Array of all groups and sites.
1275 * @param array $all_groups Array of all groups.
1276 * @param array $allThemes Array of all themes.
1277 * @param array $themesInfo Array of all themes info.
1278 * @param int $site_offset_for_groups Offset value.
1279 *
1280 * @since 4.1
1281 */
1282 do_action( 'mainwp_updates_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1283 ?>
1284 </div>
1285 <?php
1286 }
1287
1288 /**
1289 * Renders translations update tab.
1290 *
1291 * @param object $websites Object containing child sites info.
1292 * @param int $total_translation_upgrades Number of available translation updates.
1293 * @param object $userExtension User extension.
1294 * @param array $all_groups_sites Array of all groups and sites.
1295 * @param array $all_groups Array of all groups.
1296 * @param array $allTranslations Array of all translations.
1297 * @param array $translationsInfo Array of all translations info.
1298 * @param bool $mainwp_show_language_updates Either or not show language updates.
1299 * @param int $site_offset_for_groups Offset value.
1300 * @param string $site_view Current Site view.
1301 *
1302 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_trans_update()
1303 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_trans_update()
1304 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_trans_update()
1305 */
1306 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.
1307 if ( 1 === (int) $mainwp_show_language_updates ) {
1308 ?>
1309 <div class="ui active tab" data-tab="translations-updates">
1310 <?php
1311 /**
1312 * Action: mainwp_updates_before_translation_updates
1313 *
1314 * Fires at the top of the Translation updates tab.
1315 *
1316 * @param object $websites Object containing child sites info.
1317 * @param int $total_translation_upgrades Number of available translation updates.
1318 * @param object $userExtension User extension.
1319 * @param array $all_groups_sites Array of all groups and sites.
1320 * @param array $all_groups Array of all groups.
1321 * @param array $allTranslations Array of all translations.
1322 * @param array $translationsInfo Array of all translations info.
1323 * @param int $site_offset_for_groups Offset value.
1324 *
1325 * @since 4.1
1326 */
1327 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 );
1328 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1329 /**
1330 * Action: mainwp_updates_persite_before_translation_updates
1331 *
1332 * Fires at the top of the Translation updates tab, per Site view.
1333 *
1334 * @param object $websites Object containing child sites info.
1335 * @param int $total_translation_upgrades Number of available translation updates.
1336 * @param object $userExtension User extension.
1337 * @param array $all_groups_sites Array of all groups and sites.
1338 * @param array $all_groups Array of all groups.
1339 * @param array $allTranslations Array of all translations.
1340 * @param array $translationsInfo Array of all translations info.
1341 * @param int $site_offset_for_groups Offset value.
1342 *
1343 * @since 4.1
1344 */
1345 do_action( 'mainwp_updates_persite_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1346 MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades );
1347 /**
1348 * Action: mainwp_updates_persite_after_translation_updates
1349 *
1350 * Fires at the bottom of the Translation updates tab, per Site view.
1351 *
1352 * @param object $websites Object containing child sites info.
1353 * @param int $total_translation_upgrades Number of available translation updates.
1354 * @param object $userExtension User extension.
1355 * @param array $all_groups_sites Array of all groups and sites.
1356 * @param array $all_groups Array of all groups.
1357 * @param array $allTranslations Array of all translations.
1358 * @param array $translationsInfo Array of all translations info.
1359 * @param int $site_offset_for_groups Offset value.
1360 *
1361 * @since 4.1
1362 */
1363 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 );
1364 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1365 /**
1366 * Action: mainwp_updates_pergroup_before_translation_updates
1367 *
1368 * Fires at the top of the Translation updates tab, per Group view.
1369 *
1370 * @param object $websites Object containing child sites info.
1371 * @param int $total_translation_upgrades Number of available translation updates.
1372 * @param object $userExtension User extension.
1373 * @param array $all_groups_sites Array of all groups and sites.
1374 * @param array $all_groups Array of all groups.
1375 * @param array $allTranslations Array of all translations.
1376 * @param array $translationsInfo Array of all translations info.
1377 * @param int $site_offset_for_groups Offset value.
1378 *
1379 * @since 4.1
1380 */
1381 do_action( 'mainwp_updates_pergroup_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1382 MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
1383 /**
1384 * Action: mainwp_updates_pergroup_after_translation_updates
1385 *
1386 * Fires at the bottom of the Translation updates tab, per Group view.
1387 *
1388 * @param object $websites Object containing child sites info.
1389 * @param int $total_translation_upgrades Number of available translation updates.
1390 * @param object $userExtension User extension.
1391 * @param array $all_groups_sites Array of all groups and sites.
1392 * @param array $all_groups Array of all groups.
1393 * @param array $allTranslations Array of all translations.
1394 * @param array $translationsInfo Array of all translations info.
1395 * @param int $site_offset_for_groups Offset value.
1396 *
1397 * @since 4.1
1398 */
1399 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 );
1400 } else {
1401 /**
1402 * Action: mainwp_updates_pertranslation_before_translation_updates
1403 *
1404 * Fires at the top of the Translation updates tab, per Translation view.
1405 *
1406 * @param object $websites Object containing child sites info.
1407 * @param int $total_translation_upgrades Number of available translation updates.
1408 * @param object $userExtension User extension.
1409 * @param array $all_groups_sites Array of all groups and sites.
1410 * @param array $all_groups Array of all groups.
1411 * @param array $allTranslations Array of all translations.
1412 * @param array $translationsInfo Array of all translations info.
1413 * @param int $site_offset_for_groups Offset value.
1414 *
1415 * @since 4.1
1416 */
1417 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 );
1418 MainWP_Updates_Per_Item::render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo );
1419 /**
1420 * Action: mainwp_updates_pertranslation_after_translation_updates
1421 *
1422 * Fires at the bottom of the Translation updates tab, per Translation view.
1423 *
1424 * @param object $websites Object containing child sites info.
1425 * @param int $total_translation_upgrades Number of available translation updates.
1426 * @param object $userExtension User extension.
1427 * @param array $all_groups_sites Array of all groups and sites.
1428 * @param array $all_groups Array of all groups.
1429 * @param array $allTranslations Array of all translations.
1430 * @param array $translationsInfo Array of all translations info.
1431 * @param int $site_offset_for_groups Offset value.
1432 *
1433 * @since 4.1
1434 */
1435 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 );
1436 }
1437 /**
1438 * Action: mainwp_updates_after_translation_updates
1439 *
1440 * Fires at the bottom of the Translation updates tab.
1441 *
1442 * @param object $websites Object containing child sites info.
1443 * @param int $total_translation_upgrades Number of available translation updates.
1444 * @param object $userExtension User extension.
1445 * @param array $all_groups_sites Array of all groups and sites.
1446 * @param array $all_groups Array of all groups.
1447 * @param array $allTranslations Array of all translations.
1448 * @param array $translationsInfo Array of all translations info.
1449 * @param int $site_offset_for_groups Offset value.
1450 *
1451 * @since 4.1
1452 */
1453 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 );
1454 ?>
1455 </div>
1456 <?php
1457 }
1458 }
1459
1460 /**
1461 * Renders abandoned plugins tab.
1462 *
1463 * @param object $websites Object containing child sites info.
1464 * @param array $all_groups_sites Array of all groups and sites.
1465 * @param array $all_groups Array of all groups.
1466 * @param array $allPluginsOutdate Array of all abandoned plugins.
1467 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1468 * @param int $site_offset_for_groups Offset value.
1469 * @param string $site_view Current site view.
1470 *
1471 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_plugins()
1472 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_plugins()
1473 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_plugins()
1474 */
1475 public static function render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view ) {
1476 ?>
1477 <div class="ui active tab" data-tab="abandoned-plugins">
1478 <?php
1479 /**
1480 * Action: mainwp_updates_before_abandoned_plugins
1481 *
1482 * Fires at the top of the Abandoned plugins tab.
1483 *
1484 * @param object $websites Object containing child sites info.
1485 * @param array $all_groups_sites Array of all groups and sites.
1486 * @param array $all_groups Array of all groups.
1487 * @param array $allPluginsOutdate Array of all abandoned plugins.
1488 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1489 * @param int $site_offset_for_groups Offset value.
1490 *
1491 * @since 4.1
1492 */
1493 do_action( 'mainwp_updates_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1494 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1495 /**
1496 * Action: mainwp_updates_persite_before_abandoned_plugins
1497 *
1498 * Fires at the top of the Abandoned plugins tab, per Site view.
1499 *
1500 * @param object $websites Object containing child sites info.
1501 * @param array $all_groups_sites Array of all groups and sites.
1502 * @param array $all_groups Array of all groups.
1503 * @param array $allPluginsOutdate Array of all abandoned plugins.
1504 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1505 * @param int $site_offset_for_groups Offset value.
1506 *
1507 * @since 4.1
1508 */
1509 do_action( 'mainwp_updates_persite_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1510 MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $decodedDismissedPlugins );
1511 /**
1512 * Action: mainwp_updates_persite_after_abandoned_plugins
1513 *
1514 * Fires at the bottom of the Abandoned plugins tab, per Site view.
1515 *
1516 * @param object $websites Object containing child sites info.
1517 * @param array $all_groups_sites Array of all groups and sites.
1518 * @param array $all_groups Array of all groups.
1519 * @param array $allPluginsOutdate Array of all abandoned plugins.
1520 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1521 * @param int $site_offset_for_groups Offset value.
1522 *
1523 * @since 4.1
1524 */
1525 do_action( 'mainwp_updates_persite_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1526 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1527 /**
1528 * Action: mainwp_updates_pergroup_before_abandoned_plugins
1529 *
1530 * Fires at the top of the Abandoned plugins tab, per Group view.
1531 *
1532 * @param object $websites Object containing child sites info.
1533 * @param array $all_groups_sites Array of all groups and sites.
1534 * @param array $all_groups Array of all groups.
1535 * @param array $allPluginsOutdate Array of all abandoned plugins.
1536 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1537 * @param int $site_offset_for_groups Offset value.
1538 *
1539 * @since 4.1
1540 */
1541 do_action( 'mainwp_updates_pergroup_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1542 MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins );
1543 /**
1544 * Action: mainwp_updates_pergroup_after_abandoned_plugins
1545 *
1546 * Fires at the bottom of the Abandoned plugins tab, per Group view.
1547 *
1548 * @param object $websites Object containing child sites info.
1549 * @param array $all_groups_sites Array of all groups and sites.
1550 * @param array $all_groups Array of all groups.
1551 * @param array $allPluginsOutdate Array of all abandoned plugins.
1552 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1553 * @param int $site_offset_for_groups Offset value.
1554 *
1555 * @since 4.1
1556 */
1557 do_action( 'mainwp_updates_pergroup_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1558 } else {
1559 /**
1560 * Action: mainwp_updates_perplugin_before_abandoned_plugins
1561 *
1562 * Fires at the top of the Abandoned plugins tab, per Plugin view.
1563 *
1564 * @param object $websites Object containing child sites info.
1565 * @param array $all_groups_sites Array of all groups and sites.
1566 * @param array $all_groups Array of all groups.
1567 * @param array $allPluginsOutdate Array of all abandoned plugins.
1568 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1569 * @param int $site_offset_for_groups Offset value.
1570 *
1571 * @since 4.1
1572 */
1573 do_action( 'mainwp_updates_perplugin_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1574 MainWP_Updates_Per_Item::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins );
1575 /**
1576 * Action: mainwp_updates_perplugin_after_abandoned_plugins
1577 *
1578 * Fires at the bottom of the Abandoned plugins tab, per Plugin view.
1579 *
1580 * @param object $websites Object containing child sites info.
1581 * @param array $all_groups_sites Array of all groups and sites.
1582 * @param array $all_groups Array of all groups.
1583 * @param array $allPluginsOutdate Array of all abandoned plugins.
1584 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1585 * @param int $site_offset_for_groups Offset value.
1586 *
1587 * @since 4.1
1588 */
1589 do_action( 'mainwp_updates_perplugin_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1590 }
1591 /**
1592 * Action: mainwp_updates_after_abandoned_plugins
1593 *
1594 * Fires at the bottom of the Abandoned plugins tab.
1595 *
1596 * @param object $websites Object containing child sites info.
1597 * @param array $all_groups_sites Array of all groups and sites.
1598 * @param array $all_groups Array of all groups.
1599 * @param array $allPluginsOutdate Array of all abandoned plugins.
1600 * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1601 * @param int $site_offset_for_groups Offset value.
1602 *
1603 * @since 4.1
1604 */
1605 do_action( 'mainwp_updates_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1606 ?>
1607 </div>
1608 <?php
1609 }
1610
1611 /**
1612 * Renders abandoned themes tab.
1613 *
1614 * @param object $websites Object containing child sites info.
1615 * @param array $all_groups_sites Array of all groups and sites.
1616 * @param array $all_groups Array of all groups.
1617 * @param array $allThemesOutdate Array of all abandoned plugins.
1618 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1619 * @param int $site_offset_for_groups Offset value.
1620 * @param string $site_view Current site view.
1621 *
1622 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_themes()
1623 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_themes()
1624 * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_themes()
1625 */
1626 public static function render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view ) {
1627 ?>
1628 <div class="ui active tab" data-tab="abandoned-themes">
1629 <?php
1630 /**
1631 * Action: mainwp_updates_before_abandoned_themes
1632 *
1633 * Fires at the top of the Abandoned themes tab.
1634 *
1635 * @param object $websites Object containing child sites info.
1636 * @param array $all_groups_sites Array of all groups and sites.
1637 * @param array $all_groups Array of all groups.
1638 * @param array $allThemesOutdate Array of all abandoned plugins.
1639 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1640 * @param int $site_offset_for_groups Offset value.
1641 *
1642 * @since 4.1
1643 */
1644 do_action( 'mainwp_updates_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1645 if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1646 /**
1647 * Action: mainwp_updates_persite_before_abandoned_themes
1648 *
1649 * Fires at the top of the Abandoned themes tab, per Site view.
1650 *
1651 * @param object $websites Object containing child sites info.
1652 * @param array $all_groups_sites Array of all groups and sites.
1653 * @param array $all_groups Array of all groups.
1654 * @param array $allThemesOutdate Array of all abandoned plugins.
1655 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1656 * @param int $site_offset_for_groups Offset value.
1657 *
1658 * @since 4.1
1659 */
1660 do_action( 'mainwp_updates_persite_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1661 MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $decodedDismissedThemes );
1662 /**
1663 * Action: mainwp_updates_persite_after_abandoned_themes
1664 *
1665 * Fires at the bottom of the Abandoned themes tab, per Site view.
1666 *
1667 * @param object $websites Object containing child sites info.
1668 * @param array $all_groups_sites Array of all groups and sites.
1669 * @param array $all_groups Array of all groups.
1670 * @param array $allThemesOutdate Array of all abandoned plugins.
1671 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1672 * @param int $site_offset_for_groups Offset value.
1673 *
1674 * @since 4.1
1675 */
1676 do_action( 'mainwp_updates_persite_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1677 } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1678 /**
1679 * Action: mainwp_updates_pergroup_before_abandoned_themes
1680 *
1681 * Fires at the top of the Abandoned themes tab, per Group view.
1682 *
1683 * @param object $websites Object containing child sites info.
1684 * @param array $all_groups_sites Array of all groups and sites.
1685 * @param array $all_groups Array of all groups.
1686 * @param array $allThemesOutdate Array of all abandoned plugins.
1687 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1688 * @param int $site_offset_for_groups Offset value.
1689 *
1690 * @since 4.1
1691 */
1692 do_action( 'mainwp_updates_pergroup_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1693 MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes );
1694 /**
1695 * Action: mainwp_updates_pergroup_after_abandoned_themes
1696 *
1697 * Fires at the bottom of the Abandoned themes tab, per Group view.
1698 *
1699 * @param object $websites Object containing child sites info.
1700 * @param array $all_groups_sites Array of all groups and sites.
1701 * @param array $all_groups Array of all groups.
1702 * @param array $allThemesOutdate Array of all abandoned plugins.
1703 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1704 * @param int $site_offset_for_groups Offset value.
1705 *
1706 * @since 4.1
1707 */
1708 do_action( 'mainwp_updates_pergroup_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1709 } else {
1710 /**
1711 * Action: mainwp_updates_pertheme_before_abandoned_themes
1712 *
1713 * Fires at the top of the Abandoned themes tab, per Theme view.
1714 *
1715 * @param object $websites Object containing child sites info.
1716 * @param array $all_groups_sites Array of all groups and sites.
1717 * @param array $all_groups Array of all groups.
1718 * @param array $allThemesOutdate Array of all abandoned plugins.
1719 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1720 * @param int $site_offset_for_groups Offset value.
1721 *
1722 * @since 4.1
1723 */
1724 do_action( 'mainwp_updates_pertheme_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1725 MainWP_Updates_Per_Item::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes );
1726 /**
1727 * Action: mainwp_updates_pertheme_after_abandoned_themes
1728 *
1729 * Fires at the bottom of the Abandoned themes tab, per Theme view.
1730 *
1731 * @param object $websites Object containing child sites info.
1732 * @param array $all_groups_sites Array of all groups and sites.
1733 * @param array $all_groups Array of all groups.
1734 * @param array $allThemesOutdate Array of all abandoned plugins.
1735 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1736 * @param int $site_offset_for_groups Offset value.
1737 *
1738 * @since 4.1
1739 */
1740 do_action( 'mainwp_updates_pertheme_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1741 }
1742 /**
1743 * Action: mainwp_updates_after_abandoned_themes
1744 *
1745 * Fires at the bottom of the Abandoned themes tab.
1746 *
1747 * @param object $websites Object containing child sites info.
1748 * @param array $all_groups_sites Array of all groups and sites.
1749 * @param array $all_groups Array of all groups.
1750 * @param array $allThemesOutdate Array of all abandoned plugins.
1751 * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1752 * @param int $site_offset_for_groups Offset value.
1753 *
1754 * @since 4.1
1755 */
1756 do_action( 'mainwp_updates_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1757 ?>
1758 </div>
1759 <?php
1760 }
1761
1762 /**
1763 * Renders JavaScript for update page.
1764 *
1765 * @param string $site_view current site view.
1766 */
1767 public static function render_js_updates( $site_view ) {
1768 $table_features = array(
1769 'searching' => 'false',
1770 'paging' => 'false',
1771 'stateSave' => 'true',
1772 'info' => 'false',
1773 'exclusive' => 'false',
1774 'duration' => '200',
1775 );
1776 /**
1777 * Filter: mainwp_updates_table_features
1778 *
1779 * Filters the Updates table features.
1780 *
1781 * @since 4.1
1782 */
1783 $table_features = apply_filters( 'mainwp_updates_table_features', $table_features );
1784 ?>
1785 <script type="text/javascript">
1786 jQuery( document ).ready( function () {
1787 jQuery( '#mainwp-manage-updates .ui.accordion' ).accordion( {
1788 "exclusive": <?php echo esc_html( $table_features['exclusive'] ); ?>,
1789 "duration": <?php echo esc_html( $table_features['duration'] ); ?>,
1790 onOpen: function(){
1791 //mainwp_datatable_init_and_fix_recalc('table.mainwp-manage-updates-item-table');
1792 }
1793 } );
1794 } );
1795
1796 mainwp_datatable_init_and_fix_recalc = function(selector){
1797 jQuery(selector).each( function(e) {
1798 if(jQuery(this).is(":visible")){
1799 console.log('visible ' + jQuery(this).attr('id'));
1800 jQuery(this).css( 'display', 'table' );
1801 jQuery(this).DataTable().destroy();
1802 let tb = jQuery(this).DataTable({
1803 "paging":false,
1804 "info": false,
1805 "searching": false,
1806 "ordering" : false,
1807 "responsive": true
1808 });
1809 tb.columns.adjust();
1810 tb.responsive.recalc();
1811 }
1812 });
1813 }
1814
1815 jQuery( document ).on( 'click', '.trigger-all-accordion', function() {
1816 if ( jQuery( this ).hasClass( 'active' ) ) {
1817 jQuery( this ).removeClass( 'active' );
1818 jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1819 if ( jQuery( this ).hasClass( 'active' ) ) {
1820 jQuery( this ).trigger( 'click' );
1821 }
1822 } );
1823 } else {
1824 jQuery( this ).addClass( 'active' );
1825 jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1826 if ( !jQuery( this ).hasClass( 'active' ) ) {
1827 jQuery( this ).trigger( 'click' );
1828 }
1829 } );
1830 }
1831 } );
1832
1833 </script>
1834 <?php
1835
1836 if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1837 ?>
1838 <script type="text/javascript">
1839 jQuery( document ).ready( function () {
1840 updatesoverview_updates_init_group_view();
1841 } );
1842 </script>
1843 <?php
1844 }
1845 }
1846
1847
1848 /**
1849 * Gets sites for updates
1850 *
1851 * @return object Object containing websites info.
1852 *
1853 * @uses \MainWP\Dashboard\MainWP_DB::query()
1854 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id()
1855 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1856 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1857 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1858 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1859 */
1860 public static function get_sites_for_current_user() {
1861 /**
1862 * Current user global.
1863 *
1864 * @global string
1865 */
1866 global $current_user;
1867
1868 $current_wpid = MainWP_System_Utility::get_current_wpid();
1869 if ( $current_wpid ) {
1870 $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
1871 } else {
1872 $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
1873 $is_staging = 'no';
1874 if ( $staging_enabled ) {
1875 $staging_updates_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users();
1876 if ( 'staging' === $staging_updates_view ) {
1877 $is_staging = 'yes';
1878 }
1879 }
1880 $params = array(
1881 'connected' => 'yes',
1882 );
1883
1884 $limit_sites = get_option( 'mainwp_manage_updates_limit_sites' );
1885 if ( ! empty( $limit_sites ) ) {
1886 $params['limit_sites'] = $limit_sites;
1887 }
1888 $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 );
1889 }
1890 return MainWP_DB::instance()->query( $sql );
1891 }
1892
1893 /**
1894 * Renders header tabs
1895 *
1896 * @param bool $show_language_updates show language update.
1897 * @param string $current_tab current tab.
1898 * @param int $total_wp_upgrades total WP update.
1899 * @param int $total_plugin_upgrades total plugins update.
1900 * @param int $total_theme_upgrades total themes update.
1901 * @param int $total_translation_upgrades total translation update.
1902 * @param int $total_plugins_outdate total plugins outdate.
1903 * @param int $total_themes_outdate total theme outdate.
1904 * @param string $site_view current site view.
1905 */
1906 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.
1907
1908 /**
1909 * Action: mainwp_updates_before_nav_tabs
1910 *
1911 * Fires before the navigation tabs on the Updates page.
1912 *
1913 * @since 4.1
1914 */
1915 do_action( 'mainwp_updates_before_nav_tabs' );
1916
1917 $header_tabs = array(
1918 'plugins-updates' => array(
1919 'slug' => 'plugins-updates',
1920 'title' => esc_html__( 'Plugins Updates', 'mainwp' ),
1921 'total_upgrades' => $total_plugin_upgrades,
1922 ),
1923 'themes-updates' => array(
1924 'slug' => 'themes-updates',
1925 'title' => esc_html__( 'Themes Updates', 'mainwp' ),
1926 'total_upgrades' => $total_theme_upgrades,
1927 ),
1928 'wordpress-updates' => array(
1929 'slug' => 'wordpress-updates',
1930 'title' => esc_html__( 'WordPress Updates', 'mainwp' ),
1931 'total_upgrades' => $total_wp_upgrades,
1932 ),
1933 );
1934
1935 if ( $show_language_updates ) {
1936 $header_tabs['translations-updates'] = array(
1937 'slug' => 'translations-updates',
1938 'title' => esc_html__( 'Translations Updates', 'mainwp' ),
1939 'total_upgrades' => $total_translation_upgrades,
1940 );
1941 }
1942
1943 $header_tabs['abandoned-plugins'] = array(
1944 'slug' => 'abandoned-plugins',
1945 'title' => esc_html__( 'Abandoned Plugins', 'mainwp' ),
1946 'total_upgrades' => $total_plugins_outdate,
1947 );
1948
1949 $header_tabs['abandoned-themes'] = array(
1950 'slug' => 'abandoned-themes',
1951 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ),
1952 'total_upgrades' => $total_themes_outdate,
1953 );
1954
1955 $header_tabs = apply_filters( 'mainwp_page_hearder_tabs_updates', $header_tabs );
1956
1957 ?>
1958 <div id="mainwp-page-navigation-wrapper">
1959 <div class="ui vertical menu mainwp-page-navigation">
1960 <?php
1961 foreach ( $header_tabs as $slug => $tab ) {
1962 if ( empty( $tab['title'] ) ) {
1963 continue;
1964 }
1965 ?>
1966 <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>
1967 <?php
1968 }
1969 ?>
1970 </div>
1971 </div>
1972 <?php
1973
1974 $hide_show_updates_per = 'updates-ignore' === $current_tab ? true : false;
1975
1976 $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', $hide_show_updates_per, $current_tab );
1977
1978 /**
1979 * Action: mainwp_updates_after_nav_tabs
1980 *
1981 * Fires after the navigation tabs on the Updates page.
1982 *
1983 * @since 4.1
1984 */
1985 do_action( 'mainwp_updates_after_nav_tabs' );
1986
1987 /**
1988 * Action: mainwp_updates_before_actions_bar
1989 *
1990 * Fires before the actions bar on the Updates page.
1991 *
1992 * @since 4.1
1993 */
1994 do_action( 'mainwp_updates_before_actions_bar' );
1995
1996 if ( ! $hide_show_updates_per ) {
1997 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1998 ?>
1999 <div class="mainwp-sub-header">
2000 <div class="ui grid">
2001 <div class="equal width row">
2002 <div class="middle aligned column">
2003 <form method="post" action="" class="ui mini form">
2004 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2005 <div class="inline field">
2006 <select class="ui dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview">
2007 <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option>
2008 <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>
2009 <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option>
2010 </select>
2011 </div>
2012 </form>
2013 </div>
2014 <div class="middle aligned right aligned column">
2015 <?php
2016 /**
2017 * Filter: mainwp_widgetupdates_actions_top
2018 *
2019 * Filters the udpates actions top content.
2020 *
2021 * @since Unknown
2022 */
2023 echo apply_filters( 'mainwp_widgetupdates_actions_top', '' ); // phpcs:ignore WordPress.Security.EscapeOutput
2024 if ( 'abandoned-plugins' === $current_tab ) {
2025 if ( $is_demo ) {
2026 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>' );
2027 } else {
2028 ?>
2029 <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>
2030 <?php
2031 }
2032 } elseif ( 'abandoned-themes' === $current_tab ) {
2033 if ( $is_demo ) {
2034 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>' );
2035 } else {
2036 ?>
2037 <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>
2038 <?php
2039 }
2040 }
2041 ?>
2042 </div>
2043 </div>
2044 </div>
2045 </div>
2046 <?php
2047 static::render_button_view_ignored_updates( $current_tab );
2048 }
2049
2050 /**
2051 * Action: mainwp_updates_after_actions_bar
2052 *
2053 * Fires after the actions bar on the Updates page.
2054 *
2055 * @since 4.1
2056 */
2057 do_action( 'mainwp_updates_after_actions_bar' );
2058 }
2059
2060
2061 /**
2062 * Method render_button_view_ignored_updates().
2063 *
2064 * @param string $current_tab current tab.
2065 *
2066 * @return null
2067 */
2068 public static function render_button_view_ignored_updates( $current_tab = '' ) {
2069 if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ) ) ) {
2070 return;
2071 }
2072 ?>
2073 <div class="mainwp-sub-header">
2074 <div class="ui grid">
2075 <div class="equal width row">
2076 <div class="middle aligned column">
2077 </div>
2078 <div class="middle aligned right aligned column">
2079 <?php
2080 if ( 'wordpress-updates' === $current_tab ) {
2081 ?>
2082 <a class="ui green mini basic button" href="admin.php?page=UpdatesManage&tab=updates-ignore" data-position="top right" data-tooltip="Update WordPress Core files on selected child sites." data-inverted=""><?php esc_html_e( 'View Ignored Core Updates', 'mainwp' ); ?></a>
2083 <?php
2084 } elseif ( 'plugins-updates' === $current_tab ) {
2085 ?>
2086 <a class="ui green mini basic button" href="admin.php?page=PluginsIgnore" data-position="top right" data-tooltip="Update WordPress Core files on selected child sites." data-inverted=""><?php esc_html_e( 'View Ignored Plugins Updates', 'mainwp' ); ?></a>
2087 <?php
2088 } elseif ( 'themes-updates' === $current_tab ) {
2089 ?>
2090 <a class="ui green mini basic button" href="admin.php?page=ThemesIgnore" data-position="top right" data-tooltip="Update WordPress Core files on selected child sites." data-inverted=""><?php esc_html_e( 'View Ignored Themes Updates', 'mainwp' ); ?></a>
2091 <?php
2092 }
2093 ?>
2094 </div>
2095 </div>
2096 </div>
2097 </div>
2098 <?php
2099 }
2100
2101 /**
2102 * Method handle_limit_sites().
2103 */
2104 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.
2105 // put hook here before loading sites.
2106 $limit_number = apply_filters( 'mainwp_manage_updates_limit_loading', false, 'updates' );
2107 $current_limit = get_option( 'mainwp_manage_updates_limit_sites' );
2108
2109 if ( (int) $limit_number !== (int) $current_limit ) {
2110 update_option( 'mainwp_manage_updates_limit_sites', $limit_number );
2111 update_option( 'mainwp_manage_updates_limit_current_page', 1 );
2112 }
2113
2114 if ( ! empty( $limit_number ) ) {
2115
2116 $count = MainWP_DB::instance()->get_websites_count( null, true );
2117
2118 $current_page = 1;
2119 if ( isset( $_GET['current_page'] ) && isset( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) ) {
2120 $current_page = intval( $_GET['current_page'] );
2121 }
2122
2123 if ( 0 >= $current_page ) {
2124 $current_page = 1;
2125 }
2126
2127 $total_page = ceil( $count / $limit_number );
2128
2129 if ( $current_page > $total_page ) {
2130 $current_page = $total_page;
2131 }
2132 update_option( 'mainwp_manage_updates_limit_current_page', $current_page );
2133 }
2134 }
2135
2136 /**
2137 * Method render_limit_load_sites().
2138 *
2139 * @param int $limit_number limit loading sites.
2140 */
2141 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.
2142
2143 $count = MainWP_DB::instance()->get_websites_count( null, true );
2144 $total_page = ceil( $count / $limit_number );
2145
2146 $current_page = (int) get_option( 'mainwp_manage_updates_limit_current_page' );
2147
2148 $first = 1 === $current_page;
2149 $last = $total_page <= $current_page;
2150
2151 ?>
2152 <div class="dt-paging paging_full_numbers">
2153 <div class="ui stackable pagination menu"><menu>
2154 <?php if ( $first ) { ?>
2155 <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>
2156 <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>
2157 <?php } else { ?>
2158 <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>
2159 <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>
2160 <?php } ?>
2161 <?php
2162 for ( $i = 1; $i <= $total_page;$i++ ) {
2163 ?>
2164 <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>
2165 <?php
2166 }
2167 ?>
2168 <?php if ( $last ) { ?>
2169 <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>
2170 <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>
2171 <?php } else { ?>
2172 <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>
2173 <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>
2174 <?php } ?>
2175 </menu></div>
2176 </div>
2177 <br/>
2178 <?php
2179 }
2180
2181 /**
2182 * Renders the HTTP Check html content.
2183 *
2184 * @param object $websites Child Sites.
2185 *
2186 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2187 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
2188 */
2189 public static function render_http_checks( $websites ) { //phpcs:ignore -- NOSONAR - complex.
2190
2191 $enable_legacy_backup = get_option( 'mainwp_enableLegacyBackupFeature' );
2192 $mainwp_primaryBackup = get_option( 'mainwp_primaryBackup' );
2193
2194 /**
2195 * Custom backup pages
2196 *
2197 * Filters backup options to set correct page for restore options.
2198 *
2199 * @since 4.0
2200 */
2201 $customPage = apply_filters_deprecated( 'mainwp-getcustompage-backups', array( false ), '4.0.7.2', 'mainwp_getcustompage_backups' ); // @deprecated Use 'mainwp_getcustompage_backups' instead. NOSONAR - not IP.
2202 $customPage = apply_filters( 'mainwp_getcustompage_backups', $customPage );
2203
2204 $restorePageSlug = '';
2205 if ( empty( $enable_legacy_backup ) && ! empty( $mainwp_primaryBackup ) && is_array( $customPage ) && isset( $customPage['managesites_slug'] ) ) {
2206 $restorePageSlug = 'admin.php?page=ManageSites' . $customPage['managesites_slug'];
2207 } elseif ( $enable_legacy_backup ) {
2208 $restorePageSlug = 'admin.php?page=managesites';
2209 }
2210 ?>
2211 <div class="" id="mainwp-http-response-issues">
2212 <?php
2213 /**
2214 * Action: mainwp_updates_before_http_response_table
2215 *
2216 * Fires before the HTTP responses table on the Updates pages
2217 *
2218 * @since 4.1
2219 */
2220 do_action( 'mainwp_updates_before_http_response_table' );
2221 ?>
2222 <table class="ui single line inverted unstackable table" id="mainwp-http-response-issues-table">
2223 <thead>
2224 <tr>
2225 <th scope="col" class="no-sort" colspan="3"><?php esc_html_e( 'HTTP Response Check Results', 'mainwp' ); ?></th>
2226 </tr>
2227 <tr>
2228 <th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
2229 <th scope="col"><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th>
2230 <th scope="col" class="collapsing no-sort"></th>
2231 </tr>
2232 </thead>
2233 <tbody>
2234 <?php
2235 MainWP_DB::data_seek( $websites, 0 );
2236 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2237 if ( 1 === (int) $website->offline_check_result || '-1' === $website->http_response_code ) {
2238 continue;
2239 }
2240
2241 $restoreSlug = '';
2242
2243 if ( ! empty( $restorePageSlug ) ) {
2244 if ( $enable_legacy_backup ) {
2245 $restoreSlug = $restorePageSlug . '&backupid=' . intval( $website->id );
2246 } elseif ( static::activated_primary_backup_plugin( $mainwp_primaryBackup, $website ) ) {
2247 $restoreSlug = $restorePageSlug . '&id=' . intval( $website->id );
2248 }
2249 }
2250 ?>
2251 <tr id="child-site-<?php echo intval( $website->id ); ?>" class="child-site mainwp-child-site-<?php echo intval( $website->id ); ?>" siteid="<?php echo intval( $website->id ); ?>" site-url="<?php echo esc_url( $website->url ); ?>">
2252 <td>
2253 <?php static::render_site_link_dashboard( $website ); ?>
2254 </td>
2255 <td id="wp_http_response_code_<?php echo esc_attr( $website->id ); ?>">
2256 <label class="ui red label http-code"><?php echo 'HTTP ' . esc_html( $website->http_response_code ); ?></label>
2257 </td>
2258 <td class="right aligned">
2259 <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $website->id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="ui mini button" target="_blank"><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></a>
2260 <a href="javascript:void(0)" onclick="return updatesoverview_recheck_http( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini green button"><?php esc_html_e( 'Recheck', 'mainwp' ); ?></a>
2261 <?php if ( ! empty( $website->sync_errors ) ) { ?>
2262 <a href="#" class="mainwp_site_reconnect ui green mini button"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
2263 <?php } ?>
2264 <a href="javascript:void(0)" onClick="return updatesoverview_ignore_http_response( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?></a>
2265 <?php if ( ! empty( $restoreSlug ) ) { ?>
2266 <a href="<?php echo esc_url( $restoreSlug ); ?>" class="ui green mini basic button"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a>
2267 <?php } ?>
2268 </td>
2269 </tr>
2270 <?php
2271 }
2272 ?>
2273 </tbody>
2274 <tfoot>
2275 <tr>
2276 <th scope="col" ><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
2277 <th scope="col" ><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th>
2278 <th scope="col" class="collapsing no-sort"></th>
2279 </tr>
2280 </tfoot>
2281 </table>
2282 <?php
2283 /**
2284 * Action: mainwp_updates_after_http_response_table
2285 *
2286 * Fires after the HTTP responses table on the Updates pages.
2287 *
2288 * @since 4.1
2289 */
2290 do_action( 'mainwp_updates_after_http_response_table' );
2291
2292 $table_features = array(
2293 'searching' => 'false',
2294 'paging' => 'false',
2295 'stateSave' => 'true',
2296 'info' => 'false',
2297 'responsive' => 'true',
2298 );
2299
2300 /**
2301 * Filter: mainwp_updates_http_responses_datatable_features
2302 *
2303 * Filters the DataTable options for the HTTP Responses table on the Updates page.
2304 *
2305 * @since 4.1
2306 */
2307 $table_features = apply_filters( 'mainwp_updates_http_responses_datatable_features', $table_features );
2308 ?>
2309 <script>
2310 jQuery( document ).ready( function() {
2311 let responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
2312 if( jQuery( window ).width() > 1140 ) {
2313 responsive = false;
2314 }
2315 jQuery( '#mainwp-http-response-issues-table' ).DataTable( {
2316 "responsive": responsive,
2317 "searching": <?php echo esc_html( $table_features['searching'] ); ?>,
2318 "paging" : <?php echo esc_html( $table_features['paging'] ); ?>,
2319 "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>,
2320 "info" : <?php echo esc_html( $table_features['info'] ); ?>,
2321 "columnDefs" : [ { "orderable": false, "targets": "no-sort" } ],
2322 "language" : { "emptyTable": "No HTTP issues detected." },
2323 } );
2324 } );
2325 </script>
2326 </div>
2327 <div class="ui hidden clearing divider"></div>
2328 <?php
2329 }
2330
2331 /**
2332 * Cheks which primary backup plugin is being used.
2333 *
2334 * @param mixed $what Which backup plugin is being use.
2335 * @param object $website Website array of information.
2336 *
2337 * @return boolean True|False.
2338 */
2339 public static function activated_primary_backup_plugin( $what, $website ) {
2340 $plugins = json_decode( $website->plugins, 1 );
2341 if ( ! is_array( $plugins ) || empty( $plugins ) ) {
2342 return false;
2343 }
2344
2345 $checks = array(
2346 'backupbuddy' => 'backupbuddy/backupbuddy.php',
2347 'backupwp' => array( 'backwpup/backwpup.php', 'backwpup-pro/backwpup.php' ),
2348 'updraftplus' => 'updraftplus/updraftplus.php',
2349
2350 );
2351
2352 $slug = isset( $checks[ $what ] ) ? $checks[ $what ] : '';
2353
2354 if ( empty( $slug ) ) {
2355 return false;
2356 }
2357
2358 $installed = false;
2359
2360 foreach ( $plugins as $plugin ) {
2361 if ( ( is_string( $slug ) && strtolower( $plugin['slug'] ) === $slug ) || ( is_array( $slug ) && in_array( $plugin['slug'], $slug ) ) ) {
2362 if ( $plugin['active'] ) {
2363 $installed = true;
2364 }
2365 break;
2366 }
2367 }
2368
2369 return $installed;
2370 }
2371
2372 /**
2373 * Sets the HTML selector to continue updates.
2374 *
2375 * @param string $current_update current update string.
2376 * @param bool $slug Whether to update slug.
2377 */
2378 public static function set_continue_update_html_selector( $current_update, $slug = false ) {
2379
2380 $check_slug = true;
2381 if ( ! empty( $slug ) ) {
2382 $check_slug = ( $slug === static::$continue_update_slug ) ? true : false;
2383 }
2384
2385 if ( $check_slug && $current_update === static::$continue_update ) {
2386 static::$continue_selector = 'updatesoverview_continue_update_me';
2387 } else {
2388 static::$continue_selector = '';
2389 }
2390 }
2391
2392 /**
2393 * Gets the HTML selector to continue updates.
2394 *
2395 * @return void.
2396 */
2397 public static function get_continue_update_selector() {
2398 echo esc_attr( static::$continue_selector );
2399 }
2400
2401 /**
2402 * Displays the updates modal window during updates.
2403 */
2404 public static function render_updates_modal() {
2405 ?>
2406 <div class="ui modal" id="updatesoverview-backup-box">
2407 <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
2408 <div class="scrolling content mainwp-modal-content"></div>
2409 <div class="actions mainwp-modal-actions">
2410 <input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/>
2411 <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;
2412 <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
2413 </div>
2414 </div>
2415 <?php
2416 }
2417
2418 /**
2419 * Displays the plugin details modal window.
2420 */
2421 public static function render_plugin_details_modal() {
2422 ?>
2423 <div class="ui modal" id="mainwp-plugin-details-modal">
2424 <i class="close icon"></i>
2425 <div class="header"><?php echo esc_html__( 'Plugin Details', 'mainwp' ); ?></div>
2426 <div class="content">
2427 <div class="ui embed"></div>
2428 </div>
2429 <div class="actions">
2430 </div>
2431 </div>
2432 <?php
2433 }
2434
2435 /**
2436 * Method render_screen_options_modal()
2437 *
2438 * Renders Page Settings Modal.
2439 */
2440 public static function render_screen_options_modal() { // phpcs:ignore -- NOSONAR - complex method.
2441
2442 $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' );
2443 $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' );
2444 $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' );
2445 $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 );
2446 $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
2447 $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
2448 ?>
2449 <div class="ui modal" id="mainwp-manage-updates-screen-options-modal">
2450 <i class="close icon"></i>
2451 <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
2452 <div class="scrolling content ui form">
2453 <form method="POST" action="" id="manage-updates-screen-options-form" name="manage-updates-screen-options-form">
2454 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2455 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdatesScrOptions' ) ); ?>" />
2456 <div class="ui grid field">
2457 <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label>
2458 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugins updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2459 <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
2460 <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2461 <option value="0" <?php echo ( false !== $snPluginAutomaticDailyUpdate && empty( $snPluginAutomaticDailyUpdate ) ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2462 </select>
2463 </div>
2464 </div>
2465 <div class="ui grid field">
2466 <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label>
2467 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic themes updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2468 <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
2469 <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2470 <option value="0" <?php echo ( false !== $snThemeAutomaticDailyUpdate && 0 === $snThemeAutomaticDailyUpdate ) || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2471 </select>
2472 </div>
2473 </div>
2474 <div class="ui grid field">
2475 <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label>
2476 <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">
2477 <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
2478 <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2479 <option value="0" <?php echo ( false !== $snAutomaticDailyUpdate && 0 === $snAutomaticDailyUpdate ) || 2 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2480 </select>
2481 </div>
2482 </div>
2483 <div class="ui grid field">
2484 <label class="six wide column middle aligned"><?php esc_html_e( 'Advanced automatic updates delay', 'mainwp' ); ?></label>
2485 <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">
2486 <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
2487 <option value="0" <?php echo 0 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
2488 <option value="1" <?php echo 1 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
2489 <option value="2" <?php echo 2 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
2490 <option value="3" <?php echo 3 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
2491 <option value="4" <?php echo 4 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
2492 <option value="5" <?php echo 5 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
2493 <option value="6" <?php echo 6 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
2494 <option value="7" <?php echo 7 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
2495 <option value="14" <?php echo 14 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
2496 <option value="30" <?php echo 30 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
2497 </select>
2498 </div>
2499 </div>
2500 <div class="ui grid field">
2501 <label class="six wide column middle aligned"><?php esc_html_e( 'Show WordPress language updates', 'mainwp' ); ?></label>
2502 <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">
2503 <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo 1 === $mainwp_show_language_updates ? 'checked="true"' : ''; ?>/>
2504 </div>
2505 </div>
2506 <div class="ui grid field">
2507 <label class="six wide column middle aligned"><?php esc_html_e( 'Update confirmations', 'mainwp' ); ?></label>
2508 <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">
2509 <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
2510 <option value="0" <?php echo 0 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
2511 <option value="2" <?php echo 2 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
2512 <option value="1" <?php echo 1 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
2513 </select>
2514 </div>
2515 </div>
2516 <div class="ui hidden divider"></div>
2517 <div class="ui hidden divider"></div>
2518 </div>
2519 <div class="actions">
2520 <div class="ui two columns grid">
2521 <div class="left aligned column"></div>
2522 <div class="ui right aligned column">
2523 <input type="submit" class="ui green button" name="btnSubmit" id="submit-manage-updates-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2524 </div>
2525 </div>
2526 </div>
2527 </form>
2528 </div>
2529 <?php
2530 }
2531
2532
2533 /**
2534 * Method mainwp_help_content()
2535 *
2536 * Creates the MainWP Help Documentation List for the help component in the sidebar.
2537 */
2538 public static function mainwp_help_content() {
2539 if ( isset( $_GET['page'] ) && 'UpdatesManage' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2540 ?>
2541 <p><?php esc_html_e( 'If you need help with managing updates, please review following help documents', 'mainwp' ); ?></p>
2542 <div class="ui list">
2543 <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>
2544 <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>
2545 <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>
2546 <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>
2547 <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>
2548 <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>
2549 <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>
2550 <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>
2551 <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>
2552 <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>
2553 <?php
2554 /**
2555 * Action: mainwp_updates_help_item
2556 *
2557 * Fires at the bottom of the help articles list in the Help sidebar on the Updates page.
2558 *
2559 * Suggested HTML markup:
2560 *
2561 * <div class="item"><a href="Your custom URL">Your custom text</a></div>
2562 *
2563 * @since 4.1
2564 */
2565 do_action( 'mainwp_updates_help_item' );
2566 ?>
2567 </div>
2568 <?php
2569 }
2570 }
2571 }
2572