Upgrade/Install: Pass details about the specific plugin and theme updates attempted to filters.

This adds an additional parameter to the `auto_plugin_update_send_email` and `auto_theme_update_send_email` filters to provide the additional context of which updates were attempted and their outcome. This will help plugin and theme auto-update emails to be better tailored to a site owner’s liking.

Props audrasjb, Paddy Landau, desrosj.
Fixes #50988.

git-svn-id: https://develop.svn.wordpress.org/trunk@48888 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2020-08-27 19:25:38 +00:00
parent f3c37d87d2
commit c14417c5c9

View File

@ -879,7 +879,7 @@ class WP_Automatic_Updater {
*
* @since 5.5.0
*
* @param array $update_results The result of updates tasks.
* @param array $update_results The results of update tasks.
*/
protected function after_plugin_theme_update( $update_results ) {
$successful_updates = array();
@ -889,10 +889,12 @@ class WP_Automatic_Updater {
* Filters whether to send an email following an automatic background plugin update.
*
* @since 5.5.0
* @since 5.5.1 Added the $update_results parameter.
*
* @param bool $enabled True if plugins notifications are enabled, false otherwise.
* @param bool $enabled True if plugins notifications are enabled, false otherwise.
* @param array $update_results The results of plugins update tasks.
*/
$notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true );
$notifications_enabled = apply_filters( 'auto_plugin_update_send_email', true, $update_results['plugin'] );
if ( ! empty( $update_results['plugin'] ) && $notifications_enabled ) {
foreach ( $update_results['plugin'] as $update_result ) {
@ -908,10 +910,12 @@ class WP_Automatic_Updater {
* Filters whether to send an email following an automatic background theme update.
*
* @since 5.5.0
* @since 5.5.1 Added the $update_results parameter.
*
* @param bool $enabled True if notifications are enabled, false otherwise.
* @param bool $enabled True if notifications are enabled, false otherwise.
* @param array $update_results The results of theme update tasks.
*/
$notifications_enabled = apply_filters( 'auto_theme_update_send_email', true );
$notifications_enabled = apply_filters( 'auto_theme_update_send_email', true, $update_results['theme'] );
if ( ! empty( $update_results['theme'] ) && $notifications_enabled ) {
foreach ( $update_results['theme'] as $update_result ) {