Ticket #20166: url_shorten.patch
| File url_shorten.patch, 1.9 KB (added by mulvane, 16 months ago) |
|---|
-
wp-admin/includes/misc.php
211 211 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); 212 212 213 213 /** 214 * Shorten an URL, to be used as link text215 *216 * @since 1.2.1217 *218 * @param string $url219 * @return string220 */221 function url_shorten( $url ) {222 $short_url = str_replace( 'http://', '', stripslashes( $url ));223 $short_url = str_replace( 'www.', '', $short_url );224 $short_url = untrailingslashit( $short_url );225 if ( strlen( $short_url ) > 35 )226 $short_url = substr( $short_url, 0, 32 ) . '...';227 return $short_url;228 }229 230 /**231 214 * Resets global variables based on $_GET and $_POST 232 215 * 233 216 * This function resets global variables based on the names passed -
wp-includes/functions.php
3664 3664 return $clean; 3665 3665 } 3666 3666 3667 /** 3668 * Shorten an URL, to be used as link text 3669 * 3670 * @since 1.2.1 3671 * 3672 * @param string $url 3673 * @return string 3674 */ 3675 function url_shorten( $url, $url_len = 35, $strip_lead = 1, $strip_trailslash = 1 ) { 3676 $short_url = $url; 3677 if ( $strip_lead == 1 ) { 3678 $short_url = str_replace( 'http://', '', stripslashes( $url ) ); 3679 $short_url = str_replace( 'www.', '', $short_url ); 3680 } 3681 if ( $strip_trailslash == 1 ) { 3682 $short_url = untrailingslashit ( $short_url ); 3683 } 3684 if ( is_int ( $url_len ) && $url_len <= 2000 ) { 3685 $short_url_len = $url_len; 3686 } 3687 if ( strlen( $short_url ) > $short_url_len ) 3688 $short_url = substr( $short_url, 0, $short_url_len - 3 ) . '...'; 3689 return $short_url; 3690 }