convert_chars()WP 0.71

Converts lone & characters into & (a.k.a. &)

No Hooks.

Return

String. Converted string.

Usage

convert_chars( $content, $deprecated );
$content(string) (required)
String of characters to be converted.
$deprecated(string)
Not used.
Default: ''

Changelog

Since 0.71 Introduced.

convert_chars() code WP 6.8

function convert_chars( $content, $deprecated = '' ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '0.71' );
	}

	if ( str_contains( $content, '&' ) ) {
		$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content );
	}

	return $content;
}