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.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 All 156 releases
mainwp / pages / page-mainwp-updates-per-item.php

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

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