wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
url_shorten › WordPress Function
Depuis1.2.0
Dépréciéen/a
› url_shorten ( $url, $length = 35 )
| Paramètres: (2) |
|
| Retourne: |
|
| Défini(e) dans: |
|
| Codex: | |
| Changelog: |
|
Shortens a URL, to be used as link text.
Fonctions en relation: do_shortcode, sort_menu, apply_shortcodes, remove_shortcode, strip_shortcodes
Source
function url_shorten( $url, $length = 35 ) {
$stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url );
$short_url = untrailingslashit( $stripped );
if ( strlen( $short_url ) > $length ) {
$short_url = substr( $short_url, 0, $length - 3 ) . '…';
}
return $short_url;
}