W3cubDocs

/WordPress

convert_chars( string $content, string $deprecated = ): string

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

Parameters

$contentstringrequired
String of characters to be converted.
$deprecatedstringoptional
Not used.

Default:''

Return

string Converted string.

Source

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;
}

Changelog

Version Description
0.71 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/convert_chars