From 4fb300c67a3442cd0209a6129d53f0f727b60743 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 22 Dec 2006 12:54:24 +0000 Subject: WP Merge to rev 4661 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@828 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/formatting.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'wp-includes/formatting.php') diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index cef58dd..badd080 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -749,22 +749,22 @@ function human_time_diff( $from, $to = '' ) { $diff = (int) abs($to - $from); if ($diff <= 3600) { $mins = round($diff / 60); - if ($mins <= 1) - $since = __('1 min'); - else - $since = sprintf( __('%s mins'), $mins); + if ($mins <= 1) { + $mins = 1; + } + $since = sprintf(__ngettext('%s min', '%s mins', $mins), $mins); } else if (($diff <= 86400) && ($diff > 3600)) { $hours = round($diff / 3600); - if ($hours <= 1) - $since = __('1 hour'); - else - $since = sprintf( __('%s hours'), $hours ); + if ($hours <= 1) { + $hour = 1; + } + $since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours); } elseif ($diff >= 86400) { $days = round($diff / 86400); - if ($days <= 1) - $since = __('1 day'); - else - $since = sprintf( __('%s days'), $days ); + if ($days <= 1) { + $days = 1; + } + $since = sprintf(__('%s day', '%s days', $days), $days); } return $since; } @@ -1087,9 +1087,16 @@ function htmlentities2($myHTML) { // Escape single quotes, specialchar double quotes, and fix line endings. function js_escape($text) { - $text = wp_specialchars($text, 'double'); - $text = str_replace(''', "'", $text); - return preg_replace("/\r?\n/", "\\n", addslashes($text)); + $safe_text = wp_specialchars($text, 'double'); + $safe_text = str_replace(''', "'", $safe_text); + $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text)); + return apply_filters('js_escape', $safe_text, $text); +} + +// Escaping for HTML attributes +function attribute_escape($text) { + $safe_text = wp_specialchars($text, true); + return apply_filters('attribute_escape', $safe_text, $text); } function wp_make_link_relative( $link ) { -- cgit