PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.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-site.php

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

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