_make_web_ftp_clickable_cb()
Callback to convert URL match to HTML A element.
This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable().
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
String. HTML A element with URL address.
Usage
_make_web_ftp_clickable_cb( $matches );
- $matches(array) (required)
- Single Regex Match.
Changelog
| Since 2.3.2 | Introduced. |
_make_web_ftp_clickable_cb() make web ftp clickable cb code WP 7.0
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 ) ) {
$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}";
}