View difference between Paste ID: VkCwfEAU and QDHJpr9A
SHOW: | | - or go back to the newest paste.
1
	public static function span_comment($remote, $local = NULL) {
2
		if ($local === NULL) {
3
			$local = current_time('timestamp', 1);
4
		}
5
6
		$span = self::span($remote, $local);
7
		$timespan = abs($remote - $local);
8
		$output = '';
9
		$hours = '';
10
		$minutes = '';
11
12
		// Years
13
		if (!empty($span['years'])) {
14
			$output = get_comment_date();
15
		}
16
17
		// Months
18
		elseif (!empty($span['months'])) {
19
			if ($span['months'] == '1') {
20
				$output = __('1 month ago', 'social');
21
			}
22
			else {
23
				$output = sprintf(__('%s months ago', 'social'), $span['months']);
24
			}
25
		}
26
27
		// Weeks
28
		elseif (!empty($span['weeks'])) {
29
			if ($span['weeks'] == '1') {
30
				$output = __('1 week ago', 'social');
31
			}
32
			else {
33
				$output = sprintf(__('%s weeks ago', $span['weeks']), $span['weeks']);
34
			}
35
		}
36
37
		// Days
38
		elseif (!empty($span['days'])) {
39
			if ($span['days'] == '1') {
40
				$output = __('1 day ago', 'social');
41
			}
42
			else {
43
				$output = sprintf(__('%s days ago', 'social'), $span['days']);
44
			}
45
		}
46
47
		// Hours
48
49
		elseif (!empty($span['hours'])) {
50
			if ($span['hours'] == '1') {
51
				$hours = __('1 hour', 'social');
52
				$output = __('1 hour ago', 'social');
53
			}
54
			else {
55
				$hours = sprintf(__('%s hours', 'social'), $span['hours']);
56
			}
57
		}
58
59
		// Minutes
60
61
		elseif (!empty($span['minutes'])) {
62
			if ($span['minutes'] == '1') {
63
				$minutes = __('1 minute', 'social');
64
				$output = __('1 minute ago', 'social');
65
			}
66
			else {
67
				$minutes = sprintf(__('%s minutes', 'social'), $span['minutes']);
68
				$output = sprintf(__('%s minutes ago', 'social'), $span['minutes']);
69
			}
70
		}
71
72
		// Seconds
73
		elseif (empty($hours) and empty($minutes)) {
74-
		elseif (!empty($hours)) {
74+
75
		}
76
77
		else {
78
			$output = sprintf(__('%s ago', 'social'), $minutes);
79
		}
80
81
		if (!empty($hours)) {
82
			if ($span['hours'] > 1) {
83
				$output = sprintf(__('%s ago', 'social'), $hours);
84
			}
85
			else {
86
				$output = sprintf(__('%s ago', 'social'), $hours.' '.$minutes);
87
			}
88
		}
89
90
		return apply_filters('social_comment_date', $output, $remote, $local);
91
	}