WP_Ajax_Upgrader_Skin::error() WordPress Method

The WP_Ajax_Upgrader_Skin::error() method is used to display an error message during an AJAX upgrade process. This can be useful if there are any problems with the upgrade process, or if you want to display a custom message to the user.

WP_Ajax_Upgrader_Skin::error( string|WP_Error $errors, mixed $args ) #

Stores an error message about the upgrade.


Parameters

$errors

(string|WP_Error)(Required)Errors.

$args

(mixed)(Optional)text replacements.


Top ↑

Source

File: wp-admin/includes/class-wp-ajax-upgrader-skin.php

	public function error( $errors, ...$args ) {
		if ( is_string( $errors ) ) {
			$string = $errors;
			if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
				$string = $this->upgrader->strings[ $string ];
			}

			if ( false !== strpos( $string, '%' ) ) {
				if ( ! empty( $args ) ) {
					$string = vsprintf( $string, $args );
				}
			}

			// Count existing errors to generate a unique error code.
			$errors_count = count( $this->errors->get_error_codes() );
			$this->errors->add( 'unknown_upgrade_error_' . ( $errors_count + 1 ), $string );
		} elseif ( is_wp_error( $errors ) ) {
			foreach ( $errors->get_error_codes() as $error_code ) {
				$this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) );
			}
		}

		parent::error( $errors, ...$args );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Formalized the existing ...$args parameter by adding it to the function signature.
4.6.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.