Upgrade/Install: Add plugin URL to the automatic update email.

For each automatic plugin update, both successful and failed, information about each plugin is included in the email upon completion of the process.  This change adds the plugin URL, if known, to the information included for each plugin that was processed.

This change also adds unit tests to validate the email contents after various automatic plugin update scenarios.

Props JosVelasco, pbiron, oliverstapelfeldt, ChrisHardie, Ipstenu, dd32, peterwilsoncc, audrasjb, costdev.
Fixes #53049.

git-svn-id: https://develop.svn.wordpress.org/trunk@54212 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
David Baumwald
2022-09-19 20:26:09 +00:00
parent e573d73355
commit 906ec63c78
2 changed files with 612 additions and 16 deletions
@@ -1101,23 +1101,34 @@ class WP_Automatic_Updater {
$body[] = __( 'These plugins failed to update:' );
foreach ( $failed_updates['plugin'] as $item ) {
$body_message = '';
$item_url = '';
if ( ! empty( $item->item->url ) ) {
$item_url = ' : ' . esc_url( $item->item->url );
}
if ( $item->item->current_version ) {
$body[] = sprintf(
/* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
__( '- %1$s (from version %2$s to %3$s)' ),
$body_message .= sprintf(
/* translators: 1: Plugin name, 2: Current version number, 3: New version number, 4: Plugin URL. */
__( '- %1$s (from version %2$s to %3$s)%4$s' ),
$item->name,
$item->item->current_version,
$item->item->new_version
$item->item->new_version,
$item_url
);
} else {
$body[] = sprintf(
/* translators: 1: Plugin name, 2: Version number. */
__( '- %1$s version %2$s' ),
$body_message .= sprintf(
/* translators: 1: Plugin name, 2: Version number, 3: Plugin URL. */
__( '- %1$s version %2$s%3$s' ),
$item->name,
$item->item->new_version
$item->item->new_version,
$item_url
);
}
$body[] = $body_message;
$past_failure_emails[ $item->item->plugin ] = $item->item->new_version;
}
@@ -1162,22 +1173,32 @@ class WP_Automatic_Updater {
$body[] = __( 'These plugins are now up to date:' );
foreach ( $successful_updates['plugin'] as $item ) {
$body_message = '';
$item_url = '';
if ( ! empty( $item->item->url ) ) {
$item_url = ' : ' . esc_url( $item->item->url );
}
if ( $item->item->current_version ) {
$body[] = sprintf(
/* translators: 1: Plugin name, 2: Current version number, 3: New version number. */
__( '- %1$s (from version %2$s to %3$s)' ),
$body_message .= sprintf(
/* translators: 1: Plugin name, 2: Current version number, 3: New version number, 4: Plugin URL. */
__( '- %1$s (from version %2$s to %3$s)%4$s' ),
$item->name,
$item->item->current_version,
$item->item->new_version
$item->item->new_version,
$item_url
);
} else {
$body[] = sprintf(
/* translators: 1: Plugin name, 2: Version number. */
__( '- %1$s version %2$s' ),
$body_message .= sprintf(
/* translators: 1: Plugin name, 2: Version number, 3: Plugin URL. */
__( '- %1$s version %2$s%3$s' ),
$item->name,
$item->item->new_version
$item->item->new_version,
$item_url
);
}
$body[] = $body_message;
unset( $past_failure_emails[ $item->item->plugin ] );
}