Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function span_comment($remote, $local = NULL) {
- if ($local === NULL) {
- $local = current_time('timestamp', 1);
- }
- $span = self::span($remote, $local);
- $timespan = abs($remote - $local);
- $output = '';
- $hours = '';
- $minutes = '';
- // Years
- if (!empty($span['years'])) {
- $output = get_comment_date();
- }
- // Months
- elseif (!empty($span['months'])) {
- if ($span['months'] == '1') {
- $output = __('1 month ago', 'social');
- }
- else {
- $output = sprintf(__('%s months ago', 'social'), $span['months']);
- }
- }
- // Weeks
- elseif (!empty($span['weeks'])) {
- if ($span['weeks'] == '1') {
- $output = __('1 week ago', 'social');
- }
- else {
- $output = sprintf(__('%s weeks ago', 'social'), $span['weeks']);
- }
- }
- // Days
- elseif (!empty($span['days'])) {
- if ($span['days'] == '1') {
- $output = __('1 day ago', 'social');
- }
- else {
- $output = sprintf(__('%s days ago', 'social'), $span['days']);
- }
- }
- // Hours
- elseif (!empty($span['hours'])) {
- if ($span['hours'] == '1') {
- $hours = __('1 hour', 'social');
- $output = __('1 hour ago', 'social');
- }
- else {
- $hours = sprintf(__('%s hours', 'social'), $span['hours']);
- }
- }
- // Minutes
- elseif (!empty($span['minutes'])) {
- if ($span['minutes'] == '1') {
- $minutes = __('1 minute', 'social');
- $output = __('1 minute ago', 'social');
- }
- else {
- $minutes = sprintf(__('%s minutes', 'social'), $span['minutes']);
- $output = sprintf(__('%s minutes ago', 'social'), $span['minutes']);
- }
- }
- // Seconds
- elseif (empty($hours) and empty($minutes)) {
- $output = __('just now', 'social');
- }
- else {
- $output = sprintf(__('%s ago', 'social'), $minutes);
- }
- if (!empty($hours)) {
- if ($span['hours'] > 1) {
- $output = sprintf(__('%s ago', 'social'), $hours);
- }
- else {
- $output = sprintf(__('%s ago', 'social'), $hours.' '.$minutes);
- }
- }
- return apply_filters('social_comment_date', $output, $remote, $local);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement