Make WordPress Core

Changeset 25837


Ignore:
Timestamp:
10/18/2013 06:32:27 AM (13 years ago)
Author:
nacin
Message:

Introduce email templates for automatic background updates.

The four templates are:

  1. We successfully updated their site. If any of their themes or plugins are out of date, it also mentions that. ('success')
  2. We are not configured to update their site, so we notify them of the new release. ('notify')
  3. We tried but failed to update their site. The error was early in the process, so no harm, no foul. This is the same as template #2, plus one sentence. ('fail')
  4. We tried to update their site, and failed while copying files. ('critical')

With assistance from markjaquith.

see #10787.

File:
1 edited

Legend:

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

    r25835 r25837  
    18371837        }
    18381838
    1839         function send_debug_email() {
    1840 
     1839        protected function send_email( $type, $core_update, $result = null ) {
     1840                if ( ! apply_filters( 'automatic_updates_send_email', true, $type, $core_update, $result ) )
     1841                        return;
     1842
     1843                switch ( $type ) {
     1844                        case 'success' : // We updated.
     1845                                /* translators: 1: Site name, 2: WordPress version number. */
     1846                                $subject = __( '[%1$s] Your site has updated to WordPress %2$s' );
     1847                                break;
     1848
     1849                        case 'fail' :   // We tried to update but couldn't.
     1850                        case 'manual' : // We can't update (and made no attempt).
     1851                                /* translators: 1: Site name, 2: WordPress version number. */
     1852                                $subject = __( '[%1$s] WordPress %2$s is available. Please update!' );
     1853                                break;
     1854
     1855                        case 'critical' : // We tried to update, started to copy files, then things went wrong.
     1856                                /* translators: 1: Site name. */
     1857                                $subject = __( '[%1$s] URGENT: Your site may be down due to a failed update' );
     1858                                break;
     1859
     1860                        default :
     1861                                return;
     1862                }
     1863
     1864                $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $core_update->current );
     1865
     1866                $body = '';
     1867
     1868                switch ( $type ) {
     1869                        case 'success' :
     1870                                $body .= sprintf( __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ), home_url(), $core_update->current );
     1871                                $body .= "\n\n" . __( 'No further action is needed on your part.' );
     1872
     1873                                // Can only reference the About screen if their update was successful.
     1874                                list( $about_version ) = explode( '-', $core_update->current, 2 );
     1875                                $body .= ' ' . sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version );
     1876                                $body .= "\n" . admin_url( 'about.php' );
     1877                                break;
     1878
     1879                        case 'fail' :
     1880                        case 'manual' :
     1881                                $body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $core_update->current );
     1882
     1883                                $body .= "\n\n";
     1884                                if ( 'fail' == $type )
     1885                                        $body .= __( 'We tried but were unable to update your site automatically.' ) . ' ';
     1886                                $body .= __( 'Updating is easy and only takes a few moments:' );
     1887                                $body .= "\n" . network_admin_url( 'update-core.php' );
     1888                                break;
     1889
     1890                        case 'critical' :
     1891                                $body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ), home_url(), $core_update->current );
     1892
     1893                                $body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." );
     1894
     1895                                $body .= "\n\n" . __( "Please check out your site now. It's possible that everything is working. If it says you need to update, you should do so:" );
     1896                                $body .= "\n" . network_admin_url( 'update-core.php' );
     1897                                break;
     1898                }
     1899
     1900                // Updates are important!
     1901                if ( $type != 'success' )
     1902                        $body .= "\n\n" . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' );
     1903
     1904                // Add a note about the support forums to all emails.
     1905                $body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
     1906                $body .= "\n" . __( 'http://wordpress.org/support/' );
     1907
     1908                // If things are successful, mention plugins and themes if any are out of date.
     1909                if ( $type == 'success' && ( get_plugin_updates() || get_theme_updates() ) ) {
     1910                        $body .= "\n\n" . __( 'You also have some plugins or themes with updates available. Update them now:' );
     1911                        $body .= "\n" . network_admin_url();
     1912                }
     1913
     1914                $body .= "\n\n" . __( 'The WordPress Team' ) . "\n";
     1915
     1916                if ( 'critical' == $type && is_wp_error( $result ) ) {
     1917                        $body .= "\n***\n\n";
     1918                        $body .= __( 'We have some data that describes the error your site encountered.' );
     1919                        $body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
     1920                        $body .= "\n" . sprintf( __( "Error code: %s" ), $result->get_error_code() );
     1921                        $body .= "\n" . $result->get_error_message();
     1922                        $body .= "\n" . implode( ', ', (array) $result->get_error_data() );
     1923                        $body .= "\n";
     1924                }
     1925
     1926                $to  = get_site_option( 'admin_email' );
     1927                $headers = '';
     1928
     1929                $email = compact( 'to', 'body', 'subject', 'headers' );
     1930                $email = apply_filters( 'automatic_update_send_email', $email, $type, $core_update, $result );
     1931
     1932                wp_mail( $email['to'], $email['subject'], $email['body'], $email['headers'] );
     1933        }
     1934
     1935        protected function send_debug_email() {
    18411936                if ( empty( $this->update_results ) )
    18421937                        return;
    … …  
    19142009                                foreach ( $update->messages as $message )
    19152010                                        $body[] = "  " . html_entity_decode( str_replace( '…', '...', $message ) );
    1916                                 if ( is_wp_error( $update->result ) )
     2011                                if ( is_wp_error( $update->result ) ) {
    19172012                                        $body[] = '  Error: [' . $update->result->get_error_code() . '] ' . $update->result->get_error_message();
     2013                                        if ( $update->result->get_error_data() )
     2014                                                $body[] = '         ' . implode( ', ', (array) $update->result->get_error_data() );
     2015                                }
    19182016                                $body[] = '';
    19192017                        }
Note: See TracChangeset for help on using the changeset viewer.