Automatic_Upgrader_Skin::feedback( string|array|WP_Error $feedback, mixed $args )

In this article

Stores a message about the upgrade.

Parameters

$feedbackstring|array|WP_Errorrequired
Message data.
$argsmixedoptional
Optional text replacements.

Source

public function feedback( $feedback, ...$args ) {
	if ( is_wp_error( $feedback ) ) {
		$string = $feedback->get_error_message();
	} elseif ( is_array( $feedback ) ) {
		return;
	} else {
		$string = $feedback;
	}

	if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
		$string = $this->upgrader->strings[ $string ];
	}

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

	$string = trim( $string );

	// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
	$string = wp_kses(
		$string,
		array(
			'a'      => array(
				'href' => true,
			),
			'br'     => true,
			'em'     => true,
			'strong' => true,
		)
	);

	if ( empty( $string ) ) {
		return;
	}

	$this->messages[] = $string;
}

Changelog

VersionDescription
5.9.0Renamed $data to $feedback for PHP 8 named parameter support.
3.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.