PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
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-item.php

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

914 lines 67.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Updates Per Item.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class MainWP_Updates_Per_Item.
17 */
18 class MainWP_Updates_Per_Item { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
19
20 /**
21 * Method get_class_name()
22 *
23 * Get Class Name.
24 *
25 * @return object class name.
26 */
27 public static function get_class_name() {
28 return __CLASS__;
29 }
30
31 /**
32 * Method render_plugins_updates()
33 *
34 * Render Plugin updates
35 *
36 * @param object $websites the websites.
37 * @param int $total_plugin_upgrades total plugin updates.
38 * @param mixed $userExtension user extension.
39 * @param array $allPlugins all plugins.
40 * @param array $pluginsInfo pugins information.
41 * @param array $trustedPlugins trusted plugins.
42 *
43 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
44 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
45 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
46 * @uses \MainWP\Dashboard\MainWP_UI
47 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
48 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
49 * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper
50 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
51 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_plugins()
52 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
53 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
54 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
55 */
56 public static function render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins ) { // phpcs:ignore -- NOSONAR - complex.
57 ?>
58 <?php if ( 0 < $total_plugin_upgrades ) : ?>
59 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-plugins-updates-table">
60 <thead>
61 <tr>
62 <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>
63 <th scope="col" class="eight wide indicator-accordion-sorting handle-accordion-sorting" data-key="plugin">
64 <div class="ui main-master checkbox ">
65 <input type="checkbox" name=""><label><?php esc_html_e( 'Plugin', 'mainwp' ); ?></label>
66 </div>
67 <?php MainWP_UI::render_sorting_icons(); ?>
68 </th>
69 <th scope="col" class="two wide indicator-accordion-sorting handle-accordion-sorting" data-key="update"><?php echo intval( $total_plugin_upgrades ) . ' ' . esc_html( _n( 'Update', 'Updates', $total_plugin_upgrades, 'mainwp' ) ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
70 <th scope="col" class="two wide indicator-accordion-sorting handle-accordion-sorting" data-key="trusted"><?php esc_html_e( 'Trusted', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
71 <th scope="col" class="four wide no-sort right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
72 </tr>
73 </thead>
74 <?php
75 $updates_table_helper = new MainWP_Updates_Table_Helper( $userExtension->site_view );
76 ?>
77 <tbody id="plugins-updates-global" class="ui accordion">
78 <?php foreach ( $allPlugins as $slug => $val ) { ?>
79 <?php
80 $cnt = intval( $val['cnt'] );
81 $plugin_name = rawurlencode( $slug );
82 $trusted = in_array( $slug, $trustedPlugins ) ? 1 : 0;
83 ?>
84 <tr class="ui title master-checkbox">
85 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
86 <td class="middle aligned">
87 <div class="ui middle aligned fitted master checkbox">
88 <input type="checkbox" name="">
89 </div>
90 &nbsp;&nbsp;<?php echo MainWP_System_Utility::get_plugin_icon( $pluginsInfo[ $slug ]['slug'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>&nbsp;&nbsp;&nbsp;&nbsp;
91 <a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&plugin=' . esc_attr( $pluginsInfo[ $slug ]['slug'] ) . '&url=' . ( isset( $pluginsInfo[ $slug ]['PluginURI'] ) ? rawurlencode( $pluginsInfo[ $slug ]['PluginURI'] ) : '' ) . '&name=' . rawurlencode( $pluginsInfo[ $slug ]['name'] ); ?>" target="_blank" class="open-plugin-details-modal" open-wpplugin="yes">
92 <?php echo esc_html( $pluginsInfo[ $slug ]['name'] ); ?>
93 </a>
94 </td>
95 <td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Update', 'Updates', $cnt, 'mainwp' ) ); ?></td>
96 <td sort-value="<?php echo esc_attr( $trusted ); ?>"><?php echo $trusted ? '<span class="ui tiny green label">Trusted</span>' : '<span class="ui tiny grey label">Not Trusted</span>'; ?></td>
97 <td class="right aligned">
98 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
99 <a href="javascript:void(0)" class="ui mini button mainwp-ignore-globally-button" onClick="return updatesoverview_plugins_ignore_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $pluginsInfo[ $slug ]['name'] ) ); ?>', this )"><?php esc_html_e( 'Ignore Globally', 'mainwp' ); ?></a>
100 <?php } ?>
101 <?php if ( MainWP_Updates::user_can_update_plugins() ) { ?>
102 <?php if ( 0 < $cnt ) { ?>
103 <?php
104 if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $userExtension->site_view ) {
105 MainWP_Updates::set_continue_update_html_selector( 'plugins_upgrade_all', $slug );
106 }
107 ?>
108 <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini basic button green <?php MainWP_Updates::get_continue_update_selector(); ?>" onClick="event.stopPropagation(); updatesoverview_plugins_upgrade_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $pluginsInfo[ $slug ]['name'] ) ); ?>', true ); return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
109 <a href="javascript:void(0)" class="mainwp-update-all-button ui mini button green <?php MainWP_Updates::get_continue_update_selector(); ?>" onClick="return updatesoverview_plugins_upgrade_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $pluginsInfo[ $slug ]['name'] ) ); ?>' )"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
110 <?php } ?>
111 <?php } ?>
112 </td>
113 </tr>
114 <tr class="plugins-bulk-updates child-checkbox content" plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" plugin_name="<?php echo esc_attr( rawurlencode( $pluginsInfo[ $slug ]['name'] ) ); ?>" premium="<?php echo $pluginsInfo[ $slug ]['premium'] ? 1 : 0; ?>">
115 <td colspan="7">
116 <table id="mainwp-plugins-updates-sites-inner-table" class="ui table mainwp-manage-updates-table">
117 <thead class="mainwp-768-hide">
118 <tr>
119 <?php $updates_table_helper->print_column_headers(); ?>
120 </tr>
121 </thead>
122 <tbody plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" >
123 <?php
124 $first_wpplugin = true;
125 MainWP_DB::data_seek( $websites, 0 );
126 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
127 if ( $website->is_ignorePluginUpdates ) {
128 continue;
129 }
130 $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
131 if ( ! is_array( $plugin_upgrades ) ) {
132 $plugin_upgrades = array();
133 }
134
135 $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data' ) );
136 if ( ! is_array( $site_opts ) ) {
137 $site_opts = array();
138 }
139 $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array();
140
141 $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array();
142
143 $rollPlugins = array();
144 if ( is_array( $rollItems ) && ! empty( $rollItems['plugin'] ) && is_array( $rollItems['plugin'] ) ) {
145 $rollPlugins = $rollItems['plugin'];
146 }
147
148 if ( is_array( $decodedPremiumUpgrades ) ) {
149 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
150 $premiumUpgrade['premium'] = true;
151 if ( 'plugin' === $premiumUpgrade['type'] ) {
152 if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
153 continue;
154 }
155 $premiumUpgrade = array_filter( $premiumUpgrade );
156 $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
157 }
158 }
159 }
160
161 $ignored_plugins = json_decode( $website->ignored_plugins, true );
162 if ( is_array( $ignored_plugins ) ) {
163 $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins );
164
165 }
166
167 if ( ! isset( $plugin_upgrades[ $slug ] ) ) {
168 continue;
169 }
170 $plugin_upgrade = $plugin_upgrades[ $slug ];
171
172 $last_version = $plugin_upgrade['update']['new_version'];
173 $current_ver = $plugin_upgrade['Version'] ?? '';
174
175 $row_columns = array(
176 'site' => true,
177 'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $current_ver ),
178 'latest' => '<strong class="mainwp-768-show">' . esc_html__( 'Latest: ', '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>',
179 'trusted' => ( in_array( $slug, $trustedPlugins ) ? true : false ),
180 'status' => ( isset( $plugin_upgrade['active'] ) && $plugin_upgrade['active'] ) ? true : false,
181 'client' => ( isset( $website->client_name ) && '' !== $website->client_name ) ? '<a href="admin.php?page=ManageClients&client_id=' . intval( $website->client_id ) . '" data-tooltip="' . __( 'Jump to the client', 'mainwp' ) . '" data-position="right center" data-inverted="">' . $website->client_name . '</a>' : '',
182 );
183
184 $others = array();
185 if ( ! empty( $rollPlugins[ $slug ][ $last_version ] ) ) {
186 $msg = MainWP_Updates_Helper::get_roll_msg( $rollPlugins[ $slug ][ $last_version ], true, 'notice' );
187 $others['roll_info'] = $msg;
188 }
189
190 $tz_info = MainWP_Updates::get_site_tz_info( $website );
191
192 $compatible_php = isset( $plugin_upgrade['wp_compatible'] ) ? $plugin_upgrade['wp_compatible'] : true;
193 $compatible_wp = isset( $plugin_upgrade['php_compatible'] ) ? $plugin_upgrade['php_compatible'] : true;
194
195 ?>
196 <tr site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( $website->name ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" plugin_slug="<?php echo esc_attr( $plugin_name ); ?>" plugin_name="<?php echo esc_attr( $plugin_upgrade['Name'] ); ?>" last-version="<?php echo esc_attr( rawurlencode( $last_version ) ); ?>" site_name="<?php echo esc_attr( stripslashes( $website->name ) ); ?>" updated="0" <?php echo $first_wpplugin ? 'open-wpplugin-siteid="' . intval( $website->id ) . '"' : ''; ?> tz-info="<?php echo esc_attr( $tz_info ); ?>">
197 <?php
198 $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others );
199 $action_rendered = isset( $row_columns['action'] ) ? true : false;
200 if ( ! $action_rendered ) {
201 ?>
202 <td class="right aligned">
203 <a href="#" history-view="update-plugin-per-item" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
204 <?php if ( MainWP_Updates::user_can_ignore_updates() ) : ?>
205 <div class="ui top left pointing dropdown mini button">
206 <?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i>
207 <div class="menu">
208 <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>
209 <a href="javascript:void(0)" class="mainwp-ignore-globally-button item" onClick="return updatesoverview_plugins_ignore_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_attr( rawurlencode( $pluginsInfo[ $slug ]['name'] ) ); ?>', this, '<?php echo esc_js( rawurlencode( $last_version ) ); ?>' )"><?php esc_html_e( 'Ignore this version globally', 'mainwp' ); ?></a>
210 <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>
211 </div>
212 </div>
213 <?php endif; ?>
214 <?php
215 if ( MainWP_Updates::user_can_update_plugins() ) :
216 if ( $compatible_php && $compatible_wp ) {
217 ?>
218 <a href="javascript:void(0)" class="mainwp-update-now-button ui mini green button" onClick="return updatesoverview_plugins_upgrade( '<?php echo esc_js( $plugin_name ); ?>', <?php echo intval( $website->id ); ?> )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
219 <?php
220 } else {
221 self::render_incompatible_message( $compatible_php, $compatible_wp );
222 }
223 ?>
224 <?php endif; ?>
225 </td>
226 <?php } ?>
227 </tr>
228 <?php
229 $first_wpplugin = false;
230 }
231 ?>
232 </tbody>
233 </table>
234 </td>
235 </tr>
236 <?php } ?>
237 </tbody>
238 </table>
239 <?php else : ?>
240 <?php MainWP_UI::render_empty_page_placeholder( __( 'Plugins are up to date', 'mainwp' ), __( 'No plugin updates available right now.', 'mainwp' ) ); ?>
241 <?php endif; ?>
242 <?php
243 }
244
245 /**
246 * Method render_incompatible_message().
247 *
248 * @param mixed $compatible_php Compatible php.
249 * @param mixed $compatible_wp Compatible wp. *
250 * @param mixed $echo_content Print content or not.
251 *
252 * @return string Message
253 */
254 public static function render_incompatible_message( $compatible_php, $compatible_wp, $echo_content = true ) {
255 $msg = static::get_incompatible_message( $compatible_php, $compatible_wp );
256 if ( ! empty( $msg ) ) {
257 $html = '<span class="ui yellow message">' . esc_html( $msg ) . '</span>';
258 if ( $echo_content ) {
259 echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
260 } else {
261 return $html;
262 }
263 }
264 return '';
265 }
266
267 /**
268 * Method get_incompatible_message().
269 *
270 * @param mixed $compatible_php Compatible php.
271 * @param mixed $compatible_wp Compatible wp.
272 * @return string Message
273 */
274 public static function get_incompatible_message( $compatible_php, $compatible_wp ) {
275 $msg = '';
276 if ( ! $compatible_php || ! $compatible_wp ) {
277 if ( ! $compatible_php && ! $compatible_wp ) {
278 $msg .= __( 'This plugin does not work with your versions of WordPress and PHP.', 'mainwp' );
279 } elseif ( ! $compatible_wp ) {
280 $msg .= __( 'This plugin does not work with your version of WordPress.', 'mainwp' );
281 } elseif ( ! $compatible_php ) {
282 $msg .= __( 'This plugin does not work with your version of PHP.', 'mainwp' );
283 }
284 }
285 return $msg;
286 }
287
288 /**
289 * Method render_themes_updates()
290 *
291 * Render theme updates
292 *
293 * @param object $websites the websites.
294 * @param int $total_theme_upgrades total theme updates.
295 * @param mixed $userExtension user extension.
296 * @param array $allThemes all themes.
297 * @param array $themesInfo themes information.
298 * @param array $trustedThemes trusted themes.
299 *
300 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
301 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
302 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
303 * @uses \MainWP\Dashboard\MainWP_UI
304 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
305 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
306 * @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper
307 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_themes()
308 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
309 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
310 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
311 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
312 */
313 public static function render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes ) { // phpcs:ignore -- NOSONAR - complex.
314 $updates_table_helper = new MainWP_Updates_Table_Helper( $userExtension->site_view, 'theme' );
315 ?>
316 <?php if ( 0 < $total_theme_upgrades ) : ?>
317 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table mainwp-themes-updates-items-table" id="mainwp-themes-updates-table">
318 <thead>
319 <tr>
320 <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>
321 <th scope="col" class="eight wide handle-accordion-sorting indicator-accordion-sorting" data-key="theme">
322 <div class="ui main-master checkbox ">
323 <input type="checkbox" name=""><label><?php esc_html_e( 'Theme', 'mainwp' ); ?></label>
324 </div>
325 <?php MainWP_UI::render_sorting_icons(); ?>
326 </th>
327 <th scope="col" class="two wide handle-accordion-sorting indicator-accordion-sorting" data-key="update"><?php echo intval( $total_theme_upgrades ) . ' ' . esc_html( _n( 'Update', 'Updates', $total_theme_upgrades, 'mainwp' ) ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
328 <th scope="col" class="two wide handle-accordion-sorting indicator-accordion-sorting" data-key="trusted"><?php esc_html_e( 'Trusted', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
329 <th scope="col" class="four wide no-sort right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
330 </tr>
331 </thead>
332 <tbody id="themes-updates-global" class="ui accordion">
333 <?php foreach ( $allThemes as $slug => $val ) { ?>
334 <?php
335 $cnt = intval( $val['cnt'] );
336 $theme_name = rawurlencode( $slug );
337 $trusted = in_array( $slug, $trustedThemes ) ? 1 : 0;
338 ?>
339 <tr class="ui title master-checkbox">
340 <td class="accordion-trigger"><i class="icon dropdown"></i></td>
341 <td class="middle aligned">
342 <div class="ui middle aligned fitted master checkbox">
343 <input type="checkbox" name="">
344 </div>
345 &nbsp;&nbsp;<?php echo MainWP_System_Utility::get_theme_icon( $slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo esc_html( $themesInfo[ $slug ]['name'] ); ?>
346 </td>
347 <td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Update', 'Updates', $cnt, 'mainwp' ) ); ?></td>
348 <td sort-value="<?php echo esc_attr( $trusted ); ?>"><?php echo $trusted ? '<span class="ui tiny green label">Trusted</span>' : '<span class="ui tiny grey label">Not Trusted</span>'; ?></td>
349 <td class="right aligned">
350 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
351 <a href="javascript:void(0)" class="ui mini button mainwp-ignore-globally-button" onClick="return updatesoverview_themes_ignore_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $themesInfo[ $slug ]['name'] ) ); ?>', this )"><?php esc_html_e( 'Ignore Globally', 'mainwp' ); ?></a>
352 <?php } ?>
353 <?php if ( MainWP_Updates::user_can_update_themes() ) { ?>
354 <?php
355 if ( 0 < $cnt ) {
356 if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $userExtension->site_view ) {
357 MainWP_Updates::set_continue_update_html_selector( 'themes_upgrade_all', $slug );
358 }
359 ?>
360 <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini basic button green <?php MainWP_Updates::get_continue_update_selector(); ?>" onClick="updatesoverview_themes_upgrade_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $themesInfo[ $slug ]['name'] ) ); ?>', true ); return false;"><?php esc_html_e( 'Update Selected', 'mainwp' ); ?></a>
361 <a href="javascript:void(0)" class="mainwp-update-all-button ui mini button green <?php MainWP_Updates::get_continue_update_selector(); ?>" onClick="updatesoverview_themes_upgrade_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $themesInfo[ $slug ]['name'] ) ); ?>' ); return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
362
363 <?php } ?>
364 <?php } ?>
365 </td>
366 </tr>
367 <tr class="themes-bulk-updates child-checkbox content" theme_slug="<?php echo esc_attr( $theme_name ); ?>" theme_name="<?php echo esc_attr( rawurlencode( $themesInfo[ $slug ]['name'] ) ); ?>" premium="<?php echo $themesInfo[ $slug ]['premium'] ? 1 : 0; ?>">
368 <td colspan="5">
369 <table id="mainwp-themes-updates-sites-inner-table" class="ui table mainwp-manage-updates-table mainwp-updates-list">
370 <thead class="mainwp-768-hide">
371 <tr>
372 <?php $updates_table_helper->print_column_headers(); ?>
373 </tr>
374 </thead>
375 <tbody theme_slug="<?php echo esc_attr( $theme_name ); ?>">
376 <?php
377 MainWP_DB::data_seek( $websites, 0 );
378 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
379 if ( $website->is_ignoreThemeUpdates ) {
380 continue;
381 }
382 $theme_upgrades = json_decode( $website->theme_upgrades, true );
383
384 $site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data' ) );
385 if ( ! is_array( $site_opts ) ) {
386 $site_opts = array();
387 }
388 $decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array();
389
390 $rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array();
391
392 $rollThemes = array();
393 if ( is_array( $rollItems ) && ! empty( $rollItems['theme'] ) && is_array( $rollItems['theme'] ) ) {
394 $rollThemes = $rollItems['theme'];
395 }
396
397 if ( is_array( $decodedPremiumUpgrades ) ) {
398 foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
399 $premiumUpgrade['premium'] = true;
400 if ( 'theme' === $premiumUpgrade['type'] ) {
401 if ( ! is_array( $theme_upgrades ) ) {
402 $theme_upgrades = array();
403 }
404 $premiumUpgrade = array_filter( $premiumUpgrade );
405 if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) {
406 $theme_upgrades[ $crrSlug ] = array();
407 }
408 $theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade );
409 }
410 }
411 }
412 $ignored_themes = json_decode( $website->ignored_themes, true );
413 if ( is_array( $ignored_themes ) ) {
414 $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes );
415 }
416
417 if ( ! isset( $theme_upgrades[ $slug ] ) ) {
418 continue;
419 }
420 $theme_upgrade = $theme_upgrades[ $slug ];
421 $last_version = $theme_upgrade['update']['new_version'];
422 $current_ver = $theme_upgrade['Version'] ?? '';
423 if ( empty( $current_ver ) ) {
424 $current_ver = static::get_installed_theme_version( $website, $slug );
425 }
426 $row_columns = array(
427 'site' => true,
428 'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $current_ver ),
429 'latest' => '<strong class="mainwp-768-show">' . esc_html__( 'Latest: ', 'mainwp' ) . '</strong>' . esc_html( $last_version ),
430 'trusted' => ( in_array( $slug, $trustedThemes ) ? true : false ),
431 'status' => ( isset( $theme_upgrade['active'] ) && $theme_upgrade['active'] ) ? true : false,
432 'client' => ( isset( $website->client_name ) && '' !== $website->client_name ) ? '<a href="admin.php?page=ManageClients&client_id=' . intval( $website->client_id ) . '" data-tooltip="' . __( 'Jump to the client', 'mainwp' ) . '" data-position="right center" data-inverted="">' . $website->client_name . '</a>' : '',
433 );
434
435 $others = array();
436 if ( ! empty( $rollThemes[ $slug ][ $last_version ] ) ) {
437 $msg = MainWP_Updates_Helper::get_roll_msg( $rollThemes[ $slug ][ $last_version ], true, 'notice' );
438 $others['roll_info'] = $msg;
439 }
440
441 $tz_info = MainWP_Updates::get_site_tz_info( $website );
442
443 ?>
444 <tr site_id="<?php echo esc_attr( $website->id ); ?>" theme_slug="<?php echo esc_attr( $theme_name ); ?>" theme_name="<?php echo esc_attr( $theme_upgrade['Name'] ); ?>" last-version="<?php echo esc_attr( rawurlencode( $last_version ) ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" site_url="<?php echo esc_attr( $website->url ); ?>" updated="0" tz-info="<?php echo esc_attr( $tz_info ); ?>">
445 <?php
446 $row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others );
447 $action_rendered = isset( $row_columns['action'] ) ? true : false;
448 if ( ! $action_rendered ) {
449 ?>
450 <td class="right aligned">
451 <a href="#" history-view="update-theme-per-item" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
452 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
453 <div class="ui top left pointing dropdown mini button">
454 <?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i>
455 <div class="menu">
456 <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>
457 <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>
458 <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>
459 </div>
460 </div>
461 <?php } ?>
462 <?php if ( MainWP_Updates::user_can_update_themes() ) : ?>
463 <a href="javascript:void(0)" class="mainwp-update-now-button ui mini green button" onClick="return updatesoverview_themes_upgrade( '<?php echo esc_js( $theme_name ); ?>', <?php echo intval( $website->id ); ?> )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
464 <?php endif; ?>
465 </td>
466 <?php } ?>
467 </tr>
468 <?php
469 }
470 ?>
471 </tbody>
472 </table>
473 </td>
474 </tr>
475 <?php } ?>
476 </tbody>
477 </table>
478 <?php else : ?>
479 <?php MainWP_UI::render_empty_page_placeholder( __( 'Themes are up to date', 'mainwp' ), __( 'No theme updates available right now.', 'mainwp' ) ); ?>
480 <?php endif; ?>
481 <?php
482 }
483
484
485 /**
486 * Get the installed version of a theme for a website.
487 *
488 * @param object $website Website object containing installed themes.
489 * @param string $slug Theme slug to look up.
490 * @return string Installed theme version, or an empty string if not found.
491 */
492 public static function get_installed_theme_version( $website, $slug ) {
493 static $site_themes = array();
494
495 $siteid = is_object( $website ) && isset( $website->id ) ? (int) $website->id : 0;
496
497 if ( $siteid && ! isset( $site_themes[ $siteid ] ) && ! empty( $website->themes ) ) {
498 $themes = json_decode( $website->themes, true );
499 $site_themes[ $siteid ] = $themes;
500 }
501
502 $installed_themes = $siteid && ! empty( $site_themes[ $siteid ] ) ? $site_themes[ $siteid ] : array();
503
504 $current_ver = '';
505 if ( is_array( $installed_themes ) ) {
506 foreach ( $installed_themes as $installed_theme ) {
507 if ( is_array( $installed_theme ) && isset( $installed_theme['slug'] ) && $installed_theme['slug'] === $slug ) {
508 $current_ver = $installed_theme['version'] ?? '';
509 break;
510 }
511 }
512 }
513
514 return $current_ver;
515 }
516
517 /**
518 * Method render_trans_update()
519 *
520 * Render translations updates
521 *
522 * @param object $websites the websites.
523 * @param int $total_translation_upgrades total translation updates.
524 * @param mixed $userExtension user extension.
525 * @param array $allTranslations all translations.
526 * @param array $translationsInfo translations information.
527 *
528 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
529 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
530 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
531 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
532 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_trans()
533 * @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector()
534 * @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector()
535 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
536 */
537 public static function render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo ) { // phpcs:ignore -- NOSONAR - complex.
538 $user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' );
539 $trustedPlugins = ! empty( $userExtension->trusted_plugins ) ? json_decode( $userExtension->trusted_plugins, true ) : array();
540 if ( ! is_array( $trustedPlugins ) ) {
541 $trustedPlugins = array();
542 }
543
544 $trustedThemes = json_decode( $userExtension->trusted_themes, true );
545 if ( ! is_array( $trustedThemes ) ) {
546 $trustedThemes = array();
547 }
548 ?>
549
550 <?php if ( 0 < $total_translation_upgrades ) : ?>
551 <table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-translations-sites-table">
552 <thead>
553 <tr>
554 <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>
555 <th scope="col" class="eight wide indicator-accordion-sorting handle-accordion-sorting" data-key="translation">
556 <div class="ui main-master checkbox ">
557 <input type="checkbox" name=""><label><?php esc_html_e( 'Translation', 'mainwp' ); ?></label>
558 </div>
559 <?php MainWP_UI::render_sorting_icons(); ?>
560 </th>
561 <th scope="col" class="two wide indicator-accordion-sorting handle-accordion-sorting" data-key="trusted"><?php esc_html_e( 'Updates', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
562 <th scope="col" class="six wide right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
563 </tr>
564 </thead>
565 <tbody id="translations-updates-global" class="ui accordion">
566 <?php foreach ( $allTranslations as $slug => $val ) { ?>
567 <?php $cnt = intval( $val['cnt'] ); ?>
568 <tr class="title master-checkbox">
569 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
570 <td>
571 <div class="ui master checkbox">
572 <input type="checkbox" name=""><label><?php echo esc_html( $translationsInfo[ $slug ]['name'] ); ?></label>
573 </div>
574 </td>
575 <td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Update', 'Updates', $cnt, 'mainwp' ) ); ?></td>
576 <td class="right aligned">
577 <?php if ( MainWP_Updates::user_can_update_trans() ) { ?>
578 <?php
579 if ( 0 < $cnt ) {
580 if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $userExtension->site_view ) {
581 MainWP_Updates::set_continue_update_html_selector( 'translations_upgrade_all', $slug );
582 }
583 ?>
584 <a href="javascript:void(0)" class="mainwp-update-all-button ui mini button green <?php MainWP_Updates::get_continue_update_selector(); ?>" onClick="updatesoverview_translations_upgrade_all( '<?php echo esc_js( $slug ); ?>', '<?php echo esc_js( rawurlencode( $translationsInfo[ $slug ]['name'] ) ); ?>' ); return false;"><?php esc_html_e( 'Update All', 'mainwp' ); ?></a>
585 <?php } ?>
586 <?php } ?>
587 </td>
588 </tr>
589 <tr class="child-checkbox content">
590 <td colspan="4">
591 <table class="ui table mainwp-manage-updates-table" id="mainwp-translations-sites-table">
592 <thead class="mainwp-768-hide">
593 <tr>
594 <th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
595 <th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
596 <th scope="col" ><?php esc_html_e( 'Trusted', 'mainwp' ); ?></th>
597 <?php if ( $user_can_see_client ) { ?>
598 <th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th>
599 <?php } ?>
600 <th scope="col" class="collapsing no-sort"></th>
601 </tr>
602 </thead>
603 <tbody class="translations-bulk-updates" translation_slug="<?php echo esc_attr( $slug ); ?>" translation_name="<?php echo esc_attr( rawurlencode( $translationsInfo[ $slug ]['name'] ) ); ?>">
604 <?php
605 MainWP_DB::data_seek( $websites, 0 );
606 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
607 $translation_upgrades = json_decode( $website->translation_upgrades, true );
608 $translation_upgrade = null;
609 foreach ( $translation_upgrades as $current_translation_upgrade ) {
610 if ( $current_translation_upgrade['slug'] === $slug ) {
611 $translation_upgrade = $current_translation_upgrade;
612 break;
613 }
614 }
615 if ( null === $translation_upgrade ) {
616 continue;
617 }
618 ?>
619 <tr site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" updated="0">
620 <td class="middle aligned">
621 <div class="ui child checkbox middle aligned fitted">
622 <input type="checkbox" name="">
623 </div>
624 <span class="ui middle aligned fitted" >
625 <?php MainWP_Updates::render_site_link_dashboard( $website ); ?>
626 </span>
627 </td>
628 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $translation_upgrade['version'] ); ?></td>
629 <?php
630 // trusted column.
631 $is_trust = MainWP_Manage_Sites_Update_View::is_trans_trusted_update( $translation_upgrade, $trustedPlugins, $trustedThemes );
632 echo MainWP_Manage_Sites_Update_View::get_column_trusted($is_trust ); //phpcs:ignore -- NOSONAR - escaped.
633 ?>
634 <?php if ( $user_can_see_client ) { ?>
635 <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>
636 <?php } ?>
637 <td class="right aligned">
638 <?php if ( MainWP_Updates::user_can_update_trans() ) : ?>
639 <a href="javascript:void(0)" class="mainwp-update-now-button ui green mini button" onClick="return updatesoverview_upgrade_translation( <?php echo esc_attr( $website->id ); ?>, '<?php echo esc_js( $slug ); ?>' )"><?php esc_html_e( 'Update', 'mainwp' ); ?></a>
640 <?php endif; ?>
641 </td>
642 </tr>
643 <?php
644 }
645 ?>
646 </tbody>
647 </table>
648 </td>
649 </tr>
650 <?php } ?>
651 </tbody>
652 </table>
653 <?php else : ?>
654 <?php MainWP_UI::render_empty_page_placeholder( __( 'Translations are up to date', 'mainwp' ), __( 'No translation updates available right now.', 'mainwp' ) ); ?>
655 <?php endif; ?>
656 <?php
657 }
658
659 /**
660 * Method render_abandoned_plugins()
661 *
662 * Render abandoned plugins
663 *
664 * @param object $websites the websites.
665 * @param array $allPluginsOutdate All abandoned plugins.
666 * @param array $decodedDismissedPlugins all dismissed abandoned plugins.
667 *
668 * @throws \MainWP_Exception Error message.
669 *
670 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
671 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
672 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
673 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
674 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
675 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
676 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
677 */
678 public static function render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins ) { // phpcs:ignore -- NOSONAR - complex.
679 // translators: %s is the number of days since the plugin was last updated.
680 $str_format = esc_html__( 'Updated %s days ago', 'mainwp' );
681 $count_abandoned = count( $allPluginsOutdate );
682 ?>
683 <?php if ( 0 < $count_abandoned ) : ?>
684 <table class="ui tablet stackable table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-abandoned-plugins-items-table">
685 <thead>
686 <tr>
687 <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>
688 <th scope="col" class="no-sort"></th>
689 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="plugin"><?php esc_html_e( 'Plugin', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
690 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
691 <th scope="col" class="collapsing no-sort"><?php MainWP_UI::render_show_all_updates_button(); ?></th>
692 </tr>
693 </thead>
694 <tbody class="ui accordion">
695 <?php foreach ( $allPluginsOutdate as $slug => $val ) { ?>
696 <?php
697 $cnt = intval( $val['cnt'] );
698 $plugin_name = rawurlencode( $slug );
699 ?>
700 <tr class="title">
701 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
702 <td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( dirname( $slug ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
703 <td><a href="<?php echo esc_url( admin_url() ) . 'plugin-install.php?tab=plugin-information&plugin=' . esc_html( dirname( $slug ) ) . '&url=' . ( isset( $val['uri'] ) ? rawurlencode( $val['uri'] ) : '' ) . '&name=' . rawurlencode( $val['name'] ); ?>" target="_blank" class="open-plugin-details-modal" open-wpplugin="yes"><?php echo esc_html( $val['name'] ); ?></a></td>
704 <td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Website', 'Websites', $cnt, 'mainwp' ) ); ?></td>
705 <td class="right aligned">
706 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
707 <a href="javascript:void(0)" class="ui mini green mainwp-ignore-globally-button button" onClick="return updatesoverview_plugins_abandoned_ignore_all( '<?php echo esc_js( $plugin_name ); ?>', '<?php echo esc_js( rawurlencode( $val['name'] ) ); ?>', this )"><?php esc_html_e( 'Ignore Globally', 'mainwp' ); ?></a>
708 <?php } ?>
709 </td>
710 </tr>
711 <tr class="content">
712 <td colspan="5">
713 <table class="ui table mainwp-manage-updates-table" id="mainwp-abandoned-plugins-sites-table">
714 <thead class="mainwp-768-hide">
715 <tr>
716 <th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
717 <th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
718 <th scope="col"><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th>
719 <th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th>
720 <th scope="col" class="no-sort"></th>
721 </tr>
722 </thead>
723 <tbody class="abandoned-plugins-ignore-global" plugin_slug="<?php echo esc_attr( rawurlencode( $slug ) ); ?>" plugin_name="<?php echo esc_attr( rawurlencode( $val['name'] ) ); ?>" dismissed="0">
724 <?php
725 $first_wpplugin = true;
726 MainWP_DB::data_seek( $websites, 0 );
727 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
728 $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
729 $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
730
731 if ( ! is_array( $plugins_outdate ) ) {
732 $plugins_outdate = array();
733 }
734
735 if ( ! empty( $plugins_outdate ) ) {
736 $pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
737 $pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array();
738
739 if ( is_array( $pluginsOutdateDismissed ) ) {
740 $plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed );
741 }
742
743 if ( is_array( $decodedDismissedPlugins ) ) {
744 $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
745 }
746 }
747
748 if ( ! isset( $plugins_outdate[ $slug ] ) ) {
749 continue;
750 }
751
752 $plugin_outdate = $plugins_outdate[ $slug ];
753 $now = new \DateTime();
754 $last_updated = $plugin_outdate['last_updated'];
755 $plugin_last_updated_date = new \DateTime( '@' . $last_updated );
756 $diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
757 $outdate_notice = sprintf( $str_format, $diff_in_days );
758 ?>
759 <tr site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" dismissed="0" <?php echo $first_wpplugin ? 'open-wpplugin-siteid="' . intval( $website->id ) . '"' : ''; ?>>
760 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?>
761 </td>
762 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $plugin_outdate['Version'] ); ?></td>
763 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td>
764 <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>
765 <td class="right aligned">
766 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
767 <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>
768 <?php } ?>
769 </td>
770 </tr>
771 <?php
772 $first_wpplugin = false;
773 }
774 ?>
775 </tbody>
776 </table>
777 </td>
778 </tr>
779 <?php } ?>
780 </tbody>
781 </table>
782 <?php else : ?>
783 <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned plugins detected', 'mainwp' ), __( 'None of your plugins are currently marked as abandoned.', 'mainwp' ) ); ?>
784 <?php endif; ?>
785 <?php
786 }
787
788 /**
789 * Method render_abandoned_themes()
790 *
791 * Render abandoned themes
792 *
793 * @param object $websites the websites.
794 * @param array $allThemesOutdate all abandoned themes.
795 * @param array $decodedDismissedThemes all dismissed abandoned themes.
796 *
797 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
798 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
799 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
800 * @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons()
801 * @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button()
802 * @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates()
803 * @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard()
804 */
805 public static function render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes ) { // phpcs:ignore -- NOSONAR - complex.
806 // translators: %s is the number of days since the theme was last updated.
807 $str_format = esc_html__( 'Updated %s days ago', 'mainwp' );
808 $count_abandoned = count( $allThemesOutdate );
809 ?>
810 <?php if ( 0 < $count_abandoned ) : ?>
811 <table class="ui tablet stackable table mainwp-manage-updates-table mainwp-js-persistent-table mainwp-themes-updates-items-table" id="mainwp-themes-abandoned-updates-table">
812 <thead>
813 <tr>
814 <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>
815 <th scope="col" scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="theme"><?php esc_html_e( 'Theme', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
816 <th scope="col" class="indicator-accordion-sorting handle-accordion-sorting" data-key="abandoned"><?php esc_html_e( 'Abandoned', 'mainwp' ); ?><?php MainWP_UI::render_sorting_icons(); ?></th>
817 <th scope="col" class="collapsing no-sort">
818 <?php MainWP_UI::render_show_all_updates_button(); ?>
819 </th>
820 </tr>
821 </thead>
822 <tbody class="ui accordion">
823 <?php foreach ( $allThemesOutdate as $slug => $val ) { ?>
824 <?php
825 $cnt = intval( $val['cnt'] );
826 $theme_name = rawurlencode( $slug );
827 ?>
828 <tr class="title">
829 <td class="accordion-trigger"><i class="dropdown icon"></i></td>
830 <td><?php echo MainWP_System_Utility::get_theme_icon( $slug ) . '&nbsp;&nbsp;&nbsp;&nbsp;' . esc_html( $val['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
831 <td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Website', 'Websites', $cnt, 'mainwp' ) ); ?></td>
832 <td class="right aligned">
833 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
834 <a href="javascript:void(0)" class="ui mini green mainwp-ignore-globally-button button" onClick="return updatesoverview_themes_abandoned_ignore_all( '<?php echo esc_js( $theme_name ); ?>', '<?php echo esc_js( rawurlencode( $val['name'] ) ); ?>', this )"><?php esc_html_e( 'Ignore Globally', 'mainwp' ); ?></a>
835 <?php } ?>
836 </td>
837 </tr>
838 <tr class="content">
839 <td colspan="4">
840 <table class="ui table mainwp-manage-updates-item-table" id="mainwp-abandoned-themes-sites-table">
841 <thead class="mainwp-768-hide">
842 <tr>
843 <th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
844 <th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
845 <th scope="col"><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th>
846 <th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th>
847 <th scope="col" class="no-sort"></th>
848 </tr>
849 </thead>
850 <tbody class="abandoned-themes-ignore-global" theme_slug="<?php echo esc_attr( $slug ); ?>" theme_name="<?php echo esc_attr( rawurlencode( $val['name'] ) ); ?>">
851 <?php
852 MainWP_DB::data_seek( $websites, 0 );
853 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
854 $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
855 $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
856
857 if ( ! is_array( $themes_outdate ) ) {
858 $themes_outdate = array();
859 }
860
861 if ( ! empty( $themes_outdate ) ) {
862 $themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
863 $themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array();
864
865 if ( is_array( $themesOutdateDismissed ) ) {
866 $themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed );
867 }
868
869 if ( is_array( $decodedDismissedThemes ) ) {
870 $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
871 }
872 }
873
874 if ( ! isset( $themes_outdate[ $slug ] ) ) {
875 continue;
876 }
877
878 $theme_outdate = $themes_outdate[ $slug ];
879 $now = new \DateTime();
880 $last_updated = $theme_outdate['last_updated'];
881 $theme_last_updated_date = new \DateTime( '@' . $last_updated );
882 $diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' );
883 $outdate_notice = sprintf( $str_format, $diff_in_days );
884 ?>
885 <tr site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" outdate="1" dismissed="0">
886 <td>
887 <strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?>
888 </td>
889 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $theme_outdate['Version'] ); ?></td>
890 <td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td>
891 <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>
892 <td class="right aligned">
893 <?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?>
894 <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>
895 <?php } ?>
896 </td>
897 </tr>
898 <?php
899 }
900 ?>
901 </tbody>
902 </table>
903 </td>
904 </tr>
905 <?php } ?>
906 </tbody>
907 </table>
908 <?php else : ?>
909 <?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned themes detected', 'mainwp' ), __( 'None of your themes are currently marked as abandoned.', 'mainwp' ) ); ?>
910 <?php endif; ?>
911 <?php
912 }
913 }
914