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

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