WP_Widget_Media::sanitize_token_list( string|array $tokens ): string

In this article

Sanitize a token list string, such as used in HTML rel and class attributes.

Parameters

$tokensstring|arrayrequired
List of tokens separated by spaces, or an array of tokens.

Return

string Sanitized token string list.

Source

public function sanitize_token_list( $tokens ) {
	if ( is_string( $tokens ) ) {
		$tokens = preg_split( '/\s+/', trim( $tokens ) );
	}
	$tokens = array_map( 'sanitize_html_class', $tokens );
	$tokens = array_filter( $tokens );
	return implode( ' ', $tokens );
}

Changelog

VersionDescription
4.8.0Introduced.

User Contributed Notes

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