WP_Ajax_Upgrader_Skin::error()publicWP 4.6.0

Stores an error message about the upgrade.

Метод класса: WP_Ajax_Upgrader_Skin{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Ajax_Upgrader_Skin = new WP_Ajax_Upgrader_Skin();
$WP_Ajax_Upgrader_Skin->error( $errors, ...$args );
$errors(строка|WP_Error) (обязательный)
Errors.
...$args(разное) (обязательный)
Optional text replacements.

Список изменений

С версии 4.6.0 Введена.
С версии 5.3.0 Formalized the existing ...$args parameter by adding it to the function signature.

Код WP_Ajax_Upgrader_Skin::error() WP 6.6.2

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

		if ( str_contains( $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 );
}