run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄class-wp-recovery-mode-email-service.php
1<?php
2/**
3 * Error Protection API: WP_Recovery_Mode_Email_Link class
4 *
5 * @package WordPress
6 * @since 5.2.0
7 */
8
9/**
10 * Core class used to send an email with a link to begin Recovery Mode.
11 *
12 * @since 5.2.0
13 */
14#[AllowDynamicProperties]
15final class WP_Recovery_Mode_Email_Service {
16
17 const RATE_LIMIT_OPTION = 'recovery_mode_email_last_sent';
18
19 /**
20 * Service to generate recovery mode URLs.
21 *
22 * @since 5.2.0
23 * @var WP_Recovery_Mode_Link_Service
24 */
25 private $link_service;
26
27 /**
28 * WP_Recovery_Mode_Email_Service constructor.
29 *
30 * @since 5.2.0
31 *
32 * @param WP_Recovery_Mode_Link_Service $link_service
33 */
34 public function __construct( WP_Recovery_Mode_Link_Service $link_service ) {
35 $this->link_service = $link_service;
36 }
37
38 /**
39 * Sends the recovery mode email if the rate limit has not been sent.
40 *
41 * @since 5.2.0
42 *
43 * @param int $rate_limit Number of seconds before another email can be sent.
44 * @param array $error Error details from `error_get_last()`.
45 * @param array $extension {
46 * The extension that caused the error.
47 *
48 * @type string $slug The extension slug. The plugin or theme's directory.
49 * @type string $type The extension type. Either 'plugin' or 'theme'.
50 * }
51 * @return true|WP_Error True if email sent, WP_Error otherwise.
52 */
53 public function maybe_send_recovery_mode_email( $rate_limit, $error, $extension ) {
54
55 $last_sent = get_option( self::RATE_LIMIT_OPTION );
56
57 if ( ! $last_sent || time() > $last_sent + $rate_limit ) {
58 if ( ! update_option( self::RATE_LIMIT_OPTION, time() ) ) {
59 return new WP_Error( 'storage_error', __( 'Could not update the email last sent time.' ) );
60 }
61
62 $sent = $this->send_recovery_mode_email( $rate_limit, $error, $extension );
63
64 if ( $sent ) {
65 return true;
66 }
67
68 return new WP_Error(
69 'email_failed',
70 sprintf(
71 /* translators: %s: mail() */
72 __( 'The email could not be sent. Possible reason: your host may have disabled the %s function.' ),
73 'mail()'
74 )
75 );
76 }
77
78 $err_message = sprintf(
79 /* translators: 1: Last sent as a human time diff, 2: Wait time as a human time diff. */
80 __( 'A recovery link was already sent %1$s ago. Please wait another %2$s before requesting a new email.' ),
81 human_time_diff( $last_sent ),
82 human_time_diff( $last_sent + $rate_limit )
83 );
84
85 return new WP_Error( 'email_sent_already', $err_message );
86 }
87
88 /**
89 * Clears the rate limit, allowing a new recovery mode email to be sent immediately.
90 *
91 * @since 5.2.0
92 *
93 * @return bool True on success, false on failure.
94 */
95 public function clear_rate_limit() {
96 return delete_option( self::RATE_LIMIT_OPTION );
97 }
98
99 /**
100 * Sends the Recovery Mode email to the site admin email address.
101 *
102 * @since 5.2.0
103 *
104 * @param int $rate_limit Number of seconds before another email can be sent.
105 * @param array $error Error details from `error_get_last()`.
106 * @param array $extension {
107 * The extension that caused the error.
108 *
109 * @type string $slug The extension slug. The directory of the plugin or theme.
110 * @type string $type The extension type. Either 'plugin' or 'theme'.
111 * }
112 * @return bool Whether the email was sent successfully.
113 */
114 private function send_recovery_mode_email( $rate_limit, $error, $extension ) {
115
116 $url = $this->link_service->generate_url();
117 $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
118
119 $switched_locale = switch_to_locale( get_locale() );
120
121 if ( $extension ) {
122 $cause = $this->get_cause( $extension );
123 $details = wp_strip_all_tags( wp_get_extension_error_description( $error ) );
124
125 if ( $details ) {
126 $header = __( 'Error Details' );
127 $details = "\n\n" . $header . "\n" . str_pad( '', strlen( $header ), '=' ) . "\n" . $details;
128 }
129 } else {
130 $cause = '';
131 $details = '';
132 }
133
134 /**
135 * Filters the support message sent with the the fatal error protection email.
136 *
137 * @since 5.2.0
138 *
139 * @param string $message The Message to include in the email.
140 */
141 $support = apply_filters( 'recovery_email_support_info', __( 'Please contact your host for assistance with investigating this issue further.' ) );
142
143 /**
144 * Filters the debug information included in the fatal error protection email.
145 *
146 * @since 5.3.0
147 *
148 * @param array $message An associative array of debug information.
149 */
150 $debug = apply_filters( 'recovery_email_debug_info', $this->get_debug( $extension ) );
151
152 /* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT. DEBUG: those are placeholders. */
153 $message = __(
154 'Howdy!
155
156WordPress 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.
157###CAUSE###
158First, 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.
159
160###SUPPORT###
161
162If 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.
163
164###LINK###
165
166To 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.
167
168When seeking help with this issue, you may be asked for some of the following information:
169###DEBUG###
170
171###DETAILS###'
172 );
173 $message = str_replace(
174 array(
175 '###LINK###',
176 '###EXPIRES###',
177 '###CAUSE###',
178 '###DETAILS###',
179 '###SITEURL###',
180 '###PAGEURL###',
181 '###SUPPORT###',
182 '###DEBUG###',
183 ),
184 array(
185 $url,
186 human_time_diff( time() + $rate_limit ),
187 $cause ? "\n{$cause}\n" : "\n",
188 $details,
189 home_url( '/' ),
190 home_url( $_SERVER['REQUEST_URI'] ),
191 $support,
192 implode( "\r\n", $debug ),
193 ),
194 $message
195 );
196
197 $email = array(
198 'to' => $this->get_recovery_mode_email_address(),
199 /* translators: %s: Site title. */
200 'subject' => __( '[%s] Your Site is Experiencing a Technical Issue' ),
201 'message' => $message,
202 'headers' => '',
203 'attachments' => '',
204 );
205
206 /**
207 * Filters the contents of the Recovery Mode email.
208 *
209 * @since 5.2.0
210 * @since 5.6.0 The `$email` argument includes the `attachments` key.
211 *
212 * @param array $email {
213 * Used to build a call to wp_mail().
214 *
215 * @type string|array $to Array or comma-separated list of email addresses to send message.
216 * @type string $subject Email subject
217 * @type string $message Message contents
218 * @type string|array $headers Optional. Additional headers.
219 * @type string|array $attachments Optional. Files to attach.
220 * }
221 * @param string $url URL to enter recovery mode.
222 */
223 $email = apply_filters( 'recovery_mode_email', $email, $url );
224
225 $sent = wp_mail(
226 $email['to'],
227 wp_specialchars_decode( sprintf( $email['subject'], $blogname ) ),
228 $email['message'],
229 $email['headers'],
230 $email['attachments']
231 );
232
233 if ( $switched_locale ) {
234 restore_previous_locale();
235 }
236
237 return $sent;
238 }
239
240 /**
241 * Gets the email address to send the recovery mode link to.
242 *
243 * @since 5.2.0
244 *
245 * @return string Email address to send recovery mode link to.
246 */
247 private function get_recovery_mode_email_address() {
248 if ( defined( 'RECOVERY_MODE_EMAIL' ) && is_email( RECOVERY_MODE_EMAIL ) ) {
249 return RECOVERY_MODE_EMAIL;
250 }
251
252 return get_option( 'admin_email' );
253 }
254
255 /**
256 * Gets the description indicating the possible cause for the error.
257 *
258 * @since 5.2.0
259 *
260 * @param array $extension {
261 * The extension that caused the error.
262 *
263 * @type string $slug The extension slug. The directory of the plugin or theme.
264 * @type string $type The extension type. Either 'plugin' or 'theme'.
265 * }
266 * @return string Message about which extension caused the error.
267 */
268 private function get_cause( $extension ) {
269
270 if ( 'plugin' === $extension['type'] ) {
271 $plugin = $this->get_plugin( $extension );
272
273 if ( false === $plugin ) {
274 $name = $extension['slug'];
275 } else {
276 $name = $plugin['Name'];
277 }
278
279 /* translators: %s: Plugin name. */
280 $cause = sprintf( __( 'In this case, WordPress caught an error with one of your plugins, %s.' ), $name );
281 } else {
282 $theme = wp_get_theme( $extension['slug'] );
283 $name = $theme->exists() ? $theme->display( 'Name' ) : $extension['slug'];
284
285 /* translators: %s: Theme name. */
286 $cause = sprintf( __( 'In this case, WordPress caught an error with your theme, %s.' ), $name );
287 }
288
289 return $cause;
290 }
291
292 /**
293 * Return the details for a single plugin based on the extension data from an error.
294 *
295 * @since 5.3.0
296 *
297 * @param array $extension {
298 * The extension that caused the error.
299 *
300 * @type string $slug The extension slug. The directory of the plugin or theme.
301 * @type string $type The extension type. Either 'plugin' or 'theme'.
302 * }
303 * @return array|false A plugin array {@see get_plugins()} or `false` if no plugin was found.
304 */
305 private function get_plugin( $extension ) {
306 if ( ! function_exists( 'get_plugins' ) ) {
307 require_once ABSPATH . 'wp-admin/includes/plugin.php';
308 }
309
310 $plugins = get_plugins();
311
312 // Assume plugin main file name first since it is a common convention.
313 if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) {
314 return $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ];
315 } else {
316 foreach ( $plugins as $file => $plugin_data ) {
317 if ( str_starts_with( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) {
318 return $plugin_data;
319 }
320 }
321 }
322
323 return false;
324 }
325
326 /**
327 * Return debug information in an easy to manipulate format.
328 *
329 * @since 5.3.0
330 *
331 * @param array $extension {
332 * The extension that caused the error.
333 *
334 * @type string $slug The extension slug. The directory of the plugin or theme.
335 * @type string $type The extension type. Either 'plugin' or 'theme'.
336 * }
337 * @return array An associative array of debug information.
338 */
339 private function get_debug( $extension ) {
340 $theme = wp_get_theme();
341 $wp_version = get_bloginfo( 'version' );
342
343 if ( $extension ) {
344 $plugin = $this->get_plugin( $extension );
345 } else {
346 $plugin = null;
347 }
348
349 $debug = array(
350 'wp' => sprintf(
351 /* translators: %s: Current WordPress version number. */
352 __( 'WordPress version %s' ),
353 $wp_version
354 ),
355 'theme' => sprintf(
356 /* translators: 1: Current active theme name. 2: Current active theme version. */
357 __( 'Active theme: %1$s (version %2$s)' ),
358 $theme->get( 'Name' ),
359 $theme->get( 'Version' )
360 ),
361 );
362
363 if ( null !== $plugin ) {
364 $debug['plugin'] = sprintf(
365 /* translators: 1: The failing plugins name. 2: The failing plugins version. */
366 __( 'Current plugin: %1$s (version %2$s)' ),
367 $plugin['Name'],
368 $plugin['Version']
369 );
370 }
371
372 $debug['php'] = sprintf(
373 /* translators: %s: The currently used PHP version. */
374 __( 'PHP version %s' ),
375 PHP_VERSION
376 );
377
378 return $debug;
379 }
380}
381
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.