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