WP_Recovery_Mode_Email_Service

Service class for sending recovery mode notification emails with rate limiting.

Source: wp-includes/class-wp-recovery-mode-email-service.php
Since: 5.2.0

Constants

ConstantValueDescription
RATE_LIMIT_OPTION'recovery_mode_email_last_sent'Option name for rate limiting

Properties

PropertyTypeVisibilityDescription
$link_serviceWP_Recovery_Mode_Link_ServiceprivateService for generating recovery URLs

Methods

__construct()

Creates the email service instance.

php
public function __construct( WP_Recovery_Mode_Link_Service $link_service )
ParameterTypeDescription
$link_serviceWP_Recovery_Mode_Link_ServiceLink generation service

maybe_send_recovery_mode_email()

Sends recovery email if rate limit allows.

php
public function maybe_send_recovery_mode_email( int $rate_limit, array $error, array $extension ): true|WP_Error
ParameterTypeDescription
$rate_limitintSeconds before another email can be sent
$errorarrayError details from error_get_last()
$extensionarrayExtension that caused the error

Returns: true if sent, WP_Error otherwise.

Error Codes:

  • storage_error — Could not update last sent time
  • email_failedmail() function failed
  • email_sent_already — Rate limit not expired

clear_rate_limit()

Clears the rate limit, allowing immediate email send.

php
public function clear_rate_limit(): bool

Returns: true on success, false on failure.


send_recovery_mode_email() (private)

Sends the recovery mode email to the admin.

php
private function send_recovery_mode_email( int $rate_limit, array $error, array $extension ): bool
ParameterTypeDescription
$rate_limitintTTL for the recovery link
$errorarrayError details
$extensionarrayExtension info

Returns: true if email sent.

Email Contents:

  • Recovery mode link URL
  • Link expiration time
  • Cause description (plugin/theme name)
  • Error details (type, line, file, message)
  • Debug info (WP version, active theme, plugin version, PHP version)
  • Support contact message

Placeholders in Template:

  • ###LINK### — Recovery mode URL
  • ###EXPIRES### — Human-readable expiration
  • ###CAUSE### — Extension that caused the error
  • ###DETAILS### — Formatted error details
  • ###SITEURL### — Site home URL
  • ###PAGEURL### — Page where error occurred
  • ###SUPPORT### — Support message
  • ###DEBUG### — Debug information

Filter: recovery_mode_email


get_recovery_mode_email_address() (private)

Gets the recipient email address.

php
private function get_recovery_mode_email_address(): string

Returns: Email from RECOVERY_MODE_EMAIL constant if defined and valid, otherwise admin_email option.


get_cause() (private)

Gets a description of which extension caused the error.

php
private function get_cause( array $extension ): string
ParameterTypeDescription
$extensionarrayExtension info (slug, type)

Returns: Human-readable cause message.


get_plugin() (private)

Gets plugin data for an extension.

php
private function get_plugin( array $extension ): array|false
ParameterTypeDescription
$extensionarrayExtension info

Returns: Plugin array from get_plugins() or false.

Lookup Order:

  1. {slug}/{slug}.php (common convention)
  2. Any plugin file starting with {slug}/

get_debug() (private)

Gets debug information for the email.

php
private function get_debug( array $extension ): array
ParameterTypeDescription
$extensionarrayExtension info

Returns: Associative array with debug info.

Keys:

  • wp — WordPress version
  • theme — Active theme name and version
  • plugin — Failing plugin name and version (if applicable)
  • php — PHP version

Filter: recovery_email_debug_info