WP_Recovery_Mode::handle_exit_recovery_mode() WordPress Method

The WP_Recovery_Mode::handle_exit_recovery_mode() method is used to gracefully exit the recovery mode. This is useful when the site is no longer in need of recovery mode and you want to exit it without losing any data.

WP_Recovery_Mode::handle_exit_recovery_mode() #

Handles a request to exit Recovery Mode.


Source

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

	public function handle_exit_recovery_mode() {
		$redirect_to = wp_get_referer();

		// Safety check in case referrer returns false.
		if ( ! $redirect_to ) {
			$redirect_to = is_user_logged_in() ? admin_url() : home_url();
		}

		if ( ! $this->is_active() ) {
			wp_safe_redirect( $redirect_to );
			die;
		}

		if ( ! isset( $_GET['action'] ) || self::EXIT_ACTION !== $_GET['action'] ) {
			return;
		}

		if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], self::EXIT_ACTION ) ) {
			wp_die( __( 'Exit recovery mode link expired.' ), 403 );
		}

		if ( ! $this->exit_recovery_mode() ) {
			wp_die( __( 'Failed to exit recovery mode. Please try again later.' ) );
		}

		wp_safe_redirect( $redirect_to );
		die;
	}


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.