PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.6.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.6.0.1
6.2.3 6.2.2 6.2.1 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 All 156 releases
mainwp / pages / page-mainwp-updates.php

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

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