Bulk_Upgrader_Skin::error()publicWP 3.0.0

Displays an error message about the update.

Method of the class: Bulk_Upgrader_Skin{}

No Hooks.

Return

null. Nothing (null).

Usage

$Bulk_Upgrader_Skin = new Bulk_Upgrader_Skin();
$Bulk_Upgrader_Skin->error( $errors );
$errors(string|WP_Error) (required)
Errors.

Changelog

Since 3.0.0 Introduced.
Since 5.9.0 Renamed $error to $errors for PHP 8 named parameter support.

Bulk_Upgrader_Skin::error() code WP 6.6.2

public function error( $errors ) {
	if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
		$this->error = $this->upgrader->strings[ $errors ];
	}

	if ( is_wp_error( $errors ) ) {
		$messages = array();
		foreach ( $errors->get_error_messages() as $emessage ) {
			if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
				$messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
			} else {
				$messages[] = $emessage;
			}
		}
		$this->error = implode( ', ', $messages );
	}
	echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
}