Automattic\WooCommerce\Internal\Admin\Suggestions

PaymentExtensionSuggestions::sanitize_extension_incentive()privateWC 1.0

Sanitize the incentive details for a payment extension.

Method of the class: PaymentExtensionSuggestions{}

No Hooks.

Return

Array. The sanitized incentive details.

Usage

// private - for code of main (parent) class only
$result = $this->sanitize_extension_incentive( $incentive ): array;
$incentive(array) (required)
The incentive details.

PaymentExtensionSuggestions::sanitize_extension_incentive() code WC 9.6.0

private function sanitize_extension_incentive( array $incentive ): array {
	// Apply a very lose sanitization. Stricter sanitization can be applied downstream, if needed.
	return array_map(
		function ( $value ) {
			// Make sure that if we have HTML tags, we only allow a limited set of tags (only stylistic ones).
			if ( is_string( $value ) && preg_match( '/<[^>]+>/', $value ) ) {
					$value = wp_kses( $value, wp_kses_allowed_html( 'data' ) );
			}

			return $value;
		},
		$incentive
	);
}