Upgrade/Install: Only show errors if there is nothing to update.

Previously, when the `do-plugin-upgrade` or `do-theme-upgrade` actions were accessed directly on `update-core.php`, an error message stating "Select one or 
more (plugins|themes) to update" would be shown even if there was nothing to update.

This ensures that the error message only appears when there is something to update.

Props Presskopp, sabernhardt, pbiron, afragen, zunaid321, shuvoaftab, ugyensupport, costdev.
Fixes #57999.




git-svn-id: https://develop.svn.wordpress.org/trunk@56107 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2023-06-29 07:19:04 +00:00
parent 239484f717
commit b58eebb2a5

View File

@ -1037,13 +1037,21 @@ if ( 'upgrade-core' === $action ) {
<?php
if ( $upgrade_error ) {
echo '<div class="error"><p>';
if ( 'themes' === $upgrade_error ) {
_e( 'Please select one or more themes to update.' );
$theme_updates = get_theme_updates();
if ( ! empty( $theme_updates ) ) {
echo '<div class="error"><p>';
_e( 'Please select one or more themes to update.' );
echo '</p></div>';
}
} else {
_e( 'Please select one or more plugins to update.' );
$plugin_updates = get_plugin_updates();
if ( ! empty( $plugin_updates ) ) {
echo '<div class="error"><p>';
_e( 'Please select one or more plugins to update.' );
echo '</p></div>';
}
}
echo '</p></div>';
}
$last_update_check = false;