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-site.php

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

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