Bootstrap/Load: Tweak the recovery mode email text and behaviour.

- Change the recovery mode link expiry to 1 day.
- Improve the email text.
- Add a new `recovery_email_support_info` filter, for hosts to be able to customise their support contact information.

Props pento, chanthaboune, michelleweber, matt.
Fixes #46898.


Built from https://develop.svn.wordpress.org/trunk@45268


git-svn-id: http://core.svn.wordpress.org/trunk@45077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2019-04-25 00:47:52 +00:00
parent 0b6f00fde2
commit 3b5307339d
3 changed files with 32 additions and 14 deletions

View File

@ -122,20 +122,32 @@ final class WP_Recovery_Mode_Email_Service {
$details = ''; $details = '';
} }
/**
* Filters the support message sent with the the fatal error protection email.
*
* @since 5.2.0
*
* @param $message string The Message to include in the email.
*/
$support = apply_filters( 'recovery_email_support_info', __( 'Please contact your host for assistance with investigating this issue further.' ) );
/* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT: those are placeholders. */
$message = __( $message = __(
'Howdy, 'Howdy!
Your site recently crashed and may not be working as expected. Since WordPress 5.2 there is a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.
###CAUSE### ###CAUSE###
Please click the link below to initiate recovery mode and fix the problem. First, visit your website (###SITEURL###) and check for any visible issues. Next, visit the page where the error was caught (###PAGEURL###) and check for any visible issues.
This link expires in ###EXPIRES###. ###SUPPORT###
###LINK### ###DETAILS### If your site appears broken and you can\'t access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely login to your dashboard and investigate further.
--The WordPress Team ###LINK###
https://wordpress.org/
' To keep your site safe, this link will expire in ###EXPIRES###. Don\'t worry about that, though: a new link will be emailed to you if the error occurs again after it expires.
###DETAILS###'
); );
$message = str_replace( $message = str_replace(
array( array(
@ -143,12 +155,18 @@ https://wordpress.org/
'###EXPIRES###', '###EXPIRES###',
'###CAUSE###', '###CAUSE###',
'###DETAILS###', '###DETAILS###',
'###SITEURL###',
'###PAGEURL###',
'###SUPPORT###',
), ),
array( array(
$url, $url,
human_time_diff( time() + $rate_limit ), human_time_diff( time() + $rate_limit ),
$cause ? "\n{$cause}\n" : "\n", $cause ? "\n{$cause}\n" : "\n",
$details, $details,
home_url( '/' ),
home_url( $_SERVER['REQUEST_URI'] ),
$support,
), ),
$message $message
); );
@ -224,7 +242,7 @@ https://wordpress.org/
$name = $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]['Name']; $name = $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]['Name'];
} else { } else {
foreach ( $plugins as $file => $plugin_data ) { foreach ( $plugins as $file => $plugin_data ) {
if ( 0 === strpos( $file, "{$extension['slug']}/" ) ) { if ( 0 === strpos( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) {
$name = $plugin_data['Name']; $name = $plugin_data['Name'];
break; break;
} }
@ -236,13 +254,13 @@ https://wordpress.org/
} }
/* translators: %s: plugin name */ /* translators: %s: plugin name */
$cause = sprintf( __( 'This was caused by the following plugin: %s.' ), $name ); $cause = sprintf( __( 'In this case, WordPress caught an error with one of your plugins, %s.' ), $name );
} else { } else {
$theme = wp_get_theme( $extension['slug'] ); $theme = wp_get_theme( $extension['slug'] );
$name = $theme->exists() ? $theme->display( 'Name' ) : $extension['slug']; $name = $theme->exists() ? $theme->display( 'Name' ) : $extension['slug'];
/* translators: %s: theme name */ /* translators: %s: theme name */
$cause = sprintf( __( 'This was caused by the following theme: %s.' ), $name ); $cause = sprintf( __( 'In this case, WordPress caught an error with your theme, %s.' ), $name );
} }
return $cause; return $cause;

View File

@ -299,9 +299,9 @@ class WP_Recovery_Mode {
* *
* @since 5.2.0 * @since 5.2.0
* *
* @param int $rate_limit Time to wait in seconds. Defaults to 4 hours. * @param int $rate_limit Time to wait in seconds. Defaults to 1 day.
*/ */
return apply_filters( 'recovery_mode_email_rate_limit', 4 * HOUR_IN_SECONDS ); return apply_filters( 'recovery_mode_email_rate_limit', DAY_IN_SECONDS );
} }
/** /**

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.2-beta3-45267'; $wp_version = '5.2-beta3-45268';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.