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.
Built from https://develop.svn.wordpress.org/trunk@54212


git-svn-id: http://core.svn.wordpress.org/trunk@53771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2022-09-19 20:28:11 +00:00
parent 3639a578ef
commit 5358008d68
2 changed files with 38 additions and 17 deletions

View File

@ -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 ] );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-54211';
$wp_version = '6.1-alpha-54212';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.