Automattic\WooCommerce\Internal\Utilities

HtmlSanitizer::apply_string_callbacks()privateWC 1.0

Applies callbacks used to process the string before and after wp_kses().

If a callback is invalid we will short-circuit and return an empty string, on the grounds that it is better to output nothing than risky HTML. We also call the problem out via _doing_it_wrong() to highlight the problem (and increase the chances of this being caught during development).

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

Хуков нет.

Возвращает

Строку.

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

// private - только в коде основоного (родительского) класса
$result = $this->apply_string_callbacks( $callbacks, $string ): string;
$callbacks(callable[]) (обязательный)
The callbacks used to mutate the string.
$string(строка) (обязательный)
The string being processed.

Код HtmlSanitizer::apply_string_callbacks() WC 8.7.0

private function apply_string_callbacks( array $callbacks, string $string ): string {
	foreach ( $callbacks as $callback ) {
		if ( ! is_callable( $callback ) ) {
			_doing_it_wrong( __CLASS__ . '::apply', esc_html__( 'String processors must be an array of valid callbacks.', 'woocommerce' ), esc_html( WC()->version ) );
			return '';
		}

		$string = (string) $callback( $string );
	}

	return $string;
}