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

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