Make WordPress Core


Ignore:
Timestamp:
06/22/2020 06:16:30 PM (4 years ago)
Author:
desrosj
Message:

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 [47835].
See #50052.
Fixes #50268.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r48105 r48123  
    941941            return;
    942942        }
    943         $body = array();
     943
     944        $body               = array();
     945        $successful_plugins = ( ! empty( $successful_updates['plugin'] ) );
     946        $successful_themes  = ( ! empty( $successful_updates['theme'] ) );
     947        $failed_plugins     = ( ! empty( $failed_updates['plugin'] ) );
     948        $failed_themes      = ( ! empty( $failed_updates['theme'] ) );
    944949
    945950        switch ( $type ) {
    946951            case 'success':
    947                 /* translators: %s: Site title. */
    948                 $subject = __( '[%s] Some plugins or themes were automatically updated' );
     952                if ( $successful_plugins && $successful_themes ) {
     953                    /* translators: %s: Site title. */
     954                    $subject = __( '[%s] Some plugins and themes have automatically updated' );
     955                    $body[]  = sprintf(
     956                        /* translators: %s: Home URL. */
     957                        __( '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.' ),
     958                        home_url()
     959                    );
     960                } elseif ( $successful_plugins ) {
     961                    /* translators: %s: Site title. */
     962                    $subject = __( '[%s] Some plugins were automatically updated' );
     963                    $body[]  = sprintf(
     964                        /* translators: %s: Home URL. */
     965                        __( 'Howdy! Some plugins have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
     966                        home_url()
     967                    );
     968                } else {
     969                    /* translators: %s: Site title. */
     970                    $subject = __( '[%s] Some themes were automatically updated' );
     971                    $body[]  = sprintf(
     972                        /* translators: %s: Home URL. */
     973                        __( 'Howdy! Some themes have automatically updated to their latest versions on your site at %s. No further action is needed on your part.' ),
     974                        home_url()
     975                    );
     976                }
     977
    949978                break;
    950979            case 'fail':
    951                 /* translators: %s: Site title. */
    952                 $subject = __( '[%s] Some plugins or themes have failed to update' );
    953                 $body[]  = sprintf(
    954                     /* translators: %s: Home URL. */
    955                     __( 'Howdy! Failures occurred when attempting to update plugins/themes on your site at %s.' ),
    956                     home_url()
    957                 );
     980            case 'mixed':
     981                if ( $failed_plugins && $failed_themes ) {
     982                    /* translators: %s: Site title. */
     983                    $subject = __( '[%s] Some plugins and themes have failed to update' );
     984                    $body[]  = sprintf(
     985                        /* translators: %s: Home URL. */
     986                        __( 'Howdy! Plugins and themes failed to update on your site at %s.' ),
     987                        home_url()
     988                    );
     989                } elseif ( $failed_plugins ) {
     990                    /* translators: %s: Site title. */
     991                    $subject = __( '[%s] Some plugins have failed to update' );
     992                    $body[]  = sprintf(
     993                        /* translators: %s: Home URL. */
     994                        __( 'Howdy! Plugins failed to update on your site at %s.' ),
     995                        home_url()
     996                    );
     997                } else {
     998                    /* translators: %s: Site title. */
     999                    $subject = __( '[%s] Some themes have failed to update' );
     1000                    $body[]  = sprintf(
     1001                        /* translators: %s: Home URL. */
     1002                        __( 'Howdy! Themes failed to update on your site at %s.' ),
     1003                        home_url()
     1004                    );
     1005                }
     1006
     1007                break;
     1008        }
     1009
     1010        if ( in_array( $type, array( 'fail', 'mixed' ), true ) ) {
     1011            $body[] = "\n";
     1012            $body[] = __( 'Please check your site now. It’s possible that everything is working. If there are updates available, you should update.' );
     1013            $body[] = "\n";
     1014
     1015            // List failed plugin updates.
     1016            if ( ! empty( $failed_updates['plugin'] ) ) {
     1017                $body[] = __( 'These plugins failed to update:' );
     1018
     1019                foreach ( $failed_updates['plugin'] as $item ) {
     1020                    $body[] = "- {$item->name}";
     1021                }
    9581022                $body[] = "\n";
    959                 $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.' );
    960                 break;
    961             case 'mixed':
    962                 /* translators: %s: Site title. */
    963                 $subject = __( '[%s] Some plugins or themes were automatically updated' );
    964                 $body[]  = sprintf(
    965                     /* translators: %s: Home URL. */
    966                     __( 'Howdy! Failures occurred when attempting to update plugins/themes on your site at %s.' ),
    967                     home_url()
    968                 );
     1023            }
     1024
     1025            // List failed theme updates.
     1026            if ( ! empty( $failed_updates['theme'] ) ) {
     1027                $body[] = __( 'These themes failed to update:' );
     1028
     1029                foreach ( $failed_updates['theme'] as $item ) {
     1030                    $body[] = "- {$item->name}";
     1031                }
    9691032                $body[] = "\n";
    970                 $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.' );
     1033            }
     1034        }
     1035
     1036        // List successful updates.
     1037        if ( in_array( $type, array( 'success', 'mixed' ), true ) ) {
     1038            $body[] = "\n";
     1039
     1040            // List successful plugin updates.
     1041            if ( ! empty( $successful_updates['plugin'] ) ) {
     1042                $body[] = __( 'These plugins are now up to date:' );
     1043
     1044                foreach ( $successful_updates['plugin'] as $item ) {
     1045                    $body[] = "- {$item->name}";
     1046                }
    9711047                $body[] = "\n";
    972                 break;
    973         }
    974 
    975         // Get failed plugin updates.
    976         if ( in_array( $type, array( 'fail', 'mixed' ), true ) && ! empty( $failed_updates['plugin'] ) ) {
    977             $body[] = __( 'The following plugins failed to update:' );
    978             // List failed updates.
    979             foreach ( $failed_updates['plugin'] as $item ) {
    980                 $body[] = "- {$item->name}";
    981             }
     1048            }
     1049
     1050            // List successful theme updates.
     1051            if ( ! empty( $successful_updates['theme'] ) ) {
     1052                $body[] = __( 'These themes are now up to date:' );
     1053                // List successful updates.
     1054                foreach ( $successful_updates['theme'] as $item ) {
     1055                    $body[] = "- {$item->name}";
     1056                }
     1057                $body[] = "\n";
     1058            }
     1059        }
     1060
     1061        if ( $failed_plugins ) {
     1062            $body[] = sprintf(
     1063                /* translators: %s: Plugins screen URL. */
     1064                __( 'To manage plugins on your site, visit the Plugins page: %s' ),
     1065                admin_url( 'plugins.php' )
     1066            );
    9821067            $body[] = "\n";
    9831068        }
    984         // Get failed theme updates.
    985         if ( in_array( $type, array( 'fail', 'mixed' ), true ) && ! empty( $failed_updates['theme'] ) ) {
    986             $body[] = __( 'The following themes failed to update:' );
    987             // List failed updates.
    988             foreach ( $failed_updates['theme'] as $item ) {
    989                 $body[] = "- {$item->name}";
    990             }
     1069
     1070        if ( $failed_themes ) {
     1071            $body[] = sprintf(
     1072                /* translators: %s: Themes screen URL. */
     1073                __( 'To manage themes on your site, visit the Themes page: %s' ),
     1074                admin_url( 'themes.php' )
     1075            );
    9911076            $body[] = "\n";
    9921077        }
    993         // Get successful plugin updates.
    994         if ( in_array( $type, array( 'success', 'mixed' ), true ) && ! empty( $successful_updates['plugin'] ) ) {
    995             $body[] = __( 'The following plugins were successfully updated:' );
    996             // List successful updates.
    997             foreach ( $successful_updates['plugin'] as $item ) {
    998                 $body[] = "- {$item->name}";
    999             }
    1000             $body[] = "\n";
    1001         }
    1002         // Get successful theme updates.
    1003         if ( in_array( $type, array( 'success', 'mixed' ), true ) && ! empty( $successful_updates['theme'] ) ) {
    1004             $body[] = __( 'The following themes were successfully updated:' );
    1005             // List successful updates.
    1006             foreach ( $successful_updates['theme'] as $item ) {
    1007                 $body[] = "- {$item->name}";
    1008             }
    1009             $body[] = "\n";
    1010         }
    1011         $body[] = "\n";
    10121078
    10131079        // Add a note about the support forums.
Note: See TracChangeset for help on using the changeset viewer.