From 0324721ed2217a37a042adb11c8e210bc5b687d8 Mon Sep 17 00:00:00 2001 From: scribu Date: Mon, 22 Nov 2010 17:17:31 +0000 Subject: [PATCH] Document url_shorten() and use in more places. Props latz for initial patch. Fixes #15540 git-svn-id: http://svn.automattic.com/wordpress/trunk@16536 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-links-list-table.php | 7 +------ wp-admin/includes/class-wp-users-list-table.php | 8 +------- wp-admin/includes/misc.php | 8 ++++---- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/wp-admin/includes/class-wp-links-list-table.php b/wp-admin/includes/class-wp-links-list-table.php index 09e3e5f83e..627d5be491 100644 --- a/wp-admin/includes/class-wp-links-list-table.php +++ b/wp-admin/includes/class-wp-links-list-table.php @@ -105,12 +105,7 @@ class WP_Links_List_Table extends WP_List_Table { $link->link_name = esc_attr( $link->link_name ); $link->link_category = wp_get_link_cats( $link->link_id ); - $short_url = str_replace( 'http://', '', $link->link_url ); - $short_url = preg_replace( '/^www\./i', '', $short_url ); - if ( '/' == substr( $short_url, -1 ) ) - $short_url = substr( $short_url, 0, -1 ); - if ( strlen( $short_url ) > 35 ) - $short_url = substr( $short_url, 0, 32 ).'...'; + $short_url = url_shorten( $link->link_url ); $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); $rating = $link->link_rating; diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php index 9e80033493..f46a572002 100644 --- a/wp-admin/includes/class-wp-users-list-table.php +++ b/wp-admin/includes/class-wp-users-list-table.php @@ -171,13 +171,7 @@ class WP_Users_List_Table extends WP_List_Table { $user_object = new WP_User( (int) $user_object ); $user_object = sanitize_user_object( $user_object, 'display' ); $email = $user_object->user_email; - $url = $user_object->user_url; - $short_url = str_replace( 'http://', '', $url ); - $short_url = str_replace( 'www.', '', $short_url ); - if ( '/' == substr( $short_url, -1 ) ) - $short_url = substr( $short_url, 0, -1 ); - if ( strlen( $short_url ) > 35 ) - $short_url = substr( $short_url, 0, 32 ).'...'; + $checkbox = ''; // Check if the user for this row is editable if ( current_user_can( 'list_users' ) ) { diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 980e17a185..50ecd1883b 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -212,12 +212,12 @@ add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); /** - * {@internal Missing Short Description}} + * Shorten an URL, to be used as link text * - * @since unknown + * @since 1.2.1 * - * @param unknown_type $url - * @return unknown + * @param string $url + * @return string */ function url_shorten( $url ) { $short_url = str_replace( 'http://', '', stripslashes( $url ));