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