<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[48123] trunk/src/wp-admin/includes/class-wp-automatic-updater.php: Administration: Improve the plugin and theme auto-update emails.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/48123">48123</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/48123","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-06-22 18:16:30 +0000 (Mon, 22 Jun 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Administration: Improve the plugin and theme auto-update emails.

This makes several improvements to the emails sent to site admins when plugin and theme auto-updates are attempted.

- Emails are now specifically tailored to the three results (success, failed, or mixed).
- Subject lines and body copy for mixed and failed results now correctly convey the importance of double checking the site in question.
- The site's URL is now included in all emails.
- When failures occur, links to the Plugins and/or Themes pages in the admin are now included so that site owners can easily take action.

Props audrasjb, desrosj, azaozz, garrett-eclipse, paaljoachim, johnbillion, marybaum, pbiron.
Follow up to <a href="https://core.trac.wordpress.org/changeset/47835">[47835]</a>.
See <a href="https://core.trac.wordpress.org/ticket/50052">#50052</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/50268">#50268</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpautomaticupdaterphp">trunk/src/wp-admin/includes/class-wp-automatic-updater.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpautomaticupdaterphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-automatic-updater.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-automatic-updater.php        2020-06-22 17:31:37 UTC (rev 48122)
+++ trunk/src/wp-admin/includes/class-wp-automatic-updater.php  2020-06-22 18:16:30 UTC (rev 48123)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -940,75 +940,141 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( empty( $successful_updates ) && empty( $failed_updates ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $body = array();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $body               = array();
+               $successful_plugins = ( ! empty( $successful_updates['plugin'] ) );
+               $successful_themes  = ( ! empty( $successful_updates['theme'] ) );
+               $failed_plugins     = ( ! empty( $failed_updates['plugin'] ) );
+               $failed_themes      = ( ! empty( $failed_updates['theme'] ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 switch ( $type ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'success':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                /* translators: %s: Site title. */
-                               $subject = __( '[%s] Some plugins or themes were automatically updated' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( $successful_plugins && $successful_themes ) {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some plugins and themes have automatically updated' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Some plugins and themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
+                                               home_url()
+                                       );
+                               } elseif ( $successful_plugins ) {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some plugins were automatically updated' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Some plugins have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
+                                               home_url()
+                                       );
+                               } else {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some themes were automatically updated' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Some themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
+                                               home_url()
+                                       );
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 break;
</span><span class="cx" style="display: block; padding: 0 10px">                        case 'fail':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                /* translators: %s: Site title. */
-                               $subject = __( '[%s] Some plugins or themes have failed to update' );
-                               $body[]  = sprintf(
-                                       /* translators: %s: Home URL. */
-                                       __( 'Howdy! Failures occurred when attempting to update plugins/themes on your site at %s.' ),
-                                       home_url()
-                               );
-                               $body[] = "\n";
-                               $body[] = __( 'Please check out your site now. It’s possible that everything is working. If it says you need to update, you should do so.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 case 'mixed':
+                               if ( $failed_plugins && $failed_themes ) {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some plugins and themes have failed to update' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Plugins and themes failed to update on your site at %s.' ),
+                                               home_url()
+                                       );
+                               } elseif ( $failed_plugins ) {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some plugins have failed to update' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Plugins failed to update on your site at %s.' ),
+                                               home_url()
+                                       );
+                               } else {
+                                       /* translators: %s: Site title. */
+                                       $subject = __( '[%s] Some themes have failed to update' );
+                                       $body[]  = sprintf(
+                                               /* translators: %s: Home URL. */
+                                               __( 'Howdy! Themes failed to update on your site at %s.' ),
+                                               home_url()
+                                       );
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 break;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        case 'mixed':
-                               /* translators: %s: Site title. */
-                               $subject = __( '[%s] Some plugins or themes were automatically updated' );
-                               $body[]  = sprintf(
-                                       /* translators: %s: Home URL. */
-                                       __( 'Howdy! Failures occurred when attempting to update plugins/themes on your site at %s.' ),
-                                       home_url()
-                               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         }
+
+               if ( in_array( $type, array( 'fail', 'mixed' ), true ) ) {
+                       $body[] = "\n";
+                       $body[] = __( 'Please check your site now. It’s possible that everything is working. If there are updates available, you should update.' );
+                       $body[] = "\n";
+
+                       // List failed plugin updates.
+                       if ( ! empty( $failed_updates['plugin'] ) ) {
+                               $body[] = __( 'These plugins failed to update:' );
+
+                               foreach ( $failed_updates['plugin'] as $item ) {
+                                       $body[] = "- {$item->name}";
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $body[] = "\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $body[] = __( 'Please check out your site now. It’s possible that everything is working. If it says you need to update, you should do so.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 }
+
+                       // List failed theme updates.
+                       if ( ! empty( $failed_updates['theme'] ) ) {
+                               $body[] = __( 'These themes failed to update:' );
+
+                               foreach ( $failed_updates['theme'] as $item ) {
+                                       $body[] = "- {$item->name}";
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $body[] = "\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 }
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Get failed plugin updates.
-               if ( in_array( $type, array( 'fail', 'mixed' ), true ) && ! empty( $failed_updates['plugin'] ) ) {
-                       $body[] = __( 'The following plugins failed to update:' );
-                       // List failed updates.
-                       foreach ( $failed_updates['plugin'] as $item ) {
-                               $body[] = "- {$item->name}";
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // List successful updates.
+               if ( in_array( $type, array( 'success', 'mixed' ), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $body[] = "\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                }
-               // Get failed theme updates.
-               if ( in_array( $type, array( 'fail', 'mixed' ), true ) && ! empty( $failed_updates['theme'] ) ) {
-                       $body[] = __( 'The following themes failed to update:' );
-                       // List failed updates.
-                       foreach ( $failed_updates['theme'] as $item ) {
-                               $body[] = "- {$item->name}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       // List successful plugin updates.
+                       if ( ! empty( $successful_updates['plugin'] ) ) {
+                               $body[] = __( 'These plugins are now up to date:' );
+
+                               foreach ( $successful_updates['plugin'] as $item ) {
+                                       $body[] = "- {$item->name}";
+                               }
+                               $body[] = "\n";
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $body[] = "\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       // List successful theme updates.
+                       if ( ! empty( $successful_updates['theme'] ) ) {
+                               $body[] = __( 'These themes are now up to date:' );
+                               // List successful updates.
+                               foreach ( $successful_updates['theme'] as $item ) {
+                                       $body[] = "- {$item->name}";
+                               }
+                               $body[] = "\n";
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Get successful plugin updates.
-               if ( in_array( $type, array( 'success', 'mixed' ), true ) && ! empty( $successful_updates['plugin'] ) ) {
-                       $body[] = __( 'The following plugins were successfully updated:' );
-                       // List successful updates.
-                       foreach ( $successful_updates['plugin'] as $item ) {
-                               $body[] = "- {$item->name}";
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               if ( $failed_plugins ) {
+                       $body[] = sprintf(
+                               /* translators: %s: Plugins screen URL. */
+                               __( 'To manage plugins on your site, visit the Plugins page: %s' ),
+                               admin_url( 'plugins.php' )
+                       );
</ins><span class="cx" style="display: block; padding: 0 10px">                         $body[] = "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Get successful theme updates.
-               if ( in_array( $type, array( 'success', 'mixed' ), true ) && ! empty( $successful_updates['theme'] ) ) {
-                       $body[] = __( 'The following themes were successfully updated:' );
-                       // List successful updates.
-                       foreach ( $successful_updates['theme'] as $item ) {
-                               $body[] = "- {$item->name}";
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               if ( $failed_themes ) {
+                       $body[] = sprintf(
+                               /* translators: %s: Themes screen URL. */
+                               __( 'To manage themes on your site, visit the Themes page: %s' ),
+                               admin_url( 'themes.php' )
+                       );
</ins><span class="cx" style="display: block; padding: 0 10px">                         $body[] = "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $body[] = "\n";
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Add a note about the support forums.
</span><span class="cx" style="display: block; padding: 0 10px">                $body[] = __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
</span></span></pre>
</div>
</div>

</body>
</html>