Automattic\WooCommerce\Gateways\PayPal

Helper::redact_data │ public static │ WC 1.0

Remove PII (Personally Identifiable Information) from data for logging.

This function recursively traverses the data array and redacts sensitive information while preserving the structure for debugging purposes.

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

Хуков нет.

Возвращает

mixed. The data with PII redacted.

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

$result = Helper::redact_data( $data );
$data(разное) (обязательный)
The data to remove PII from (array, string, or other types).

Код Helper::redact_data() WC 11.2.2

public static function redact_data( $data ) {
	if ( ! is_array( $data ) ) {
		return $data;
	}

	$redacted_data = array();

	foreach ( $data as $key => $value ) {
		// Skip redacting the payee information as it belongs to the store merchant.
		if ( 'payee' === $key ) {
			$redacted_data[ $key ] = $value;
			continue;
		}
		// Mask the email address.
		if ( 'email_address' === $key || 'email' === $key ) {
			$redacted_data[ $key ] = self::mask_email( (string) $value );
			continue;
		}

		if ( is_array( $value ) ) {
			$redacted_data[ $key ] = self::redact_data( $value );
		} elseif ( in_array( $key, Constants::FIELDS_TO_REDACT, true ) ) {
			$redacted_data[ $key ] = '[redacted]';
		} else {
			// Keep non-PII data as is.
			$redacted_data[ $key ] = $value;
		}
	}

	return $redacted_data;
}