WP_Recovery_Mode_Email_Service
- Since
- 5.2.0
- Source
wp-includes/class-wp-recovery-mode-email-service.php:14
Core class used to send an email with a link to begin Recovery Mode.
Compatibility
- WordPress
- since 5.2.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 3
Every hook that fires from inside WP_Recovery_Mode_Email_Service, in the order it appears in the class, grouped by the method that fires it.
WP_Recovery_Mode_Email_Service::send_recovery_mode_email()
- apply_filters( recovery_email_support_info )filter line 141
- apply_filters( recovery_email_debug_info )filter line 150
- apply_filters( recovery_mode_email )filter line 223
Properties · 1
$link_serviceWP_Recovery_Mode_Link_Serviceprivate- Service to generate recovery mode URLs.
Methods · 8
- __construct()WP_Recovery_Mode_Email_Service constructor.
- maybe_send_recovery_mode_email()Sends the recovery mode email if the rate limit has not been sent.
- clear_rate_limit()Clears the rate limit, allowing a new recovery mode email to be sent immediately.
- send_recovery_mode_email()Sends the Recovery Mode email to the site admin email address.
- get_recovery_mode_email_address()Gets the email address to send the recovery mode link to.
- get_cause()Gets the description indicating the possible cause for the error.
- get_plugin()Return the details for a single plugin based on the extension data from an error.
- get_debug()Return debug information in an easy to manipulate format.
Source code
#[AllowDynamicProperties]final class WP_Recovery_Mode_Email_Service { const RATE_LIMIT_OPTION = 'recovery_mode_email_last_sent'; /** * Service to generate recovery mode URLs. * * @since 5.2.0 * @var WP_Recovery_Mode_Link_Service */ private $link_service; /** * WP_Recovery_Mode_Email_Service constructor. * * @since 5.2.0 * * @param WP_Recovery_Mode_Link_Service $link_service */ public function __construct( WP_Recovery_Mode_Link_Service $link_service ) { $this->link_service = $link_service; } /** * Sends the recovery mode email if the rate limit has not been sent. * * @since 5.2.0 * * @param int $rate_limit Number of seconds before another email can be sent. * @param array $error Error details from `error_get_last()`. * @param array $extension { * The extension that caused the error. * * @type string $slug The extension slug. The plugin or theme's directory. * @type string $type The extension type. Either 'plugin' or 'theme'. * } * @return true|WP_Error True if email sent, WP_Error otherwise. */ public function maybe_send_recovery_mode_email( $rate_limit, $error, $extension ) { $last_sent = get_option( self::RATE_LIMIT_OPTION ); if ( ! $last_sent || time() > $last_sent + $rate_limit ) { if ( ! update_option( self::RATE_LIMIT_OPTION, time() ) ) { return new WP_Error( 'storage_error', __( 'Could not update the email last sent time.' ) ); } $sent = $this->send_recovery_mode_email( $rate_limit, $error, $extension ); if ( $sent ) { return true; } return new WP_Error( 'email_failed', sprintf( /* translators: %s: mail() */ __( 'The email could not be sent. Possible reason: your host may have disabled the %s function.' ), 'mail()' ) ); } $err_message = sprintf( /* translators: 1: Last sent as a human time diff, 2: Wait time as a human time diff. */ __( 'A recovery link was already sent %1$s ago. Please wait another %2$s before requesting a new email.' ), human_time_diff( $last_sent ), human_time_diff( $last_sent + $rate_limit ) ); return new WP_Error( 'email_sent_already', $err_message ); } /** * Clears the rate limit, allowing a new recovery mode email to be sent immediately. * * @since 5.2.0 * * @return bool True on success, false on failure.Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/class-wp-recovery-mode-email-service.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.