PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.0.12
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.0.12
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-per-group.php

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

1,199 lines 99.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Updates Per Group.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class MainWP_Updates_Per_Group
17 *
18 * @package MainWP\Dashboard
19 */
20 class MainWP_Updates_Per_Group { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
21
22 /**
23 * Method get_class_name()
24 *
25 * Get Class Name.
26 *
27 * @return object
28 */
29 public static function get_class_name() {
30 return __CLASS__;
31 }
32
33 /**
34 * Method render_wpcore_updates()
35 *
36 * Render WP core updates
37 *
38 * @param object $websites the websites.
39 * @param object $userExtension User Extension.
40 * @param int $total_wp_upgrades total update.
41 * @param array $all_groups_sites all groups of sites.
42 * @param array $all_groups all groups.
43 * @param int $site_offset_for_groups offset value.
44 *
45 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
46 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
47 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
48 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
49 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_wp()
50 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
51 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
52 */
53 public static function render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups ) { // phpcs:ignore -- NOSONAR - complex method. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
54 $user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' );
55 $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
56 if ( ! is_array( $decodedIgnoredCores ) ) {
57 $decodedIgnoredCores = array();
58 }
59
60 ?>
61 <?php if ( 0 < $total_wp_upgrades ) : ?>
62 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-wordpress-updates-groups-table"> <!-- Per Group table -->
63 <thead>
64 <tr>
65 <th scope="col" class="collapsing no-sort trigger-all-accordion">
66 <span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span>
67 </th>
68 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag">
69 <div class="ui main-master checkbox ">
70 <input type="checkbox" name=""><label><?php esc_html_e( 'Tag', 'mainwp' ); ?></label>
71 </div>
72 <?php MainWP_UI::render_sorting_icons(); ?>
73 </th>
74 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
75 <th scope="col" class="no-sort"></th>
76 </tr>
77 </thead>
78 <tbody class="ui accordion"> <!-- per group -->
79 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
80 <?php
81 $total_group_wp_updates = 0;
82 $group_name = $all_groups[ $group_id ];
83 ?>
84 <tr row-uid="uid_wp_upgrades_<?php echo esc_attr( $group_id ); ?>" class="ui title master-checkbox">
85 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
86 <td>
87 <div class="ui master checkbox">
88 <input type="checkbox" name=""><label><?php echo esc_html( stripslashes( $group_name ) ); ?></label>
89 </div>
90
91 </td>
92 <td sort-value="0"><span total-uid="uid_wp_upgrades_<?php echo esc_attr( $group_id ); ?>" data-inverted="" data-tooltip="<?php esc_attr_e( 'Click to see available updates', 'mainwp' ); ?>"></span></td>
93 <td class="right aligned">
94 <?php if ( MainWP_Updates::user_can_update_wp() ) : ?>
95 <a href="javascript:void(0)" btn-all-uid2="uid_wp_upgrades_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-selected-button ui basic green mini button" onClick="event.stopPropagation();updatesoverview_wordpress_global_upgrade_all( <?php echo esc_attr( $group_id ); ?>, true ); return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
96 <a href="javascript:void(0)" btn-all-uid="uid_wp_upgrades_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-all-button ui green mini button" onClick="updatesoverview_wordpress_global_upgrade_all( <?php echo esc_attr( $group_id ); ?> ); return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
97 <?php endif; ?>
98 </td>
99 </tr>
100 <tr class="child-checkbox content">
101 <td colspan="4">
102 <table id="mainwp-wordpress-updates-groups-inner-table" class="ui table mainwp-manage-updates-table mainwp-per-group-table">
103 <thead class="mainwp-768-hide">
104 <tr>
105 <th scope="col" ><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
106 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
107 <th scope="col" class="no-sort"><?php esc_html_e( 'Latest', 'mainwp' ); ?></th>
108 <?php if ( $user_can_see_client ) { ?>
109 <th scope="col" ><?php esc_html_e( 'Client', 'mainwp' ); ?></th>
110 <?php } ?>
111 <th scope="col" class="no-sort"></th>
112 </tr>
113 </thead>
114 <tbody id="update_wrapper_wp_upgrades_group_<?php echo esc_attr( $group_id ); ?>">
115 <?php foreach ( $site_ids as $site_id ) : ?>
116 <?php
117 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
118 continue;
119 }
120 $seek = $site_offset_for_groups[ $site_id ];
121 MainWP_DB::data_seek( $websites, $seek );
122 $website = MainWP_DB::fetch_object( $websites );
123
124 if ( $website->is_ignoreCoreUpdates ) {
125 continue;
126 }
127
128 $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array();
129 $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
130
131 if ( MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedIgnoredCores, 'core' ) ) {
132 $wp_upgrades = array();
133 }
134
135 if ( ( empty( $wp_upgrades ) ) && empty( $website->sync_errors ) ) {
136 continue;
137 }
138
139 $wpcore_update_disabled_by = MainWP_System_Utility::disabled_wpcore_update_by( $website );
140
141 ++$total_group_wp_updates;
142 $last_version = ! empty( $wp_upgrades ) && ! empty( $wp_upgrades['new'] ) ? $wp_upgrades['new'] : '';
143 ?>
144 <tr class="mainwp-wordpress-update" last-version="<?php echo esc_attr( rawurlencode( $last_version ) ); ?>" site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" updated="<?php echo ! empty( $wp_upgrades ) && empty( $wpcore_update_disabled_by ) ? '0' : '1'; ?>">
145 <td>
146 <div class="ui child checkbox">
147 <input type="checkbox" name=""><label><?php MainWP_Updates::render_site_link_dashboard( $website ); ?></label>
148 </div>
149 <input type="hidden" id="wp-updated-<?php echo esc_attr( $website->id ); ?>" value="<?php echo ! empty( $wp_upgrades ) ? '0' : '1'; ?>" />
150 </td>
151 <td>
152 <?php if ( ! empty( $wp_upgrades ) ) : ?>
153 <strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $wp_upgrades['current'] ); ?>
154 <?php endif; ?>
155 </td>
156 <td>
157 <?php if ( ! empty( $wp_upgrades ) ) : ?>
158 <strong class="mainwp-768-show"><?php esc_html_e( 'Latest:', 'mainwp' ); ?></strong> <?php echo esc_html( $wp_upgrades['new'] ); ?>
159 <?php endif; ?>
160 </td>
161 <?php if ( $user_can_see_client ) { ?>
162 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
163 <?php } ?>
164 <td>
165 <?php if ( MainWP_Updates::user_can_update_wp() ) : ?>
166 <?php if ( ! empty( $wp_upgrades ) ) : ?>
167 <?php if ( ! empty( $wpcore_update_disabled_by ) ) : ?>
168 <span data-tooltip="<?php echo esc_html( $wpcore_update_disabled_by ); ?>" data-inverted="" data-position="left center"><a href="javascript:void(0)" class="ui green button mini disabled"><?php esc_html_e( 'Update', 'mainwp' ); ?></a></span>
169 <?php else : ?>
170 <div class="ui top left pointing dropdown mini button">
171 <?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i>
172 <div class="menu">
173 <a href="javascript:void(0)" onClick="return updatesoverview_upgrade_ignore( <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )" class="item"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a>
174 <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_upgrade_ignore_this_version_globally( '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a>
175 <a href="javascript:void(0)" onClick="return updatesoverview_upgrade_ignore_all_version( <?php echo intval( $website->id ); ?>, this )" class="item"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a>
176 </div>
177 </div>
178 <a href="javascript:void(0)" class="mainwp-update-now-button ui green button mini" onClick="return updatesoverview_upgrade(<?php echo esc_attr( $website->id ); ?>, this )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
179 <?php endif; ?>
180 <?php endif; ?>
181 <?php endif; ?>
182 </td>
183 </tr>
184 <?php endforeach; ?>
185 </tbody>
186 </table>
187 </td>
188 </tr>
189 <input type="hidden" class="element_ui_view_values" elem-uid="uid_wp_upgrades_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_wp_updates ); ?>" can-update="<?php echo MainWP_Updates::user_can_update_wp() ? 1 : 0; ?>">
190 <?php endforeach; ?>
191 </tbody>
192 </table>
193 <?php else : ?>
194 <?php MainWP_UI::render_empty_page_placeholder( __( 'WordPress is up to date', 'mainwp' ), __( 'No WordPress core updates available right now.', 'mainwp' ) ); ?>
195 <?php endif; ?>
196 <?php
197 }
198
199 /**
200 * Method render_plugins_updates()
201 *
202 * Render Plugin updates
203 *
204 * @param object $websites the websites.
205 * @param int $total_plugin_upgrades total plugin updates.
206 * @param mixed $userExtension The user extension.
207 * @param array $all_groups_sites all groups of sites.
208 * @param array $all_groups all groups.
209 * @param int $site_offset_for_groups offset value.
210 * @param array $trustedPlugins all plugins trusted by user.
211 *
212 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
213 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
214 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
215 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
216 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
217 * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper
218 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_plugins()
219 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
220 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
221 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
222 */
223 public static function render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins ) { // phpcs:ignore -- NOSONAR - complex.
224 $updates_table_helper = new MainWP_Updates_Table_Helper( $userExtension->site_view );
225 $user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' );
226 ?>
227 <?php if ( 0 < $total_plugin_upgrades ) : ?>
228 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-plugins-updates-groups-table">
229 <thead>
230 <tr>
231 <th scope="col" class="collapsing no-sort trigger-all-accordion">
232 <span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span>
233 </th>
234 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag">
235 <div class="ui main-master checkbox ">
236 <input type="checkbox" name=""><label><?php esc_html_e( 'Tag', 'mainwp' ); ?></label>
237 </div>
238 <?php MainWP_UI::render_sorting_icons(); ?>
239 </th>
240 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
241 <th scope="col" class="no-sort"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
242 </tr>
243 </thead>
244 <tbody id="plugins-updates-global" class="ui accordion">
245 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
246 <?php
247 if ( empty( $site_ids ) ) {
248 continue;
249 }
250
251 $total_group_plugin_updates = 0;
252 $group_name = $all_groups[ $group_id ];
253 ?>
254 <tr class="title main-master-checkbox" row-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>">
255 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
256 <td>
257 <div class="ui main-master checkbox ">
258 <input type="checkbox" name=""><label><?php echo esc_html( stripslashes( $group_name ) ); ?></label>
259 </div>
260 </td>
261 <td total-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>" sort-value="0"></td>
262 <td>
263 <?php if ( MainWP_Updates::user_can_update_plugins() ) : ?>
264 <a href="javascript:void(0)" none-btn-all-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-selected-button ui green basic mini button" onClick="event.stopPropagation(); updatesoverview_plugins_global_upgrade_all( <?php echo esc_attr( $group_id ); ?>, true ); return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
265 <a href="javascript:void(0)" btn-all-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-all-button ui green mini button" onClick="updatesoverview_plugins_global_upgrade_all( <?php echo esc_attr( $group_id ); ?> ); return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
266 <?php endif; ?>
267 </td>
268 </tr>
269 <tr class="main-child-checkbox content" row-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>">
270 <td colspan="4">
271 <table id="mainwp-plugins-updates-sites-inner-table" class="ui grey table mainwp-per-group-table mainwp-manage-updates-table mainwp-js-persistent-table">
272 <thead class="mainwp-768-hide">
273 <tr>
274 <th scope="col" class="collapsing no-sort"></th>
275 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="website"><?php esc_html_e( 'Website', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
276 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
277 <?php if ( $user_can_see_client ) { ?>
278 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="client"><?php echo esc_html__( 'Client', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
279 <?php } ?>
280 <th scope="col" class="collapsing no-sort"></th>
281 </tr>
282 </thead>
283 <tbody id="update_wrapper_plugin_upgrades_group_<?php echo esc_attr( $group_id ); ?>" >
284 <?php foreach ( $site_ids as $site_id ) : ?>
285 <?php
286 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
287 continue;
288 }
289 $seek = $site_offset_for_groups[ $site_id ];
290 MainWP_DB::data_seek( $websites, $seek );
291
292 $website = MainWP_DB::fetch_object( $websites );
293 if ( $website->is_ignorePluginUpdates ) {
294 continue;
295 }
296
297 $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
298
299 $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data' ) );
300 if ( ! is_array( $site_opts ) ) {
301 $site_opts = array();
302 }
303 $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array();
304
305 $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array();
306
307 $rollPlugins = array();
308 if ( is_array( $rollItems ) && ! empty( $rollItems['plugin'] ) && is_array( $rollItems['plugin'] ) ) {
309 $rollPlugins = $rollItems['plugin'];
310 }
311
312 if ( is_array( $decodedPremiumUpgrades ) ) {
313 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
314 $premiumUpgrade['premium'] = true;
315
316 if ( 'plugin' === $premiumUpgrade['type'] ) {
317 if ( ! is_array( $plugin_upgrades ) ) {
318 $plugin_upgrades = array();
319 }
320
321 if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
322 continue;
323 }
324
325 $premiumUpgrade = array_filter( $premiumUpgrade );
326 if ( isset( $plugin_upgrades[ $crrSlug ] ) && is_array( $plugin_upgrades[ $crrSlug ] ) ) {
327 $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
328 } else {
329 $plugin_upgrades[ $crrSlug ] = $premiumUpgrade;
330 }
331 }
332 }
333 }
334
335 $ignored_plugins = json_decode( $website->ignored_plugins, true );
336 if ( is_array( $ignored_plugins ) ) {
337 $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
338 }
339
340 $ignored_plugins = json_decode( $userExtension->ignored_plugins, true );
341 if ( is_array( $ignored_plugins ) ) {
342 $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
343 }
344
345 $total_group_plugin_updates += count( $plugin_upgrades );
346
347 if ( ( empty( $plugin_upgrades ) ) && ( empty( $website->sync_errors ) ) ) {
348 continue;
349 }
350
351 $tz_info = MainWP_Updates::get_site_tz_info( $website );
352 ?>
353 <tr class="ui title master-checkbox">
354 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
355 <td>
356 <div class="ui master checkbox">
357 <input type="checkbox" name="">
358 </div>
359 <?php MainWP_Utility::mainwp_display_site( $website, true, true ); ?>
360 </td>
361 <td sort-value="<?php echo count( $plugin_upgrades ); ?>"><strong class="mainwp-768-show"><?php echo esc_html__( 'Updates: ', 'mainwp' ); ?></strong> <?php echo count( $plugin_upgrades ) . ' ' . esc_html( _n( 'Update', 'Updates', count( $plugin_upgrades ), 'mainwp' ) ); ?></td>
362 <?php if ( $user_can_see_client ) { ?>
363 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
364 <?php } ?>
365 <td>
366 <?php if ( MainWP_Updates::user_can_update_plugins() ) : ?>
367 <?php if ( ! empty( $plugin_upgrades ) ) : ?>
368 <a href="javascript:void(0)" class="mainwp-update-selected-button ui green basic mini button" onClick="event.stopPropagation(); return updatesoverview_group_upgrade_plugin_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?>, true )"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
369 <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini button" onClick="return updatesoverview_group_upgrade_plugin_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?> )"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
370 <?php endif; ?>
371 <?php endif; ?>
372 </td>
373 </tr>
374 <tr class="child-checkbox content">
375 <td colspan="5">
376 <table id="mainwp-wordpress-updates-plugins-inner-table" class="ui table mainwp-manage-updates-table mainwp-updates-list">
377 <thead class="mainwp-768-hide">
378 <tr>
379 <?php $updates_table_helper->print_column_headers(); ?>
380 </tr>
381 </thead>
382 <tbody class="plugins-bulk-updates" id="wp_plugin_upgrades_<?php echo esc_attr( $website->id ); ?>_group_<?php echo esc_attr( $group_id ); ?>" site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" tz-info="<?php echo esc_attr( $tz_info ); ?>">
383 <?php foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) : ?>
384 <?php $plugin_name = rawurlencode( $slug ); ?>
385 <?php
386 $indent_hidden = '<input type="hidden" id="wp_upgraded_plugin_' . esc_attr( $website->id ) . '_group_' . esc_attr( $group_id ) . '_' . $plugin_name . '" value="0"/>';
387
388 $last_version = $plugin_upgrade['update']['new_version'];
389
390 $row_columns = array(
391 'title' => MainWP_System_Utility::get_plugin_icon( dirname( $slug ) ) . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '" target="_blank" class="open-plugin-details-modal">' . esc_html( $plugin_upgrade['Name'] ) . '</a>' . $indent_hidden,
392 'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $plugin_upgrade['Version'] ),
393 'latest' => '<strong class="mainwp-768-show">' . esc_html__( 'Updates: ', 'mainwp' ) . '</strong><a href="' . admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_attr( $plugin_upgrade['update']['slug'] ) . '&url=' . ( isset( $plugin_upgrade['PluginURI'] ) ? rawurlencode( $plugin_upgrade['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $plugin_upgrade['Name'] ) . '&section=changelog" target="_blank" class="open-plugin-details-modal">' . esc_html( $last_version ) . '</a>',
394 'trusted' => ( in_array( $slug, $trustedPlugins ) ? true : false ),
395 'status' => ( isset( $plugin_upgrade['active'] ) && $plugin_upgrade['active'] ) ? true : false,
396 );
397
398 $others = array();
399 if ( ! empty( $rollPlugins[ $slug ][ $last_version ] ) ) {
400 $msg = MainWP_Updates_Helper::get_roll_msg( $rollPlugins[ $slug ][ $last_version ], true, 'notice' );
401 $others['roll_info'] = $msg;
402 }
403
404 $compatible_php = isset( $plugin_upgrade['wp_compatible'] ) ? $plugin_upgrade['wp_compatible'] : true;
405 $compatible_wp = isset( $plugin_upgrade['php_compatible'] ) ? $plugin_upgrade['php_compatible'] : true;
406
407 ?>
408 <tr class="mainwp-plugin-update" plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" plugin_name="<?php echo esc_attr( $plugin_upgrade['Name'] ); ?>" version="<?php echo esc_attr( rawurlencode( $plugin_upgrade['Version'] ) ); ?>" site_name="<?php echo esc_attr( stripslashes( $website->name ) ); ?>" premium="<?php echo isset( $plugin_upgrade['premium'] ) && ! empty( $plugin_upgrade['premium'] ) ? 1 : 0; ?>" updated="0">
409 <?php
410 $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others );
411 $action_rendered = isset( $row_columns['action'] ) ? true : false;
412 if ( ! $action_rendered ) :
413 ?>
414 <td>
415 <a href="#" history-view="update-plugin-per-tag" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
416 <?php if ( MainWP_Updates::user_can_ignore_updates() ) : ?>
417 <div class="ui top left pointing dropdown mini button">
418 <?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i>
419 <div class="menu">
420 <a href="javascript:void(0)" class="mainwp-ignore-update-button item" onClick="return updatesoverview_plugins_ignore_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a>
421 <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_plugins_ignore_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a>
422 <a href="javascript:void(0)" class="mainwp-ignore-update-button item" onClick="return updatesoverview_plugins_ignore_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, 'all_versions' )"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a>
423 </div>
424 </div>
425 <?php endif; ?>
426 <?php
427 if ( MainWP_Updates::user_can_update_plugins() ) :
428 if ( $compatible_php && $compatible_wp ) {
429 ?>
430 <a href="javascript:void(0)" class="mainwp-update-now-button ui mini green button" onClick="return updatesoverview_plugins_upgrade( '<?php echo esc_js( $plugin_name ); ?>', <?php echo intval( $website->id ); ?> )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
431 <?php
432 } else {
433 MainWP_Updates_Per_Item::render_incompatible_message( $compatible_php, $compatible_wp );
434 }
435 ?>
436 <?php endif; ?>
437 </td>
438 <?php endif; ?>
439 </tr>
440 <?php endforeach; ?>
441 </tbody>
442 </table>
443 </td>
444 </tr>
445 <?php endforeach; ?>
446 </tbody>
447 </table>
448 </td>
449 </tr>
450 <input type="hidden" class="element_ui_view_values" elem-uid="uid_plugin_updates_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_plugin_updates ); ?>" can-update="<?php echo MainWP_Updates::user_can_update_plugins() ? 1 : 0; ?>">
451 <?php endforeach; ?>
452 </tbody>
453 </table>
454 <?php else : ?>
455 <?php MainWP_UI::render_empty_page_placeholder( __( 'Plugins are up to date', 'mainwp' ), __( 'No plugin updates available right now.', 'mainwp' ) ); ?>
456 <?php endif; ?>
457 <?php
458 }
459
460
461 /**
462 * Method render_themes_updates()
463 *
464 * Render theme updates
465 *
466 * @param object $websites the websites.
467 * @param int $total_theme_upgrades total theme updates.
468 * @param mixed $userExtension The user extension.
469 * @param array $all_groups_sites all groups of sites.
470 * @param array $all_groups all groups.
471 * @param int $site_offset_for_groups offset value.
472 * @param array $trustedThemes all themes trusted by user.
473 *
474 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
475 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
476 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
477 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
478 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
479 * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper
480 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_themes()
481 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
482 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_themes()
483 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
484 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
485 */
486 public static function render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedThemes ) { // phpcs:ignore -- NOSONAR - complex.
487 $updates_table_helper = new MainWP_Updates_Table_Helper( $userExtension->site_view, 'theme' );
488 $user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' );
489 ?>
490 <?php if ( 0 < $total_theme_upgrades ) : ?>
491 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-themes-updates-groups-table">
492 <thead>
493 <tr>
494 <th scope="col" class="collapsing no-sort trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></th>
495 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag">
496 <div class="ui main-master checkbox ">
497 <input type="checkbox" name=""><label><?php esc_html_e( 'Tag', 'mainwp' ); ?></label>
498 </div>
499 <?php MainWP_UI::render_sorting_icons(); ?>
500 </th>
501 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
502 <th scope="col" class="no-sort right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
503 </tr>
504 </thead>
505 <tbody id="themes-updates-global" class="ui accordion">
506 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
507 <?php
508 if ( empty( $site_ids ) ) {
509 continue;
510 }
511
512 $total_group_theme_updates = 0;
513 $group_name = $all_groups[ $group_id ];
514 ?>
515 <tr class="title main-master-checkbox" row-uid="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>">
516 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
517 <td>
518 <div class="ui main-master checkbox ">
519 <input type="checkbox" name=""><label><?php echo esc_html( stripslashes( $group_name ) ); ?></label>
520 </div>
521 </td>
522 <td total-uid="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>" sort-value="0"></td>
523 <td>
524 <?php if ( MainWP_Updates::user_can_update_themes() ) : ?>
525 <a href="javascript:void(0)" btn-all-uid2="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-selected-button ui green basic mini button" onClick="updatesoverview_themes_global_upgrade_all( <?php echo esc_attr( $group_id ); ?>, true );return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
526 <a href="javascript:void(0)" btn-all-uid="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-all-button ui green mini button" onClick="updatesoverview_themes_global_upgrade_all( <?php echo esc_attr( $group_id ); ?> );return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
527 <?php endif; ?>
528 </td>
529 </tr>
530 <tr class="title main-child-checkbox content" row-uid="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>">
531 <td colspan="4">
532 <table id="mainwp-themes-updates-sites-inner-table" class="ui grey table mainwp-per-group-table mainwp-manage-updates-table mainwp-js-persistent-table">
533 <thead class="mainwp-768-hide">
534 <tr>
535 <th scope="col" class="collapsing no-sort"></th>
536 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="website"><?php esc_html_e( 'Website', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
537 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
538 <?php if ( $user_can_see_client ) { ?>
539 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="client"><?php echo esc_html__( 'Client', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
540 <?php } ?>
541 <th scope="col" class="collapsing no-sort"></th>
542 </tr>
543 </thead>
544 <tbody class="accordion" id="update_wrapper_theme_upgrades_group_<?php echo esc_attr( $group_id ); ?>">
545 <?php foreach ( $site_ids as $site_id ) : ?>
546 <?php
547 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
548 continue;
549 }
550 $seek = $site_offset_for_groups[ $site_id ];
551 MainWP_DB::data_seek( $websites, $seek );
552
553 $website = MainWP_DB::fetch_object( $websites );
554 if ( $website->is_ignoreThemeUpdates ) {
555 continue;
556 }
557
558 $theme_upgrades = json_decode( $website->theme_upgrades, true );
559
560 $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data' ) );
561 if ( ! is_array( $site_opts ) ) {
562 $site_opts = array();
563 }
564 $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array();
565
566 $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array();
567
568 $rollThemes = array();
569 if ( is_array( $rollItems ) && ! empty( $rollItems['theme'] ) && is_array( $rollItems['theme'] ) ) {
570 $rollThemes = $rollItems['theme'];
571 }
572
573 if ( is_array( $decodedPremiumUpgrades ) ) {
574 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
575 $premiumUpgrade['premium'] = true;
576
577 if ( 'theme' === $premiumUpgrade['type'] ) {
578 if ( ! is_array( $theme_upgrades ) ) {
579 $theme_upgrades = array();
580 }
581 $premiumUpgrade = array_filter( $premiumUpgrade );
582 if ( isset( $theme_upgrades[ $crrSlug ] ) && is_array( $theme_upgrades[ $crrSlug ] ) ) {
583 $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade );
584 } else {
585 $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
586 }
587 }
588 }
589 }
590
591 $ignored_themes = json_decode( $website->ignored_themes, true );
592 if ( is_array( $ignored_themes ) ) {
593 $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
594 }
595
596 $ignored_themes = json_decode( $userExtension->ignored_themes, true );
597 if ( is_array( $ignored_themes ) ) {
598 $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
599 }
600
601 $total_group_theme_updates += count( $theme_upgrades );
602
603 if ( ( empty( $theme_upgrades ) ) && ( empty( $website->sync_errors ) ) ) {
604 continue;
605 }
606
607 $tz_info = MainWP_Updates::get_site_tz_info( $website );
608 ?>
609 <tr class="ui title master-checkbox">
610 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
611 <td>
612 <div class="ui master checkbox">
613 <input type="checkbox" name=""><label>
614 </div>
615 <?php MainWP_Utility::mainwp_display_site( $website, true, true ); ?>
616 </td>
617 <td sort-value="<?php echo count( $theme_upgrades ); ?>"><strong class="mainwp-768-show"><?php esc_html_e( 'Updates:', 'mainwp' ); ?></strong> <?php echo count( $theme_upgrades ) . ' ' . esc_html( _n( 'Update', 'Updates', count( $theme_upgrades ), 'mainwp' ) ); ?></td>
618 <?php if ( $user_can_see_client ) { ?>
619 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
620 <?php } ?>
621 <td class="right aligned">
622 <?php if ( MainWP_Updates::user_can_update_themes() ) : ?>
623 <?php if ( ! empty( $theme_upgrades ) ) : ?>
624 <a href="javascript:void(0)" class="mainwp-update-selected-button ui green basic mini button" onClick="event.stopPropagation(); return updatesoverview_group_upgrade_theme_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?>, true )"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
625 <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini button" onClick="return updatesoverview_group_upgrade_theme_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?> )"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
626 <?php endif; ?>
627 <?php endif; ?>
628 </td>
629 </tr>
630 <tr class="child-checkbox content">
631 <td colspan="5">
632 <table id="mainwp-wordpress-updates-themes-inner-table" class="ui table mainwp-manage-updates-table mainwp-updates-list">
633 <thead class="mainwp-768-hide">
634 <tr>
635 <?php $updates_table_helper->print_column_headers(); ?>
636 </tr>
637 </thead>
638 <tbody class="themes-bulk-updates" id="wp_theme_upgrades_<?php echo esc_attr( $website->id ); ?>_group_<?php echo esc_attr( $group_id ); ?>" site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" tz-info="<?php echo esc_attr( $tz_info ); ?>">
639 <?php foreach ( $theme_upgrades as $slug => $theme_upgrade ) : ?>
640 <?php $theme_name = rawurlencode( $slug ); ?>
641 <?php $indent_hidden = '<input type="hidden" id="wp_upgraded_theme_' . esc_attr( $website->id ) . '_group_' . esc_attr( $group_id ) . '_' . $theme_name . '" value="0"/>'; ?>
642 <?php
643 $last_version = $theme_upgrade['update']['new_version'];
644 $row_columns = array(
645 'title' => MainWP_System_Utility::get_theme_icon( $slug ) . '&nbsp;&nbsp;&nbsp;&nbsp;' . esc_html( $theme_upgrade['Name'] ) . $indent_hidden,
646 'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $theme_upgrade['Version'] ),
647 'latest' => '<strong class="mainwp-768-show">' . esc_html__( 'Latest: ', 'mainwp' ) . '</strong>' . esc_html( $last_version ),
648 'trusted' => ( in_array( $slug, $trustedThemes, true ) ? true : false ),
649 'status' => ( isset( $theme_upgrade['active'] ) && $theme_upgrade['active'] ) ? true : false,
650 );
651 $others = array();
652 if ( ! empty( $rollThemes[ $slug ][ $last_version ] ) ) {
653 $msg = MainWP_Updates_Helper::get_roll_msg( $rollThemes[ $slug ][ $last_version ], true, 'notice' );
654 $others['roll_info'] = $msg;
655 }
656 ?>
657 <tr class="mainwp-theme-update" theme_slug="<?php echo esc_attr( $theme_name ); ?>" theme_name="<?php echo esc_attr( $theme_upgrade['Name'] ); ?>" version="<?php echo esc_attr( rawurlencode( $theme_upgrade['Version'] ) ); ?>" premium="<?php echo isset( $theme_upgrade['premium'] ) && ! empty( $theme_upgrade['premium'] ) ? 1 : 0; ?>" updated="0">
658 <?php
659 $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others );
660 $action_rendered = isset( $row_columns['action'] ) ? true : false;
661 if ( ! $action_rendered ) :
662 ?>
663 <td class="right aligned">
664 <a href="#" history-view="update-theme-per-tag" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
665 <?php if ( MainWP_Updates::user_can_ignore_updates() ) : ?>
666 <div class="ui top left pointing dropdown mini button">
667 <?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i>
668 <div class="menu">
669 <a href="javascript:void(0)" class="mainwp-ignore-update-button item" onClick="return updatesoverview_themes_ignore_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version', 'mainwp' ); ?></a>
670 <a href="javascript:void(0)" class="item mainwp-ignore-globally-button" onClick="return updatesoverview_themes_ignore_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a>
671 <a href="javascript:void(0)" class="mainwp-ignore-update-button item" onClick="return updatesoverview_themes_ignore_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_upgrade['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this, 'all_versions' )"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a>
672 </div>
673 </div>
674 <?php endif; ?>
675 <?php if ( MainWP_Updates::user_can_update_themes() ) : ?>
676 <a href="javascript:void(0)" class="mainwp-update-now-button ui mini green button" onClick="return updatesoverview_themes_upgrade( '<?php echo esc_js( $theme_name ); ?>', <?php echo intval( $website->id ); ?> )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
677 <?php endif; ?>
678 </td>
679 <?php endif; ?>
680 </tr>
681 <?php endforeach; ?>
682 </tbody>
683 </table>
684 </td>
685 </tr>
686 <?php endforeach; ?>
687 </tbody>
688
689 </table>
690 </td>
691 </tr>
692 <input type="hidden" class="element_ui_view_values" elem-uid="uid_theme_updates_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_theme_updates ); ?>" can-update="<?php echo MainWP_Updates::user_can_update_themes() ? 1 : 0; ?>">
693 <?php endforeach; ?>
694 </tbody>
695 </table>
696 <?php else : ?>
697 <?php MainWP_UI::render_empty_page_placeholder( __( 'Themes are up to date', 'mainwp' ), __( 'No theme updates available right now.', 'mainwp' ) ); ?>
698 <?php endif; ?>
699 <?php
700 }
701
702 /**
703 * Method render_trans_update()
704 *
705 * Render translations updates
706 *
707 * @param object $websites the websites.
708 * @param int $total_translation_upgrades total translation updates.
709 * @param array $all_groups_sites all groups of sites.
710 * @param array $all_groups all groups.
711 * @param int $site_offset_for_groups offset value.
712 * @param object $userExtension User Extension data.
713 *
714 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
715 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
716 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
717 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
718 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_trans()
719 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
720 */
721 public static function render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $userExtension ) { //phpcs:ignore -- NOSONAR - complex method.
722 $user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' );
723
724 $trustedPlugins = ! empty( $userExtension->trusted_plugins ) ? json_decode( $userExtension->trusted_plugins, true ) : array();
725 if ( ! is_array( $trustedPlugins ) ) {
726 $trustedPlugins = array();
727 }
728
729 $trustedThemes = json_decode( $userExtension->trusted_themes, true );
730 if ( ! is_array( $trustedThemes ) ) {
731 $trustedThemes = array();
732 }
733
734 ?>
735 <?php if ( 0 < $total_translation_upgrades ) : ?>
736 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-translations-groups-table">
737 <thead>
738 <tr>
739 <th scope="col" class="collapsing no-sort trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></th>
740 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag">
741 <div class="ui main-master checkbox">
742 <input type="checkbox" name=""><label><?php esc_html_e( 'Tag', 'mainwp' ); ?></label>
743 </div>
744 <?php MainWP_UI::render_sorting_icons(); ?>
745 </th>
746 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
747 <th scope="col"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
748 </tr>
749 </thead>
750 <tbody id="translations-updates-global" class="ui accordion">
751 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
752 <?php
753 $total_group_translation_updates = 0;
754 $group_name = $all_groups[ $group_id ];
755 ?>
756 <tr row-uid="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>" class="title main-master-checkbox">
757 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
758 <td>
759 <div class="ui main-master checkbox">
760 <input type="checkbox" name="" data-group-id="<?php echo esc_attr( $group_id ); ?>">
761 <label for=""> <?php echo esc_html( stripslashes( $group_name ) ); ?></label>
762 </div>
763 </td>
764 <td total-uid="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>" sort-value="0"></td>
765 <td class="right aligned">
766 <?php if ( MainWP_Updates::user_can_update_trans() ) { ?>
767 <a href="javascript:void(0)" btn-all-uid2="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-selected-button ui green basic mini button" onClick="event.stopPropagation(); updatesoverview_translations_global_upgrade_all( <?php echo esc_attr( $group_id ); ?>, true ); return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
768 <a href="javascript:void(0)" btn-all-uid="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>" class="mainwp-update-all-button ui green mini button" onClick="updatesoverview_translations_global_upgrade_all( <?php echo esc_attr( $group_id ); ?> ); return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
769
770 <?php } ?>
771 </td>
772 </tr>
773 <tr class="content main-child-checkbox">
774 <td colspan="4">
775 <table class="ui grey table mainwp-per-group-table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-translations-sites-table">
776 <thead class="mainwp-768-hide">
777 <tr>
778 <th scope="col" class="collapsing no-sort"></th>
779 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="website"><?php esc_html_e( 'Website', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
780 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="updates"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
781 <?php if ( $user_can_see_client ) { ?>
782 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="client"><?php echo esc_html__( 'Client', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
783 <?php } ?>
784 <th scope="col" ></th>
785 </tr>
786 </thead>
787 <tbody class="accordion" id="update_wrapper_translation_upgrades_group_<?php echo esc_attr( $group_id ); ?>" row-uid="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>">
788 <?php foreach ( $site_ids as $site_id ) : ?>
789 <?php
790 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
791 continue;
792 }
793 $seek = $site_offset_for_groups[ $site_id ];
794 MainWP_DB::data_seek( $websites, $seek );
795 $website = MainWP_DB::fetch_object( $websites );
796 $translation_upgrades = json_decode( $website->translation_upgrades, true );
797 $total_group_translation_updates += count( $translation_upgrades );
798
799 if ( ( empty( $translation_upgrades ) ) && ( empty( $website->sync_errors ) ) ) {
800 continue;
801 }
802 ?>
803 <tr class="ui title master-checkbox">
804 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
805 <td>
806 <div class="ui master checkbox">
807 <input type="checkbox" name=""><label><?php MainWP_Updates::render_site_link_dashboard( $website ); ?></label>
808 </div>
809 </td>
810 <td sort-value="<?php echo count( $translation_upgrades ); ?>">
811 <strong class="mainwp-768-show"><?php esc_html_e( 'Updates:', 'mainwp' ); ?></strong> <?php echo esc_html( _n( 'Update', 'Updates', count( $translation_upgrades ), 'mainwp' ) ); ?>
812 </td>
813 <?php if ( $user_can_see_client ) { ?>
814 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
815 <?php } ?>
816 <td>
817 <?php if ( MainWP_Updates::user_can_update_trans() ) : ?>
818 <?php if ( ! empty( $translation_upgrades ) ) : ?>
819 <a href="javascript:void(0)" class="mainwp-update-selected-button ui green basic mini button" onClick="event.stopPropagation(); return updatesoverview_group_upgrade_translation_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?>, true )"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
820 <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini button" onClick="return updatesoverview_group_upgrade_translation_all( <?php echo esc_attr( $website->id ); ?>, <?php echo esc_attr( $group_id ); ?> )"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
821 <?php endif; ?>
822 <?php endif; ?>
823 </td>
824 </tr>
825 <tr class="child-checkbox content">
826 <td colspan="5">
827 <table class="ui table mainwp-manage-updates-table" id="mainwp-translations-table">
828 <thead class="mainwp-768-hide">
829 <tr>
830 <th scope="col" ><?php esc_html_e( 'translationName', 'mainwp' ); ?></th>
831 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
832 <th scope="col" ><?php esc_html_e( 'Trusted', 'mainwp' ); ?></th>
833 <th scope="col" ></th>
834 </tr>
835 </thead>
836 <tbody id="wp_translation_upgrades_<?php echo esc_attr( $website->id ); ?>_group_<?php echo esc_attr( $group_id ); ?>" site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>">
837 <?php foreach ( $translation_upgrades as $translation_upgrade ) : ?>
838 <?php
839 $translation_name = isset( $translation_upgrade['name'] ) ? $translation_upgrade['name'] : $translation_upgrade['slug'];
840 $translation_slug = $translation_upgrade['slug'];
841 ?>
842 <tr class="mainwp-translation-update" translation_slug="<?php echo esc_attr( $translation_slug ); ?>" updated="0">
843 <td>
844 <div class="ui child checkbox">
845 <input type="checkbox" name="">
846 </div>
847 <?php echo esc_html( $translation_name ); ?>
848 <input type="hidden" id="wp_upgraded_translation_<?php echo esc_attr( $website->id ); ?>_group_<?php echo esc_attr( $group_id ); ?>_<?php echo esc_attr( $translation_slug ); ?>" value="0"/>
849 </td>
850 <td>
851 <strong class="mainwp-768-show"><?php esc_html_e( 'Varsion:', 'mainwp' ); ?></strong> <?php echo esc_html( $translation_upgrade['version'] ); ?>
852 </td>
853 <?php
854 // trusted column.
855 $is_trust = MainWP_Manage_Sites_Update_View::is_trans_trusted_update( $translation_upgrade, $trustedPlugins, $trustedThemes );
856 echo MainWP_Manage_Sites_Update_View::get_column_trusted($is_trust ); //phpcs:ignore -- NOSONAR - escaped.
857 ?>
858 <td>
859 <?php if ( MainWP_Updates::user_can_update_trans() ) : ?>
860 <a href="javascript:void(0)" class="mainwp-update-now-button ui green mini button" onClick="return updatesoverview_group_upgrade_translation( <?php echo esc_attr( $website->id ); ?>, '<?php echo esc_js( $translation_slug ); ?>', <?php echo esc_attr( $group_id ); ?> )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
861 <?php endif; ?>
862 </td>
863 </tr>
864 <?php endforeach; ?>
865 </tbody>
866 </table>
867 </td>
868 </tr>
869 <?php endforeach; ?>
870 </tbody>
871 </table>
872 </td>
873 </tr>
874 <input type="hidden" class="element_ui_view_values" elem-uid="uid_translation_updates_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_translation_updates ); ?>" can-update="<?php echo MainWP_Updates::user_can_update_trans() ? 1 : 0; ?>">
875 <?php endforeach; ?>
876 </tbody>
877 </table>
878 <?php else : ?>
879 <?php MainWP_UI::render_empty_page_placeholder( __( 'Translations are up to date', 'mainwp' ), __( 'No translation updates available right now.', 'mainwp' ) ); ?>
880 <?php endif; ?>
881 <?php
882 }
883
884 /**
885 * Method render_abandoned_plugins()
886 *
887 * Render abandoned plugins
888 *
889 * @param object $websites the websites.
890 * @param array $allPluginsOutdate All Plugins Outdate.
891 * @param array $all_groups_sites all groups of sites.
892 * @param array $all_groups all groups.
893 * @param int $site_offset_for_groups offset value.
894 * @param array $decodedDismissedPlugins all dismissed plugins.
895 *
896 * @throws \MainWP_Exception Error message.
897 *
898 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
899 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
900 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
901 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
902 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
903 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
904 */
905 public static function render_abandoned_plugins( $websites, $allPluginsOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins ) { // phpcs:ignore -- NOSONAR - complex.
906 /* translators: %s: number of days */
907 $str_format = esc_html__( 'Updated %s days ago', 'mainwp' );
908 $count_abandoned = count( $allPluginsOutdate );
909 ?>
910 <?php if ( 0 < $count_abandoned ) : ?>
911 <table class="ui tablet stackable table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-abandoned-plugins-groups-table">
912 <thead>
913 <tr>
914 <th scope="col" class="collapsing no-sort trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></th>
915 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag"><?php esc_html_e( 'Tag', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
916 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
917 </tr>
918 </thead>
919 <tbody class="ui accordion">
920 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
921 <?php
922 $total_group_plugins_outdate = 0;
923 $group_name = $all_groups[ $group_id ];
924 ?>
925 <tr class="title" row-uid="uid_plugins_outdate_<?php echo esc_attr( $group_id ); ?>">
926 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
927 <td><?php echo esc_html( stripslashes( $group_name ) ); ?></td>
928 <td total-uid="uid_plugins_outdate_<?php echo esc_attr( $group_id ); ?>" sort-value="0"></td>
929 </tr>
930 <tr class="content" row-uid="uid_plugins_outdate_<?php echo esc_attr( $group_id ); ?>">
931 <td colspan="3">
932 <table class="ui grey table mainwp-per-group-table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-abandoned-plugins-sites-table">
933 <thead class="mainwp-768-hide">
934 <tr>
935 <th scope="col" class="collapsing no-sort"></th>
936 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="website"><?php esc_html_e( 'Website', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
937 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="client"><?php echo esc_html__( 'Client', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
938 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
939 </tr>
940 </thead>
941 <tbody class="accordion">
942 <?php foreach ( $site_ids as $site_id ) : ?>
943 <?php
944 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
945 continue;
946 }
947 $seek = $site_offset_for_groups[ $site_id ];
948 MainWP_DB::data_seek( $websites, $seek );
949
950 $website = MainWP_DB::fetch_object( $websites );
951
952 $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
953 $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
954
955 if ( ! is_array( $plugins_outdate ) ) {
956 $plugins_outdate = array();
957 }
958
959 if ( ! empty( $plugins_outdate ) ) {
960 $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
961 $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array();
962
963 if ( is_array( $pluginsOutdateDismissed ) ) {
964 $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed );
965 }
966
967 if ( is_array( $decodedDismissedPlugins ) ) {
968 $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
969 }
970 }
971
972 $total_group_plugins_outdate += count( $plugins_outdate );
973 ?>
974 <?php if ( ! empty( $plugins_outdate ) ) : ?>
975 <tr class="ui title master-checkbox">
976 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
977 <td>
978 <strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?>
979 </td>
980 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
981 <td sort-value="<?php echo count( $plugins_outdate ); ?>">
982 <strong class="mainwp-768-show"><?php esc_html_e( 'Abandoned:', 'mainwp' ); ?></strong> <?php echo count( $plugins_outdate ); ?> <?php echo esc_html( _n( 'Plugin', 'Plugins', count( $plugins_outdate ), 'mainwp' ) ); ?>
983 </td>
984 </tr>
985 <tr class="child-checkbox content">
986 <td colspan="4">
987 <table class="ui mainwp-manage-updates-table table" id="mainwp-abandoned-plugins-table">
988 <thead class="mainwp-768-hide">
989 <tr>
990 <th scope="col" ></th>
991 <th scope="col" ><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
992 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
993 <th scope="col" ><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th>
994 <th scope="col" class="no-sort"></th>
995 </tr>
996 </thead>
997 <tbody site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>">
998 <?php foreach ( $plugins_outdate as $slug => $plugin_outdate ) : ?>
999 <?php
1000 $plugin_name = rawurlencode( $slug );
1001 $now = new \DateTime();
1002 $last_updated = $plugin_outdate['last_updated'];
1003 $plugin_last_updated_date = new \DateTime( '@' . $last_updated );
1004 $diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
1005 $outdate_notice = sprintf( $str_format, $diff_in_days );
1006 ?>
1007 <tr dismissed="0">
1008 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( dirname( $slug ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
1009 <td>
1010 <a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $slug ) ) . '&url=' . ( isset( $plugin_outdate['PluginURI'] ) ? esc_html( rawurlencode( $plugin_outdate['PluginURI'] ) ) : '' ) . '&name=' . esc_html( rawurlencode( $plugin_outdate['Name'] ) ); ?>" target="_blank" class="open-plugin-details-modal"><?php echo esc_html( $plugin_outdate['Name'] ); ?></a>
1011 <input type="hidden" id="wp_dismissed_plugin_<?php echo esc_attr( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>" value="0"/>
1012 </td>
1013 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $plugin_outdate['Version'] ); ?></td>
1014 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td>
1015 <td id="wp_dismissbuttons_plugin_<?php echo esc_attr( $website->id ); ?>_<?php echo esc_attr( $plugin_name ); ?>">
1016 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
1017 <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_plugins_dismiss_outdate_detail( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $plugin_outdate['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a>
1018 <?php } ?>
1019 </td>
1020 </tr>
1021 <?php endforeach; ?>
1022 </tbody>
1023 </table>
1024 </td>
1025 </tr>
1026 <?php endif; ?>
1027 <?php endforeach; ?>
1028 </tbody>
1029 </table>
1030 </td>
1031 </tr>
1032 <input type="hidden" class="element_ui_view_values" elem-uid="uid_plugins_outdate_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_plugins_outdate ); ?>" can-update="0">
1033 <?php endforeach; ?>
1034 </tbody>
1035 </table>
1036 <?php else : ?>
1037 <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned plugins detected', 'mainwp' ), __( 'None of your plugins are currently marked as abandoned.', 'mainwp' ) ); ?>
1038 <?php endif; ?>
1039 <?php
1040 }
1041
1042
1043 /**
1044 * Method render_abandoned_themes()
1045 *
1046 * Render abandoned themes
1047 *
1048 * @param object $websites the websites.
1049 * @param array $allThemesOutdate All Themes Outdate.
1050 * @param array $all_groups_sites all groups of sites.
1051 * @param array $all_groups all groups.
1052 * @param int $site_offset_for_groups offset value.
1053 * @param array $decodedDismissedThemes all dismissed themes.
1054 *
1055 * @throws \MainWP_Exception Error message.
1056 *
1057 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1058 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1059 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
1060 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
1061 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
1062 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
1063 */
1064 public static function render_abandoned_themes( $websites, $allThemesOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes ) { // phpcs:ignore -- NOSONAR - complex.
1065 /* translators: %s: number of days */
1066 $str_format = esc_html__( 'Updated %s days ago', 'mainwp' );
1067 $count_abandoned = count( $allThemesOutdate );
1068 ?>
1069 <?php if ( 0 < $count_abandoned ) : ?>
1070 <table class="ui tablet stackable table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-abandoned-themes-groups-table">
1071 <thead>
1072 <tr>
1073 <th scope="col" class="collapsing no-sort trigger-all-accordion"><span class="trigger-handle-arrow"><i class="caret right icon"></i><i class="caret down icon"></i></span></th>
1074 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="tag"><?php esc_html_e( 'Tag', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
1075 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
1076 </tr>
1077 </thead>
1078 <tbody class="ui accordion">
1079 <?php foreach ( $all_groups_sites as $group_id => $site_ids ) : ?>
1080 <?php
1081 $total_group_themes_outdate = 0;
1082 $group_name = $all_groups[ $group_id ];
1083 ?>
1084 <tr row-uid="uid_themes_outdate_<?php echo esc_attr( $group_id ); ?>" class="title">
1085 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
1086 <td><?php echo esc_html( stripslashes( $group_name ) ); ?></td>
1087 <td total-uid="uid_themes_outdate_<?php echo esc_attr( $group_id ); ?>" sort-value="0"></td>
1088 </tr>
1089 <tr class="content" row-uid="uid_themes_outdate_<?php echo esc_attr( $group_id ); ?>">
1090 <td colspan="3">
1091 <table class="ui grey table manage-updates-item-table mainwp-manage-updates-table mainwp-per-group-table mainwp-js-persistent-table" id="mainwp-abandoned-themes-sites-table">
1092 <thead class="mainwp-768-hide">
1093 <tr>
1094 <th scope="col" class="collapsing no-sort"></th>
1095 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="website"><?php esc_html_e( 'Website', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
1096 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="client"><?php echo esc_html__( 'Client', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
1097 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
1098 </tr>
1099 </thead>
1100 <tbody class="accordion">
1101 <?php foreach ( $site_ids as $site_id ) : ?>
1102 <?php
1103 if ( ! isset( $site_offset_for_groups[ $site_id ] ) ) {
1104 continue;
1105 }
1106 $seek = $site_offset_for_groups[ $site_id ];
1107 MainWP_DB::data_seek( $websites, $seek );
1108
1109 $website = MainWP_DB::fetch_object( $websites );
1110
1111 $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
1112 $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
1113
1114 if ( ! is_array( $themes_outdate ) ) {
1115 $themes_outdate = array();
1116 }
1117
1118 if ( ! empty( $themes_outdate ) ) {
1119 $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
1120 $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array();
1121
1122 if ( is_array( $themesOutdateDismissed ) ) {
1123 $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed );
1124 }
1125
1126 if ( is_array( $decodedDismissedThemes ) ) {
1127 $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
1128 }
1129 }
1130
1131 $total_group_themes_outdate += count( $themes_outdate );
1132 ?>
1133 <?php if ( ! empty( $themes_outdate ) ) : ?>
1134 <tr class="ui title">
1135 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
1136 <td>
1137 <strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?>
1138 </td>
1139 <td><a href="<?php echo 'admin.php?page=ManageClients&client_id=' . intval( $website->client_id ); ?>" data-tooltip="<?php esc_attr_e( 'Jump to the client', 'mainwp' ); ?>" data-position="right center" data-inverted="" ><?php echo esc_html( $website->client_name ); ?></a></td>
1140 <td sort-value="<?php echo count( $themes_outdate ); ?>">
1141 <strong class="mainwp-768-show"><?php esc_html_e( 'Abandoned:', 'mainwp' ); ?></strong> <?php echo count( $themes_outdate ); ?> <?php echo esc_html( _n( 'Theme', 'Themes', count( $themes_outdate ), 'mainwp' ) ); ?>
1142 </td>
1143 </tr>
1144 <tr class="content">
1145 <td colspan="4">
1146 <table class="ui mainwp-manage-updates-item-table mainwp-manage-updates-table table" id="mainwp-abandoned-themes-table">
1147 <thead class="mainwp-768-hide">
1148 <tr>
1149 <th scope="col" ><?php esc_html_e( 'Theme', 'mainwp' ); ?></th>
1150 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
1151 <th scope="col" ><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th>
1152 <th scope="col" class="no-sort"></th>
1153 </tr>
1154 </thead>
1155 <tbody site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>">
1156 <?php foreach ( $themes_outdate as $slug => $theme_outdate ) : ?>
1157 <?php
1158 $theme_name = rawurlencode( $slug );
1159 $now = new \DateTime();
1160 $last_updated = $theme_outdate['last_updated'];
1161 $theme_last_updated_date = new \DateTime( '@' . $last_updated );
1162 $diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' );
1163 $outdate_notice = sprintf( $str_format, $diff_in_days );
1164 ?>
1165 <tr dismissed="0">
1166 <td>
1167 <?php echo MainWP_System_Utility::get_theme_icon( $slug ) . '&nbsp;&nbsp;&nbsp;&nbsp;' . esc_html( $theme_outdate['Name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
1168 <input type="hidden" id="wp_dismissed_theme_<?php echo esc_attr( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>" value="0"/>
1169 </td>
1170 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $theme_outdate['Version'] ); ?></td>
1171 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td>
1172 <td id="wp_dismissbuttons_theme_<?php echo esc_attr( $website->id ); ?>_<?php echo esc_attr( $theme_name ); ?>">
1173 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
1174 <a href="javascript:void(0)" class="ui mini button" onClick="return updatesoverview_themes_dismiss_outdate_detail( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $theme_outdate['Name'] ) ); ?>', <?php echo intval( $website->id ); ?>, this )"><?php esc_html_e( 'Ignore Now', 'mainwp' ); ?></a>
1175 <?php } ?>
1176 </td>
1177 </tr>
1178 <?php endforeach; ?>
1179 </tbody>
1180 </table>
1181 </td>
1182 </tr>
1183 <?php endif; ?>
1184 <?php endforeach; ?>
1185 </tbody>
1186 </table>
1187 </td>
1188 </tr>
1189 <input type="hidden" class="element_ui_view_values" elem-uid="uid_themes_outdate_<?php echo esc_attr( $group_id ); ?>" total="<?php echo intval( $total_group_themes_outdate ); ?>" can-update="0">
1190 <?php endforeach; ?>
1191 </tbody>
1192 </table>
1193 <?php else : ?>
1194 <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned themes detected', 'mainwp' ), __( 'None of your themes are currently marked as abandoned.', 'mainwp' ) ); ?>
1195 <?php endif; ?>
1196 <?php
1197 }
1198 }
1199