Ticket #46898: 46898.6.alt.diff
File 46898.6.alt.diff, 6.6 KB (added by , 6 years ago) |
---|
-
src/wp-includes/class-wp-recovery-mode-email-service.php
93 93 * 94 94 * @param int $rate_limit Number of seconds before another email can be sent. 95 95 * @param array $error Error details from {@see error_get_last()} 96 * @param array $extension Extension that caused the error. 97 * 96 * @param array $extension The extension that caused the error. { 97 * @type string $slug The extension slug. The plugin or theme's directory. 98 * @type string $type The extension type. Either 'plugin' or 'theme'. 99 * } 98 100 * @return bool Whether the email was sent successfully. 99 101 */ 100 102 private function send_recovery_mode_email( $rate_limit, $error, $extension ) { … … 110 112 } 111 113 112 114 if ( $extension ) { 113 $ cause = $this->get_cause( $extension );114 $details = wp_strip_all_tags( wp_get_extension_error_description( $error ) );115 $extension_name = $this->get_extension_name( $extension ); 116 $details = wp_strip_all_tags( wp_get_extension_error_description( $error ) ); 115 117 116 118 if ( $details ) { 117 119 $header = __( 'Error Details' ); 118 120 $details = "\n\n" . $header . "\n" . str_pad( '', strlen( $header ), '=' ) . "\n" . $details; 119 121 } 122 123 if ( 'plugin' === $extension['type'] ) { 124 /* translators: %s: plugin name */ 125 $cause = sprintf( __( 'In this case, WordPress caught an error with one of your plugins: %s.' ), $extension_name ); 126 $support = sprintf( 127 /* translators: 1: plugin name, 2: plugin slug */ 128 __( 129 'If nothing looks broken, the author of %1$s would greatly appreciate if you could post more information about this error in the support forums. You can find the error details at the end of this email. 130 131 https://wordpress.org/support/plugin/%2$s/ 132 133 If your site appears broken and you can\'t access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely log in to your dashboard and disable the %1$s plugin.' 134 ), 135 $extension_name, 136 $extension['slug'] 137 ); 138 } else { 139 /* translators: %s: theme name */ 140 $cause = sprintf( __( 'In this case, WordPress caught an error with your active theme: %s.' ), $extension_name ); 141 $support = sprintf( 142 /* translators: 1: theme name, 2: theme slug */ 143 __( 144 'If nothing looks broken, the author of %1$s would greatly appreciate if you could post more information about this error in the support forums. You can find the error details at the end of this email. 145 146 https://wordpress.org/support/theme/%2$s/ 147 148 If your site appears broken and you can\'t access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely log in to your dashboard and switch to another theme.' 149 ), 150 $extension_name, 151 $extension['slug'] 152 ); 153 } 120 154 } else { 121 155 $cause = ''; 156 $support = __( 'If your site appears broken and you can\'t access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely log in to your dashboard.' ); 122 157 $details = ''; 123 158 } 124 159 160 /* translators: Do not translate CAUSE, SITEURL, ERROR_PAGE, SUPPORT, RECOVERY_LINK, EXPIRES, DETAILS: those are placeholders. */ 125 161 $message = __( 126 'Howdy ,162 'Howdy! 127 163 128 Your site recently crashed and may not be working as expected.164 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 sends you this automated email. 129 165 ###CAUSE### 130 Please click the link below to initiate recovery mode and fix the problem.166 First, visit your website (###SITEURL###) and check for any visible issues. Next, visit the page where the error was caught (###ERROR_PAGE###) and check for any visible issues. 131 167 132 This link expires in ###EXPIRES###. 168 ###SUPPORT### 133 169 134 ### LINK### ###DETAILS###170 ###RECOVERY_LINK### 135 171 172 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 you click on it after it expires. 173 ###DETAILS### 174 136 175 --The WordPress Team 137 176 https://wordpress.org/ 138 177 ' … … 139 178 ); 140 179 $message = str_replace( 141 180 array( 142 '###LINK###', 181 '###CAUSE###', 182 '###SITEURL###', 183 '###ERROR_PAGE###', 184 '###SUPPORT###', 185 '###RECOVERY_LINK###', 143 186 '###EXPIRES###', 144 '###CAUSE###',145 187 '###DETAILS###', 146 188 ), 147 189 array( 190 $cause ? "\n{$cause}\n" : "\n", 191 home_url(), 192 home_url( $_SERVER['REQUEST_URI'] ), 193 $support, 148 194 $url, 149 195 human_time_diff( time() + $rate_limit ), 150 $cause ? "\n{$cause}\n" : "\n",151 196 $details, 152 197 ), 153 198 $message … … 201 246 } 202 247 203 248 /** 204 * Gets the description indicating the possible cause forthe error.249 * Gets the name of the extension that caused the error. 205 250 * 206 251 * @since 5.2.0 207 252 * 208 * @param array $extension The extension that caused the error. 209 * @return string Message about which extension caused the error. 253 * @param array $extension The extension that caused the error. { 254 * @type string $slug The extension slug. The plugin or theme's directory. 255 * @type string $type The extension type. Either 'plugin' or 'theme'. 256 * } 257 * @return string Name of extension that caused the error. 210 258 */ 211 private function get_ cause( $extension ) {259 private function get_extension_name( $extension ) { 212 260 213 261 if ( 'plugin' === $extension['type'] ) { 214 262 if ( ! function_exists( 'get_plugins' ) ) { … … 222 270 // Assume plugin main file name first since it is a common convention. 223 271 if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) { 224 272 $name = $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]['Name']; 273 } elseif ( isset( $plugins[ $extension['slug'] ] ) ) { 274 // Plugin does not have a parent directory. 275 $name = $plugins[ $extension['slug'] ]['Name']; 225 276 } else { 226 277 foreach ( $plugins as $file => $plugin_data ) { 227 278 if ( 0 === strpos( $file, "{$extension['slug']}/" ) ) { … … 234 285 if ( empty( $name ) ) { 235 286 $name = $extension['slug']; 236 287 } 237 238 /* translators: %s: plugin name */239 $cause = sprintf( __( 'This was caused by the following plugin: %s.' ), $name );240 288 } else { 241 $theme = wp_get_theme( $extension['slug'] ); 242 $name = $theme->exists() ? $theme->display( 'Name' ) : $extension['slug']; 243 244 /* translators: %s: theme name */ 245 $cause = sprintf( __( 'This was caused by the following theme: %s.' ), $name ); 289 $name = $theme->exists() ? $theme->display( 'Name' ) : $extension['slug']; 246 290 } 247 291 248 return $ cause;292 return $name; 249 293 } 250 294 }