WP_Recovery_Mode::handle_error() WordPress Method

The WP_Recovery_Mode::handle_error() method is used to display an error message when a user tries to access a WordPress site that is in recover mode. This mode is used when a site is unable to load its normal content due to a fatal error.

WP_Recovery_Mode::handle_error( array $error ) #

Handles a fatal error occurring.


Description

The calling API should immediately die() after calling this function.


Top ↑

Parameters

$error

(array)(Required)Error details from error_get_last().


Top ↑

Return

(true|WP_Error) True if the error was handled and headers have already been sent. Or the request will exit to try and catch multiple errors at once. WP_Error if an error occurred preventing it from being handled.


Top ↑

Source

File: wp-includes/class-wp-recovery-mode.php

	public function handle_error( array $error ) {

		$extension = $this->get_extension_for_error( $error );

		if ( ! $extension || $this->is_network_plugin( $extension ) ) {
			return new WP_Error( 'invalid_source', __( 'Error not caused by a plugin or theme.' ) );
		}

		if ( ! $this->is_active() ) {
			if ( ! is_protected_endpoint() ) {
				return new WP_Error( 'non_protected_endpoint', __( 'Error occurred on a non-protected endpoint.' ) );
			}

			if ( ! function_exists( 'wp_generate_password' ) ) {
				require_once ABSPATH . WPINC . '/pluggable.php';
			}

			return $this->email_service->maybe_send_recovery_mode_email( $this->get_email_rate_limit(), $error, $extension );
		}

		if ( ! $this->store_error( $error ) ) {
			return new WP_Error( 'storage_error', __( 'Failed to store the error.' ) );
		}

		if ( headers_sent() ) {
			return true;
		}

		$this->redirect_protected();
	}


Top ↑

Changelog

Changelog
VersionDescription
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.