wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
_make_url_clickable_cb is private and should not be used in themes or plugins directly.
_make_url_clickable_cb › WordPress Function
Seit2.3.2
Veraltetn/v
› _make_url_clickable_cb ( $matches )
Zugriff: |
|
Parameter: |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Callback to convert URI match to HTML A element.
This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable().Ähnliche Funktionen: _make_email_clickable_cb, _make_web_ftp_clickable_cb, make_clickable, _make_clickable_rel_attr, get_user_locale
Quellcode
function _make_url_clickable_cb( $matches ) {
$url = $matches[2];
if ( ')' === $matches[3] && strpos( $url, '(' ) ) {
/*
* If the trailing character is a closing parenthesis, and the URL has an opening parenthesis in it,
* add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below.
*/
$url .= $matches[3];
$suffix = '';
} else {
$suffix = $matches[3];
}
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
$url .= $matches[4];
}
// Include parentheses in the URL only if paired.
while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
$suffix = strrchr( $url, ')' ) . $suffix;
$url = substr( $url, 0, strrpos( $url, ')' ) );
}
$url = esc_url( $url );
if ( empty( $url ) ) {
return $matches[0];
}
$rel_attr = _make_clickable_rel_attr( $url );
return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix;
}