Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_make_web_ftp_clickable_cb( array $matches ): string

Callback to convert URL match to HTML A element.


Description

This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable() .


Top ↑

Parameters

$matches array Required
Single Regex Match.

Top ↑

Return

string HTML A element with URL address.


Top ↑

Source

File: wp-includes/formatting.php. View all references

function _make_web_ftp_clickable_cb( $matches ) {
	$ret  = '';
	$dest = $matches[2];
	$dest = 'http://' . $dest;

	// Removed trailing [.,;:)] from URL.
	$last_char = substr( $dest, -1 );
	if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
		$ret  = $last_char;
		$dest = substr( $dest, 0, strlen( $dest ) - 1 );
	}

	$dest = esc_url( $dest );
	if ( empty( $dest ) ) {
		return $matches[0];
	}

	$rel_attr = _make_clickable_rel_attr( $dest );

	return $matches[1] . "<a href=\"{$dest}\"{$rel_attr}>{$dest}</a>{$ret}";
}


Top ↑

Changelog

Changelog
Version Description
2.3.2 Introduced.

Top ↑

User Contributed Notes

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