PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.1
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 5.2.1 All 155 releases
mainwp / pages / page-mainwp-updates-per-group.php

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

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