equal
deleted
inserted
replaced
9 /** |
9 /** |
10 * Core class used to send an email with a link to begin Recovery Mode. |
10 * Core class used to send an email with a link to begin Recovery Mode. |
11 * |
11 * |
12 * @since 5.2.0 |
12 * @since 5.2.0 |
13 */ |
13 */ |
|
14 #[AllowDynamicProperties] |
14 final class WP_Recovery_Mode_Email_Service { |
15 final class WP_Recovery_Mode_Email_Service { |
15 |
16 |
16 const RATE_LIMIT_OPTION = 'recovery_mode_email_last_sent'; |
17 const RATE_LIMIT_OPTION = 'recovery_mode_email_last_sent'; |
17 |
18 |
18 /** |
19 /** |
113 private function send_recovery_mode_email( $rate_limit, $error, $extension ) { |
114 private function send_recovery_mode_email( $rate_limit, $error, $extension ) { |
114 |
115 |
115 $url = $this->link_service->generate_url(); |
116 $url = $this->link_service->generate_url(); |
116 $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
117 $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
117 |
118 |
118 $switched_locale = false; |
119 $switched_locale = switch_to_locale( get_locale() ); |
119 |
|
120 // The switch_to_locale() function is loaded before it can actually be used. |
|
121 if ( function_exists( 'switch_to_locale' ) && isset( $GLOBALS['wp_locale_switcher'] ) ) { |
|
122 $switched_locale = switch_to_locale( get_locale() ); |
|
123 } |
|
124 |
120 |
125 if ( $extension ) { |
121 if ( $extension ) { |
126 $cause = $this->get_cause( $extension ); |
122 $cause = $this->get_cause( $extension ); |
127 $details = wp_strip_all_tags( wp_get_extension_error_description( $error ) ); |
123 $details = wp_strip_all_tags( wp_get_extension_error_description( $error ) ); |
128 |
124 |
155 |
151 |
156 /* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT. DEBUG: those are placeholders. */ |
152 /* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT. DEBUG: those are placeholders. */ |
157 $message = __( |
153 $message = __( |
158 'Howdy! |
154 'Howdy! |
159 |
155 |
160 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. |
156 WordPress has 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. |
161 ###CAUSE### |
157 ###CAUSE### |
162 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. |
158 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. |
163 |
159 |
164 ###SUPPORT### |
160 ###SUPPORT### |
165 |
161 |
316 // Assume plugin main file name first since it is a common convention. |
312 // Assume plugin main file name first since it is a common convention. |
317 if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) { |
313 if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) { |
318 return $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]; |
314 return $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]; |
319 } else { |
315 } else { |
320 foreach ( $plugins as $file => $plugin_data ) { |
316 foreach ( $plugins as $file => $plugin_data ) { |
321 if ( 0 === strpos( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) { |
317 if ( str_starts_with( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) { |
322 return $plugin_data; |
318 return $plugin_data; |
323 } |
319 } |
324 } |
320 } |
325 } |
321 } |
326 |
322 |