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

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

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