diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index d776681ccc..de6fc4e94c 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -288,21 +288,6 @@ function update_home_siteurl( $old_value, $value ) { } } -/** - * Shorten an URL, to be used as link text - * - * @since 1.2.0 - * - * @param string $url - * @return string - */ -function url_shorten( $url ) { - $short_url = str_replace( array( 'http://', 'www.' ), '', $url ); - $short_url = untrailingslashit( $short_url ); - if ( strlen( $short_url ) > 35 ) - $short_url = substr( $short_url, 0, 32 ) . '…'; - return $short_url; -} /** * Resets global variables based on $_GET and $_POST diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 65ef3e36d2..231c252ae4 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -4769,3 +4769,23 @@ function wp_staticize_emoji_for_email( $mail ) { return $mail; } + +/** + * Shorten an URL, to be used as link text + * + * @since 1.2.0 + * @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param + * + * @param string $url URL to shorten + * @param int $length Maxiumum length of url to return + * @return string +*/ +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; +} \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 0e6448f2a3..0b018097ab 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35313'; +$wp_version = '4.4-alpha-35314'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.