| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Updates Per Item. |
| 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_Item. |
| 17 |
*/ |
| 18 |
class MainWP_Updates_Per_Item { // 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_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 |
<?php echo MainWP_System_Utility::get_plugin_icon( $pluginsInfo[ $slug ]['slug'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?> |
| 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 |
} |
| 134 |
|
| 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(); |
| 140 |
|
| 141 |
$rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array(); |
| 142 |
|
| 143 |
$rollPlugins = array(); |
| 144 |
if ( is_array( $rollItems ) && ! empty( $rollItems['plugin'] ) && is_array( $rollItems['plugin'] ) ) { |
| 145 |
$rollPlugins = $rollItems['plugin']; |
| 146 |
} |
| 147 |
|
| 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 |
} |
| 160 |
|
| 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 ); |
| 164 |
|
| 165 |
} |
| 166 |
|
| 167 |
if ( ! isset( $plugin_upgrades[ $slug ] ) ) { |
| 168 |
continue; |
| 169 |
} |
| 170 |
$plugin_upgrade = $plugin_upgrades[ $slug ]; |
| 171 |
|
| 172 |
$last_version = $plugin_upgrade['update']['new_version']; |
| 173 |
$row_columns = array( |
| 174 |
'site' => true, |
| 175 |
'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $plugin_upgrade['Version'] ), |
| 176 |
'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>', |
| 177 |
'trusted' => ( in_array( $slug, $trustedPlugins ) ? true : false ), |
| 178 |
'status' => ( isset( $plugin_upgrade['active'] ) && $plugin_upgrade['active'] ) ? true : false, |
| 179 |
'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>' : '', |
| 180 |
); |
| 181 |
|
| 182 |
$others = array(); |
| 183 |
if ( ! empty( $rollPlugins[ $slug ][ $last_version ] ) ) { |
| 184 |
$msg = MainWP_Updates_Helper::get_roll_msg( $rollPlugins[ $slug ][ $last_version ], true, 'notice' ); |
| 185 |
$others['roll_info'] = $msg; |
| 186 |
} |
| 187 |
|
| 188 |
$tz_info = MainWP_Updates::get_site_tz_info( $website ); |
| 189 |
|
| 190 |
$compatible_php = isset( $plugin_upgrade['wp_compatible'] ) ? $plugin_upgrade['wp_compatible'] : true; |
| 191 |
$compatible_wp = isset( $plugin_upgrade['php_compatible'] ) ? $plugin_upgrade['php_compatible'] : true; |
| 192 |
|
| 193 |
?> |
| 194 |
<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 ); ?>"> |
| 195 |
<?php |
| 196 |
$row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others ); |
| 197 |
$action_rendered = isset( $row_columns['action'] ) ? true : false; |
| 198 |
if ( ! $action_rendered ) { |
| 199 |
?> |
| 200 |
<td class="right aligned"> |
| 201 |
<a href="#" history-view="update-plugin-per-item" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a> |
| 202 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) : ?> |
| 203 |
<div class="ui top left pointing dropdown mini button"> |
| 204 |
<?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i> |
| 205 |
<div class="menu"> |
| 206 |
<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> |
| 207 |
<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> |
| 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, 'all_versions' )"><?php esc_html_e( 'Ignore all versions', 'mainwp' ); ?></a> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
<?php endif; ?> |
| 212 |
<?php |
| 213 |
if ( MainWP_Updates::user_can_update_plugins() ) : |
| 214 |
if ( $compatible_php && $compatible_wp ) { |
| 215 |
?> |
| 216 |
<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> |
| 217 |
<?php |
| 218 |
} else { |
| 219 |
self::render_incompatible_message( $compatible_php, $compatible_wp ); |
| 220 |
} |
| 221 |
?> |
| 222 |
<?php endif; ?> |
| 223 |
</td> |
| 224 |
<?php } ?> |
| 225 |
</tr> |
| 226 |
<?php |
| 227 |
$first_wpplugin = false; |
| 228 |
} |
| 229 |
?> |
| 230 |
</tbody> |
| 231 |
</table> |
| 232 |
</td> |
| 233 |
</tr> |
| 234 |
<?php } ?> |
| 235 |
</tbody> |
| 236 |
</table> |
| 237 |
<?php else : ?> |
| 238 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'Plugins are up to date', 'mainwp' ), __( 'No plugin updates available right now.', 'mainwp' ) ); ?> |
| 239 |
<?php endif; ?> |
| 240 |
<?php |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Method render_incompatible_message(). |
| 245 |
* |
| 246 |
* @param mixed $compatible_php Compatible php. |
| 247 |
* @param mixed $compatible_wp Compatible wp. * |
| 248 |
* @param mixed $echo_content Print content or not. |
| 249 |
* |
| 250 |
* @return string Message |
| 251 |
*/ |
| 252 |
public static function render_incompatible_message( $compatible_php, $compatible_wp, $echo_content = true ) { |
| 253 |
$msg = static::get_incompatible_message( $compatible_php, $compatible_wp ); |
| 254 |
if ( ! empty( $msg ) ) { |
| 255 |
$html = '<span class="ui yellow message">' . esc_html( $msg ) . '</span>'; |
| 256 |
if ( $echo_content ) { |
| 257 |
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 258 |
} else { |
| 259 |
return $html; |
| 260 |
} |
| 261 |
} |
| 262 |
return ''; |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* Method get_incompatible_message(). |
| 267 |
* |
| 268 |
* @param mixed $compatible_php Compatible php. |
| 269 |
* @param mixed $compatible_wp Compatible wp. |
| 270 |
* @return string Message |
| 271 |
*/ |
| 272 |
public static function get_incompatible_message( $compatible_php, $compatible_wp ) { |
| 273 |
$msg = ''; |
| 274 |
if ( ! $compatible_php || ! $compatible_wp ) { |
| 275 |
if ( ! $compatible_php && ! $compatible_wp ) { |
| 276 |
$msg .= __( 'This plugin does not work with your versions of WordPress and PHP.', 'mainwp' ); |
| 277 |
} elseif ( ! $compatible_wp ) { |
| 278 |
$msg .= __( 'This plugin does not work with your version of WordPress.', 'mainwp' ); |
| 279 |
} elseif ( ! $compatible_php ) { |
| 280 |
$msg .= __( 'This plugin does not work with your version of PHP.', 'mainwp' ); |
| 281 |
} |
| 282 |
} |
| 283 |
return $msg; |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* Method render_themes_updates() |
| 288 |
* |
| 289 |
* Render theme updates |
| 290 |
* |
| 291 |
* @param object $websites the websites. |
| 292 |
* @param int $total_theme_upgrades total theme updates. |
| 293 |
* @param mixed $userExtension user extension. |
| 294 |
* @param array $allThemes all themes. |
| 295 |
* @param array $themesInfo themes information. |
| 296 |
* @param array $trustedThemes trusted themes. |
| 297 |
* |
| 298 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 299 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 300 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 301 |
* @uses \MainWP\Dashboard\MainWP_UI |
| 302 |
* @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons() |
| 303 |
* @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button() |
| 304 |
* @uses \MainWP\Dashboard\MainWP_Updates_Table_Helper |
| 305 |
* @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_themes() |
| 306 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 307 |
* @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates() |
| 308 |
* @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard() |
| 309 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 310 |
*/ |
| 311 |
public static function render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes ) { // phpcs:ignore -- NOSONAR - complex. |
| 312 |
$updates_table_helper = new MainWP_Updates_Table_Helper( $userExtension->site_view, 'theme' ); |
| 313 |
?> |
| 314 |
<?php if ( 0 < $total_theme_upgrades ) : ?> |
| 315 |
<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"> |
| 316 |
<thead> |
| 317 |
<tr> |
| 318 |
<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> |
| 319 |
<th scope="col" class="eight wide handle-accordion-sorting indicator-accordion-sorting" data-key="theme"> |
| 320 |
<div class="ui main-master checkbox "> |
| 321 |
<input type="checkbox" name=""><label><?php esc_html_e( 'Theme', 'mainwp' ); ?></label> |
| 322 |
</div> |
| 323 |
<?php MainWP_UI::render_sorting_icons(); ?> |
| 324 |
</th> |
| 325 |
<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> |
| 326 |
<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> |
| 327 |
<th scope="col" class="four wide no-sort right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th> |
| 328 |
</tr> |
| 329 |
</thead> |
| 330 |
<tbody id="themes-updates-global" class="ui accordion"> |
| 331 |
<?php foreach ( $allThemes as $slug => $val ) { ?> |
| 332 |
<?php |
| 333 |
$cnt = intval( $val['cnt'] ); |
| 334 |
$theme_name = rawurlencode( $slug ); |
| 335 |
$trusted = in_array( $slug, $trustedThemes ) ? 1 : 0; |
| 336 |
?> |
| 337 |
<tr class="ui title master-checkbox"> |
| 338 |
<td class="accordion-trigger"><i class="icon dropdown"></i></td> |
| 339 |
<td class="middle aligned"> |
| 340 |
<div class="ui middle aligned fitted master checkbox"> |
| 341 |
<input type="checkbox" name=""> |
| 342 |
</div> |
| 343 |
<?php echo MainWP_System_Utility::get_theme_icon( $slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?> <?php echo esc_html( $themesInfo[ $slug ]['name'] ); ?> |
| 344 |
</td> |
| 345 |
<td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Update', 'Updates', $cnt, 'mainwp' ) ); ?></td> |
| 346 |
<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> |
| 347 |
<td class="right aligned"> |
| 348 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 349 |
<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> |
| 350 |
<?php } ?> |
| 351 |
<?php if ( MainWP_Updates::user_can_update_themes() ) { ?> |
| 352 |
<?php |
| 353 |
if ( 0 < $cnt ) { |
| 354 |
if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $userExtension->site_view ) { |
| 355 |
MainWP_Updates::set_continue_update_html_selector( 'themes_upgrade_all', $slug ); |
| 356 |
} |
| 357 |
?> |
| 358 |
<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> |
| 359 |
<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> |
| 360 |
|
| 361 |
<?php } ?> |
| 362 |
<?php } ?> |
| 363 |
</td> |
| 364 |
</tr> |
| 365 |
<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; ?>"> |
| 366 |
<td colspan="5"> |
| 367 |
<table id="mainwp-themes-updates-sites-inner-table" class="ui table mainwp-manage-updates-table mainwp-updates-list"> |
| 368 |
<thead class="mainwp-768-hide"> |
| 369 |
<tr> |
| 370 |
<?php $updates_table_helper->print_column_headers(); ?> |
| 371 |
</tr> |
| 372 |
</thead> |
| 373 |
<tbody theme_slug="<?php echo esc_attr( $theme_name ); ?>"> |
| 374 |
<?php |
| 375 |
MainWP_DB::data_seek( $websites, 0 ); |
| 376 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 377 |
if ( $website->is_ignoreThemeUpdates ) { |
| 378 |
continue; |
| 379 |
} |
| 380 |
$theme_upgrades = json_decode( $website->theme_upgrades, true ); |
| 381 |
|
| 382 |
$site_opts = MainWP_DB::instance()->get_website_options_array( $website, array( 'premium_upgrades', 'rollback_updates_data' ) ); |
| 383 |
if ( ! is_array( $site_opts ) ) { |
| 384 |
$site_opts = array(); |
| 385 |
} |
| 386 |
$decodedPremiumUpgrades = ! empty( $site_opts['premium_upgrades'] ) ? json_decode( $site_opts['premium_upgrades'], true ) : array(); |
| 387 |
|
| 388 |
$rollItems = ! empty( $site_opts['rollback_updates_data'] ) ? json_decode( $site_opts['rollback_updates_data'], true ) : array(); |
| 389 |
|
| 390 |
$rollThemes = array(); |
| 391 |
if ( is_array( $rollItems ) && ! empty( $rollItems['theme'] ) && is_array( $rollItems['theme'] ) ) { |
| 392 |
$rollThemes = $rollItems['theme']; |
| 393 |
} |
| 394 |
|
| 395 |
if ( is_array( $decodedPremiumUpgrades ) ) { |
| 396 |
foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) { |
| 397 |
$premiumUpgrade['premium'] = true; |
| 398 |
if ( 'theme' === $premiumUpgrade['type'] ) { |
| 399 |
if ( ! is_array( $theme_upgrades ) ) { |
| 400 |
$theme_upgrades = array(); |
| 401 |
} |
| 402 |
$premiumUpgrade = array_filter( $premiumUpgrade ); |
| 403 |
if ( ! isset( $theme_upgrades[ $crrSlug ] ) ) { |
| 404 |
$theme_upgrades[ $crrSlug ] = array(); |
| 405 |
} |
| 406 |
$theme_upgrades[ $crrSlug ] = array_merge( $theme_upgrades[ $crrSlug ], $premiumUpgrade ); |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
$ignored_themes = json_decode( $website->ignored_themes, true ); |
| 411 |
if ( is_array( $ignored_themes ) ) { |
| 412 |
$theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); |
| 413 |
} |
| 414 |
|
| 415 |
if ( ! isset( $theme_upgrades[ $slug ] ) ) { |
| 416 |
continue; |
| 417 |
} |
| 418 |
$theme_upgrade = $theme_upgrades[ $slug ]; |
| 419 |
$last_version = $theme_upgrade['update']['new_version']; |
| 420 |
$row_columns = array( |
| 421 |
'site' => true, |
| 422 |
'version' => '<strong class="mainwp-768-show">' . esc_html__( 'Version: ', 'mainwp' ) . '</strong>' . esc_html( $theme_upgrade['Version'] ), |
| 423 |
'latest' => '<strong class="mainwp-768-show">' . esc_html__( 'Latest: ', 'mainwp' ) . '</strong>' . esc_html( $last_version ), |
| 424 |
'trusted' => ( in_array( $slug, $trustedThemes ) ? true : false ), |
| 425 |
'status' => ( isset( $theme_upgrade['active'] ) && $theme_upgrade['active'] ) ? true : false, |
| 426 |
'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>' : '', |
| 427 |
); |
| 428 |
|
| 429 |
$others = array(); |
| 430 |
if ( ! empty( $rollThemes[ $slug ][ $last_version ] ) ) { |
| 431 |
$msg = MainWP_Updates_Helper::get_roll_msg( $rollThemes[ $slug ][ $last_version ], true, 'notice' ); |
| 432 |
$others['roll_info'] = $msg; |
| 433 |
} |
| 434 |
|
| 435 |
$tz_info = MainWP_Updates::get_site_tz_info( $website ); |
| 436 |
|
| 437 |
?> |
| 438 |
<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 ); ?>"> |
| 439 |
<?php |
| 440 |
$row_columns = $updates_table_helper->render_columns( $row_columns, $website, $others ); |
| 441 |
$action_rendered = isset( $row_columns['action'] ) ? true : false; |
| 442 |
if ( ! $action_rendered ) { |
| 443 |
?> |
| 444 |
<td class="right aligned"> |
| 445 |
<a href="#" history-view="update-theme-per-item" class="mainwp-show-history ui mini button"><?php esc_html_e( 'History', 'mainwp' ); ?></a> |
| 446 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 447 |
<div class="ui top left pointing dropdown mini button"> |
| 448 |
<?php esc_html_e( 'Ignore', 'mainwp' ); ?><i class="dropdown icon"></i> |
| 449 |
<div class="menu"> |
| 450 |
<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> |
| 451 |
<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> |
| 452 |
<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> |
| 453 |
</div> |
| 454 |
</div> |
| 455 |
<?php } ?> |
| 456 |
<?php if ( MainWP_Updates::user_can_update_themes() ) : ?> |
| 457 |
<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> |
| 458 |
<?php endif; ?> |
| 459 |
</td> |
| 460 |
<?php } ?> |
| 461 |
</tr> |
| 462 |
<?php |
| 463 |
} |
| 464 |
?> |
| 465 |
</tbody> |
| 466 |
</table> |
| 467 |
</td> |
| 468 |
</tr> |
| 469 |
<?php } ?> |
| 470 |
</tbody> |
| 471 |
</table> |
| 472 |
<?php else : ?> |
| 473 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'Themes are up to date', 'mainwp' ), __( 'No theme updates available right now.', 'mainwp' ) ); ?> |
| 474 |
<?php endif; ?> |
| 475 |
<?php |
| 476 |
} |
| 477 |
|
| 478 |
/** |
| 479 |
* Method render_trans_update() |
| 480 |
* |
| 481 |
* Render translations updates |
| 482 |
* |
| 483 |
* @param object $websites the websites. |
| 484 |
* @param int $total_translation_upgrades total translation updates. |
| 485 |
* @param mixed $userExtension user extension. |
| 486 |
* @param array $allTranslations all translations. |
| 487 |
* @param array $translationsInfo translations information. |
| 488 |
* |
| 489 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 490 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 491 |
* @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons() |
| 492 |
* @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button() |
| 493 |
* @uses \MainWP\Dashboard\MainWP_Updates::user_can_update_trans() |
| 494 |
* @uses \MainWP\Dashboard\MainWP_Updates::set_continue_update_html_selector() |
| 495 |
* @uses \MainWP\Dashboard\MainWP_Updates::get_continue_update_selector() |
| 496 |
* @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard() |
| 497 |
*/ |
| 498 |
public static function render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo ) { // phpcs:ignore -- NOSONAR - complex. |
| 499 |
$user_can_see_client = \mainwp_current_user_can( 'dashboard', 'manage_clients' ); |
| 500 |
$trustedPlugins = ! empty( $userExtension->trusted_plugins ) ? json_decode( $userExtension->trusted_plugins, true ) : array(); |
| 501 |
if ( ! is_array( $trustedPlugins ) ) { |
| 502 |
$trustedPlugins = array(); |
| 503 |
} |
| 504 |
|
| 505 |
$trustedThemes = json_decode( $userExtension->trusted_themes, true ); |
| 506 |
if ( ! is_array( $trustedThemes ) ) { |
| 507 |
$trustedThemes = array(); |
| 508 |
} |
| 509 |
?> |
| 510 |
|
| 511 |
<?php if ( 0 < $total_translation_upgrades ) : ?> |
| 512 |
<table class="ui tablet stackable table mainwp-manage-updates-table main-master-checkbox mainwp-js-persistent-table" id="mainwp-translations-sites-table"> |
| 513 |
<thead> |
| 514 |
<tr> |
| 515 |
<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> |
| 516 |
<th scope="col" class="eight wide indicator-accordion-sorting handle-accordion-sorting" data-key="translation"> |
| 517 |
<div class="ui main-master checkbox "> |
| 518 |
<input type="checkbox" name=""><label><?php esc_html_e( 'Translation', 'mainwp' ); ?></label> |
| 519 |
</div> |
| 520 |
<?php MainWP_UI::render_sorting_icons(); ?> |
| 521 |
</th> |
| 522 |
<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> |
| 523 |
<th scope="col" class="six wide right aligned"><?php MainWP_UI::render_show_all_updates_button(); ?></th> |
| 524 |
</tr> |
| 525 |
</thead> |
| 526 |
<tbody id="translations-updates-global" class="ui accordion"> |
| 527 |
<?php foreach ( $allTranslations as $slug => $val ) { ?> |
| 528 |
<?php $cnt = intval( $val['cnt'] ); ?> |
| 529 |
<tr class="title master-checkbox"> |
| 530 |
<td class="accordion-trigger"><i class="dropdown icon"></i></td> |
| 531 |
<td> |
| 532 |
<div class="ui master checkbox"> |
| 533 |
<input type="checkbox" name=""><label><?php echo esc_html( $translationsInfo[ $slug ]['name'] ); ?></label> |
| 534 |
</div> |
| 535 |
</td> |
| 536 |
<td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Update', 'Updates', $cnt, 'mainwp' ) ); ?></td> |
| 537 |
<td class="right aligned"> |
| 538 |
<?php if ( MainWP_Updates::user_can_update_trans() ) { ?> |
| 539 |
<?php |
| 540 |
if ( 0 < $cnt ) { |
| 541 |
if ( MAINWP_VIEW_PER_PLUGIN_THEME === (int) $userExtension->site_view ) { |
| 542 |
MainWP_Updates::set_continue_update_html_selector( 'translations_upgrade_all', $slug ); |
| 543 |
} |
| 544 |
?> |
| 545 |
<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> |
| 546 |
<?php } ?> |
| 547 |
<?php } ?> |
| 548 |
</td> |
| 549 |
</tr> |
| 550 |
<tr class="child-checkbox content"> |
| 551 |
<td colspan="4"> |
| 552 |
<table class="ui table mainwp-manage-updates-table" id="mainwp-translations-sites-table"> |
| 553 |
<thead class="mainwp-768-hide"> |
| 554 |
<tr> |
| 555 |
<th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> |
| 556 |
<th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th> |
| 557 |
<th scope="col" ><?php esc_html_e( 'Trusted', 'mainwp' ); ?></th> |
| 558 |
<?php if ( $user_can_see_client ) { ?> |
| 559 |
<th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th> |
| 560 |
<?php } ?> |
| 561 |
<th scope="col" class="collapsing no-sort"></th> |
| 562 |
</tr> |
| 563 |
</thead> |
| 564 |
<tbody class="translations-bulk-updates" translation_slug="<?php echo esc_attr( $slug ); ?>" translation_name="<?php echo esc_attr( rawurlencode( $translationsInfo[ $slug ]['name'] ) ); ?>"> |
| 565 |
<?php |
| 566 |
MainWP_DB::data_seek( $websites, 0 ); |
| 567 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 568 |
$translation_upgrades = json_decode( $website->translation_upgrades, true ); |
| 569 |
$translation_upgrade = null; |
| 570 |
foreach ( $translation_upgrades as $current_translation_upgrade ) { |
| 571 |
if ( $current_translation_upgrade['slug'] === $slug ) { |
| 572 |
$translation_upgrade = $current_translation_upgrade; |
| 573 |
break; |
| 574 |
} |
| 575 |
} |
| 576 |
if ( null === $translation_upgrade ) { |
| 577 |
continue; |
| 578 |
} |
| 579 |
?> |
| 580 |
<tr site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" updated="0"> |
| 581 |
<td class="middle aligned"> |
| 582 |
<div class="ui child checkbox middle aligned fitted"> |
| 583 |
<input type="checkbox" name=""> |
| 584 |
</div> |
| 585 |
<span class="ui middle aligned fitted" > |
| 586 |
<?php MainWP_Updates::render_site_link_dashboard( $website ); ?> |
| 587 |
</span> |
| 588 |
</td> |
| 589 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $translation_upgrade['version'] ); ?></td> |
| 590 |
<?php |
| 591 |
// trusted column. |
| 592 |
$is_trust = MainWP_Manage_Sites_Update_View::is_trans_trusted_update( $translation_upgrade, $trustedPlugins, $trustedThemes ); |
| 593 |
echo MainWP_Manage_Sites_Update_View::get_column_trusted($is_trust ); //phpcs:ignore -- NOSONAR - escaped. |
| 594 |
?> |
| 595 |
<?php if ( $user_can_see_client ) { ?> |
| 596 |
<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> |
| 597 |
<?php } ?> |
| 598 |
<td class="right aligned"> |
| 599 |
<?php if ( MainWP_Updates::user_can_update_trans() ) : ?> |
| 600 |
<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> |
| 601 |
<?php endif; ?> |
| 602 |
</td> |
| 603 |
</tr> |
| 604 |
<?php |
| 605 |
} |
| 606 |
?> |
| 607 |
</tbody> |
| 608 |
</table> |
| 609 |
</td> |
| 610 |
</tr> |
| 611 |
<?php } ?> |
| 612 |
</tbody> |
| 613 |
</table> |
| 614 |
<?php else : ?> |
| 615 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'Translations are up to date', 'mainwp' ), __( 'No translation updates available right now.', 'mainwp' ) ); ?> |
| 616 |
<?php endif; ?> |
| 617 |
<?php |
| 618 |
} |
| 619 |
|
| 620 |
/** |
| 621 |
* Method render_abandoned_plugins() |
| 622 |
* |
| 623 |
* Render abandoned plugins |
| 624 |
* |
| 625 |
* @param object $websites the websites. |
| 626 |
* @param array $allPluginsOutdate All abandoned plugins. |
| 627 |
* @param array $decodedDismissedPlugins all dismissed abandoned plugins. |
| 628 |
* |
| 629 |
* @throws \MainWP_Exception Error message. |
| 630 |
* |
| 631 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 632 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 633 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 634 |
* @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons() |
| 635 |
* @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button() |
| 636 |
* @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates() |
| 637 |
* @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard() |
| 638 |
*/ |
| 639 |
public static function render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins ) { // phpcs:ignore -- NOSONAR - complex. |
| 640 |
// translators: %s is the number of days since the plugin was last updated. |
| 641 |
$str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); |
| 642 |
$count_abandoned = count( $allPluginsOutdate ); |
| 643 |
?> |
| 644 |
<?php if ( 0 < $count_abandoned ) : ?> |
| 645 |
<table class="ui tablet stackable table mainwp-manage-updates-table mainwp-js-persistent-table" id="mainwp-abandoned-plugins-items-table"> |
| 646 |
<thead> |
| 647 |
<tr> |
| 648 |
<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> |
| 649 |
<th scope="col" class="no-sort"></th> |
| 650 |
<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> |
| 651 |
<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> |
| 652 |
<th scope="col" class="collapsing no-sort"><?php MainWP_UI::render_show_all_updates_button(); ?></th> |
| 653 |
</tr> |
| 654 |
</thead> |
| 655 |
<tbody class="ui accordion"> |
| 656 |
<?php foreach ( $allPluginsOutdate as $slug => $val ) { ?> |
| 657 |
<?php |
| 658 |
$cnt = intval( $val['cnt'] ); |
| 659 |
$plugin_name = rawurlencode( $slug ); |
| 660 |
?> |
| 661 |
<tr class="title"> |
| 662 |
<td class="accordion-trigger"><i class="dropdown icon"></i></td> |
| 663 |
<td class="collapsing"><?php echo MainWP_System_Utility::get_plugin_icon( dirname( $slug ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td> |
| 664 |
<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> |
| 665 |
<td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Website', 'Websites', $cnt, 'mainwp' ) ); ?></td> |
| 666 |
<td class="right aligned"> |
| 667 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 668 |
<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> |
| 669 |
<?php } ?> |
| 670 |
</td> |
| 671 |
</tr> |
| 672 |
<tr class="content"> |
| 673 |
<td colspan="5"> |
| 674 |
<table class="ui table mainwp-manage-updates-table" id="mainwp-abandoned-plugins-sites-table"> |
| 675 |
<thead class="mainwp-768-hide"> |
| 676 |
<tr> |
| 677 |
<th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> |
| 678 |
<th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th> |
| 679 |
<th scope="col"><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> |
| 680 |
<th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th> |
| 681 |
<th scope="col" class="no-sort"></th> |
| 682 |
</tr> |
| 683 |
</thead> |
| 684 |
<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"> |
| 685 |
<?php |
| 686 |
$first_wpplugin = true; |
| 687 |
MainWP_DB::data_seek( $websites, 0 ); |
| 688 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 689 |
$plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' ); |
| 690 |
$plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array(); |
| 691 |
|
| 692 |
if ( ! is_array( $plugins_outdate ) ) { |
| 693 |
$plugins_outdate = array(); |
| 694 |
} |
| 695 |
|
| 696 |
if ( ! empty( $plugins_outdate ) ) { |
| 697 |
$pluginsOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' ); |
| 698 |
$pluginsOutdateDismissed = ! empty( $pluginsOutdateDismissed ) ? json_decode( $pluginsOutdateDismissed, true ) : array(); |
| 699 |
|
| 700 |
if ( is_array( $pluginsOutdateDismissed ) ) { |
| 701 |
$plugins_outdate = array_diff_key( $plugins_outdate, $pluginsOutdateDismissed ); |
| 702 |
} |
| 703 |
|
| 704 |
if ( is_array( $decodedDismissedPlugins ) ) { |
| 705 |
$plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins ); |
| 706 |
} |
| 707 |
} |
| 708 |
|
| 709 |
if ( ! isset( $plugins_outdate[ $slug ] ) ) { |
| 710 |
continue; |
| 711 |
} |
| 712 |
|
| 713 |
$plugin_outdate = $plugins_outdate[ $slug ]; |
| 714 |
$now = new \DateTime(); |
| 715 |
$last_updated = $plugin_outdate['last_updated']; |
| 716 |
$plugin_last_updated_date = new \DateTime( '@' . $last_updated ); |
| 717 |
$diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' ); |
| 718 |
$outdate_notice = sprintf( $str_format, $diff_in_days ); |
| 719 |
?> |
| 720 |
<tr site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" dismissed="0" <?php echo $first_wpplugin ? 'open-wpplugin-siteid="' . intval( $website->id ) . '"' : ''; ?>> |
| 721 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?> |
| 722 |
</td> |
| 723 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $plugin_outdate['Version'] ); ?></td> |
| 724 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td> |
| 725 |
<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> |
| 726 |
<td class="right aligned"> |
| 727 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 728 |
<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> |
| 729 |
<?php } ?> |
| 730 |
</td> |
| 731 |
</tr> |
| 732 |
<?php |
| 733 |
$first_wpplugin = false; |
| 734 |
} |
| 735 |
?> |
| 736 |
</tbody> |
| 737 |
</table> |
| 738 |
</td> |
| 739 |
</tr> |
| 740 |
<?php } ?> |
| 741 |
</tbody> |
| 742 |
</table> |
| 743 |
<?php else : ?> |
| 744 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned plugins detected', 'mainwp' ), __( 'None of your plugins are currently marked as abandoned.', 'mainwp' ) ); ?> |
| 745 |
<?php endif; ?> |
| 746 |
<?php |
| 747 |
} |
| 748 |
|
| 749 |
/** |
| 750 |
* Method render_abandoned_themes() |
| 751 |
* |
| 752 |
* Render abandoned themes |
| 753 |
* |
| 754 |
* @param object $websites the websites. |
| 755 |
* @param array $allThemesOutdate all abandoned themes. |
| 756 |
* @param array $decodedDismissedThemes all dismissed abandoned themes. |
| 757 |
* |
| 758 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 759 |
* @uses \MainWP\Dashboard\MainWP_DB::fetch_object() |
| 760 |
* @uses \MainWP\Dashboard\MainWP_DB::data_seek() |
| 761 |
* @uses \MainWP\Dashboard\MainWP_UI::render_sorting_icons() |
| 762 |
* @uses \MainWP\Dashboard\MainWP_UI::render_show_all_updates_button() |
| 763 |
* @uses \MainWP\Dashboard\MainWP_Updates::user_can_ignore_updates() |
| 764 |
* @uses \MainWP\Dashboard\MainWP_Updates::render_site_link_dashboard() |
| 765 |
*/ |
| 766 |
public static function render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes ) { // phpcs:ignore -- NOSONAR - complex. |
| 767 |
// translators: %s is the number of days since the theme was last updated. |
| 768 |
$str_format = esc_html__( 'Updated %s days ago', 'mainwp' ); |
| 769 |
$count_abandoned = count( $allThemesOutdate ); |
| 770 |
?> |
| 771 |
<?php if ( 0 < $count_abandoned ) : ?> |
| 772 |
<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"> |
| 773 |
<thead> |
| 774 |
<tr> |
| 775 |
<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> |
| 776 |
<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> |
| 777 |
<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> |
| 778 |
<th scope="col" class="collapsing no-sort"> |
| 779 |
<?php MainWP_UI::render_show_all_updates_button(); ?> |
| 780 |
</th> |
| 781 |
</tr> |
| 782 |
</thead> |
| 783 |
<tbody class="ui accordion"> |
| 784 |
<?php foreach ( $allThemesOutdate as $slug => $val ) { ?> |
| 785 |
<?php |
| 786 |
$cnt = intval( $val['cnt'] ); |
| 787 |
$theme_name = rawurlencode( $slug ); |
| 788 |
?> |
| 789 |
<tr class="title"> |
| 790 |
<td class="accordion-trigger"><i class="dropdown icon"></i></td> |
| 791 |
<td><?php echo MainWP_System_Utility::get_theme_icon( $slug ) . ' ' . esc_html( $val['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td> |
| 792 |
<td sort-value="<?php echo intval( $cnt ); ?>"><?php echo intval( $cnt ); ?> <?php echo esc_html( _n( 'Website', 'Websites', $cnt, 'mainwp' ) ); ?></td> |
| 793 |
<td class="right aligned"> |
| 794 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 795 |
<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> |
| 796 |
<?php } ?> |
| 797 |
</td> |
| 798 |
</tr> |
| 799 |
<tr class="content"> |
| 800 |
<td colspan="4"> |
| 801 |
<table class="ui table mainwp-manage-updates-item-table" id="mainwp-abandoned-themes-sites-table"> |
| 802 |
<thead class="mainwp-768-hide"> |
| 803 |
<tr> |
| 804 |
<th scope="col"><?php esc_html_e( 'Website', 'mainwp' ); ?></th> |
| 805 |
<th scope="col"><?php esc_html_e( 'Version', 'mainwp' ); ?></th> |
| 806 |
<th scope="col"><?php esc_html_e( 'Last Update', 'mainwp' ); ?></th> |
| 807 |
<th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th> |
| 808 |
<th scope="col" class="no-sort"></th> |
| 809 |
</tr> |
| 810 |
</thead> |
| 811 |
<tbody class="abandoned-themes-ignore-global" theme_slug="<?php echo esc_attr( $slug ); ?>" theme_name="<?php echo esc_attr( rawurlencode( $val['name'] ) ); ?>"> |
| 812 |
<?php |
| 813 |
MainWP_DB::data_seek( $websites, 0 ); |
| 814 |
while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 815 |
$themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' ); |
| 816 |
$themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array(); |
| 817 |
|
| 818 |
if ( ! is_array( $themes_outdate ) ) { |
| 819 |
$themes_outdate = array(); |
| 820 |
} |
| 821 |
|
| 822 |
if ( ! empty( $themes_outdate ) ) { |
| 823 |
$themesOutdateDismissed = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' ); |
| 824 |
$themesOutdateDismissed = ! empty( $themesOutdateDismissed ) ? json_decode( $themesOutdateDismissed, true ) : array(); |
| 825 |
|
| 826 |
if ( is_array( $themesOutdateDismissed ) ) { |
| 827 |
$themes_outdate = array_diff_key( $themes_outdate, $themesOutdateDismissed ); |
| 828 |
} |
| 829 |
|
| 830 |
if ( is_array( $decodedDismissedThemes ) ) { |
| 831 |
$themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes ); |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
if ( ! isset( $themes_outdate[ $slug ] ) ) { |
| 836 |
continue; |
| 837 |
} |
| 838 |
|
| 839 |
$theme_outdate = $themes_outdate[ $slug ]; |
| 840 |
$now = new \DateTime(); |
| 841 |
$last_updated = $theme_outdate['last_updated']; |
| 842 |
$theme_last_updated_date = new \DateTime( '@' . $last_updated ); |
| 843 |
$diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' ); |
| 844 |
$outdate_notice = sprintf( $str_format, $diff_in_days ); |
| 845 |
?> |
| 846 |
<tr site_id="<?php echo esc_attr( $website->id ); ?>" site_name="<?php echo esc_attr( rawurlencode( stripslashes( $website->name ) ) ); ?>" outdate="1" dismissed="0"> |
| 847 |
<td> |
| 848 |
<strong class="mainwp-768-show"><?php esc_html_e( 'Website:', 'mainwp' ); ?></strong> <?php MainWP_Updates::render_site_link_dashboard( $website ); ?> |
| 849 |
</td> |
| 850 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Version:', 'mainwp' ); ?></strong> <?php echo esc_html( $theme_outdate['Version'] ); ?></td> |
| 851 |
<td><strong class="mainwp-768-show"><?php esc_html_e( 'Last Update:', 'mainwp' ); ?></strong> <?php echo esc_html( $outdate_notice ); ?></td> |
| 852 |
<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> |
| 853 |
<td class="right aligned"> |
| 854 |
<?php if ( MainWP_Updates::user_can_ignore_updates() ) { ?> |
| 855 |
<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> |
| 856 |
<?php } ?> |
| 857 |
</td> |
| 858 |
</tr> |
| 859 |
<?php |
| 860 |
} |
| 861 |
?> |
| 862 |
</tbody> |
| 863 |
</table> |
| 864 |
</td> |
| 865 |
</tr> |
| 866 |
<?php } ?> |
| 867 |
</tbody> |
| 868 |
</table> |
| 869 |
<?php else : ?> |
| 870 |
<?php MainWP_UI::render_empty_page_placeholder( __( 'No abandoned themes detected', 'mainwp' ), __( 'None of your themes are currently marked as abandoned.', 'mainwp' ) ); ?> |
| 871 |
<?php endif; ?> |
| 872 |
<?php |
| 873 |
} |
| 874 |
} |
| 875 |
|