@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * @param int $timeout |
21 | 21 | */ |
22 | 22 | public function __construct($server, $path = false, $port = false, $timeout = 15) { |
23 | - if ( ! $path ) { |
|
23 | + if ( ! $path) { |
|
24 | 24 | // Assume we have been given a URL instead |
25 | 25 | $bits = parse_url($server); |
26 | 26 | $this->scheme = $bits['scheme']; |
27 | 27 | $this->server = $bits['host']; |
28 | 28 | $this->port = isset($bits['port']) ? $bits['port'] : $port; |
29 | - $this->path = !empty($bits['path']) ? $bits['path'] : '/'; |
|
29 | + $this->path = ! empty($bits['path']) ? $bits['path'] : '/'; |
|
30 | 30 | |
31 | 31 | // Make absolutely sure we have a path |
32 | - if ( ! $this->path ) { |
|
32 | + if ( ! $this->path) { |
|
33 | 33 | $this->path = '/'; |
34 | 34 | } |
35 | 35 | |
36 | - if ( ! empty( $bits['query'] ) ) { |
|
37 | - $this->path .= '?' . $bits['query']; |
|
36 | + if ( ! empty($bits['query'])) { |
|
37 | + $this->path .= '?'.$bits['query']; |
|
38 | 38 | } |
39 | 39 | } else { |
40 | 40 | $this->scheme = 'http'; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $xml = $request->getXml(); |
57 | 57 | |
58 | 58 | $port = $this->port ? ":$this->port" : ''; |
59 | - $url = $this->scheme . '://' . $this->server . $port . $this->path; |
|
59 | + $url = $this->scheme.'://'.$this->server.$port.$this->path; |
|
60 | 60 | $args = array( |
61 | 61 | 'headers' => array('Content-Type' => 'text/xml'), |
62 | 62 | 'user-agent' => $this->useragent, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Merge Custom headers ala #8145 |
67 | - foreach ( $this->headers as $header => $value ) { |
|
67 | + foreach ($this->headers as $header => $value) { |
|
68 | 68 | $args['headers'][$header] = $value; |
69 | 69 | } |
70 | 70 | |
@@ -75,45 +75,45 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param array $headers Array of headers to be sent. |
77 | 77 | */ |
78 | - $args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] ); |
|
78 | + $args['headers'] = apply_filters('wp_http_ixr_client_headers', $args['headers']); |
|
79 | 79 | |
80 | - if ( $this->timeout !== false ) { |
|
80 | + if ($this->timeout !== false) { |
|
81 | 81 | $args['timeout'] = $this->timeout; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // Now send the request |
85 | - if ( $this->debug ) { |
|
86 | - echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n"; |
|
85 | + if ($this->debug) { |
|
86 | + echo '<pre class="ixr_request">'.htmlspecialchars($xml)."\n</pre>\n\n"; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $response = wp_remote_post($url, $args); |
90 | 90 | |
91 | - if ( is_wp_error($response) ) { |
|
91 | + if (is_wp_error($response)) { |
|
92 | 92 | $errno = $response->get_error_code(); |
93 | 93 | $errorstr = $response->get_error_message(); |
94 | 94 | $this->error = new IXR_Error(-32300, "transport error: $errno $errorstr"); |
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if ( 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
99 | - $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')'); |
|
98 | + if (200 != wp_remote_retrieve_response_code($response)) { |
|
99 | + $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 ('.wp_remote_retrieve_response_code($response).')'); |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | - if ( $this->debug ) { |
|
104 | - echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n"; |
|
103 | + if ($this->debug) { |
|
104 | + echo '<pre class="ixr_response">'.htmlspecialchars(wp_remote_retrieve_body($response))."\n</pre>\n\n"; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // Now parse what we've got back |
108 | - $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) ); |
|
109 | - if ( ! $this->message->parse() ) { |
|
108 | + $this->message = new IXR_Message(wp_remote_retrieve_body($response)); |
|
109 | + if ( ! $this->message->parse()) { |
|
110 | 110 | // XML error |
111 | 111 | $this->error = new IXR_Error(-32700, 'parse error. not well formed'); |
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Is the message a fault? |
116 | - if ( $this->message->messageType == 'fault' ) { |
|
116 | + if ($this->message->messageType == 'fault') { |
|
117 | 117 | $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); |
118 | 118 | return false; |
119 | 119 | } |
@@ -22,227 +22,227 @@ |
||
22 | 22 | */ |
23 | 23 | class Text_Diff_Engine_string { |
24 | 24 | |
25 | - /** |
|
26 | - * Parses a unified or context diff. |
|
27 | - * |
|
28 | - * First param contains the whole diff and the second can be used to force |
|
29 | - * a specific diff type. If the second parameter is 'autodetect', the |
|
30 | - * diff will be examined to find out which type of diff this is. |
|
31 | - * |
|
32 | - * @param string $diff The diff content. |
|
33 | - * @param string $mode The diff mode of the content in $diff. One of |
|
34 | - * 'context', 'unified', or 'autodetect'. |
|
35 | - * |
|
36 | - * @return array List of all diff operations. |
|
37 | - */ |
|
38 | - function diff($diff, $mode = 'autodetect') |
|
39 | - { |
|
40 | - // Detect line breaks. |
|
41 | - $lnbr = "\n"; |
|
42 | - if (strpos($diff, "\r\n") !== false) { |
|
43 | - $lnbr = "\r\n"; |
|
44 | - } elseif (strpos($diff, "\r") !== false) { |
|
45 | - $lnbr = "\r"; |
|
46 | - } |
|
47 | - |
|
48 | - // Make sure we have a line break at the EOF. |
|
49 | - if (substr($diff, -strlen($lnbr)) != $lnbr) { |
|
50 | - $diff .= $lnbr; |
|
51 | - } |
|
52 | - |
|
53 | - if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { |
|
54 | - return PEAR::raiseError('Type of diff is unsupported'); |
|
55 | - } |
|
56 | - |
|
57 | - if ($mode == 'autodetect') { |
|
58 | - $context = strpos($diff, '***'); |
|
59 | - $unified = strpos($diff, '---'); |
|
60 | - if ($context === $unified) { |
|
61 | - return PEAR::raiseError('Type of diff could not be detected'); |
|
62 | - } elseif ($context === false || $unified === false) { |
|
63 | - $mode = $context !== false ? 'context' : 'unified'; |
|
64 | - } else { |
|
65 | - $mode = $context < $unified ? 'context' : 'unified'; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - // Split by new line and remove the diff header, if there is one. |
|
70 | - $diff = explode($lnbr, $diff); |
|
71 | - if (($mode == 'context' && strpos($diff[0], '***') === 0) || |
|
72 | - ($mode == 'unified' && strpos($diff[0], '---') === 0)) { |
|
73 | - array_shift($diff); |
|
74 | - array_shift($diff); |
|
75 | - } |
|
76 | - |
|
77 | - if ($mode == 'context') { |
|
78 | - return $this->parseContextDiff($diff); |
|
79 | - } else { |
|
80 | - return $this->parseUnifiedDiff($diff); |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Parses an array containing the unified diff. |
|
86 | - * |
|
87 | - * @param array $diff Array of lines. |
|
88 | - * |
|
89 | - * @return array List of all diff operations. |
|
90 | - */ |
|
91 | - function parseUnifiedDiff($diff) |
|
92 | - { |
|
93 | - $edits = array(); |
|
94 | - $end = count($diff) - 1; |
|
95 | - for ($i = 0; $i < $end;) { |
|
96 | - $diff1 = array(); |
|
97 | - switch (substr($diff[$i], 0, 1)) { |
|
98 | - case ' ': |
|
99 | - do { |
|
100 | - $diff1[] = substr($diff[$i], 1); |
|
101 | - } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); |
|
102 | - $edits[] = new Text_Diff_Op_copy($diff1); |
|
103 | - break; |
|
104 | - |
|
105 | - case '+': |
|
106 | - // get all new lines |
|
107 | - do { |
|
108 | - $diff1[] = substr($diff[$i], 1); |
|
109 | - } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); |
|
110 | - $edits[] = new Text_Diff_Op_add($diff1); |
|
111 | - break; |
|
112 | - |
|
113 | - case '-': |
|
114 | - // get changed or removed lines |
|
115 | - $diff2 = array(); |
|
116 | - do { |
|
117 | - $diff1[] = substr($diff[$i], 1); |
|
118 | - } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); |
|
119 | - |
|
120 | - while ($i < $end && substr($diff[$i], 0, 1) == '+') { |
|
121 | - $diff2[] = substr($diff[$i++], 1); |
|
122 | - } |
|
123 | - if (count($diff2) == 0) { |
|
124 | - $edits[] = new Text_Diff_Op_delete($diff1); |
|
125 | - } else { |
|
126 | - $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
127 | - } |
|
128 | - break; |
|
129 | - |
|
130 | - default: |
|
131 | - $i++; |
|
132 | - break; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - return $edits; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Parses an array containing the context diff. |
|
141 | - * |
|
142 | - * @param array $diff Array of lines. |
|
143 | - * |
|
144 | - * @return array List of all diff operations. |
|
145 | - */ |
|
146 | - function parseContextDiff(&$diff) |
|
147 | - { |
|
148 | - $edits = array(); |
|
149 | - $i = $max_i = $j = $max_j = 0; |
|
150 | - $end = count($diff) - 1; |
|
151 | - while ($i < $end && $j < $end) { |
|
152 | - while ($i >= $max_i && $j >= $max_j) { |
|
153 | - // Find the boundaries of the diff output of the two files |
|
154 | - for ($i = $j; |
|
155 | - $i < $end && substr($diff[$i], 0, 3) == '***'; |
|
156 | - $i++); |
|
157 | - for ($max_i = $i; |
|
158 | - $max_i < $end && substr($diff[$max_i], 0, 3) != '---'; |
|
159 | - $max_i++); |
|
160 | - for ($j = $max_i; |
|
161 | - $j < $end && substr($diff[$j], 0, 3) == '---'; |
|
162 | - $j++); |
|
163 | - for ($max_j = $j; |
|
164 | - $max_j < $end && substr($diff[$max_j], 0, 3) != '***'; |
|
165 | - $max_j++); |
|
166 | - } |
|
167 | - |
|
168 | - // find what hasn't been changed |
|
169 | - $array = array(); |
|
170 | - while ($i < $max_i && |
|
171 | - $j < $max_j && |
|
172 | - strcmp($diff[$i], $diff[$j]) == 0) { |
|
173 | - $array[] = substr($diff[$i], 2); |
|
174 | - $i++; |
|
175 | - $j++; |
|
176 | - } |
|
177 | - |
|
178 | - while ($i < $max_i && ($max_j-$j) <= 1) { |
|
179 | - if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') { |
|
180 | - break; |
|
181 | - } |
|
182 | - $array[] = substr($diff[$i++], 2); |
|
183 | - } |
|
184 | - |
|
185 | - while ($j < $max_j && ($max_i-$i) <= 1) { |
|
186 | - if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') { |
|
187 | - break; |
|
188 | - } |
|
189 | - $array[] = substr($diff[$j++], 2); |
|
190 | - } |
|
191 | - if (count($array) > 0) { |
|
192 | - $edits[] = new Text_Diff_Op_copy($array); |
|
193 | - } |
|
194 | - |
|
195 | - if ($i < $max_i) { |
|
196 | - $diff1 = array(); |
|
197 | - switch (substr($diff[$i], 0, 1)) { |
|
198 | - case '!': |
|
199 | - $diff2 = array(); |
|
200 | - do { |
|
201 | - $diff1[] = substr($diff[$i], 2); |
|
202 | - if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { |
|
203 | - $diff2[] = substr($diff[$j++], 2); |
|
204 | - } |
|
205 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); |
|
206 | - $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
207 | - break; |
|
208 | - |
|
209 | - case '+': |
|
210 | - do { |
|
211 | - $diff1[] = substr($diff[$i], 2); |
|
212 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); |
|
213 | - $edits[] = new Text_Diff_Op_add($diff1); |
|
214 | - break; |
|
215 | - |
|
216 | - case '-': |
|
217 | - do { |
|
218 | - $diff1[] = substr($diff[$i], 2); |
|
219 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); |
|
220 | - $edits[] = new Text_Diff_Op_delete($diff1); |
|
221 | - break; |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - if ($j < $max_j) { |
|
226 | - $diff2 = array(); |
|
227 | - switch (substr($diff[$j], 0, 1)) { |
|
228 | - case '+': |
|
229 | - do { |
|
230 | - $diff2[] = substr($diff[$j++], 2); |
|
231 | - } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); |
|
232 | - $edits[] = new Text_Diff_Op_add($diff2); |
|
233 | - break; |
|
234 | - |
|
235 | - case '-': |
|
236 | - do { |
|
237 | - $diff2[] = substr($diff[$j++], 2); |
|
238 | - } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); |
|
239 | - $edits[] = new Text_Diff_Op_delete($diff2); |
|
240 | - break; |
|
241 | - } |
|
242 | - } |
|
243 | - } |
|
244 | - |
|
245 | - return $edits; |
|
246 | - } |
|
25 | + /** |
|
26 | + * Parses a unified or context diff. |
|
27 | + * |
|
28 | + * First param contains the whole diff and the second can be used to force |
|
29 | + * a specific diff type. If the second parameter is 'autodetect', the |
|
30 | + * diff will be examined to find out which type of diff this is. |
|
31 | + * |
|
32 | + * @param string $diff The diff content. |
|
33 | + * @param string $mode The diff mode of the content in $diff. One of |
|
34 | + * 'context', 'unified', or 'autodetect'. |
|
35 | + * |
|
36 | + * @return array List of all diff operations. |
|
37 | + */ |
|
38 | + function diff($diff, $mode = 'autodetect') |
|
39 | + { |
|
40 | + // Detect line breaks. |
|
41 | + $lnbr = "\n"; |
|
42 | + if (strpos($diff, "\r\n") !== false) { |
|
43 | + $lnbr = "\r\n"; |
|
44 | + } elseif (strpos($diff, "\r") !== false) { |
|
45 | + $lnbr = "\r"; |
|
46 | + } |
|
47 | + |
|
48 | + // Make sure we have a line break at the EOF. |
|
49 | + if (substr($diff, -strlen($lnbr)) != $lnbr) { |
|
50 | + $diff .= $lnbr; |
|
51 | + } |
|
52 | + |
|
53 | + if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { |
|
54 | + return PEAR::raiseError('Type of diff is unsupported'); |
|
55 | + } |
|
56 | + |
|
57 | + if ($mode == 'autodetect') { |
|
58 | + $context = strpos($diff, '***'); |
|
59 | + $unified = strpos($diff, '---'); |
|
60 | + if ($context === $unified) { |
|
61 | + return PEAR::raiseError('Type of diff could not be detected'); |
|
62 | + } elseif ($context === false || $unified === false) { |
|
63 | + $mode = $context !== false ? 'context' : 'unified'; |
|
64 | + } else { |
|
65 | + $mode = $context < $unified ? 'context' : 'unified'; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + // Split by new line and remove the diff header, if there is one. |
|
70 | + $diff = explode($lnbr, $diff); |
|
71 | + if (($mode == 'context' && strpos($diff[0], '***') === 0) || |
|
72 | + ($mode == 'unified' && strpos($diff[0], '---') === 0)) { |
|
73 | + array_shift($diff); |
|
74 | + array_shift($diff); |
|
75 | + } |
|
76 | + |
|
77 | + if ($mode == 'context') { |
|
78 | + return $this->parseContextDiff($diff); |
|
79 | + } else { |
|
80 | + return $this->parseUnifiedDiff($diff); |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Parses an array containing the unified diff. |
|
86 | + * |
|
87 | + * @param array $diff Array of lines. |
|
88 | + * |
|
89 | + * @return array List of all diff operations. |
|
90 | + */ |
|
91 | + function parseUnifiedDiff($diff) |
|
92 | + { |
|
93 | + $edits = array(); |
|
94 | + $end = count($diff) - 1; |
|
95 | + for ($i = 0; $i < $end;) { |
|
96 | + $diff1 = array(); |
|
97 | + switch (substr($diff[$i], 0, 1)) { |
|
98 | + case ' ': |
|
99 | + do { |
|
100 | + $diff1[] = substr($diff[$i], 1); |
|
101 | + } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); |
|
102 | + $edits[] = new Text_Diff_Op_copy($diff1); |
|
103 | + break; |
|
104 | + |
|
105 | + case '+': |
|
106 | + // get all new lines |
|
107 | + do { |
|
108 | + $diff1[] = substr($diff[$i], 1); |
|
109 | + } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); |
|
110 | + $edits[] = new Text_Diff_Op_add($diff1); |
|
111 | + break; |
|
112 | + |
|
113 | + case '-': |
|
114 | + // get changed or removed lines |
|
115 | + $diff2 = array(); |
|
116 | + do { |
|
117 | + $diff1[] = substr($diff[$i], 1); |
|
118 | + } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); |
|
119 | + |
|
120 | + while ($i < $end && substr($diff[$i], 0, 1) == '+') { |
|
121 | + $diff2[] = substr($diff[$i++], 1); |
|
122 | + } |
|
123 | + if (count($diff2) == 0) { |
|
124 | + $edits[] = new Text_Diff_Op_delete($diff1); |
|
125 | + } else { |
|
126 | + $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
127 | + } |
|
128 | + break; |
|
129 | + |
|
130 | + default: |
|
131 | + $i++; |
|
132 | + break; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + return $edits; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Parses an array containing the context diff. |
|
141 | + * |
|
142 | + * @param array $diff Array of lines. |
|
143 | + * |
|
144 | + * @return array List of all diff operations. |
|
145 | + */ |
|
146 | + function parseContextDiff(&$diff) |
|
147 | + { |
|
148 | + $edits = array(); |
|
149 | + $i = $max_i = $j = $max_j = 0; |
|
150 | + $end = count($diff) - 1; |
|
151 | + while ($i < $end && $j < $end) { |
|
152 | + while ($i >= $max_i && $j >= $max_j) { |
|
153 | + // Find the boundaries of the diff output of the two files |
|
154 | + for ($i = $j; |
|
155 | + $i < $end && substr($diff[$i], 0, 3) == '***'; |
|
156 | + $i++); |
|
157 | + for ($max_i = $i; |
|
158 | + $max_i < $end && substr($diff[$max_i], 0, 3) != '---'; |
|
159 | + $max_i++); |
|
160 | + for ($j = $max_i; |
|
161 | + $j < $end && substr($diff[$j], 0, 3) == '---'; |
|
162 | + $j++); |
|
163 | + for ($max_j = $j; |
|
164 | + $max_j < $end && substr($diff[$max_j], 0, 3) != '***'; |
|
165 | + $max_j++); |
|
166 | + } |
|
167 | + |
|
168 | + // find what hasn't been changed |
|
169 | + $array = array(); |
|
170 | + while ($i < $max_i && |
|
171 | + $j < $max_j && |
|
172 | + strcmp($diff[$i], $diff[$j]) == 0) { |
|
173 | + $array[] = substr($diff[$i], 2); |
|
174 | + $i++; |
|
175 | + $j++; |
|
176 | + } |
|
177 | + |
|
178 | + while ($i < $max_i && ($max_j-$j) <= 1) { |
|
179 | + if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') { |
|
180 | + break; |
|
181 | + } |
|
182 | + $array[] = substr($diff[$i++], 2); |
|
183 | + } |
|
184 | + |
|
185 | + while ($j < $max_j && ($max_i-$i) <= 1) { |
|
186 | + if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') { |
|
187 | + break; |
|
188 | + } |
|
189 | + $array[] = substr($diff[$j++], 2); |
|
190 | + } |
|
191 | + if (count($array) > 0) { |
|
192 | + $edits[] = new Text_Diff_Op_copy($array); |
|
193 | + } |
|
194 | + |
|
195 | + if ($i < $max_i) { |
|
196 | + $diff1 = array(); |
|
197 | + switch (substr($diff[$i], 0, 1)) { |
|
198 | + case '!': |
|
199 | + $diff2 = array(); |
|
200 | + do { |
|
201 | + $diff1[] = substr($diff[$i], 2); |
|
202 | + if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { |
|
203 | + $diff2[] = substr($diff[$j++], 2); |
|
204 | + } |
|
205 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); |
|
206 | + $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
207 | + break; |
|
208 | + |
|
209 | + case '+': |
|
210 | + do { |
|
211 | + $diff1[] = substr($diff[$i], 2); |
|
212 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); |
|
213 | + $edits[] = new Text_Diff_Op_add($diff1); |
|
214 | + break; |
|
215 | + |
|
216 | + case '-': |
|
217 | + do { |
|
218 | + $diff1[] = substr($diff[$i], 2); |
|
219 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); |
|
220 | + $edits[] = new Text_Diff_Op_delete($diff1); |
|
221 | + break; |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + if ($j < $max_j) { |
|
226 | + $diff2 = array(); |
|
227 | + switch (substr($diff[$j], 0, 1)) { |
|
228 | + case '+': |
|
229 | + do { |
|
230 | + $diff2[] = substr($diff[$j++], 2); |
|
231 | + } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); |
|
232 | + $edits[] = new Text_Diff_Op_add($diff2); |
|
233 | + break; |
|
234 | + |
|
235 | + case '-': |
|
236 | + do { |
|
237 | + $diff2[] = substr($diff[$j++], 2); |
|
238 | + } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); |
|
239 | + $edits[] = new Text_Diff_Op_delete($diff2); |
|
240 | + break; |
|
241 | + } |
|
242 | + } |
|
243 | + } |
|
244 | + |
|
245 | + return $edits; |
|
246 | + } |
|
247 | 247 | |
248 | 248 | } |
@@ -95,41 +95,41 @@ discard block |
||
95 | 95 | for ($i = 0; $i < $end;) { |
96 | 96 | $diff1 = array(); |
97 | 97 | switch (substr($diff[$i], 0, 1)) { |
98 | - case ' ': |
|
99 | - do { |
|
100 | - $diff1[] = substr($diff[$i], 1); |
|
101 | - } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); |
|
102 | - $edits[] = new Text_Diff_Op_copy($diff1); |
|
103 | - break; |
|
104 | - |
|
105 | - case '+': |
|
106 | - // get all new lines |
|
107 | - do { |
|
108 | - $diff1[] = substr($diff[$i], 1); |
|
109 | - } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); |
|
110 | - $edits[] = new Text_Diff_Op_add($diff1); |
|
111 | - break; |
|
112 | - |
|
113 | - case '-': |
|
114 | - // get changed or removed lines |
|
115 | - $diff2 = array(); |
|
116 | - do { |
|
117 | - $diff1[] = substr($diff[$i], 1); |
|
118 | - } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); |
|
119 | - |
|
120 | - while ($i < $end && substr($diff[$i], 0, 1) == '+') { |
|
121 | - $diff2[] = substr($diff[$i++], 1); |
|
122 | - } |
|
123 | - if (count($diff2) == 0) { |
|
124 | - $edits[] = new Text_Diff_Op_delete($diff1); |
|
125 | - } else { |
|
126 | - $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
127 | - } |
|
128 | - break; |
|
129 | - |
|
130 | - default: |
|
131 | - $i++; |
|
132 | - break; |
|
98 | + case ' ': |
|
99 | + do { |
|
100 | + $diff1[] = substr($diff[$i], 1); |
|
101 | + } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); |
|
102 | + $edits[] = new Text_Diff_Op_copy($diff1); |
|
103 | + break; |
|
104 | + |
|
105 | + case '+': |
|
106 | + // get all new lines |
|
107 | + do { |
|
108 | + $diff1[] = substr($diff[$i], 1); |
|
109 | + } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); |
|
110 | + $edits[] = new Text_Diff_Op_add($diff1); |
|
111 | + break; |
|
112 | + |
|
113 | + case '-': |
|
114 | + // get changed or removed lines |
|
115 | + $diff2 = array(); |
|
116 | + do { |
|
117 | + $diff1[] = substr($diff[$i], 1); |
|
118 | + } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); |
|
119 | + |
|
120 | + while ($i < $end && substr($diff[$i], 0, 1) == '+') { |
|
121 | + $diff2[] = substr($diff[$i++], 1); |
|
122 | + } |
|
123 | + if (count($diff2) == 0) { |
|
124 | + $edits[] = new Text_Diff_Op_delete($diff1); |
|
125 | + } else { |
|
126 | + $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
127 | + } |
|
128 | + break; |
|
129 | + |
|
130 | + default: |
|
131 | + $i++; |
|
132 | + break; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -195,49 +195,49 @@ discard block |
||
195 | 195 | if ($i < $max_i) { |
196 | 196 | $diff1 = array(); |
197 | 197 | switch (substr($diff[$i], 0, 1)) { |
198 | - case '!': |
|
199 | - $diff2 = array(); |
|
200 | - do { |
|
201 | - $diff1[] = substr($diff[$i], 2); |
|
202 | - if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { |
|
203 | - $diff2[] = substr($diff[$j++], 2); |
|
204 | - } |
|
205 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); |
|
206 | - $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
207 | - break; |
|
208 | - |
|
209 | - case '+': |
|
210 | - do { |
|
211 | - $diff1[] = substr($diff[$i], 2); |
|
212 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); |
|
213 | - $edits[] = new Text_Diff_Op_add($diff1); |
|
214 | - break; |
|
215 | - |
|
216 | - case '-': |
|
217 | - do { |
|
218 | - $diff1[] = substr($diff[$i], 2); |
|
219 | - } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); |
|
220 | - $edits[] = new Text_Diff_Op_delete($diff1); |
|
221 | - break; |
|
198 | + case '!': |
|
199 | + $diff2 = array(); |
|
200 | + do { |
|
201 | + $diff1[] = substr($diff[$i], 2); |
|
202 | + if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { |
|
203 | + $diff2[] = substr($diff[$j++], 2); |
|
204 | + } |
|
205 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); |
|
206 | + $edits[] = new Text_Diff_Op_change($diff1, $diff2); |
|
207 | + break; |
|
208 | + |
|
209 | + case '+': |
|
210 | + do { |
|
211 | + $diff1[] = substr($diff[$i], 2); |
|
212 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); |
|
213 | + $edits[] = new Text_Diff_Op_add($diff1); |
|
214 | + break; |
|
215 | + |
|
216 | + case '-': |
|
217 | + do { |
|
218 | + $diff1[] = substr($diff[$i], 2); |
|
219 | + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); |
|
220 | + $edits[] = new Text_Diff_Op_delete($diff1); |
|
221 | + break; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | 225 | if ($j < $max_j) { |
226 | 226 | $diff2 = array(); |
227 | 227 | switch (substr($diff[$j], 0, 1)) { |
228 | - case '+': |
|
229 | - do { |
|
230 | - $diff2[] = substr($diff[$j++], 2); |
|
231 | - } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); |
|
232 | - $edits[] = new Text_Diff_Op_add($diff2); |
|
233 | - break; |
|
234 | - |
|
235 | - case '-': |
|
236 | - do { |
|
237 | - $diff2[] = substr($diff[$j++], 2); |
|
238 | - } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); |
|
239 | - $edits[] = new Text_Diff_Op_delete($diff2); |
|
240 | - break; |
|
228 | + case '+': |
|
229 | + do { |
|
230 | + $diff2[] = substr($diff[$j++], 2); |
|
231 | + } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); |
|
232 | + $edits[] = new Text_Diff_Op_add($diff2); |
|
233 | + break; |
|
234 | + |
|
235 | + case '-': |
|
236 | + do { |
|
237 | + $diff2[] = substr($diff[$j++], 2); |
|
238 | + } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); |
|
239 | + $edits[] = new Text_Diff_Op_delete($diff2); |
|
240 | + break; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
@@ -175,14 +175,14 @@ |
||
175 | 175 | $j++; |
176 | 176 | } |
177 | 177 | |
178 | - while ($i < $max_i && ($max_j-$j) <= 1) { |
|
178 | + while ($i < $max_i && ($max_j - $j) <= 1) { |
|
179 | 179 | if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') { |
180 | 180 | break; |
181 | 181 | } |
182 | 182 | $array[] = substr($diff[$i++], 2); |
183 | 183 | } |
184 | 184 | |
185 | - while ($j < $max_j && ($max_i-$i) <= 1) { |
|
185 | + while ($j < $max_j && ($max_i - $i) <= 1) { |
|
186 | 186 | if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') { |
187 | 187 | break; |
188 | 188 | } |
@@ -2126,11 +2126,11 @@ discard block |
||
2126 | 2126 | $html5 = 'html5' === $args['format']; |
2127 | 2127 | $fields = array( |
2128 | 2128 | 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2129 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
2129 | + '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
2130 | 2130 | 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2131 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
2131 | + '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
2132 | 2132 | 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
2133 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
2133 | + '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
2134 | 2134 | ); |
2135 | 2135 | |
2136 | 2136 | $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
@@ -2148,20 +2148,20 @@ discard block |
||
2148 | 2148 | 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
2149 | 2149 | /** This filter is documented in wp-includes/link-template.php */ |
2150 | 2150 | 'must_log_in' => '<p class="must-log-in">' . sprintf( |
2151 | - /* translators: %s: login URL */ |
|
2152 | - __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
2153 | - wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2154 | - ) . '</p>', |
|
2151 | + /* translators: %s: login URL */ |
|
2152 | + __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
2153 | + wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2154 | + ) . '</p>', |
|
2155 | 2155 | /** This filter is documented in wp-includes/link-template.php */ |
2156 | 2156 | 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
2157 | - /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
|
2158 | - __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
2159 | - get_edit_user_link(), |
|
2160 | - /* translators: %s: user name */ |
|
2161 | - esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
2162 | - $user_identity, |
|
2163 | - wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2164 | - ) . '</p>', |
|
2157 | + /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
|
2158 | + __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
2159 | + get_edit_user_link(), |
|
2160 | + /* translators: %s: user name */ |
|
2161 | + esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
2162 | + $user_identity, |
|
2163 | + wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2164 | + ) . '</p>', |
|
2165 | 2165 | 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
2166 | 2166 | 'comment_notes_after' => '', |
2167 | 2167 | 'id_form' => 'commentform', |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @since 1.5.0 |
18 | 18 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
19 | 19 | * |
20 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
|
20 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
|
21 | 21 | * Default current comment. |
22 | 22 | * @return string The comment author |
23 | 23 | */ |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @since 0.71 |
53 | 53 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
54 | 54 | * |
55 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
|
55 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
|
56 | 56 | * Default current comment. |
57 | 57 | */ |
58 | 58 | function comment_author( $comment_ID = 0 ) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @since 1.5.0 |
78 | 78 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
79 | 79 | * |
80 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. |
|
80 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. |
|
81 | 81 | * Default current comment. |
82 | 82 | * @return string The current comment author's email |
83 | 83 | */ |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @since 0.71 |
110 | 110 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
111 | 111 | * |
112 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
|
112 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
|
113 | 113 | * Default current comment. |
114 | 114 | */ |
115 | 115 | function comment_author_email( $comment_ID = 0 ) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @since 1.5.0 |
210 | 210 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
211 | 211 | * |
212 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
|
212 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
|
213 | 213 | * Default current comment. |
214 | 214 | * @return string The comment author name or HTML link for author's URL. |
215 | 215 | */ |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @since 0.71 |
244 | 244 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
245 | 245 | * |
246 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
|
246 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
|
247 | 247 | * Default current comment. |
248 | 248 | */ |
249 | 249 | function comment_author_link( $comment_ID = 0 ) { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @since 1.5.0 |
257 | 257 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
258 | 258 | * |
259 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
|
259 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
|
260 | 260 | * Default current comment. |
261 | 261 | * @return string Comment author's IP address. |
262 | 262 | */ |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @since 0.71 |
283 | 283 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
284 | 284 | * |
285 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
|
285 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
|
286 | 286 | * Default current comment. |
287 | 287 | */ |
288 | 288 | function comment_author_IP( $comment_ID = 0 ) { |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @since 1.5.0 |
296 | 296 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
297 | 297 | * |
298 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
|
298 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
|
299 | 299 | * Default current comment. |
300 | 300 | * @return string Comment author URL. |
301 | 301 | */ |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @since 0.71 |
329 | 329 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
330 | 330 | * |
331 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
|
331 | + * @param integer $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
|
332 | 332 | * Default current comment. |
333 | 333 | */ |
334 | 334 | function comment_author_url( $comment_ID = 0 ) { |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * Default empty. |
367 | 367 | * @param string $after Optional. The text or HTML to display after the email link. |
368 | 368 | * Default empty. |
369 | - * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
|
369 | + * @param integer $comment Optional. Comment ID or WP_Comment object. |
|
370 | 370 | * Default is the current comment. |
371 | 371 | * @return string The HTML link between the $before and $after parameters. |
372 | 372 | */ |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * Default empty. |
405 | 405 | * @param string $after Optional. Text or HTML to display after the email link. |
406 | 406 | * Default empty. |
407 | - * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
|
407 | + * @param integer $comment Optional. Comment ID or WP_Comment object. |
|
408 | 408 | * Default is the current comment. |
409 | 409 | */ |
410 | 410 | function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
533 | 533 | * |
534 | 534 | * @param string $d Optional. The format of the date. Default user's setting. |
535 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date. |
|
535 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the date. |
|
536 | 536 | * Default current comment. |
537 | 537 | * @return string The comment's date. |
538 | 538 | */ |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
562 | 562 | * |
563 | 563 | * @param string $d Optional. The format of the date. Default user's settings. |
564 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. |
|
564 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the date. |
|
565 | 565 | * Default current comment. |
566 | 566 | */ |
567 | 567 | function comment_date( $d = '', $comment_ID = 0 ) { |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @since 1.5.0 |
579 | 579 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
580 | 580 | * |
581 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
|
581 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
|
582 | 582 | * Default current comment. |
583 | 583 | * @return string The maybe truncated comment with 20 words or less. |
584 | 584 | */ |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * @since 1.2.0 |
625 | 625 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
626 | 626 | * |
627 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
|
627 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
|
628 | 628 | * Default current comment. |
629 | 629 | */ |
630 | 630 | function comment_excerpt( $comment_ID = 0 ) { |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @since 1.5.0 |
797 | 797 | * |
798 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
798 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
799 | 799 | * @return string The link to the comments. |
800 | 800 | */ |
801 | 801 | function get_comments_link( $post_id = 0 ) { |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | * |
835 | 835 | * @since 1.5.0 |
836 | 836 | * |
837 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
837 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
838 | 838 | * @return int The number of comments a post has. |
839 | 839 | */ |
840 | 840 | function get_comments_number( $post_id = 0 ) { |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @see Walker_Comment::comment() |
924 | 924 | * |
925 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the text. |
|
925 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to get the text. |
|
926 | 926 | * Default current comment. |
927 | 927 | * @param array $args Optional. An array of arguments. Default empty. |
928 | 928 | * @return string The comment content. |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * |
953 | 953 | * @see Walker_Comment::comment() |
954 | 954 | * |
955 | - * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text. |
|
955 | + * @param integer $comment_ID WP_Comment or ID of the comment for which to print the text. |
|
956 | 956 | * Default current comment. |
957 | 957 | * @param array $args Optional. An array of arguments. Default empty array. Default empty. |
958 | 958 | */ |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | * @since 1.5.0 |
1026 | 1026 | * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
1027 | 1027 | * |
1028 | - * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. |
|
1028 | + * @param integer $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. |
|
1029 | 1029 | * Default current comment. |
1030 | 1030 | * @return string The comment type. |
1031 | 1031 | */ |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * Default current comment. |
22 | 22 | * @return string The comment author |
23 | 23 | */ |
24 | -function get_comment_author( $comment_ID = 0 ) { |
|
25 | - $comment = get_comment( $comment_ID ); |
|
24 | +function get_comment_author($comment_ID = 0) { |
|
25 | + $comment = get_comment($comment_ID); |
|
26 | 26 | |
27 | - if ( empty( $comment->comment_author ) ) { |
|
28 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
27 | + if (empty($comment->comment_author)) { |
|
28 | + if ($comment->user_id && $user = get_userdata($comment->user_id)) |
|
29 | 29 | $author = $user->display_name; |
30 | 30 | else |
31 | 31 | $author = __('Anonymous'); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param int $comment_ID The comment ID. |
44 | 44 | * @param WP_Comment $comment The comment object. |
45 | 45 | */ |
46 | - return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment ); |
|
46 | + return apply_filters('get_comment_author', $author, $comment->comment_ID, $comment); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
56 | 56 | * Default current comment. |
57 | 57 | */ |
58 | -function comment_author( $comment_ID = 0 ) { |
|
59 | - $comment = get_comment( $comment_ID ); |
|
60 | - $author = get_comment_author( $comment ); |
|
58 | +function comment_author($comment_ID = 0) { |
|
59 | + $comment = get_comment($comment_ID); |
|
60 | + $author = get_comment_author($comment); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Filters the comment author's name for display. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $author The comment author's username. |
69 | 69 | * @param int $comment_ID The comment ID. |
70 | 70 | */ |
71 | - echo apply_filters( 'comment_author', $author, $comment->comment_ID ); |
|
71 | + echo apply_filters('comment_author', $author, $comment->comment_ID); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * Default current comment. |
82 | 82 | * @return string The current comment author's email |
83 | 83 | */ |
84 | -function get_comment_author_email( $comment_ID = 0 ) { |
|
85 | - $comment = get_comment( $comment_ID ); |
|
84 | +function get_comment_author_email($comment_ID = 0) { |
|
85 | + $comment = get_comment($comment_ID); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Filters the comment author's returned email address. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param int $comment_ID The comment ID. |
95 | 95 | * @param WP_Comment $comment The comment object. |
96 | 96 | */ |
97 | - return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); |
|
97 | + return apply_filters('get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
113 | 113 | * Default current comment. |
114 | 114 | */ |
115 | -function comment_author_email( $comment_ID = 0 ) { |
|
116 | - $comment = get_comment( $comment_ID ); |
|
117 | - $author_email = get_comment_author_email( $comment ); |
|
115 | +function comment_author_email($comment_ID = 0) { |
|
116 | + $comment = get_comment($comment_ID); |
|
117 | + $author_email = get_comment_author_email($comment); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Filters the comment author's email for display. |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string $author_email The comment author's email address. |
126 | 126 | * @param int $comment_ID The comment ID. |
127 | 127 | */ |
128 | - echo apply_filters( 'author_email', $author_email, $comment->comment_ID ); |
|
128 | + echo apply_filters('author_email', $author_email, $comment->comment_ID); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
147 | 147 | * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. |
148 | 148 | */ |
149 | -function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { |
|
150 | - if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) { |
|
149 | +function comment_author_email_link($linktext = '', $before = '', $after = '', $comment = null) { |
|
150 | + if ($link = get_comment_author_email_link($linktext, $before, $after, $comment)) { |
|
151 | 151 | echo $link; |
152 | 152 | } |
153 | 153 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return string HTML markup for the comment author email link. By default, the email address is obfuscated |
173 | 173 | * via the {@see 'comment_email'} filter with antispambot(). |
174 | 174 | */ |
175 | -function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { |
|
176 | - $comment = get_comment( $comment ); |
|
175 | +function get_comment_author_email_link($linktext = '', $before = '', $after = '', $comment = null) { |
|
176 | + $comment = get_comment($comment); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the comment author's email for display. |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | * @param string $comment_author_email The comment author's email address. |
188 | 188 | * @param WP_Comment $comment The comment object. |
189 | 189 | */ |
190 | - $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); |
|
190 | + $email = apply_filters('comment_email', $comment->comment_author_email, $comment); |
|
191 | 191 | |
192 | - if ((!empty($email)) && ($email != '@')) { |
|
192 | + if (( ! empty($email)) && ($email != '@')) { |
|
193 | 193 | $display = ($linktext != '') ? $linktext : $email; |
194 | 194 | $return = $before; |
195 | - $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); |
|
195 | + $return .= sprintf('<a href="%1$s">%2$s</a>', esc_url('mailto:'.$email), esc_html($display)); |
|
196 | 196 | $return .= $after; |
197 | 197 | return $return; |
198 | 198 | } else { |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | * Default current comment. |
214 | 214 | * @return string The comment author name or HTML link for author's URL. |
215 | 215 | */ |
216 | -function get_comment_author_link( $comment_ID = 0 ) { |
|
217 | - $comment = get_comment( $comment_ID ); |
|
218 | - $url = get_comment_author_url( $comment ); |
|
219 | - $author = get_comment_author( $comment ); |
|
216 | +function get_comment_author_link($comment_ID = 0) { |
|
217 | + $comment = get_comment($comment_ID); |
|
218 | + $url = get_comment_author_url($comment); |
|
219 | + $author = get_comment_author($comment); |
|
220 | 220 | |
221 | - if ( empty( $url ) || 'http://' == $url ) |
|
221 | + if (empty($url) || 'http://' == $url) |
|
222 | 222 | $return = $author; |
223 | 223 | else |
224 | 224 | $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param string $author The comment author's username. |
235 | 235 | * @param int $comment_ID The comment ID. |
236 | 236 | */ |
237 | - return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); |
|
237 | + return apply_filters('get_comment_author_link', $return, $author, $comment->comment_ID); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
247 | 247 | * Default current comment. |
248 | 248 | */ |
249 | -function comment_author_link( $comment_ID = 0 ) { |
|
250 | - echo get_comment_author_link( $comment_ID ); |
|
249 | +function comment_author_link($comment_ID = 0) { |
|
250 | + echo get_comment_author_link($comment_ID); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * Default current comment. |
261 | 261 | * @return string Comment author's IP address. |
262 | 262 | */ |
263 | -function get_comment_author_IP( $comment_ID = 0 ) { |
|
264 | - $comment = get_comment( $comment_ID ); |
|
263 | +function get_comment_author_IP($comment_ID = 0) { |
|
264 | + $comment = get_comment($comment_ID); |
|
265 | 265 | |
266 | 266 | /** |
267 | 267 | * Filters the comment author's returned IP address. |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @param int $comment_ID The comment ID. |
274 | 274 | * @param WP_Comment $comment The comment object. |
275 | 275 | */ |
276 | - return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); |
|
276 | + return apply_filters('get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
286 | 286 | * Default current comment. |
287 | 287 | */ |
288 | -function comment_author_IP( $comment_ID = 0 ) { |
|
289 | - echo esc_html( get_comment_author_IP( $comment_ID ) ); |
|
288 | +function comment_author_IP($comment_ID = 0) { |
|
289 | + echo esc_html(get_comment_author_IP($comment_ID)); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | * Default current comment. |
300 | 300 | * @return string Comment author URL. |
301 | 301 | */ |
302 | -function get_comment_author_url( $comment_ID = 0 ) { |
|
303 | - $comment = get_comment( $comment_ID ); |
|
302 | +function get_comment_author_url($comment_ID = 0) { |
|
303 | + $comment = get_comment($comment_ID); |
|
304 | 304 | $url = ''; |
305 | 305 | $id = 0; |
306 | - if ( ! empty( $comment ) ) { |
|
307 | - $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; |
|
308 | - $url = esc_url( $author_url, array( 'http', 'https' ) ); |
|
306 | + if ( ! empty($comment)) { |
|
307 | + $author_url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; |
|
308 | + $url = esc_url($author_url, array('http', 'https')); |
|
309 | 309 | $id = $comment->ID; |
310 | 310 | } |
311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param int $comment_ID The comment ID. |
320 | 320 | * @param WP_Comment $comment The comment object. |
321 | 321 | */ |
322 | - return apply_filters( 'get_comment_author_url', $url, $id, $comment ); |
|
322 | + return apply_filters('get_comment_author_url', $url, $id, $comment); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
332 | 332 | * Default current comment. |
333 | 333 | */ |
334 | -function comment_author_url( $comment_ID = 0 ) { |
|
335 | - $comment = get_comment( $comment_ID ); |
|
336 | - $author_url = get_comment_author_url( $comment ); |
|
334 | +function comment_author_url($comment_ID = 0) { |
|
335 | + $comment = get_comment($comment_ID); |
|
336 | + $author_url = get_comment_author_url($comment); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Filters the comment author's URL for display. |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param string $author_url The comment author's URL. |
345 | 345 | * @param int $comment_ID The comment ID. |
346 | 346 | */ |
347 | - echo apply_filters( 'comment_url', $author_url, $comment->comment_ID ); |
|
347 | + echo apply_filters('comment_url', $author_url, $comment->comment_ID); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * Default is the current comment. |
371 | 371 | * @return string The HTML link between the $before and $after parameters. |
372 | 372 | */ |
373 | -function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
|
374 | - $url = get_comment_author_url( $comment ); |
|
373 | +function get_comment_author_url_link($linktext = '', $before = '', $after = '', $comment = 0) { |
|
374 | + $url = get_comment_author_url($comment); |
|
375 | 375 | $display = ($linktext != '') ? $linktext : $url; |
376 | - $display = str_replace( 'http://www.', '', $display ); |
|
377 | - $display = str_replace( 'http://', '', $display ); |
|
376 | + $display = str_replace('http://www.', '', $display); |
|
377 | + $display = str_replace('http://', '', $display); |
|
378 | 378 | |
379 | - if ( '/' == substr($display, -1) ) { |
|
379 | + if ('/' == substr($display, -1)) { |
|
380 | 380 | $display = substr($display, 0, -1); |
381 | 381 | } |
382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @param string $return The HTML-formatted comment author URL link. |
391 | 391 | */ |
392 | - return apply_filters( 'get_comment_author_url_link', $return ); |
|
392 | + return apply_filters('get_comment_author_url_link', $return); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
408 | 408 | * Default is the current comment. |
409 | 409 | */ |
410 | -function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
|
411 | - echo get_comment_author_url_link( $linktext, $before, $after, $comment ); |
|
410 | +function comment_author_url_link($linktext = '', $before = '', $after = '', $comment = 0) { |
|
411 | + echo get_comment_author_url_link($linktext, $before, $after, $comment); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | * Default true. |
426 | 426 | * @return string If `$echo` is false, the class will be returned. Void otherwise. |
427 | 427 | */ |
428 | -function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
|
428 | +function comment_class($class = '', $comment = null, $post_id = null, $echo = true) { |
|
429 | 429 | // Separates classes with a single space, collates classes for comment DIV |
430 | - $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
|
431 | - if ( $echo) |
|
430 | + $class = 'class="'.join(' ', get_comment_class($class, $comment, $post_id)).'"'; |
|
431 | + if ($echo) |
|
432 | 432 | echo $class; |
433 | 433 | else |
434 | 434 | return $class; |
@@ -449,39 +449,39 @@ discard block |
||
449 | 449 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
450 | 450 | * @return array An array of classes. |
451 | 451 | */ |
452 | -function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
|
452 | +function get_comment_class($class = '', $comment_id = null, $post_id = null) { |
|
453 | 453 | global $comment_alt, $comment_depth, $comment_thread_alt; |
454 | 454 | |
455 | 455 | $classes = array(); |
456 | 456 | |
457 | - $comment = get_comment( $comment_id ); |
|
458 | - if ( ! $comment ) { |
|
457 | + $comment = get_comment($comment_id); |
|
458 | + if ( ! $comment) { |
|
459 | 459 | return $classes; |
460 | 460 | } |
461 | 461 | |
462 | 462 | // Get the comment type (comment, trackback), |
463 | - $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; |
|
463 | + $classes[] = (empty($comment->comment_type)) ? 'comment' : $comment->comment_type; |
|
464 | 464 | |
465 | 465 | // Add classes for comment authors that are registered users. |
466 | - if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
|
466 | + if ($comment->user_id > 0 && $user = get_userdata($comment->user_id)) { |
|
467 | 467 | $classes[] = 'byuser'; |
468 | - $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
|
468 | + $classes[] = 'comment-author-'.sanitize_html_class($user->user_nicename, $comment->user_id); |
|
469 | 469 | // For comment authors who are the author of the post |
470 | - if ( $post = get_post($post_id) ) { |
|
471 | - if ( $comment->user_id === $post->post_author ) { |
|
470 | + if ($post = get_post($post_id)) { |
|
471 | + if ($comment->user_id === $post->post_author) { |
|
472 | 472 | $classes[] = 'bypostauthor'; |
473 | 473 | } |
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | - if ( empty($comment_alt) ) |
|
477 | + if (empty($comment_alt)) |
|
478 | 478 | $comment_alt = 0; |
479 | - if ( empty($comment_depth) ) |
|
479 | + if (empty($comment_depth)) |
|
480 | 480 | $comment_depth = 1; |
481 | - if ( empty($comment_thread_alt) ) |
|
481 | + if (empty($comment_thread_alt)) |
|
482 | 482 | $comment_thread_alt = 0; |
483 | 483 | |
484 | - if ( $comment_alt % 2 ) { |
|
484 | + if ($comment_alt % 2) { |
|
485 | 485 | $classes[] = 'odd'; |
486 | 486 | $classes[] = 'alt'; |
487 | 487 | } else { |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | $comment_alt++; |
492 | 492 | |
493 | 493 | // Alt for top-level comments |
494 | - if ( 1 == $comment_depth ) { |
|
495 | - if ( $comment_thread_alt % 2 ) { |
|
494 | + if (1 == $comment_depth) { |
|
495 | + if ($comment_thread_alt % 2) { |
|
496 | 496 | $classes[] = 'thread-odd'; |
497 | 497 | $classes[] = 'thread-alt'; |
498 | 498 | } else { |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | |
504 | 504 | $classes[] = "depth-$comment_depth"; |
505 | 505 | |
506 | - if ( !empty($class) ) { |
|
507 | - if ( !is_array( $class ) ) |
|
506 | + if ( ! empty($class)) { |
|
507 | + if ( ! is_array($class)) |
|
508 | 508 | $class = preg_split('#\s+#', $class); |
509 | 509 | $classes = array_merge($classes, $class); |
510 | 510 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | * @param WP_Comment $comment The comment object. |
523 | 523 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
524 | 524 | */ |
525 | - return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id ); |
|
525 | + return apply_filters('comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | * Default current comment. |
537 | 537 | * @return string The comment's date. |
538 | 538 | */ |
539 | -function get_comment_date( $d = '', $comment_ID = 0 ) { |
|
540 | - $comment = get_comment( $comment_ID ); |
|
541 | - if ( '' == $d ) |
|
539 | +function get_comment_date($d = '', $comment_ID = 0) { |
|
540 | + $comment = get_comment($comment_ID); |
|
541 | + if ('' == $d) |
|
542 | 542 | $date = mysql2date(get_option('date_format'), $comment->comment_date); |
543 | 543 | else |
544 | 544 | $date = mysql2date($d, $comment->comment_date); |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @param string $d The format of the date. |
552 | 552 | * @param WP_Comment $comment The comment object. |
553 | 553 | */ |
554 | - return apply_filters( 'get_comment_date', $date, $d, $comment ); |
|
554 | + return apply_filters('get_comment_date', $date, $d, $comment); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. |
565 | 565 | * Default current comment. |
566 | 566 | */ |
567 | -function comment_date( $d = '', $comment_ID = 0 ) { |
|
568 | - echo get_comment_date( $d, $comment_ID ); |
|
567 | +function comment_date($d = '', $comment_ID = 0) { |
|
568 | + echo get_comment_date($d, $comment_ID); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -582,10 +582,10 @@ discard block |
||
582 | 582 | * Default current comment. |
583 | 583 | * @return string The maybe truncated comment with 20 words or less. |
584 | 584 | */ |
585 | -function get_comment_excerpt( $comment_ID = 0 ) { |
|
586 | - $comment = get_comment( $comment_ID ); |
|
587 | - $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); |
|
588 | - $words = explode( ' ', $comment_text ); |
|
585 | +function get_comment_excerpt($comment_ID = 0) { |
|
586 | + $comment = get_comment($comment_ID); |
|
587 | + $comment_text = strip_tags(str_replace(array("\n", "\r"), ' ', $comment->comment_content)); |
|
588 | + $words = explode(' ', $comment_text); |
|
589 | 589 | |
590 | 590 | /** |
591 | 591 | * Filters the amount of words used in the comment excerpt. |
@@ -594,15 +594,15 @@ discard block |
||
594 | 594 | * |
595 | 595 | * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt. |
596 | 596 | */ |
597 | - $comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 ); |
|
597 | + $comment_excerpt_length = apply_filters('comment_excerpt_length', 20); |
|
598 | 598 | |
599 | - $use_ellipsis = count( $words ) > $comment_excerpt_length; |
|
600 | - if ( $use_ellipsis ) { |
|
601 | - $words = array_slice( $words, 0, $comment_excerpt_length ); |
|
599 | + $use_ellipsis = count($words) > $comment_excerpt_length; |
|
600 | + if ($use_ellipsis) { |
|
601 | + $words = array_slice($words, 0, $comment_excerpt_length); |
|
602 | 602 | } |
603 | 603 | |
604 | - $excerpt = trim( join( ' ', $words ) ); |
|
605 | - if ( $use_ellipsis ) { |
|
604 | + $excerpt = trim(join(' ', $words)); |
|
605 | + if ($use_ellipsis) { |
|
606 | 606 | $excerpt .= '…'; |
607 | 607 | } |
608 | 608 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @param int $comment_ID The comment ID. |
616 | 616 | * @param WP_Comment $comment The comment object. |
617 | 617 | */ |
618 | - return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); |
|
618 | + return apply_filters('get_comment_excerpt', $excerpt, $comment->comment_ID, $comment); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -627,9 +627,9 @@ discard block |
||
627 | 627 | * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
628 | 628 | * Default current comment. |
629 | 629 | */ |
630 | -function comment_excerpt( $comment_ID = 0 ) { |
|
631 | - $comment = get_comment( $comment_ID ); |
|
632 | - $comment_excerpt = get_comment_excerpt( $comment ); |
|
630 | +function comment_excerpt($comment_ID = 0) { |
|
631 | + $comment = get_comment($comment_ID); |
|
632 | + $comment_excerpt = get_comment_excerpt($comment); |
|
633 | 633 | |
634 | 634 | /** |
635 | 635 | * Filters the comment excerpt for display. |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * @param string $comment_excerpt The comment excerpt text. |
641 | 641 | * @param int $comment_ID The comment ID. |
642 | 642 | */ |
643 | - echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); |
|
643 | + echo apply_filters('comment_excerpt', $comment_excerpt, $comment->comment_ID); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param int $comment_ID The current comment ID. |
663 | 663 | * @param WP_Comment $comment The comment object. |
664 | 664 | */ |
665 | - return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); |
|
665 | + return apply_filters('get_comment_ID', $comment->comment_ID, $comment); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | * } |
700 | 700 | * @return string The permalink to the given comment. |
701 | 701 | */ |
702 | -function get_comment_link( $comment = null, $args = array() ) { |
|
702 | +function get_comment_link($comment = null, $args = array()) { |
|
703 | 703 | global $wp_rewrite, $in_comment_loop; |
704 | 704 | |
705 | 705 | $comment = get_comment($comment); |
706 | 706 | |
707 | 707 | // Back-compat. |
708 | - if ( ! is_array( $args ) ) { |
|
709 | - $args = array( 'page' => $args ); |
|
708 | + if ( ! is_array($args)) { |
|
709 | + $args = array('page' => $args); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | $defaults = array( |
@@ -716,33 +716,33 @@ discard block |
||
716 | 716 | 'max_depth' => '', |
717 | 717 | 'cpage' => null, |
718 | 718 | ); |
719 | - $args = wp_parse_args( $args, $defaults ); |
|
719 | + $args = wp_parse_args($args, $defaults); |
|
720 | 720 | |
721 | - $link = get_permalink( $comment->comment_post_ID ); |
|
721 | + $link = get_permalink($comment->comment_post_ID); |
|
722 | 722 | |
723 | 723 | // The 'cpage' param takes precedence. |
724 | - if ( ! is_null( $args['cpage'] ) ) { |
|
724 | + if ( ! is_null($args['cpage'])) { |
|
725 | 725 | $cpage = $args['cpage']; |
726 | 726 | |
727 | 727 | // No 'cpage' is provided, so we calculate one. |
728 | 728 | } else { |
729 | - if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { |
|
729 | + if ('' === $args['per_page'] && get_option('page_comments')) { |
|
730 | 730 | $args['per_page'] = get_option('comments_per_page'); |
731 | 731 | } |
732 | 732 | |
733 | - if ( empty( $args['per_page'] ) ) { |
|
733 | + if (empty($args['per_page'])) { |
|
734 | 734 | $args['per_page'] = 0; |
735 | 735 | $args['page'] = 0; |
736 | 736 | } |
737 | 737 | |
738 | 738 | $cpage = $args['page']; |
739 | 739 | |
740 | - if ( '' == $cpage ) { |
|
741 | - if ( ! empty( $in_comment_loop ) ) { |
|
742 | - $cpage = get_query_var( 'cpage' ); |
|
740 | + if ('' == $cpage) { |
|
741 | + if ( ! empty($in_comment_loop)) { |
|
742 | + $cpage = get_query_var('cpage'); |
|
743 | 743 | } else { |
744 | 744 | // Requires a database hit, so we only do it when we can't figure out from context. |
745 | - $cpage = get_page_of_comment( $comment->comment_ID, $args ); |
|
745 | + $cpage = get_page_of_comment($comment->comment_ID, $args); |
|
746 | 746 | } |
747 | 747 | } |
748 | 748 | |
@@ -750,29 +750,29 @@ discard block |
||
750 | 750 | * If the default page displays the oldest comments, the permalinks for comments on the default page |
751 | 751 | * do not need a 'cpage' query var. |
752 | 752 | */ |
753 | - if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) { |
|
753 | + if ('oldest' === get_option('default_comments_page') && 1 === $cpage) { |
|
754 | 754 | $cpage = ''; |
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | - if ( $cpage && get_option( 'page_comments' ) ) { |
|
759 | - if ( $wp_rewrite->using_permalinks() ) { |
|
760 | - if ( $cpage ) { |
|
761 | - $link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage; |
|
758 | + if ($cpage && get_option('page_comments')) { |
|
759 | + if ($wp_rewrite->using_permalinks()) { |
|
760 | + if ($cpage) { |
|
761 | + $link = trailingslashit($link).$wp_rewrite->comments_pagination_base.'-'.$cpage; |
|
762 | 762 | } |
763 | 763 | |
764 | - $link = user_trailingslashit( $link, 'comment' ); |
|
765 | - } elseif ( $cpage ) { |
|
766 | - $link = add_query_arg( 'cpage', $cpage, $link ); |
|
764 | + $link = user_trailingslashit($link, 'comment'); |
|
765 | + } elseif ($cpage) { |
|
766 | + $link = add_query_arg('cpage', $cpage, $link); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | - if ( $wp_rewrite->using_permalinks() ) { |
|
772 | - $link = user_trailingslashit( $link, 'comment' ); |
|
771 | + if ($wp_rewrite->using_permalinks()) { |
|
772 | + $link = user_trailingslashit($link, 'comment'); |
|
773 | 773 | } |
774 | 774 | |
775 | - $link = $link . '#comment-' . $comment->comment_ID; |
|
775 | + $link = $link.'#comment-'.$comment->comment_ID; |
|
776 | 776 | |
777 | 777 | /** |
778 | 778 | * Filters the returned single comment permalink. |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | * @param array $args An array of arguments to override the defaults. |
788 | 788 | * @param int $cpage The calculated 'cpage' value. |
789 | 789 | */ |
790 | - return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage ); |
|
790 | + return apply_filters('get_comment_link', $link, $comment, $args, $cpage); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -798,9 +798,9 @@ discard block |
||
798 | 798 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
799 | 799 | * @return string The link to the comments. |
800 | 800 | */ |
801 | -function get_comments_link( $post_id = 0 ) { |
|
802 | - $hash = get_comments_number( $post_id ) ? '#comments' : '#respond'; |
|
803 | - $comments_link = get_permalink( $post_id ) . $hash; |
|
801 | +function get_comments_link($post_id = 0) { |
|
802 | + $hash = get_comments_number($post_id) ? '#comments' : '#respond'; |
|
803 | + $comments_link = get_permalink($post_id).$hash; |
|
804 | 804 | |
805 | 805 | /** |
806 | 806 | * Filters the returned post comments permalink. |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @param string $comments_link Post comments permalink with '#comments' appended. |
811 | 811 | * @param int|WP_Post $post_id Post ID or WP_Post object. |
812 | 812 | */ |
813 | - return apply_filters( 'get_comments_link', $comments_link, $post_id ); |
|
813 | + return apply_filters('get_comments_link', $comments_link, $post_id); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -821,12 +821,12 @@ discard block |
||
821 | 821 | * @param string $deprecated Not Used. |
822 | 822 | * @param string $deprecated_2 Not Used. |
823 | 823 | */ |
824 | -function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
|
825 | - if ( !empty( $deprecated ) ) |
|
826 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
827 | - if ( !empty( $deprecated_2 ) ) |
|
828 | - _deprecated_argument( __FUNCTION__, '1.3.0' ); |
|
829 | - echo esc_url( get_comments_link() ); |
|
824 | +function comments_link($deprecated = '', $deprecated_2 = '') { |
|
825 | + if ( ! empty($deprecated)) |
|
826 | + _deprecated_argument(__FUNCTION__, '0.72'); |
|
827 | + if ( ! empty($deprecated_2)) |
|
828 | + _deprecated_argument(__FUNCTION__, '1.3.0'); |
|
829 | + echo esc_url(get_comments_link()); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
838 | 838 | * @return int The number of comments a post has. |
839 | 839 | */ |
840 | -function get_comments_number( $post_id = 0 ) { |
|
841 | - $post = get_post( $post_id ); |
|
840 | +function get_comments_number($post_id = 0) { |
|
841 | + $post = get_post($post_id); |
|
842 | 842 | |
843 | - if ( ! $post ) { |
|
843 | + if ( ! $post) { |
|
844 | 844 | $count = 0; |
845 | 845 | } else { |
846 | 846 | $count = $post->comment_count; |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | * @param int $count Number of comments a post has. |
856 | 856 | * @param int $post_id Post ID. |
857 | 857 | */ |
858 | - return apply_filters( 'get_comments_number', $count, $post_id ); |
|
858 | + return apply_filters('get_comments_number', $count, $post_id); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -868,11 +868,11 @@ discard block |
||
868 | 868 | * @param string $more Optional. Text for more than one comment. Default false. |
869 | 869 | * @param string $deprecated Not used. |
870 | 870 | */ |
871 | -function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { |
|
872 | - if ( ! empty( $deprecated ) ) { |
|
873 | - _deprecated_argument( __FUNCTION__, '1.3.0' ); |
|
871 | +function comments_number($zero = false, $one = false, $more = false, $deprecated = '') { |
|
872 | + if ( ! empty($deprecated)) { |
|
873 | + _deprecated_argument(__FUNCTION__, '1.3.0'); |
|
874 | 874 | } |
875 | - echo get_comments_number_text( $zero, $one, $more ); |
|
875 | + echo get_comments_number_text($zero, $one, $more); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -884,42 +884,42 @@ discard block |
||
884 | 884 | * @param string $one Optional. Text for one comment. Default false. |
885 | 885 | * @param string $more Optional. Text for more than one comment. Default false. |
886 | 886 | */ |
887 | -function get_comments_number_text( $zero = false, $one = false, $more = false ) { |
|
887 | +function get_comments_number_text($zero = false, $one = false, $more = false) { |
|
888 | 888 | $number = get_comments_number(); |
889 | 889 | |
890 | - if ( $number > 1 ) { |
|
891 | - if ( false === $more ) { |
|
890 | + if ($number > 1) { |
|
891 | + if (false === $more) { |
|
892 | 892 | /* translators: %s: number of comments */ |
893 | - $output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) ); |
|
893 | + $output = sprintf(_n('%s Comment', '%s Comments', $number), number_format_i18n($number)); |
|
894 | 894 | } else { |
895 | 895 | // % Comments |
896 | 896 | /* translators: If comment number in your language requires declension, |
897 | 897 | * translate this to 'on'. Do not translate into your own language. |
898 | 898 | */ |
899 | - if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) { |
|
900 | - $text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more ); |
|
901 | - $text = preg_replace( '/&.+?;/', '', $text ); // Kill entities |
|
902 | - $text = trim( strip_tags( $text ), '% ' ); |
|
899 | + if ('on' === _x('off', 'Comment number declension: on or off')) { |
|
900 | + $text = preg_replace('#<span class="screen-reader-text">.+?</span>#', '', $more); |
|
901 | + $text = preg_replace('/&.+?;/', '', $text); // Kill entities |
|
902 | + $text = trim(strip_tags($text), '% '); |
|
903 | 903 | |
904 | 904 | // Replace '% Comments' with a proper plural form |
905 | - if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { |
|
905 | + if ($text && ! preg_match('/[0-9]+/', $text) && false !== strpos($more, '%')) { |
|
906 | 906 | /* translators: %s: number of comments */ |
907 | - $new_text = _n( '%s Comment', '%s Comments', $number ); |
|
908 | - $new_text = trim( sprintf( $new_text, '' ) ); |
|
907 | + $new_text = _n('%s Comment', '%s Comments', $number); |
|
908 | + $new_text = trim(sprintf($new_text, '')); |
|
909 | 909 | |
910 | - $more = str_replace( $text, $new_text, $more ); |
|
911 | - if ( false === strpos( $more, '%' ) ) { |
|
912 | - $more = '% ' . $more; |
|
910 | + $more = str_replace($text, $new_text, $more); |
|
911 | + if (false === strpos($more, '%')) { |
|
912 | + $more = '% '.$more; |
|
913 | 913 | } |
914 | 914 | } |
915 | 915 | } |
916 | 916 | |
917 | - $output = str_replace( '%', number_format_i18n( $number ), $more ); |
|
917 | + $output = str_replace('%', number_format_i18n($number), $more); |
|
918 | 918 | } |
919 | - } elseif ( $number == 0 ) { |
|
920 | - $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; |
|
919 | + } elseif ($number == 0) { |
|
920 | + $output = (false === $zero) ? __('No Comments') : $zero; |
|
921 | 921 | } else { // must be one |
922 | - $output = ( false === $one ) ? __( '1 Comment' ) : $one; |
|
922 | + $output = (false === $one) ? __('1 Comment') : $one; |
|
923 | 923 | } |
924 | 924 | /** |
925 | 925 | * Filters the comments count for display. |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * is equal to 0, 1, or 1+. |
933 | 933 | * @param int $number The number of post comments. |
934 | 934 | */ |
935 | - return apply_filters( 'comments_number', $output, $number ); |
|
935 | + return apply_filters('comments_number', $output, $number); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | * @param array $args Optional. An array of arguments. Default empty. |
949 | 949 | * @return string The comment content. |
950 | 950 | */ |
951 | -function get_comment_text( $comment_ID = 0, $args = array() ) { |
|
952 | - $comment = get_comment( $comment_ID ); |
|
951 | +function get_comment_text($comment_ID = 0, $args = array()) { |
|
952 | + $comment = get_comment($comment_ID); |
|
953 | 953 | |
954 | 954 | /** |
955 | 955 | * Filters the text of a comment. |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * @param WP_Comment $comment The comment object. |
963 | 963 | * @param array $args An array of arguments. |
964 | 964 | */ |
965 | - return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); |
|
965 | + return apply_filters('get_comment_text', $comment->comment_content, $comment, $args); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -977,10 +977,10 @@ discard block |
||
977 | 977 | * Default current comment. |
978 | 978 | * @param array $args Optional. An array of arguments. Default empty array. Default empty. |
979 | 979 | */ |
980 | -function comment_text( $comment_ID = 0, $args = array() ) { |
|
981 | - $comment = get_comment( $comment_ID ); |
|
980 | +function comment_text($comment_ID = 0, $args = array()) { |
|
981 | + $comment = get_comment($comment_ID); |
|
982 | 982 | |
983 | - $comment_text = get_comment_text( $comment, $args ); |
|
983 | + $comment_text = get_comment_text($comment, $args); |
|
984 | 984 | /** |
985 | 985 | * Filters the text of a comment to be displayed. |
986 | 986 | * |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | * @param WP_Comment $comment The comment object. |
993 | 993 | * @param array $args An array of arguments. |
994 | 994 | */ |
995 | - echo apply_filters( 'comment_text', $comment_text, $comment, $args ); |
|
995 | + echo apply_filters('comment_text', $comment_text, $comment, $args); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | /** |
@@ -1006,11 +1006,11 @@ discard block |
||
1006 | 1006 | * Default true. |
1007 | 1007 | * @return string The formatted time. |
1008 | 1008 | */ |
1009 | -function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
|
1009 | +function get_comment_time($d = '', $gmt = false, $translate = true) { |
|
1010 | 1010 | $comment = get_comment(); |
1011 | 1011 | |
1012 | 1012 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
1013 | - if ( '' == $d ) |
|
1013 | + if ('' == $d) |
|
1014 | 1014 | $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
1015 | 1015 | else |
1016 | 1016 | $date = mysql2date($d, $comment_date, $translate); |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | * @param bool $translate Whether the time is translated. |
1027 | 1027 | * @param WP_Comment $comment The comment object. |
1028 | 1028 | */ |
1029 | - return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment ); |
|
1029 | + return apply_filters('get_comment_time', $date, $d, $gmt, $translate, $comment); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | * |
1037 | 1037 | * @param string $d Optional. The format of the time. Default user's settings. |
1038 | 1038 | */ |
1039 | -function comment_time( $d = '' ) { |
|
1039 | +function comment_time($d = '') { |
|
1040 | 1040 | echo get_comment_time($d); |
1041 | 1041 | } |
1042 | 1042 | |
@@ -1050,9 +1050,9 @@ discard block |
||
1050 | 1050 | * Default current comment. |
1051 | 1051 | * @return string The comment type. |
1052 | 1052 | */ |
1053 | -function get_comment_type( $comment_ID = 0 ) { |
|
1054 | - $comment = get_comment( $comment_ID ); |
|
1055 | - if ( '' == $comment->comment_type ) |
|
1053 | +function get_comment_type($comment_ID = 0) { |
|
1054 | + $comment = get_comment($comment_ID); |
|
1055 | + if ('' == $comment->comment_type) |
|
1056 | 1056 | $comment->comment_type = 'comment'; |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * @param int $comment_ID The comment ID. |
1066 | 1066 | * @param WP_Comment $comment The comment object. |
1067 | 1067 | */ |
1068 | - return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
|
1068 | + return apply_filters('get_comment_type', $comment->comment_type, $comment->comment_ID, $comment); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | /** |
@@ -1077,12 +1077,12 @@ discard block |
||
1077 | 1077 | * @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
1078 | 1078 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
1079 | 1079 | */ |
1080 | -function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
|
1081 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
1082 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
1083 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
1080 | +function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { |
|
1081 | + if (false === $commenttxt) $commenttxt = _x('Comment', 'noun'); |
|
1082 | + if (false === $trackbacktxt) $trackbacktxt = __('Trackback'); |
|
1083 | + if (false === $pingbacktxt) $pingbacktxt = __('Pingback'); |
|
1084 | 1084 | $type = get_comment_type(); |
1085 | - switch( $type ) { |
|
1085 | + switch ($type) { |
|
1086 | 1086 | case 'trackback' : |
1087 | 1087 | echo $trackbacktxt; |
1088 | 1088 | break; |
@@ -1106,10 +1106,10 @@ discard block |
||
1106 | 1106 | * @return string The trackback URL after being filtered. |
1107 | 1107 | */ |
1108 | 1108 | function get_trackback_url() { |
1109 | - if ( '' != get_option('permalink_structure') ) |
|
1110 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
1109 | + if ('' != get_option('permalink_structure')) |
|
1110 | + $tb_url = trailingslashit(get_permalink()).user_trailingslashit('trackback', 'single_trackback'); |
|
1111 | 1111 | else |
1112 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
1112 | + $tb_url = get_option('siteurl').'/wp-trackback.php?p='.get_the_ID(); |
|
1113 | 1113 | |
1114 | 1114 | /** |
1115 | 1115 | * Filters the returned trackback URL. |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @param string $tb_url The trackback URL. |
1120 | 1120 | */ |
1121 | - return apply_filters( 'trackback_url', $tb_url ); |
|
1121 | + return apply_filters('trackback_url', $tb_url); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | /** |
@@ -1130,17 +1130,17 @@ discard block |
||
1130 | 1130 | * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
1131 | 1131 | * for the result instead. |
1132 | 1132 | */ |
1133 | -function trackback_url( $deprecated_echo = true ) { |
|
1134 | - if ( true !== $deprecated_echo ) { |
|
1135 | - _deprecated_argument( __FUNCTION__, '2.5.0', |
|
1133 | +function trackback_url($deprecated_echo = true) { |
|
1134 | + if (true !== $deprecated_echo) { |
|
1135 | + _deprecated_argument(__FUNCTION__, '2.5.0', |
|
1136 | 1136 | /* translators: %s: get_trackback_url() */ |
1137 | - sprintf( __( 'Use %s instead if you do not want the value echoed.' ), |
|
1137 | + sprintf(__('Use %s instead if you do not want the value echoed.'), |
|
1138 | 1138 | '<code>get_trackback_url()</code>' |
1139 | 1139 | ) |
1140 | 1140 | ); |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - if ( $deprecated_echo ) { |
|
1143 | + if ($deprecated_echo) { |
|
1144 | 1144 | echo get_trackback_url(); |
1145 | 1145 | } else { |
1146 | 1146 | return get_trackback_url(); |
@@ -1156,12 +1156,12 @@ discard block |
||
1156 | 1156 | * |
1157 | 1157 | * @param int $deprecated Not used (Was $timezone = 0). |
1158 | 1158 | */ |
1159 | -function trackback_rdf( $deprecated = '' ) { |
|
1160 | - if ( ! empty( $deprecated ) ) { |
|
1161 | - _deprecated_argument( __FUNCTION__, '2.5.0' ); |
|
1159 | +function trackback_rdf($deprecated = '') { |
|
1160 | + if ( ! empty($deprecated)) { |
|
1161 | + _deprecated_argument(__FUNCTION__, '2.5.0'); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) { |
|
1164 | + if (isset($_SERVER['HTTP_USER_AGENT']) && false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { |
|
1165 | 1165 | return; |
1166 | 1166 | } |
1167 | 1167 | |
@@ -1187,11 +1187,11 @@ discard block |
||
1187 | 1187 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1188 | 1188 | * @return bool True if the comments are open. |
1189 | 1189 | */ |
1190 | -function comments_open( $post_id = null ) { |
|
1190 | +function comments_open($post_id = null) { |
|
1191 | 1191 | |
1192 | 1192 | $_post = get_post($post_id); |
1193 | 1193 | |
1194 | - $open = ( 'open' == $_post->comment_status ); |
|
1194 | + $open = ('open' == $_post->comment_status); |
|
1195 | 1195 | |
1196 | 1196 | /** |
1197 | 1197 | * Filters whether the current post is open for comments. |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @param bool $open Whether the current post is open for comments. |
1202 | 1202 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
1203 | 1203 | */ |
1204 | - return apply_filters( 'comments_open', $open, $post_id ); |
|
1204 | + return apply_filters('comments_open', $open, $post_id); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | /** |
@@ -1212,11 +1212,11 @@ discard block |
||
1212 | 1212 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1213 | 1213 | * @return bool True if pings are accepted |
1214 | 1214 | */ |
1215 | -function pings_open( $post_id = null ) { |
|
1215 | +function pings_open($post_id = null) { |
|
1216 | 1216 | |
1217 | 1217 | $_post = get_post($post_id); |
1218 | 1218 | |
1219 | - $open = ( 'open' == $_post->ping_status ); |
|
1219 | + $open = ('open' == $_post->ping_status); |
|
1220 | 1220 | |
1221 | 1221 | /** |
1222 | 1222 | * Filters whether the current post is open for pings. |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | * @param bool $open Whether the current post is open for pings. |
1227 | 1227 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
1228 | 1228 | */ |
1229 | - return apply_filters( 'pings_open', $open, $post_id ); |
|
1229 | + return apply_filters('pings_open', $open, $post_id); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1247,8 +1247,8 @@ discard block |
||
1247 | 1247 | $post = get_post(); |
1248 | 1248 | $post_id = $post ? $post->ID : 0; |
1249 | 1249 | |
1250 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
1251 | - wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
|
1250 | + if (current_user_can('unfiltered_html')) { |
|
1251 | + wp_nonce_field('unfiltered-html-comment_'.$post_id, '_wp_unfiltered_html_comment_disabled', false); |
|
1252 | 1252 | echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
1253 | 1253 | } |
1254 | 1254 | } |
@@ -1288,13 +1288,13 @@ discard block |
||
1288 | 1288 | * @param bool $separate_comments Optional. Whether to separate the comments by comment type. |
1289 | 1289 | * Default false. |
1290 | 1290 | */ |
1291 | -function comments_template( $file = '/comments.php', $separate_comments = false ) { |
|
1291 | +function comments_template($file = '/comments.php', $separate_comments = false) { |
|
1292 | 1292 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
1293 | 1293 | |
1294 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
1294 | + if ( ! (is_single() || is_page() || $withcomments) || empty($post)) |
|
1295 | 1295 | return; |
1296 | 1296 | |
1297 | - if ( empty($file) ) |
|
1297 | + if (empty($file)) |
|
1298 | 1298 | $file = '/comments.php'; |
1299 | 1299 | |
1300 | 1300 | $req = get_option('require_name_email'); |
@@ -1330,31 +1330,31 @@ discard block |
||
1330 | 1330 | 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. |
1331 | 1331 | ); |
1332 | 1332 | |
1333 | - if ( get_option('thread_comments') ) { |
|
1333 | + if (get_option('thread_comments')) { |
|
1334 | 1334 | $comment_args['hierarchical'] = 'threaded'; |
1335 | 1335 | } else { |
1336 | 1336 | $comment_args['hierarchical'] = false; |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - if ( $user_ID ) { |
|
1340 | - $comment_args['include_unapproved'] = array( $user_ID ); |
|
1341 | - } elseif ( ! empty( $comment_author_email ) ) { |
|
1342 | - $comment_args['include_unapproved'] = array( $comment_author_email ); |
|
1339 | + if ($user_ID) { |
|
1340 | + $comment_args['include_unapproved'] = array($user_ID); |
|
1341 | + } elseif ( ! empty($comment_author_email)) { |
|
1342 | + $comment_args['include_unapproved'] = array($comment_author_email); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | $per_page = 0; |
1346 | - if ( get_option( 'page_comments' ) ) { |
|
1347 | - $per_page = (int) get_query_var( 'comments_per_page' ); |
|
1348 | - if ( 0 === $per_page ) { |
|
1349 | - $per_page = (int) get_option( 'comments_per_page' ); |
|
1346 | + if (get_option('page_comments')) { |
|
1347 | + $per_page = (int) get_query_var('comments_per_page'); |
|
1348 | + if (0 === $per_page) { |
|
1349 | + $per_page = (int) get_option('comments_per_page'); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | $comment_args['number'] = $per_page; |
1353 | - $page = (int) get_query_var( 'cpage' ); |
|
1353 | + $page = (int) get_query_var('cpage'); |
|
1354 | 1354 | |
1355 | - if ( $page ) { |
|
1356 | - $comment_args['offset'] = ( $page - 1 ) * $per_page; |
|
1357 | - } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { |
|
1355 | + if ($page) { |
|
1356 | + $comment_args['offset'] = ($page - 1) * $per_page; |
|
1357 | + } elseif ('oldest' === get_option('default_comments_page')) { |
|
1358 | 1358 | $comment_args['offset'] = 0; |
1359 | 1359 | } else { |
1360 | 1360 | // If fetching the first page of 'newest', we need a top-level comment count. |
@@ -1366,17 +1366,17 @@ discard block |
||
1366 | 1366 | 'status' => 'approve', |
1367 | 1367 | ); |
1368 | 1368 | |
1369 | - if ( $comment_args['hierarchical'] ) { |
|
1369 | + if ($comment_args['hierarchical']) { |
|
1370 | 1370 | $top_level_args['parent'] = 0; |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - if ( isset( $comment_args['include_unapproved'] ) ) { |
|
1373 | + if (isset($comment_args['include_unapproved'])) { |
|
1374 | 1374 | $top_level_args['include_unapproved'] = $comment_args['include_unapproved']; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - $top_level_count = $top_level_query->query( $top_level_args ); |
|
1377 | + $top_level_count = $top_level_query->query($top_level_args); |
|
1378 | 1378 | |
1379 | - $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; |
|
1379 | + $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page; |
|
1380 | 1380 | } |
1381 | 1381 | } |
1382 | 1382 | |
@@ -1403,22 +1403,22 @@ discard block |
||
1403 | 1403 | * @type int $number Number of comments to fetch. |
1404 | 1404 | * } |
1405 | 1405 | */ |
1406 | - $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); |
|
1407 | - $comment_query = new WP_Comment_Query( $comment_args ); |
|
1406 | + $comment_args = apply_filters('comments_template_query_args', $comment_args); |
|
1407 | + $comment_query = new WP_Comment_Query($comment_args); |
|
1408 | 1408 | $_comments = $comment_query->comments; |
1409 | 1409 | |
1410 | 1410 | // Trees must be flattened before they're passed to the walker. |
1411 | - if ( $comment_args['hierarchical'] ) { |
|
1411 | + if ($comment_args['hierarchical']) { |
|
1412 | 1412 | $comments_flat = array(); |
1413 | - foreach ( $_comments as $_comment ) { |
|
1413 | + foreach ($_comments as $_comment) { |
|
1414 | 1414 | $comments_flat[] = $_comment; |
1415 | - $comment_children = $_comment->get_children( array( |
|
1415 | + $comment_children = $_comment->get_children(array( |
|
1416 | 1416 | 'format' => 'flat', |
1417 | 1417 | 'status' => $comment_args['status'], |
1418 | 1418 | 'orderby' => $comment_args['orderby'] |
1419 | - ) ); |
|
1419 | + )); |
|
1420 | 1420 | |
1421 | - foreach ( $comment_children as $comment_child ) { |
|
1421 | + foreach ($comment_children as $comment_child) { |
|
1422 | 1422 | $comments_flat[] = $comment_child; |
1423 | 1423 | } |
1424 | 1424 | } |
@@ -1434,13 +1434,13 @@ discard block |
||
1434 | 1434 | * @param array $comments Array of comments supplied to the comments template. |
1435 | 1435 | * @param int $post_ID Post ID. |
1436 | 1436 | */ |
1437 | - $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); |
|
1437 | + $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID); |
|
1438 | 1438 | |
1439 | 1439 | $comments = &$wp_query->comments; |
1440 | 1440 | $wp_query->comment_count = count($wp_query->comments); |
1441 | 1441 | $wp_query->max_num_comment_pages = $comment_query->max_num_pages; |
1442 | 1442 | |
1443 | - if ( $separate_comments ) { |
|
1443 | + if ($separate_comments) { |
|
1444 | 1444 | $wp_query->comments_by_type = separate_comments($comments); |
1445 | 1445 | $comments_by_type = &$wp_query->comments_by_type; |
1446 | 1446 | } else { |
@@ -1448,15 +1448,15 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | $overridden_cpage = false; |
1451 | - if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { |
|
1452 | - set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
1451 | + if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) { |
|
1452 | + set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); |
|
1453 | 1453 | $overridden_cpage = true; |
1454 | 1454 | } |
1455 | 1455 | |
1456 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
1456 | + if ( ! defined('COMMENTS_TEMPLATE')) |
|
1457 | 1457 | define('COMMENTS_TEMPLATE', true); |
1458 | 1458 | |
1459 | - $theme_template = STYLESHEETPATH . $file; |
|
1459 | + $theme_template = STYLESHEETPATH.$file; |
|
1460 | 1460 | /** |
1461 | 1461 | * Filters the path to the theme template file used for the comments template. |
1462 | 1462 | * |
@@ -1464,13 +1464,13 @@ discard block |
||
1464 | 1464 | * |
1465 | 1465 | * @param string $theme_template The path to the theme template file. |
1466 | 1466 | */ |
1467 | - $include = apply_filters( 'comments_template', $theme_template ); |
|
1468 | - if ( file_exists( $include ) ) |
|
1469 | - require( $include ); |
|
1470 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
1471 | - require( TEMPLATEPATH . $file ); |
|
1467 | + $include = apply_filters('comments_template', $theme_template); |
|
1468 | + if (file_exists($include)) |
|
1469 | + require($include); |
|
1470 | + elseif (file_exists(TEMPLATEPATH.$file)) |
|
1471 | + require(TEMPLATEPATH.$file); |
|
1472 | 1472 | else // Backward compat code will be removed in a future release |
1473 | - require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
|
1473 | + require(ABSPATH.WPINC.'/theme-compat/comments.php'); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | /** |
@@ -1487,45 +1487,45 @@ discard block |
||
1487 | 1487 | * @param string $none Optional. String to display when comments have been turned off. |
1488 | 1488 | * Default false. |
1489 | 1489 | */ |
1490 | -function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
|
1490 | +function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false) { |
|
1491 | 1491 | $id = get_the_ID(); |
1492 | 1492 | $title = get_the_title(); |
1493 | - $number = get_comments_number( $id ); |
|
1493 | + $number = get_comments_number($id); |
|
1494 | 1494 | |
1495 | - if ( false === $zero ) { |
|
1495 | + if (false === $zero) { |
|
1496 | 1496 | /* translators: %s: post title */ |
1497 | - $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1497 | + $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title); |
|
1498 | 1498 | } |
1499 | 1499 | |
1500 | - if ( false === $one ) { |
|
1500 | + if (false === $one) { |
|
1501 | 1501 | /* translators: %s: post title */ |
1502 | - $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1502 | + $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | - if ( false === $more ) { |
|
1505 | + if (false === $more) { |
|
1506 | 1506 | /* translators: 1: Number of comments 2: post title */ |
1507 | - $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number ); |
|
1508 | - $more = sprintf( $more, number_format_i18n( $number ), $title ); |
|
1507 | + $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number); |
|
1508 | + $more = sprintf($more, number_format_i18n($number), $title); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | - if ( false === $none ) { |
|
1511 | + if (false === $none) { |
|
1512 | 1512 | /* translators: %s: post title */ |
1513 | - $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1513 | + $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title); |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | - if ( 0 == $number && !comments_open() && !pings_open() ) { |
|
1517 | - echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; |
|
1516 | + if (0 == $number && ! comments_open() && ! pings_open()) { |
|
1517 | + echo '<span'.(( ! empty($css_class)) ? ' class="'.esc_attr($css_class).'"' : '').'>'.$none.'</span>'; |
|
1518 | 1518 | return; |
1519 | 1519 | } |
1520 | 1520 | |
1521 | - if ( post_password_required() ) { |
|
1522 | - _e( 'Enter your password to view comments.' ); |
|
1521 | + if (post_password_required()) { |
|
1522 | + _e('Enter your password to view comments.'); |
|
1523 | 1523 | return; |
1524 | 1524 | } |
1525 | 1525 | |
1526 | 1526 | echo '<a href="'; |
1527 | - if ( 0 == $number ) { |
|
1528 | - $respond_link = get_permalink() . '#respond'; |
|
1527 | + if (0 == $number) { |
|
1528 | + $respond_link = get_permalink().'#respond'; |
|
1529 | 1529 | /** |
1530 | 1530 | * Filters the respond link when a post has no comments. |
1531 | 1531 | * |
@@ -1534,13 +1534,13 @@ discard block |
||
1534 | 1534 | * @param string $respond_link The default response link. |
1535 | 1535 | * @param integer $id The post ID. |
1536 | 1536 | */ |
1537 | - echo apply_filters( 'respond_link', $respond_link, $id ); |
|
1537 | + echo apply_filters('respond_link', $respond_link, $id); |
|
1538 | 1538 | } else { |
1539 | 1539 | comments_link(); |
1540 | 1540 | } |
1541 | 1541 | echo '"'; |
1542 | 1542 | |
1543 | - if ( !empty( $css_class ) ) { |
|
1543 | + if ( ! empty($css_class)) { |
|
1544 | 1544 | echo ' class="'.$css_class.'" '; |
1545 | 1545 | } |
1546 | 1546 | |
@@ -1552,10 +1552,10 @@ discard block |
||
1552 | 1552 | * |
1553 | 1553 | * @param string $attributes The comments link attributes. Default empty. |
1554 | 1554 | */ |
1555 | - echo apply_filters( 'comments_popup_link_attributes', $attributes ); |
|
1555 | + echo apply_filters('comments_popup_link_attributes', $attributes); |
|
1556 | 1556 | |
1557 | 1557 | echo '>'; |
1558 | - comments_number( $zero, $one, $more ); |
|
1558 | + comments_number($zero, $one, $more); |
|
1559 | 1559 | echo '</a>'; |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1587,35 +1587,35 @@ discard block |
||
1587 | 1587 | * Default current post. |
1588 | 1588 | * @return void|false|string Link to show comment form, if successful. False, if comments are closed. |
1589 | 1589 | */ |
1590 | -function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
|
1590 | +function get_comment_reply_link($args = array(), $comment = null, $post = null) { |
|
1591 | 1591 | $defaults = array( |
1592 | 1592 | 'add_below' => 'comment', |
1593 | 1593 | 'respond_id' => 'respond', |
1594 | - 'reply_text' => __( 'Reply' ), |
|
1594 | + 'reply_text' => __('Reply'), |
|
1595 | 1595 | /* translators: Comment reply button text. 1: Comment author name */ |
1596 | - 'reply_to_text' => __( 'Reply to %s' ), |
|
1597 | - 'login_text' => __( 'Log in to Reply' ), |
|
1596 | + 'reply_to_text' => __('Reply to %s'), |
|
1597 | + 'login_text' => __('Log in to Reply'), |
|
1598 | 1598 | 'max_depth' => 0, |
1599 | 1599 | 'depth' => 0, |
1600 | 1600 | 'before' => '', |
1601 | 1601 | 'after' => '' |
1602 | 1602 | ); |
1603 | 1603 | |
1604 | - $args = wp_parse_args( $args, $defaults ); |
|
1604 | + $args = wp_parse_args($args, $defaults); |
|
1605 | 1605 | |
1606 | - if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
|
1606 | + if (0 == $args['depth'] || $args['max_depth'] <= $args['depth']) { |
|
1607 | 1607 | return; |
1608 | 1608 | } |
1609 | 1609 | |
1610 | - $comment = get_comment( $comment ); |
|
1610 | + $comment = get_comment($comment); |
|
1611 | 1611 | |
1612 | - if ( empty( $post ) ) { |
|
1612 | + if (empty($post)) { |
|
1613 | 1613 | $post = $comment->comment_post_ID; |
1614 | 1614 | } |
1615 | 1615 | |
1616 | - $post = get_post( $post ); |
|
1616 | + $post = get_post($post); |
|
1617 | 1617 | |
1618 | - if ( ! comments_open( $post->ID ) ) { |
|
1618 | + if ( ! comments_open($post->ID)) { |
|
1619 | 1619 | return false; |
1620 | 1620 | } |
1621 | 1621 | |
@@ -1629,22 +1629,22 @@ discard block |
||
1629 | 1629 | * @param WP_Comment $comment The object of the comment being replied to. |
1630 | 1630 | * @param WP_Post $post The WP_Post object. |
1631 | 1631 | */ |
1632 | - $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
|
1632 | + $args = apply_filters('comment_reply_link_args', $args, $comment, $post); |
|
1633 | 1633 | |
1634 | - if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
|
1635 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
1636 | - esc_url( wp_login_url( get_permalink() ) ), |
|
1634 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
1635 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
1636 | + esc_url(wp_login_url(get_permalink())), |
|
1637 | 1637 | $args['login_text'] |
1638 | 1638 | ); |
1639 | 1639 | } else { |
1640 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
1640 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
1641 | 1641 | $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID |
1642 | 1642 | ); |
1643 | 1643 | |
1644 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
1645 | - esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'], |
|
1644 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
1645 | + esc_url(add_query_arg('replytocom', $comment->comment_ID, get_permalink($post->ID)))."#".$args['respond_id'], |
|
1646 | 1646 | $onclick, |
1647 | - esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
|
1647 | + esc_attr(sprintf($args['reply_to_text'], $comment->comment_author)), |
|
1648 | 1648 | $args['reply_text'] |
1649 | 1649 | ); |
1650 | 1650 | } |
@@ -1659,7 +1659,7 @@ discard block |
||
1659 | 1659 | * @param object $comment The object of the comment being replied. |
1660 | 1660 | * @param WP_Post $post The WP_Post object. |
1661 | 1661 | */ |
1662 | - return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); |
|
1662 | + return apply_filters('comment_reply_link', $args['before'].$link.$args['after'], $args, $comment, $post); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | /** |
@@ -1716,27 +1716,27 @@ discard block |
||
1716 | 1716 | |
1717 | 1717 | $post = get_post($post); |
1718 | 1718 | |
1719 | - if ( ! comments_open( $post->ID ) ) { |
|
1719 | + if ( ! comments_open($post->ID)) { |
|
1720 | 1720 | return false; |
1721 | 1721 | } |
1722 | 1722 | |
1723 | - if ( get_option('comment_registration') && ! is_user_logged_in() ) { |
|
1724 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
1725 | - wp_login_url( get_permalink() ), |
|
1723 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
1724 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
1725 | + wp_login_url(get_permalink()), |
|
1726 | 1726 | $args['login_text'] |
1727 | 1727 | ); |
1728 | 1728 | } else { |
1729 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
1729 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
1730 | 1730 | $args['add_below'], $post->ID, $args['respond_id'] |
1731 | 1731 | ); |
1732 | 1732 | |
1733 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
1734 | - get_permalink( $post->ID ) . '#' . $args['respond_id'], |
|
1733 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
1734 | + get_permalink($post->ID).'#'.$args['respond_id'], |
|
1735 | 1735 | $onclick, |
1736 | 1736 | $args['reply_text'] |
1737 | 1737 | ); |
1738 | 1738 | } |
1739 | - $formatted_link = $args['before'] . $link . $args['after']; |
|
1739 | + $formatted_link = $args['before'].$link.$args['after']; |
|
1740 | 1740 | |
1741 | 1741 | /** |
1742 | 1742 | * Filters the formatted post comments link HTML. |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | * @param string $formatted The HTML-formatted post comments link. |
1747 | 1747 | * @param int|WP_Post $post The post ID or WP_Post object. |
1748 | 1748 | */ |
1749 | - return apply_filters( 'post_comments_link', $formatted_link, $post ); |
|
1749 | + return apply_filters('post_comments_link', $formatted_link, $post); |
|
1750 | 1750 | } |
1751 | 1751 | |
1752 | 1752 | /** |
@@ -1773,14 +1773,14 @@ discard block |
||
1773 | 1773 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
1774 | 1774 | * @return string |
1775 | 1775 | */ |
1776 | -function get_cancel_comment_reply_link( $text = '' ) { |
|
1777 | - if ( empty($text) ) |
|
1776 | +function get_cancel_comment_reply_link($text = '') { |
|
1777 | + if (empty($text)) |
|
1778 | 1778 | $text = __('Click here to cancel reply.'); |
1779 | 1779 | |
1780 | 1780 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
1781 | - $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
|
1781 | + $link = esc_html(remove_query_arg('replytocom')).'#respond'; |
|
1782 | 1782 | |
1783 | - $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; |
|
1783 | + $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="'.$link.'"'.$style.'>'.$text.'</a>'; |
|
1784 | 1784 | |
1785 | 1785 | /** |
1786 | 1786 | * Filters the cancel comment reply link HTML. |
@@ -1791,7 +1791,7 @@ discard block |
||
1791 | 1791 | * @param string $link Cancel comment reply link URL. |
1792 | 1792 | * @param string $text Cancel comment reply link text. |
1793 | 1793 | */ |
1794 | - return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); |
|
1794 | + return apply_filters('cancel_comment_reply_link', $formatted_link, $link, $text); |
|
1795 | 1795 | } |
1796 | 1796 | |
1797 | 1797 | /** |
@@ -1801,7 +1801,7 @@ discard block |
||
1801 | 1801 | * |
1802 | 1802 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
1803 | 1803 | */ |
1804 | -function cancel_comment_reply_link( $text = '' ) { |
|
1804 | +function cancel_comment_reply_link($text = '') { |
|
1805 | 1805 | echo get_cancel_comment_reply_link($text); |
1806 | 1806 | } |
1807 | 1807 | |
@@ -1813,8 +1813,8 @@ discard block |
||
1813 | 1813 | * @param int $id Optional. Post ID. Default current post ID. |
1814 | 1814 | * @return string Hidden input HTML for replying to comments |
1815 | 1815 | */ |
1816 | -function get_comment_id_fields( $id = 0 ) { |
|
1817 | - if ( empty( $id ) ) |
|
1816 | +function get_comment_id_fields($id = 0) { |
|
1817 | + if (empty($id)) |
|
1818 | 1818 | $id = get_the_ID(); |
1819 | 1819 | |
1820 | 1820 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
@@ -1830,7 +1830,7 @@ discard block |
||
1830 | 1830 | * @param int $id The post ID. |
1831 | 1831 | * @param int $replytoid The id of the comment being replied to. |
1832 | 1832 | */ |
1833 | - return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); |
|
1833 | + return apply_filters('comment_id_fields', $result, $id, $replytoid); |
|
1834 | 1834 | } |
1835 | 1835 | |
1836 | 1836 | /** |
@@ -1840,8 +1840,8 @@ discard block |
||
1840 | 1840 | * |
1841 | 1841 | * @param int $id Optional. Post ID. Default current post ID. |
1842 | 1842 | */ |
1843 | -function comment_id_fields( $id = 0 ) { |
|
1844 | - echo get_comment_id_fields( $id ); |
|
1843 | +function comment_id_fields($id = 0) { |
|
1844 | + echo get_comment_id_fields($id); |
|
1845 | 1845 | } |
1846 | 1846 | |
1847 | 1847 | /** |
@@ -1864,21 +1864,21 @@ discard block |
||
1864 | 1864 | * @param string $linktoparent Optional. Boolean to control making the author's name a link |
1865 | 1865 | * to their comment. Default true. |
1866 | 1866 | */ |
1867 | -function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
|
1867 | +function comment_form_title($noreplytext = false, $replytext = false, $linktoparent = true) { |
|
1868 | 1868 | global $comment; |
1869 | 1869 | |
1870 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
1871 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
1870 | + if (false === $noreplytext) $noreplytext = __('Leave a Reply'); |
|
1871 | + if (false === $replytext) $replytext = __('Leave a Reply to %s'); |
|
1872 | 1872 | |
1873 | 1873 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
1874 | 1874 | |
1875 | - if ( 0 == $replytoid ) |
|
1875 | + if (0 == $replytoid) |
|
1876 | 1876 | echo $noreplytext; |
1877 | 1877 | else { |
1878 | 1878 | // Sets the global so that template tags can be used in the comment form. |
1879 | 1879 | $comment = get_comment($replytoid); |
1880 | - $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
|
1881 | - printf( $replytext, $author ); |
|
1880 | + $author = ($linktoparent) ? '<a href="#comment-'.get_comment_ID().'">'.get_comment_author($comment).'</a>' : get_comment_author($comment); |
|
1881 | + printf($replytext, $author); |
|
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | |
@@ -1920,7 +1920,7 @@ discard block |
||
1920 | 1920 | * } |
1921 | 1921 | * @param array $comments Optional. Array of WP_Comment objects. |
1922 | 1922 | */ |
1923 | -function wp_list_comments( $args = array(), $comments = null ) { |
|
1923 | +function wp_list_comments($args = array(), $comments = null) { |
|
1924 | 1924 | global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; |
1925 | 1925 | |
1926 | 1926 | $in_comment_loop = true; |
@@ -1940,12 +1940,12 @@ discard block |
||
1940 | 1940 | 'avatar_size' => 32, |
1941 | 1941 | 'reverse_top_level' => null, |
1942 | 1942 | 'reverse_children' => '', |
1943 | - 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', |
|
1943 | + 'format' => current_theme_supports('html5', 'comment-list') ? 'html5' : 'xhtml', |
|
1944 | 1944 | 'short_ping' => false, |
1945 | 1945 | 'echo' => true, |
1946 | 1946 | ); |
1947 | 1947 | |
1948 | - $r = wp_parse_args( $args, $defaults ); |
|
1948 | + $r = wp_parse_args($args, $defaults); |
|
1949 | 1949 | |
1950 | 1950 | /** |
1951 | 1951 | * Filters the arguments used in retrieving the comment list. |
@@ -1956,16 +1956,16 @@ discard block |
||
1956 | 1956 | * |
1957 | 1957 | * @param array $r An array of arguments for displaying comments. |
1958 | 1958 | */ |
1959 | - $r = apply_filters( 'wp_list_comments_args', $r ); |
|
1959 | + $r = apply_filters('wp_list_comments_args', $r); |
|
1960 | 1960 | |
1961 | 1961 | // Figure out what comments we'll be looping through ($_comments) |
1962 | - if ( null !== $comments ) { |
|
1962 | + if (null !== $comments) { |
|
1963 | 1963 | $comments = (array) $comments; |
1964 | - if ( empty($comments) ) |
|
1964 | + if (empty($comments)) |
|
1965 | 1965 | return; |
1966 | - if ( 'all' != $r['type'] ) { |
|
1966 | + if ('all' != $r['type']) { |
|
1967 | 1967 | $comments_by_type = separate_comments($comments); |
1968 | - if ( empty($comments_by_type[$r['type']]) ) |
|
1968 | + if (empty($comments_by_type[$r['type']])) |
|
1969 | 1969 | return; |
1970 | 1970 | $_comments = $comments_by_type[$r['type']]; |
1971 | 1971 | } else { |
@@ -1976,14 +1976,14 @@ discard block |
||
1976 | 1976 | * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, |
1977 | 1977 | * perform a separate comment query and allow Walker_Comment to paginate. |
1978 | 1978 | */ |
1979 | - if ( $r['page'] || $r['per_page'] ) { |
|
1980 | - $current_cpage = get_query_var( 'cpage' ); |
|
1981 | - if ( ! $current_cpage ) { |
|
1982 | - $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; |
|
1979 | + if ($r['page'] || $r['per_page']) { |
|
1980 | + $current_cpage = get_query_var('cpage'); |
|
1981 | + if ( ! $current_cpage) { |
|
1982 | + $current_cpage = 'newest' === get_option('default_comments_page') ? 1 : $wp_query->max_num_comment_pages; |
|
1983 | 1983 | } |
1984 | 1984 | |
1985 | - $current_per_page = get_query_var( 'comments_per_page' ); |
|
1986 | - if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { |
|
1985 | + $current_per_page = get_query_var('comments_per_page'); |
|
1986 | + if ($r['page'] != $current_cpage || $r['per_page'] != $current_per_page) { |
|
1987 | 1987 | $comment_args = array( |
1988 | 1988 | 'post_id' => get_the_ID(), |
1989 | 1989 | 'orderby' => 'comment_date_gmt', |
@@ -1991,24 +1991,24 @@ discard block |
||
1991 | 1991 | 'status' => 'approve', |
1992 | 1992 | ); |
1993 | 1993 | |
1994 | - if ( is_user_logged_in() ) { |
|
1994 | + if (is_user_logged_in()) { |
|
1995 | 1995 | $comment_args['include_unapproved'] = get_current_user_id(); |
1996 | 1996 | } else { |
1997 | 1997 | $commenter = wp_get_current_commenter(); |
1998 | - if ( $commenter['comment_author_email'] ) { |
|
1998 | + if ($commenter['comment_author_email']) { |
|
1999 | 1999 | $comment_args['include_unapproved'] = $commenter['comment_author_email']; |
2000 | 2000 | } |
2001 | 2001 | } |
2002 | 2002 | |
2003 | - $comments = get_comments( $comment_args ); |
|
2003 | + $comments = get_comments($comment_args); |
|
2004 | 2004 | |
2005 | - if ( 'all' != $r['type'] ) { |
|
2006 | - $comments_by_type = separate_comments( $comments ); |
|
2007 | - if ( empty( $comments_by_type[ $r['type'] ] ) ) { |
|
2005 | + if ('all' != $r['type']) { |
|
2006 | + $comments_by_type = separate_comments($comments); |
|
2007 | + if (empty($comments_by_type[$r['type']])) { |
|
2008 | 2008 | return; |
2009 | 2009 | } |
2010 | 2010 | |
2011 | - $_comments = $comments_by_type[ $r['type'] ]; |
|
2011 | + $_comments = $comments_by_type[$r['type']]; |
|
2012 | 2012 | } else { |
2013 | 2013 | $_comments = $comments; |
2014 | 2014 | } |
@@ -2016,29 +2016,29 @@ discard block |
||
2016 | 2016 | |
2017 | 2017 | // Otherwise, fall back on the comments from `$wp_query->comments`. |
2018 | 2018 | } else { |
2019 | - if ( empty($wp_query->comments) ) |
|
2019 | + if (empty($wp_query->comments)) |
|
2020 | 2020 | return; |
2021 | - if ( 'all' != $r['type'] ) { |
|
2022 | - if ( empty($wp_query->comments_by_type) ) |
|
2021 | + if ('all' != $r['type']) { |
|
2022 | + if (empty($wp_query->comments_by_type)) |
|
2023 | 2023 | $wp_query->comments_by_type = separate_comments($wp_query->comments); |
2024 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
2024 | + if (empty($wp_query->comments_by_type[$r['type']])) |
|
2025 | 2025 | return; |
2026 | 2026 | $_comments = $wp_query->comments_by_type[$r['type']]; |
2027 | 2027 | } else { |
2028 | 2028 | $_comments = $wp_query->comments; |
2029 | 2029 | } |
2030 | 2030 | |
2031 | - if ( $wp_query->max_num_comment_pages ) { |
|
2032 | - $default_comments_page = get_option( 'default_comments_page' ); |
|
2033 | - $cpage = get_query_var( 'cpage' ); |
|
2034 | - if ( 'newest' === $default_comments_page ) { |
|
2031 | + if ($wp_query->max_num_comment_pages) { |
|
2032 | + $default_comments_page = get_option('default_comments_page'); |
|
2033 | + $cpage = get_query_var('cpage'); |
|
2034 | + if ('newest' === $default_comments_page) { |
|
2035 | 2035 | $r['cpage'] = $cpage; |
2036 | 2036 | |
2037 | 2037 | /* |
2038 | 2038 | * When first page shows oldest comments, post permalink is the same as |
2039 | 2039 | * the comment permalink. |
2040 | 2040 | */ |
2041 | - } elseif ( $cpage == 1 ) { |
|
2041 | + } elseif ($cpage == 1) { |
|
2042 | 2042 | $r['cpage'] = ''; |
2043 | 2043 | } else { |
2044 | 2044 | $r['cpage'] = $cpage; |
@@ -2050,52 +2050,52 @@ discard block |
||
2050 | 2050 | } |
2051 | 2051 | } |
2052 | 2052 | |
2053 | - if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { |
|
2053 | + if ('' === $r['per_page'] && get_option('page_comments')) { |
|
2054 | 2054 | $r['per_page'] = get_query_var('comments_per_page'); |
2055 | 2055 | } |
2056 | 2056 | |
2057 | - if ( empty($r['per_page']) ) { |
|
2057 | + if (empty($r['per_page'])) { |
|
2058 | 2058 | $r['per_page'] = 0; |
2059 | 2059 | $r['page'] = 0; |
2060 | 2060 | } |
2061 | 2061 | |
2062 | - if ( '' === $r['max_depth'] ) { |
|
2063 | - if ( get_option('thread_comments') ) |
|
2062 | + if ('' === $r['max_depth']) { |
|
2063 | + if (get_option('thread_comments')) |
|
2064 | 2064 | $r['max_depth'] = get_option('thread_comments_depth'); |
2065 | 2065 | else |
2066 | 2066 | $r['max_depth'] = -1; |
2067 | 2067 | } |
2068 | 2068 | |
2069 | - if ( '' === $r['page'] ) { |
|
2070 | - if ( empty($overridden_cpage) ) { |
|
2069 | + if ('' === $r['page']) { |
|
2070 | + if (empty($overridden_cpage)) { |
|
2071 | 2071 | $r['page'] = get_query_var('cpage'); |
2072 | 2072 | } else { |
2073 | 2073 | $threaded = ( -1 != $r['max_depth'] ); |
2074 | - $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
2075 | - set_query_var( 'cpage', $r['page'] ); |
|
2074 | + $r['page'] = ('newest' == get_option('default_comments_page')) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
2075 | + set_query_var('cpage', $r['page']); |
|
2076 | 2076 | } |
2077 | 2077 | } |
2078 | 2078 | // Validation check |
2079 | 2079 | $r['page'] = intval($r['page']); |
2080 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
2080 | + if (0 == $r['page'] && 0 != $r['per_page']) |
|
2081 | 2081 | $r['page'] = 1; |
2082 | 2082 | |
2083 | - if ( null === $r['reverse_top_level'] ) |
|
2084 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
2083 | + if (null === $r['reverse_top_level']) |
|
2084 | + $r['reverse_top_level'] = ('desc' == get_option('comment_order')); |
|
2085 | 2085 | |
2086 | - wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
|
2086 | + wp_queue_comments_for_comment_meta_lazyload($_comments); |
|
2087 | 2087 | |
2088 | - if ( empty( $r['walker'] ) ) { |
|
2088 | + if (empty($r['walker'])) { |
|
2089 | 2089 | $walker = new Walker_Comment; |
2090 | 2090 | } else { |
2091 | 2091 | $walker = $r['walker']; |
2092 | 2092 | } |
2093 | 2093 | |
2094 | - $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); |
|
2094 | + $output = $walker->paged_walk($_comments, $r['max_depth'], $r['page'], $r['per_page'], $r); |
|
2095 | 2095 | |
2096 | 2096 | $in_comment_loop = false; |
2097 | 2097 | |
2098 | - if ( $r['echo'] ) { |
|
2098 | + if ($r['echo']) { |
|
2099 | 2099 | echo $output; |
2100 | 2100 | } else { |
2101 | 2101 | return $output; |
@@ -2164,18 +2164,18 @@ discard block |
||
2164 | 2164 | * } |
2165 | 2165 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
2166 | 2166 | */ |
2167 | -function comment_form( $args = array(), $post_id = null ) { |
|
2168 | - if ( null === $post_id ) |
|
2167 | +function comment_form($args = array(), $post_id = null) { |
|
2168 | + if (null === $post_id) |
|
2169 | 2169 | $post_id = get_the_ID(); |
2170 | 2170 | |
2171 | 2171 | // Exit the function when comments for the post are closed. |
2172 | - if ( ! comments_open( $post_id ) ) { |
|
2172 | + if ( ! comments_open($post_id)) { |
|
2173 | 2173 | /** |
2174 | 2174 | * Fires after the comment form if comments are closed. |
2175 | 2175 | * |
2176 | 2176 | * @since 3.0.0 |
2177 | 2177 | */ |
2178 | - do_action( 'comment_form_comments_closed' ); |
|
2178 | + do_action('comment_form_comments_closed'); |
|
2179 | 2179 | |
2180 | 2180 | return; |
2181 | 2181 | } |
@@ -2184,24 +2184,24 @@ discard block |
||
2184 | 2184 | $user = wp_get_current_user(); |
2185 | 2185 | $user_identity = $user->exists() ? $user->display_name : ''; |
2186 | 2186 | |
2187 | - $args = wp_parse_args( $args ); |
|
2188 | - if ( ! isset( $args['format'] ) ) |
|
2189 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
2187 | + $args = wp_parse_args($args); |
|
2188 | + if ( ! isset($args['format'])) |
|
2189 | + $args['format'] = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml'; |
|
2190 | 2190 | |
2191 | - $req = get_option( 'require_name_email' ); |
|
2192 | - $aria_req = ( $req ? " aria-required='true'" : '' ); |
|
2193 | - $html_req = ( $req ? " required='required'" : '' ); |
|
2191 | + $req = get_option('require_name_email'); |
|
2192 | + $aria_req = ($req ? " aria-required='true'" : ''); |
|
2193 | + $html_req = ($req ? " required='required'" : ''); |
|
2194 | 2194 | $html5 = 'html5' === $args['format']; |
2195 | - $fields = array( |
|
2196 | - 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
2197 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', |
|
2198 | - 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
2199 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
2200 | - 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
|
2201 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
|
2195 | + $fields = array( |
|
2196 | + 'author' => '<p class="comment-form-author">'.'<label for="author">'.__('Name').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
2197 | + '<input id="author" name="author" type="text" value="'.esc_attr($commenter['comment_author']).'" size="30" maxlength="245"'.$aria_req.$html_req.' /></p>', |
|
2198 | + 'email' => '<p class="comment-form-email"><label for="email">'.__('Email').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
2199 | + '<input id="email" name="email" '.($html5 ? 'type="email"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_email']).'" size="30" maxlength="100" aria-describedby="email-notes"'.$aria_req.$html_req.' /></p>', |
|
2200 | + 'url' => '<p class="comment-form-url"><label for="url">'.__('Website').'</label> '. |
|
2201 | + '<input id="url" name="url" '.($html5 ? 'type="url"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_url']).'" size="30" maxlength="200" /></p>', |
|
2202 | 2202 | ); |
2203 | 2203 | |
2204 | - $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
|
2204 | + $required_text = sprintf(' '.__('Required fields are marked %s'), '<span class="required">*</span>'); |
|
2205 | 2205 | |
2206 | 2206 | /** |
2207 | 2207 | * Filters the default comment form fields. |
@@ -2210,42 +2210,42 @@ discard block |
||
2210 | 2210 | * |
2211 | 2211 | * @param array $fields The default comment fields. |
2212 | 2212 | */ |
2213 | - $fields = apply_filters( 'comment_form_default_fields', $fields ); |
|
2213 | + $fields = apply_filters('comment_form_default_fields', $fields); |
|
2214 | 2214 | $defaults = array( |
2215 | 2215 | 'fields' => $fields, |
2216 | - 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
|
2216 | + 'comment_field' => '<p class="comment-form-comment"><label for="comment">'._x('Comment', 'noun').'</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', |
|
2217 | 2217 | /** This filter is documented in wp-includes/link-template.php */ |
2218 | - 'must_log_in' => '<p class="must-log-in">' . sprintf( |
|
2218 | + 'must_log_in' => '<p class="must-log-in">'.sprintf( |
|
2219 | 2219 | /* translators: %s: login URL */ |
2220 | - __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
2221 | - wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2222 | - ) . '</p>', |
|
2220 | + __('You must be <a href="%s">logged in</a> to post a comment.'), |
|
2221 | + wp_login_url(apply_filters('the_permalink', get_permalink($post_id))) |
|
2222 | + ).'</p>', |
|
2223 | 2223 | /** This filter is documented in wp-includes/link-template.php */ |
2224 | - 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
|
2224 | + 'logged_in_as' => '<p class="logged-in-as">'.sprintf( |
|
2225 | 2225 | /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
2226 | - __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
2226 | + __('<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>'), |
|
2227 | 2227 | get_edit_user_link(), |
2228 | 2228 | /* translators: %s: user name */ |
2229 | - esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
2229 | + esc_attr(sprintf(__('Logged in as %s. Edit your profile.'), $user_identity)), |
|
2230 | 2230 | $user_identity, |
2231 | - wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) |
|
2232 | - ) . '</p>', |
|
2233 | - 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
|
2231 | + wp_logout_url(apply_filters('the_permalink', get_permalink($post_id))) |
|
2232 | + ).'</p>', |
|
2233 | + 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">'.__('Your email address will not be published.').'</span>'.($req ? $required_text : '').'</p>', |
|
2234 | 2234 | 'comment_notes_after' => '', |
2235 | - 'action' => site_url( '/wp-comments-post.php' ), |
|
2235 | + 'action' => site_url('/wp-comments-post.php'), |
|
2236 | 2236 | 'id_form' => 'commentform', |
2237 | 2237 | 'id_submit' => 'submit', |
2238 | 2238 | 'class_form' => 'comment-form', |
2239 | 2239 | 'class_submit' => 'submit', |
2240 | 2240 | 'name_submit' => 'submit', |
2241 | - 'title_reply' => __( 'Leave a Reply' ), |
|
2242 | - 'title_reply_to' => __( 'Leave a Reply to %s' ), |
|
2241 | + 'title_reply' => __('Leave a Reply'), |
|
2242 | + 'title_reply_to' => __('Leave a Reply to %s'), |
|
2243 | 2243 | 'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">', |
2244 | 2244 | 'title_reply_after' => '</h3>', |
2245 | 2245 | 'cancel_reply_before' => ' <small>', |
2246 | 2246 | 'cancel_reply_after' => '</small>', |
2247 | - 'cancel_reply_link' => __( 'Cancel reply' ), |
|
2248 | - 'label_submit' => __( 'Post Comment' ), |
|
2247 | + 'cancel_reply_link' => __('Cancel reply'), |
|
2248 | + 'label_submit' => __('Post Comment'), |
|
2249 | 2249 | 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />', |
2250 | 2250 | 'submit_field' => '<p class="form-submit">%1$s %2$s</p>', |
2251 | 2251 | 'format' => 'xhtml', |
@@ -2260,51 +2260,51 @@ discard block |
||
2260 | 2260 | * |
2261 | 2261 | * @param array $defaults The default comment form arguments. |
2262 | 2262 | */ |
2263 | - $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
|
2263 | + $args = wp_parse_args($args, apply_filters('comment_form_defaults', $defaults)); |
|
2264 | 2264 | |
2265 | 2265 | // Ensure that the filtered args contain all required default values. |
2266 | - $args = array_merge( $defaults, $args ); |
|
2266 | + $args = array_merge($defaults, $args); |
|
2267 | 2267 | |
2268 | 2268 | /** |
2269 | 2269 | * Fires before the comment form. |
2270 | 2270 | * |
2271 | 2271 | * @since 3.0.0 |
2272 | 2272 | */ |
2273 | - do_action( 'comment_form_before' ); |
|
2273 | + do_action('comment_form_before'); |
|
2274 | 2274 | ?> |
2275 | 2275 | <div id="respond" class="comment-respond"> |
2276 | 2276 | <?php |
2277 | 2277 | echo $args['title_reply_before']; |
2278 | 2278 | |
2279 | - comment_form_title( $args['title_reply'], $args['title_reply_to'] ); |
|
2279 | + comment_form_title($args['title_reply'], $args['title_reply_to']); |
|
2280 | 2280 | |
2281 | 2281 | echo $args['cancel_reply_before']; |
2282 | 2282 | |
2283 | - cancel_comment_reply_link( $args['cancel_reply_link'] ); |
|
2283 | + cancel_comment_reply_link($args['cancel_reply_link']); |
|
2284 | 2284 | |
2285 | 2285 | echo $args['cancel_reply_after']; |
2286 | 2286 | |
2287 | 2287 | echo $args['title_reply_after']; |
2288 | 2288 | |
2289 | - if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : |
|
2289 | + if (get_option('comment_registration') && ! is_user_logged_in()) : |
|
2290 | 2290 | echo $args['must_log_in']; |
2291 | 2291 | /** |
2292 | 2292 | * Fires after the HTML-formatted 'must log in after' message in the comment form. |
2293 | 2293 | * |
2294 | 2294 | * @since 3.0.0 |
2295 | 2295 | */ |
2296 | - do_action( 'comment_form_must_log_in_after' ); |
|
2296 | + do_action('comment_form_must_log_in_after'); |
|
2297 | 2297 | else : ?> |
2298 | - <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
2298 | + <form action="<?php echo esc_url($args['action']); ?>" method="post" id="<?php echo esc_attr($args['id_form']); ?>" class="<?php echo esc_attr($args['class_form']); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
2299 | 2299 | <?php |
2300 | 2300 | /** |
2301 | 2301 | * Fires at the top of the comment form, inside the form tag. |
2302 | 2302 | * |
2303 | 2303 | * @since 3.0.0 |
2304 | 2304 | */ |
2305 | - do_action( 'comment_form_top' ); |
|
2305 | + do_action('comment_form_top'); |
|
2306 | 2306 | |
2307 | - if ( is_user_logged_in() ) : |
|
2307 | + if (is_user_logged_in()) : |
|
2308 | 2308 | /** |
2309 | 2309 | * Filters the 'logged in' message for the comment form for display. |
2310 | 2310 | * |
@@ -2316,7 +2316,7 @@ discard block |
||
2316 | 2316 | * @param string $user_identity If the commenter is a registered user, |
2317 | 2317 | * the display name, blank otherwise. |
2318 | 2318 | */ |
2319 | - echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); |
|
2319 | + echo apply_filters('comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity); |
|
2320 | 2320 | |
2321 | 2321 | /** |
2322 | 2322 | * Fires after the is_user_logged_in() check in the comment form. |
@@ -2328,7 +2328,7 @@ discard block |
||
2328 | 2328 | * @param string $user_identity If the commenter is a registered user, |
2329 | 2329 | * the display name, blank otherwise. |
2330 | 2330 | */ |
2331 | - do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
|
2331 | + do_action('comment_form_logged_in_after', $commenter, $user_identity); |
|
2332 | 2332 | |
2333 | 2333 | else : |
2334 | 2334 | |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | endif; |
2338 | 2338 | |
2339 | 2339 | // Prepare an array of all fields, including the textarea |
2340 | - $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields']; |
|
2340 | + $comment_fields = array('comment' => $args['comment_field']) + (array) $args['fields']; |
|
2341 | 2341 | |
2342 | 2342 | /** |
2343 | 2343 | * Filters the comment form fields, including the textarea. |
@@ -2346,18 +2346,18 @@ discard block |
||
2346 | 2346 | * |
2347 | 2347 | * @param array $comment_fields The comment fields. |
2348 | 2348 | */ |
2349 | - $comment_fields = apply_filters( 'comment_form_fields', $comment_fields ); |
|
2349 | + $comment_fields = apply_filters('comment_form_fields', $comment_fields); |
|
2350 | 2350 | |
2351 | 2351 | // Get an array of field names, excluding the textarea |
2352 | - $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) ); |
|
2352 | + $comment_field_keys = array_diff(array_keys($comment_fields), array('comment')); |
|
2353 | 2353 | |
2354 | 2354 | // Get the first and the last field name, excluding the textarea |
2355 | - $first_field = reset( $comment_field_keys ); |
|
2356 | - $last_field = end( $comment_field_keys ); |
|
2355 | + $first_field = reset($comment_field_keys); |
|
2356 | + $last_field = end($comment_field_keys); |
|
2357 | 2357 | |
2358 | - foreach ( $comment_fields as $name => $field ) { |
|
2358 | + foreach ($comment_fields as $name => $field) { |
|
2359 | 2359 | |
2360 | - if ( 'comment' === $name ) { |
|
2360 | + if ('comment' === $name) { |
|
2361 | 2361 | |
2362 | 2362 | /** |
2363 | 2363 | * Filters the content of the comment textarea field for display. |
@@ -2366,19 +2366,19 @@ discard block |
||
2366 | 2366 | * |
2367 | 2367 | * @param string $args_comment_field The content of the comment textarea field. |
2368 | 2368 | */ |
2369 | - echo apply_filters( 'comment_form_field_comment', $field ); |
|
2369 | + echo apply_filters('comment_form_field_comment', $field); |
|
2370 | 2370 | |
2371 | 2371 | echo $args['comment_notes_after']; |
2372 | 2372 | |
2373 | - } elseif ( ! is_user_logged_in() ) { |
|
2373 | + } elseif ( ! is_user_logged_in()) { |
|
2374 | 2374 | |
2375 | - if ( $first_field === $name ) { |
|
2375 | + if ($first_field === $name) { |
|
2376 | 2376 | /** |
2377 | 2377 | * Fires before the comment fields in the comment form, excluding the textarea. |
2378 | 2378 | * |
2379 | 2379 | * @since 3.0.0 |
2380 | 2380 | */ |
2381 | - do_action( 'comment_form_before_fields' ); |
|
2381 | + do_action('comment_form_before_fields'); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | /** |
@@ -2391,25 +2391,25 @@ discard block |
||
2391 | 2391 | * |
2392 | 2392 | * @param string $field The HTML-formatted output of the comment form field. |
2393 | 2393 | */ |
2394 | - echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
|
2394 | + echo apply_filters("comment_form_field_{$name}", $field)."\n"; |
|
2395 | 2395 | |
2396 | - if ( $last_field === $name ) { |
|
2396 | + if ($last_field === $name) { |
|
2397 | 2397 | /** |
2398 | 2398 | * Fires after the comment fields in the comment form, excluding the textarea. |
2399 | 2399 | * |
2400 | 2400 | * @since 3.0.0 |
2401 | 2401 | */ |
2402 | - do_action( 'comment_form_after_fields' ); |
|
2402 | + do_action('comment_form_after_fields'); |
|
2403 | 2403 | } |
2404 | 2404 | } |
2405 | 2405 | } |
2406 | 2406 | |
2407 | 2407 | $submit_button = sprintf( |
2408 | 2408 | $args['submit_button'], |
2409 | - esc_attr( $args['name_submit'] ), |
|
2410 | - esc_attr( $args['id_submit'] ), |
|
2411 | - esc_attr( $args['class_submit'] ), |
|
2412 | - esc_attr( $args['label_submit'] ) |
|
2409 | + esc_attr($args['name_submit']), |
|
2410 | + esc_attr($args['id_submit']), |
|
2411 | + esc_attr($args['class_submit']), |
|
2412 | + esc_attr($args['label_submit']) |
|
2413 | 2413 | ); |
2414 | 2414 | |
2415 | 2415 | /** |
@@ -2420,12 +2420,12 @@ discard block |
||
2420 | 2420 | * @param string $submit_button HTML markup for the submit button. |
2421 | 2421 | * @param array $args Arguments passed to `comment_form()`. |
2422 | 2422 | */ |
2423 | - $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); |
|
2423 | + $submit_button = apply_filters('comment_form_submit_button', $submit_button, $args); |
|
2424 | 2424 | |
2425 | 2425 | $submit_field = sprintf( |
2426 | 2426 | $args['submit_field'], |
2427 | 2427 | $submit_button, |
2428 | - get_comment_id_fields( $post_id ) |
|
2428 | + get_comment_id_fields($post_id) |
|
2429 | 2429 | ); |
2430 | 2430 | |
2431 | 2431 | /** |
@@ -2439,7 +2439,7 @@ discard block |
||
2439 | 2439 | * @param string $submit_field HTML markup for the submit field. |
2440 | 2440 | * @param array $args Arguments passed to comment_form(). |
2441 | 2441 | */ |
2442 | - echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); |
|
2442 | + echo apply_filters('comment_form_submit_field', $submit_field, $args); |
|
2443 | 2443 | |
2444 | 2444 | /** |
2445 | 2445 | * Fires at the bottom of the comment form, inside the closing </form> tag. |
@@ -2448,7 +2448,7 @@ discard block |
||
2448 | 2448 | * |
2449 | 2449 | * @param int $post_id The post ID. |
2450 | 2450 | */ |
2451 | - do_action( 'comment_form', $post_id ); |
|
2451 | + do_action('comment_form', $post_id); |
|
2452 | 2452 | ?> |
2453 | 2453 | </form> |
2454 | 2454 | <?php endif; ?> |
@@ -2460,5 +2460,5 @@ discard block |
||
2460 | 2460 | * |
2461 | 2461 | * @since 3.0.0 |
2462 | 2462 | */ |
2463 | - do_action( 'comment_form_after' ); |
|
2463 | + do_action('comment_form_after'); |
|
2464 | 2464 | } |
@@ -25,10 +25,11 @@ discard block |
||
25 | 25 | $comment = get_comment( $comment_ID ); |
26 | 26 | |
27 | 27 | if ( empty( $comment->comment_author ) ) { |
28 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
29 | - $author = $user->display_name; |
|
30 | - else |
|
31 | - $author = __('Anonymous'); |
|
28 | + if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { |
|
29 | + $author = $user->display_name; |
|
30 | + } else { |
|
31 | + $author = __('Anonymous'); |
|
32 | + } |
|
32 | 33 | } else { |
33 | 34 | $author = $comment->comment_author; |
34 | 35 | } |
@@ -218,10 +219,11 @@ discard block |
||
218 | 219 | $url = get_comment_author_url( $comment ); |
219 | 220 | $author = get_comment_author( $comment ); |
220 | 221 | |
221 | - if ( empty( $url ) || 'http://' == $url ) |
|
222 | - $return = $author; |
|
223 | - else |
|
224 | - $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
222 | + if ( empty( $url ) || 'http://' == $url ) { |
|
223 | + $return = $author; |
|
224 | + } else { |
|
225 | + $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
226 | + } |
|
225 | 227 | |
226 | 228 | /** |
227 | 229 | * Filters the comment author's link for display. |
@@ -428,11 +430,12 @@ discard block |
||
428 | 430 | function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
429 | 431 | // Separates classes with a single space, collates classes for comment DIV |
430 | 432 | $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
431 | - if ( $echo) |
|
432 | - echo $class; |
|
433 | - else |
|
434 | - return $class; |
|
435 | -} |
|
433 | + if ( $echo) { |
|
434 | + echo $class; |
|
435 | + } else { |
|
436 | + return $class; |
|
437 | + } |
|
438 | + } |
|
436 | 439 | |
437 | 440 | /** |
438 | 441 | * Returns the classes for the comment div as an array. |
@@ -474,12 +477,15 @@ discard block |
||
474 | 477 | } |
475 | 478 | } |
476 | 479 | |
477 | - if ( empty($comment_alt) ) |
|
478 | - $comment_alt = 0; |
|
479 | - if ( empty($comment_depth) ) |
|
480 | - $comment_depth = 1; |
|
481 | - if ( empty($comment_thread_alt) ) |
|
482 | - $comment_thread_alt = 0; |
|
480 | + if ( empty($comment_alt) ) { |
|
481 | + $comment_alt = 0; |
|
482 | + } |
|
483 | + if ( empty($comment_depth) ) { |
|
484 | + $comment_depth = 1; |
|
485 | + } |
|
486 | + if ( empty($comment_thread_alt) ) { |
|
487 | + $comment_thread_alt = 0; |
|
488 | + } |
|
483 | 489 | |
484 | 490 | if ( $comment_alt % 2 ) { |
485 | 491 | $classes[] = 'odd'; |
@@ -504,8 +510,9 @@ discard block |
||
504 | 510 | $classes[] = "depth-$comment_depth"; |
505 | 511 | |
506 | 512 | if ( !empty($class) ) { |
507 | - if ( !is_array( $class ) ) |
|
508 | - $class = preg_split('#\s+#', $class); |
|
513 | + if ( !is_array( $class ) ) { |
|
514 | + $class = preg_split('#\s+#', $class); |
|
515 | + } |
|
509 | 516 | $classes = array_merge($classes, $class); |
510 | 517 | } |
511 | 518 | |
@@ -538,10 +545,11 @@ discard block |
||
538 | 545 | */ |
539 | 546 | function get_comment_date( $d = '', $comment_ID = 0 ) { |
540 | 547 | $comment = get_comment( $comment_ID ); |
541 | - if ( '' == $d ) |
|
542 | - $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
543 | - else |
|
544 | - $date = mysql2date($d, $comment->comment_date); |
|
548 | + if ( '' == $d ) { |
|
549 | + $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
550 | + } else { |
|
551 | + $date = mysql2date($d, $comment->comment_date); |
|
552 | + } |
|
545 | 553 | /** |
546 | 554 | * Filters the returned comment date. |
547 | 555 | * |
@@ -822,10 +830,12 @@ discard block |
||
822 | 830 | * @param string $deprecated_2 Not Used. |
823 | 831 | */ |
824 | 832 | function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
825 | - if ( !empty( $deprecated ) ) |
|
826 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
827 | - if ( !empty( $deprecated_2 ) ) |
|
828 | - _deprecated_argument( __FUNCTION__, '1.3.0' ); |
|
833 | + if ( !empty( $deprecated ) ) { |
|
834 | + _deprecated_argument( __FUNCTION__, '0.72' ); |
|
835 | + } |
|
836 | + if ( !empty( $deprecated_2 ) ) { |
|
837 | + _deprecated_argument( __FUNCTION__, '1.3.0' ); |
|
838 | + } |
|
829 | 839 | echo esc_url( get_comments_link() ); |
830 | 840 | } |
831 | 841 | |
@@ -1010,10 +1020,11 @@ discard block |
||
1010 | 1020 | $comment = get_comment(); |
1011 | 1021 | |
1012 | 1022 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
1013 | - if ( '' == $d ) |
|
1014 | - $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
1015 | - else |
|
1016 | - $date = mysql2date($d, $comment_date, $translate); |
|
1023 | + if ( '' == $d ) { |
|
1024 | + $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
1025 | + } else { |
|
1026 | + $date = mysql2date($d, $comment_date, $translate); |
|
1027 | + } |
|
1017 | 1028 | |
1018 | 1029 | /** |
1019 | 1030 | * Filters the returned comment time. |
@@ -1052,8 +1063,9 @@ discard block |
||
1052 | 1063 | */ |
1053 | 1064 | function get_comment_type( $comment_ID = 0 ) { |
1054 | 1065 | $comment = get_comment( $comment_ID ); |
1055 | - if ( '' == $comment->comment_type ) |
|
1056 | - $comment->comment_type = 'comment'; |
|
1066 | + if ( '' == $comment->comment_type ) { |
|
1067 | + $comment->comment_type = 'comment'; |
|
1068 | + } |
|
1057 | 1069 | |
1058 | 1070 | /** |
1059 | 1071 | * Filters the returned comment type. |
@@ -1078,9 +1090,15 @@ discard block |
||
1078 | 1090 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
1079 | 1091 | */ |
1080 | 1092 | function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
1081 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
1082 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
1083 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
1093 | + if ( false === $commenttxt ) { |
|
1094 | + $commenttxt = _x( 'Comment', 'noun' ); |
|
1095 | + } |
|
1096 | + if ( false === $trackbacktxt ) { |
|
1097 | + $trackbacktxt = __( 'Trackback' ); |
|
1098 | + } |
|
1099 | + if ( false === $pingbacktxt ) { |
|
1100 | + $pingbacktxt = __( 'Pingback' ); |
|
1101 | + } |
|
1084 | 1102 | $type = get_comment_type(); |
1085 | 1103 | switch( $type ) { |
1086 | 1104 | case 'trackback' : |
@@ -1106,10 +1124,11 @@ discard block |
||
1106 | 1124 | * @return string The trackback URL after being filtered. |
1107 | 1125 | */ |
1108 | 1126 | function get_trackback_url() { |
1109 | - if ( '' != get_option('permalink_structure') ) |
|
1110 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
1111 | - else |
|
1112 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
1127 | + if ( '' != get_option('permalink_structure') ) { |
|
1128 | + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
1129 | + } else { |
|
1130 | + $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
1131 | + } |
|
1113 | 1132 | |
1114 | 1133 | /** |
1115 | 1134 | * Filters the returned trackback URL. |
@@ -1291,11 +1310,13 @@ discard block |
||
1291 | 1310 | function comments_template( $file = '/comments.php', $separate_comments = false ) { |
1292 | 1311 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
1293 | 1312 | |
1294 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
1295 | - return; |
|
1313 | + if ( !(is_single() || is_page() || $withcomments) || empty($post) ) { |
|
1314 | + return; |
|
1315 | + } |
|
1296 | 1316 | |
1297 | - if ( empty($file) ) |
|
1298 | - $file = '/comments.php'; |
|
1317 | + if ( empty($file) ) { |
|
1318 | + $file = '/comments.php'; |
|
1319 | + } |
|
1299 | 1320 | |
1300 | 1321 | $req = get_option('require_name_email'); |
1301 | 1322 | |
@@ -1453,8 +1474,9 @@ discard block |
||
1453 | 1474 | $overridden_cpage = true; |
1454 | 1475 | } |
1455 | 1476 | |
1456 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
1457 | - define('COMMENTS_TEMPLATE', true); |
|
1477 | + if ( !defined('COMMENTS_TEMPLATE') ) { |
|
1478 | + define('COMMENTS_TEMPLATE', true); |
|
1479 | + } |
|
1458 | 1480 | |
1459 | 1481 | $theme_template = STYLESHEETPATH . $file; |
1460 | 1482 | /** |
@@ -1465,13 +1487,15 @@ discard block |
||
1465 | 1487 | * @param string $theme_template The path to the theme template file. |
1466 | 1488 | */ |
1467 | 1489 | $include = apply_filters( 'comments_template', $theme_template ); |
1468 | - if ( file_exists( $include ) ) |
|
1469 | - require( $include ); |
|
1470 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
1471 | - require( TEMPLATEPATH . $file ); |
|
1472 | - else // Backward compat code will be removed in a future release |
|
1490 | + if ( file_exists( $include ) ) { |
|
1491 | + require( $include ); |
|
1492 | + } elseif ( file_exists( TEMPLATEPATH . $file ) ) { |
|
1493 | + require( TEMPLATEPATH . $file ); |
|
1494 | + } else { |
|
1495 | + // Backward compat code will be removed in a future release |
|
1473 | 1496 | require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
1474 | -} |
|
1497 | + } |
|
1498 | + } |
|
1475 | 1499 | |
1476 | 1500 | /** |
1477 | 1501 | * Displays the link to the comments for the current post ID. |
@@ -1774,8 +1798,9 @@ discard block |
||
1774 | 1798 | * @return string |
1775 | 1799 | */ |
1776 | 1800 | function get_cancel_comment_reply_link( $text = '' ) { |
1777 | - if ( empty($text) ) |
|
1778 | - $text = __('Click here to cancel reply.'); |
|
1801 | + if ( empty($text) ) { |
|
1802 | + $text = __('Click here to cancel reply.'); |
|
1803 | + } |
|
1779 | 1804 | |
1780 | 1805 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
1781 | 1806 | $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
@@ -1814,8 +1839,9 @@ discard block |
||
1814 | 1839 | * @return string Hidden input HTML for replying to comments |
1815 | 1840 | */ |
1816 | 1841 | function get_comment_id_fields( $id = 0 ) { |
1817 | - if ( empty( $id ) ) |
|
1818 | - $id = get_the_ID(); |
|
1842 | + if ( empty( $id ) ) { |
|
1843 | + $id = get_the_ID(); |
|
1844 | + } |
|
1819 | 1845 | |
1820 | 1846 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
1821 | 1847 | $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; |
@@ -1867,14 +1893,18 @@ discard block |
||
1867 | 1893 | function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
1868 | 1894 | global $comment; |
1869 | 1895 | |
1870 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
1871 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
1896 | + if ( false === $noreplytext ) { |
|
1897 | + $noreplytext = __( 'Leave a Reply' ); |
|
1898 | + } |
|
1899 | + if ( false === $replytext ) { |
|
1900 | + $replytext = __( 'Leave a Reply to %s' ); |
|
1901 | + } |
|
1872 | 1902 | |
1873 | 1903 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
1874 | 1904 | |
1875 | - if ( 0 == $replytoid ) |
|
1876 | - echo $noreplytext; |
|
1877 | - else { |
|
1905 | + if ( 0 == $replytoid ) { |
|
1906 | + echo $noreplytext; |
|
1907 | + } else { |
|
1878 | 1908 | // Sets the global so that template tags can be used in the comment form. |
1879 | 1909 | $comment = get_comment($replytoid); |
1880 | 1910 | $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
@@ -1961,12 +1991,14 @@ discard block |
||
1961 | 1991 | // Figure out what comments we'll be looping through ($_comments) |
1962 | 1992 | if ( null !== $comments ) { |
1963 | 1993 | $comments = (array) $comments; |
1964 | - if ( empty($comments) ) |
|
1965 | - return; |
|
1994 | + if ( empty($comments) ) { |
|
1995 | + return; |
|
1996 | + } |
|
1966 | 1997 | if ( 'all' != $r['type'] ) { |
1967 | 1998 | $comments_by_type = separate_comments($comments); |
1968 | - if ( empty($comments_by_type[$r['type']]) ) |
|
1969 | - return; |
|
1999 | + if ( empty($comments_by_type[$r['type']]) ) { |
|
2000 | + return; |
|
2001 | + } |
|
1970 | 2002 | $_comments = $comments_by_type[$r['type']]; |
1971 | 2003 | } else { |
1972 | 2004 | $_comments = $comments; |
@@ -2016,13 +2048,16 @@ discard block |
||
2016 | 2048 | |
2017 | 2049 | // Otherwise, fall back on the comments from `$wp_query->comments`. |
2018 | 2050 | } else { |
2019 | - if ( empty($wp_query->comments) ) |
|
2020 | - return; |
|
2051 | + if ( empty($wp_query->comments) ) { |
|
2052 | + return; |
|
2053 | + } |
|
2021 | 2054 | if ( 'all' != $r['type'] ) { |
2022 | - if ( empty($wp_query->comments_by_type) ) |
|
2023 | - $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
2024 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
2025 | - return; |
|
2055 | + if ( empty($wp_query->comments_by_type) ) { |
|
2056 | + $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
2057 | + } |
|
2058 | + if ( empty($wp_query->comments_by_type[$r['type']]) ) { |
|
2059 | + return; |
|
2060 | + } |
|
2026 | 2061 | $_comments = $wp_query->comments_by_type[$r['type']]; |
2027 | 2062 | } else { |
2028 | 2063 | $_comments = $wp_query->comments; |
@@ -2060,10 +2095,11 @@ discard block |
||
2060 | 2095 | } |
2061 | 2096 | |
2062 | 2097 | if ( '' === $r['max_depth'] ) { |
2063 | - if ( get_option('thread_comments') ) |
|
2064 | - $r['max_depth'] = get_option('thread_comments_depth'); |
|
2065 | - else |
|
2066 | - $r['max_depth'] = -1; |
|
2098 | + if ( get_option('thread_comments') ) { |
|
2099 | + $r['max_depth'] = get_option('thread_comments_depth'); |
|
2100 | + } else { |
|
2101 | + $r['max_depth'] = -1; |
|
2102 | + } |
|
2067 | 2103 | } |
2068 | 2104 | |
2069 | 2105 | if ( '' === $r['page'] ) { |
@@ -2077,11 +2113,13 @@ discard block |
||
2077 | 2113 | } |
2078 | 2114 | // Validation check |
2079 | 2115 | $r['page'] = intval($r['page']); |
2080 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
2081 | - $r['page'] = 1; |
|
2116 | + if ( 0 == $r['page'] && 0 != $r['per_page'] ) { |
|
2117 | + $r['page'] = 1; |
|
2118 | + } |
|
2082 | 2119 | |
2083 | - if ( null === $r['reverse_top_level'] ) |
|
2084 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
2120 | + if ( null === $r['reverse_top_level'] ) { |
|
2121 | + $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
2122 | + } |
|
2085 | 2123 | |
2086 | 2124 | wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
2087 | 2125 | |
@@ -2165,8 +2203,9 @@ discard block |
||
2165 | 2203 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
2166 | 2204 | */ |
2167 | 2205 | function comment_form( $args = array(), $post_id = null ) { |
2168 | - if ( null === $post_id ) |
|
2169 | - $post_id = get_the_ID(); |
|
2206 | + if ( null === $post_id ) { |
|
2207 | + $post_id = get_the_ID(); |
|
2208 | + } |
|
2170 | 2209 | |
2171 | 2210 | // Exit the function when comments for the post are closed. |
2172 | 2211 | if ( ! comments_open( $post_id ) ) { |
@@ -2185,8 +2224,9 @@ discard block |
||
2185 | 2224 | $user_identity = $user->exists() ? $user->display_name : ''; |
2186 | 2225 | |
2187 | 2226 | $args = wp_parse_args( $args ); |
2188 | - if ( ! isset( $args['format'] ) ) |
|
2189 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
2227 | + if ( ! isset( $args['format'] ) ) { |
|
2228 | + $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
2229 | + } |
|
2190 | 2230 | |
2191 | 2231 | $req = get_option( 'require_name_email' ); |
2192 | 2232 | $aria_req = ( $req ? " aria-required='true'" : '' ); |
@@ -2294,8 +2334,11 @@ discard block |
||
2294 | 2334 | * @since 3.0.0 |
2295 | 2335 | */ |
2296 | 2336 | do_action( 'comment_form_must_log_in_after' ); |
2297 | - else : ?> |
|
2298 | - <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
2337 | + else { |
|
2338 | + : ?> |
|
2339 | + <form action="<?php echo esc_url( $args['action'] ); |
|
2340 | + } |
|
2341 | + ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
2299 | 2342 | <?php |
2300 | 2343 | /** |
2301 | 2344 | * Fires at the top of the comment form, inside the form tag. |
@@ -2330,9 +2373,11 @@ discard block |
||
2330 | 2373 | */ |
2331 | 2374 | do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
2332 | 2375 | |
2333 | - else : |
|
2376 | + else { |
|
2377 | + : |
|
2334 | 2378 | |
2335 | 2379 | echo $args['comment_notes_before']; |
2380 | + } |
|
2336 | 2381 | |
2337 | 2382 | endif; |
2338 | 2383 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!function_exists('RandomCompat_strlen')) { |
|
29 | +if ( ! function_exists('RandomCompat_strlen')) { |
|
30 | 30 | if ( |
31 | 31 | defined('MB_OVERLOAD_STRING') && |
32 | 32 | ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function RandomCompat_strlen($binary_string) |
47 | 47 | { |
48 | - if (!is_string($binary_string)) { |
|
48 | + if ( ! is_string($binary_string)) { |
|
49 | 49 | throw new TypeError( |
50 | 50 | 'RandomCompat_strlen() expects a string' |
51 | 51 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function RandomCompat_strlen($binary_string) |
70 | 70 | { |
71 | - if (!is_string($binary_string)) { |
|
71 | + if ( ! is_string($binary_string)) { |
|
72 | 72 | throw new TypeError( |
73 | 73 | 'RandomCompat_strlen() expects a string' |
74 | 74 | ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | -if (!function_exists('RandomCompat_substr')) { |
|
81 | +if ( ! function_exists('RandomCompat_substr')) { |
|
82 | 82 | |
83 | 83 | if ( |
84 | 84 | defined('MB_OVERLOAD_STRING') |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function RandomCompat_substr($binary_string, $start, $length = null) |
103 | 103 | { |
104 | - if (!is_string($binary_string)) { |
|
104 | + if ( ! is_string($binary_string)) { |
|
105 | 105 | throw new TypeError( |
106 | 106 | 'RandomCompat_substr(): First argument should be a string' |
107 | 107 | ); |
108 | 108 | } |
109 | 109 | |
110 | - if (!is_int($start)) { |
|
110 | + if ( ! is_int($start)) { |
|
111 | 111 | throw new TypeError( |
112 | 112 | 'RandomCompat_substr(): Second argument should be an integer' |
113 | 113 | ); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * PHP 5.3, so we have to find the length ourselves. |
120 | 120 | */ |
121 | 121 | $length = RandomCompat_strlen($length) - $start; |
122 | - } elseif (!is_int($length)) { |
|
122 | + } elseif ( ! is_int($length)) { |
|
123 | 123 | throw new TypeError( |
124 | 124 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
125 | 125 | ); |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function RandomCompat_substr($binary_string, $start, $length = null) |
147 | 147 | { |
148 | - if (!is_string($binary_string)) { |
|
148 | + if ( ! is_string($binary_string)) { |
|
149 | 149 | throw new TypeError( |
150 | 150 | 'RandomCompat_substr(): First argument should be a string' |
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | - if (!is_int($start)) { |
|
154 | + if ( ! is_int($start)) { |
|
155 | 155 | throw new TypeError( |
156 | 156 | 'RandomCompat_substr(): Second argument should be an integer' |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | 160 | if ($length !== null) { |
161 | - if (!is_int($length)) { |
|
161 | + if ( ! is_int($length)) { |
|
162 | 162 | throw new TypeError( |
163 | 163 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
164 | 164 | ); |
@@ -27,147 +27,147 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!function_exists('RandomCompat_strlen')) { |
30 | - if ( |
|
31 | - defined('MB_OVERLOAD_STRING') && |
|
32 | - ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING |
|
33 | - ) { |
|
34 | - /** |
|
35 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
36 | - * |
|
37 | - * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
38 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
39 | - * |
|
40 | - * @param string $binary_string |
|
41 | - * |
|
42 | - * @throws TypeError |
|
43 | - * |
|
44 | - * @return int |
|
45 | - */ |
|
46 | - function RandomCompat_strlen($binary_string) |
|
47 | - { |
|
48 | - if (!is_string($binary_string)) { |
|
49 | - throw new TypeError( |
|
50 | - 'RandomCompat_strlen() expects a string' |
|
51 | - ); |
|
52 | - } |
|
30 | + if ( |
|
31 | + defined('MB_OVERLOAD_STRING') && |
|
32 | + ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING |
|
33 | + ) { |
|
34 | + /** |
|
35 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
36 | + * |
|
37 | + * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
38 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
39 | + * |
|
40 | + * @param string $binary_string |
|
41 | + * |
|
42 | + * @throws TypeError |
|
43 | + * |
|
44 | + * @return int |
|
45 | + */ |
|
46 | + function RandomCompat_strlen($binary_string) |
|
47 | + { |
|
48 | + if (!is_string($binary_string)) { |
|
49 | + throw new TypeError( |
|
50 | + 'RandomCompat_strlen() expects a string' |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | |
54 | - return mb_strlen($binary_string, '8bit'); |
|
55 | - } |
|
54 | + return mb_strlen($binary_string, '8bit'); |
|
55 | + } |
|
56 | 56 | |
57 | - } else { |
|
58 | - /** |
|
59 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
60 | - * |
|
61 | - * This version just used the default strlen() |
|
62 | - * |
|
63 | - * @param string $binary_string |
|
64 | - * |
|
65 | - * @throws TypeError |
|
66 | - * |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - function RandomCompat_strlen($binary_string) |
|
70 | - { |
|
71 | - if (!is_string($binary_string)) { |
|
72 | - throw new TypeError( |
|
73 | - 'RandomCompat_strlen() expects a string' |
|
74 | - ); |
|
75 | - } |
|
76 | - return strlen($binary_string); |
|
77 | - } |
|
78 | - } |
|
57 | + } else { |
|
58 | + /** |
|
59 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
60 | + * |
|
61 | + * This version just used the default strlen() |
|
62 | + * |
|
63 | + * @param string $binary_string |
|
64 | + * |
|
65 | + * @throws TypeError |
|
66 | + * |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + function RandomCompat_strlen($binary_string) |
|
70 | + { |
|
71 | + if (!is_string($binary_string)) { |
|
72 | + throw new TypeError( |
|
73 | + 'RandomCompat_strlen() expects a string' |
|
74 | + ); |
|
75 | + } |
|
76 | + return strlen($binary_string); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if (!function_exists('RandomCompat_substr')) { |
82 | 82 | |
83 | - if ( |
|
84 | - defined('MB_OVERLOAD_STRING') |
|
85 | - && |
|
86 | - ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING |
|
87 | - ) { |
|
88 | - /** |
|
89 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
90 | - * |
|
91 | - * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
92 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
93 | - * |
|
94 | - * @param string $binary_string |
|
95 | - * @param int $start |
|
96 | - * @param int $length (optional) |
|
97 | - * |
|
98 | - * @throws TypeError |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
103 | - { |
|
104 | - if (!is_string($binary_string)) { |
|
105 | - throw new TypeError( |
|
106 | - 'RandomCompat_substr(): First argument should be a string' |
|
107 | - ); |
|
108 | - } |
|
83 | + if ( |
|
84 | + defined('MB_OVERLOAD_STRING') |
|
85 | + && |
|
86 | + ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING |
|
87 | + ) { |
|
88 | + /** |
|
89 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
90 | + * |
|
91 | + * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
92 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
93 | + * |
|
94 | + * @param string $binary_string |
|
95 | + * @param int $start |
|
96 | + * @param int $length (optional) |
|
97 | + * |
|
98 | + * @throws TypeError |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
103 | + { |
|
104 | + if (!is_string($binary_string)) { |
|
105 | + throw new TypeError( |
|
106 | + 'RandomCompat_substr(): First argument should be a string' |
|
107 | + ); |
|
108 | + } |
|
109 | 109 | |
110 | - if (!is_int($start)) { |
|
111 | - throw new TypeError( |
|
112 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
113 | - ); |
|
114 | - } |
|
110 | + if (!is_int($start)) { |
|
111 | + throw new TypeError( |
|
112 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - if ($length === null) { |
|
117 | - /** |
|
118 | - * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
119 | - * PHP 5.3, so we have to find the length ourselves. |
|
120 | - */ |
|
121 | - $length = RandomCompat_strlen($length) - $start; |
|
122 | - } elseif (!is_int($length)) { |
|
123 | - throw new TypeError( |
|
124 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
125 | - ); |
|
126 | - } |
|
116 | + if ($length === null) { |
|
117 | + /** |
|
118 | + * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
119 | + * PHP 5.3, so we have to find the length ourselves. |
|
120 | + */ |
|
121 | + $length = RandomCompat_strlen($length) - $start; |
|
122 | + } elseif (!is_int($length)) { |
|
123 | + throw new TypeError( |
|
124 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
125 | + ); |
|
126 | + } |
|
127 | 127 | |
128 | - return mb_substr($binary_string, $start, $length, '8bit'); |
|
129 | - } |
|
128 | + return mb_substr($binary_string, $start, $length, '8bit'); |
|
129 | + } |
|
130 | 130 | |
131 | - } else { |
|
131 | + } else { |
|
132 | 132 | |
133 | - /** |
|
134 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
135 | - * |
|
136 | - * This version just uses the default substr() |
|
137 | - * |
|
138 | - * @param string $binary_string |
|
139 | - * @param int $start |
|
140 | - * @param int $length (optional) |
|
141 | - * |
|
142 | - * @throws TypeError |
|
143 | - * |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
147 | - { |
|
148 | - if (!is_string($binary_string)) { |
|
149 | - throw new TypeError( |
|
150 | - 'RandomCompat_substr(): First argument should be a string' |
|
151 | - ); |
|
152 | - } |
|
133 | + /** |
|
134 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
135 | + * |
|
136 | + * This version just uses the default substr() |
|
137 | + * |
|
138 | + * @param string $binary_string |
|
139 | + * @param int $start |
|
140 | + * @param int $length (optional) |
|
141 | + * |
|
142 | + * @throws TypeError |
|
143 | + * |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
147 | + { |
|
148 | + if (!is_string($binary_string)) { |
|
149 | + throw new TypeError( |
|
150 | + 'RandomCompat_substr(): First argument should be a string' |
|
151 | + ); |
|
152 | + } |
|
153 | 153 | |
154 | - if (!is_int($start)) { |
|
155 | - throw new TypeError( |
|
156 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
157 | - ); |
|
158 | - } |
|
154 | + if (!is_int($start)) { |
|
155 | + throw new TypeError( |
|
156 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
157 | + ); |
|
158 | + } |
|
159 | 159 | |
160 | - if ($length !== null) { |
|
161 | - if (!is_int($length)) { |
|
162 | - throw new TypeError( |
|
163 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
164 | - ); |
|
165 | - } |
|
160 | + if ($length !== null) { |
|
161 | + if (!is_int($length)) { |
|
162 | + throw new TypeError( |
|
163 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
164 | + ); |
|
165 | + } |
|
166 | 166 | |
167 | - return substr($binary_string, $start, $length); |
|
168 | - } |
|
167 | + return substr($binary_string, $start, $length); |
|
168 | + } |
|
169 | 169 | |
170 | - return substr($binary_string, $start); |
|
171 | - } |
|
172 | - } |
|
170 | + return substr($binary_string, $start); |
|
171 | + } |
|
172 | + } |
|
173 | 173 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
|
29 | +if ( ! defined('RANDOM_COMPAT_READ_BUFFER')) { |
|
30 | 30 | define('RANDOM_COMPAT_READ_BUFFER', 8); |
31 | 31 | } |
32 | 32 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * We never fall back to /dev/random |
56 | 56 | */ |
57 | 57 | $fp = fopen('/dev/urandom', 'rb'); |
58 | - if (!empty($fp)) { |
|
58 | + if ( ! empty($fp)) { |
|
59 | 59 | $st = fstat($fp); |
60 | 60 | if (($st['mode'] & 0170000) !== 020000) { |
61 | 61 | fclose($fp); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - if (!empty($fp)) { |
|
66 | + if ( ! empty($fp)) { |
|
67 | 67 | /** |
68 | 68 | * stream_set_read_buffer() does not exist in HHVM |
69 | 69 | * |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * if (empty($fp)) line is logic that should only be run once per |
103 | 103 | * page load. |
104 | 104 | */ |
105 | - if (!empty($fp)) { |
|
105 | + if ( ! empty($fp)) { |
|
106 | 106 | $remaining = $bytes; |
107 | 107 | $buf = ''; |
108 | 108 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
30 | - define('RANDOM_COMPAT_READ_BUFFER', 8); |
|
30 | + define('RANDOM_COMPAT_READ_BUFFER', 8); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -45,104 +45,104 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function random_bytes($bytes) |
47 | 47 | { |
48 | - static $fp = null; |
|
49 | - /** |
|
50 | - * This block should only be run once |
|
51 | - */ |
|
52 | - if (empty($fp)) { |
|
53 | - /** |
|
54 | - * We use /dev/urandom if it is a char device. |
|
55 | - * We never fall back to /dev/random |
|
56 | - */ |
|
57 | - $fp = fopen('/dev/urandom', 'rb'); |
|
58 | - if (!empty($fp)) { |
|
59 | - $st = fstat($fp); |
|
60 | - if (($st['mode'] & 0170000) !== 020000) { |
|
61 | - fclose($fp); |
|
62 | - $fp = false; |
|
63 | - } |
|
64 | - } |
|
48 | + static $fp = null; |
|
49 | + /** |
|
50 | + * This block should only be run once |
|
51 | + */ |
|
52 | + if (empty($fp)) { |
|
53 | + /** |
|
54 | + * We use /dev/urandom if it is a char device. |
|
55 | + * We never fall back to /dev/random |
|
56 | + */ |
|
57 | + $fp = fopen('/dev/urandom', 'rb'); |
|
58 | + if (!empty($fp)) { |
|
59 | + $st = fstat($fp); |
|
60 | + if (($st['mode'] & 0170000) !== 020000) { |
|
61 | + fclose($fp); |
|
62 | + $fp = false; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - if (!empty($fp)) { |
|
67 | - /** |
|
68 | - * stream_set_read_buffer() does not exist in HHVM |
|
69 | - * |
|
70 | - * If we don't set the stream's read buffer to 0, PHP will |
|
71 | - * internally buffer 8192 bytes, which can waste entropy |
|
72 | - * |
|
73 | - * stream_set_read_buffer returns 0 on success |
|
74 | - */ |
|
75 | - if (function_exists('stream_set_read_buffer')) { |
|
76 | - stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); |
|
77 | - } |
|
78 | - if (function_exists('stream_set_chunk_size')) { |
|
79 | - stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
66 | + if (!empty($fp)) { |
|
67 | + /** |
|
68 | + * stream_set_read_buffer() does not exist in HHVM |
|
69 | + * |
|
70 | + * If we don't set the stream's read buffer to 0, PHP will |
|
71 | + * internally buffer 8192 bytes, which can waste entropy |
|
72 | + * |
|
73 | + * stream_set_read_buffer returns 0 on success |
|
74 | + */ |
|
75 | + if (function_exists('stream_set_read_buffer')) { |
|
76 | + stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER); |
|
77 | + } |
|
78 | + if (function_exists('stream_set_chunk_size')) { |
|
79 | + stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER); |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - try { |
|
85 | - $bytes = RandomCompat_intval($bytes); |
|
86 | - } catch (TypeError $ex) { |
|
87 | - throw new TypeError( |
|
88 | - 'random_bytes(): $bytes must be an integer' |
|
89 | - ); |
|
90 | - } |
|
84 | + try { |
|
85 | + $bytes = RandomCompat_intval($bytes); |
|
86 | + } catch (TypeError $ex) { |
|
87 | + throw new TypeError( |
|
88 | + 'random_bytes(): $bytes must be an integer' |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | |
92 | - if ($bytes < 1) { |
|
93 | - throw new Error( |
|
94 | - 'Length must be greater than 0' |
|
95 | - ); |
|
96 | - } |
|
92 | + if ($bytes < 1) { |
|
93 | + throw new Error( |
|
94 | + 'Length must be greater than 0' |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * This if() block only runs if we managed to open a file handle |
|
100 | - * |
|
101 | - * It does not belong in an else {} block, because the above |
|
102 | - * if (empty($fp)) line is logic that should only be run once per |
|
103 | - * page load. |
|
104 | - */ |
|
105 | - if (!empty($fp)) { |
|
106 | - $remaining = $bytes; |
|
107 | - $buf = ''; |
|
98 | + /** |
|
99 | + * This if() block only runs if we managed to open a file handle |
|
100 | + * |
|
101 | + * It does not belong in an else {} block, because the above |
|
102 | + * if (empty($fp)) line is logic that should only be run once per |
|
103 | + * page load. |
|
104 | + */ |
|
105 | + if (!empty($fp)) { |
|
106 | + $remaining = $bytes; |
|
107 | + $buf = ''; |
|
108 | 108 | |
109 | - /** |
|
110 | - * We use fread() in a loop to protect against partial reads |
|
111 | - */ |
|
112 | - do { |
|
113 | - $read = fread($fp, $remaining); |
|
114 | - if ($read === false) { |
|
115 | - /** |
|
116 | - * We cannot safely read from the file. Exit the |
|
117 | - * do-while loop and trigger the exception condition |
|
118 | - */ |
|
119 | - $buf = false; |
|
120 | - break; |
|
121 | - } |
|
122 | - /** |
|
123 | - * Decrease the number of bytes returned from remaining |
|
124 | - */ |
|
125 | - $remaining -= RandomCompat_strlen($read); |
|
126 | - $buf .= $read; |
|
127 | - } while ($remaining > 0); |
|
109 | + /** |
|
110 | + * We use fread() in a loop to protect against partial reads |
|
111 | + */ |
|
112 | + do { |
|
113 | + $read = fread($fp, $remaining); |
|
114 | + if ($read === false) { |
|
115 | + /** |
|
116 | + * We cannot safely read from the file. Exit the |
|
117 | + * do-while loop and trigger the exception condition |
|
118 | + */ |
|
119 | + $buf = false; |
|
120 | + break; |
|
121 | + } |
|
122 | + /** |
|
123 | + * Decrease the number of bytes returned from remaining |
|
124 | + */ |
|
125 | + $remaining -= RandomCompat_strlen($read); |
|
126 | + $buf .= $read; |
|
127 | + } while ($remaining > 0); |
|
128 | 128 | |
129 | - /** |
|
130 | - * Is our result valid? |
|
131 | - */ |
|
132 | - if ($buf !== false) { |
|
133 | - if (RandomCompat_strlen($buf) === $bytes) { |
|
134 | - /** |
|
135 | - * Return our random entropy buffer here: |
|
136 | - */ |
|
137 | - return $buf; |
|
138 | - } |
|
139 | - } |
|
140 | - } |
|
129 | + /** |
|
130 | + * Is our result valid? |
|
131 | + */ |
|
132 | + if ($buf !== false) { |
|
133 | + if (RandomCompat_strlen($buf) === $bytes) { |
|
134 | + /** |
|
135 | + * Return our random entropy buffer here: |
|
136 | + */ |
|
137 | + return $buf; |
|
138 | + } |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * If we reach here, PHP has failed us. |
|
144 | - */ |
|
145 | - throw new Exception( |
|
146 | - 'Error reading from source device' |
|
147 | - ); |
|
142 | + /** |
|
143 | + * If we reach here, PHP has failed us. |
|
144 | + */ |
|
145 | + throw new Exception( |
|
146 | + 'Error reading from source device' |
|
147 | + ); |
|
148 | 148 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Test for integer overflow: |
101 | 101 | */ |
102 | - if (!is_int($range)) { |
|
102 | + if ( ! is_int($range)) { |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Still safely calculate wider ranges. |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * ... or smaller than $min, |
186 | 186 | * then try again. |
187 | 187 | */ |
188 | - } while (!is_int($val) || $val > $max || $val < $min); |
|
188 | + } while ( ! is_int($val) || $val > $max || $val < $min); |
|
189 | 189 | |
190 | 190 | return (int) $val; |
191 | 191 | } |
@@ -38,154 +38,154 @@ |
||
38 | 38 | */ |
39 | 39 | function random_int($min, $max) |
40 | 40 | { |
41 | - /** |
|
42 | - * Type and input logic checks |
|
43 | - * |
|
44 | - * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
45 | - * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
46 | - * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
47 | - * lose precision, so the <= and => operators might accidentally let a float |
|
48 | - * through. |
|
49 | - */ |
|
41 | + /** |
|
42 | + * Type and input logic checks |
|
43 | + * |
|
44 | + * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
45 | + * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
46 | + * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
47 | + * lose precision, so the <= and => operators might accidentally let a float |
|
48 | + * through. |
|
49 | + */ |
|
50 | 50 | |
51 | - try { |
|
52 | - $min = RandomCompat_intval($min); |
|
53 | - } catch (TypeError $ex) { |
|
54 | - throw new TypeError( |
|
55 | - 'random_int(): $min must be an integer' |
|
56 | - ); |
|
57 | - } |
|
51 | + try { |
|
52 | + $min = RandomCompat_intval($min); |
|
53 | + } catch (TypeError $ex) { |
|
54 | + throw new TypeError( |
|
55 | + 'random_int(): $min must be an integer' |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | - try { |
|
60 | - $max = RandomCompat_intval($max); |
|
61 | - } catch (TypeError $ex) { |
|
62 | - throw new TypeError( |
|
63 | - 'random_int(): $max must be an integer' |
|
64 | - ); |
|
65 | - } |
|
59 | + try { |
|
60 | + $max = RandomCompat_intval($max); |
|
61 | + } catch (TypeError $ex) { |
|
62 | + throw new TypeError( |
|
63 | + 'random_int(): $max must be an integer' |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Now that we've verified our weak typing system has given us an integer, |
|
69 | - * let's validate the logic then we can move forward with generating random |
|
70 | - * integers along a given range. |
|
71 | - */ |
|
72 | - if ($min > $max) { |
|
73 | - throw new Error( |
|
74 | - 'Minimum value must be less than or equal to the maximum value' |
|
75 | - ); |
|
76 | - } |
|
67 | + /** |
|
68 | + * Now that we've verified our weak typing system has given us an integer, |
|
69 | + * let's validate the logic then we can move forward with generating random |
|
70 | + * integers along a given range. |
|
71 | + */ |
|
72 | + if ($min > $max) { |
|
73 | + throw new Error( |
|
74 | + 'Minimum value must be less than or equal to the maximum value' |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - if ($max === $min) { |
|
79 | - return $min; |
|
80 | - } |
|
78 | + if ($max === $min) { |
|
79 | + return $min; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Initialize variables to 0 |
|
84 | - * |
|
85 | - * We want to store: |
|
86 | - * $bytes => the number of random bytes we need |
|
87 | - * $mask => an integer bitmask (for use with the &) operator |
|
88 | - * so we can minimize the number of discards |
|
89 | - */ |
|
90 | - $attempts = $bits = $bytes = $mask = $valueShift = 0; |
|
82 | + /** |
|
83 | + * Initialize variables to 0 |
|
84 | + * |
|
85 | + * We want to store: |
|
86 | + * $bytes => the number of random bytes we need |
|
87 | + * $mask => an integer bitmask (for use with the &) operator |
|
88 | + * so we can minimize the number of discards |
|
89 | + */ |
|
90 | + $attempts = $bits = $bytes = $mask = $valueShift = 0; |
|
91 | 91 | |
92 | - /** |
|
93 | - * At this point, $range is a positive number greater than 0. It might |
|
94 | - * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to |
|
95 | - * a float and we will lose some precision. |
|
96 | - */ |
|
97 | - $range = $max - $min; |
|
92 | + /** |
|
93 | + * At this point, $range is a positive number greater than 0. It might |
|
94 | + * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to |
|
95 | + * a float and we will lose some precision. |
|
96 | + */ |
|
97 | + $range = $max - $min; |
|
98 | 98 | |
99 | - /** |
|
100 | - * Test for integer overflow: |
|
101 | - */ |
|
102 | - if (!is_int($range)) { |
|
99 | + /** |
|
100 | + * Test for integer overflow: |
|
101 | + */ |
|
102 | + if (!is_int($range)) { |
|
103 | 103 | |
104 | - /** |
|
105 | - * Still safely calculate wider ranges. |
|
106 | - * Provided by @CodesInChaos, @oittaa |
|
107 | - * |
|
108 | - * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435 |
|
109 | - * |
|
110 | - * We use ~0 as a mask in this case because it generates all 1s |
|
111 | - * |
|
112 | - * @ref https://eval.in/400356 (32-bit) |
|
113 | - * @ref http://3v4l.org/XX9r5 (64-bit) |
|
114 | - */ |
|
115 | - $bytes = PHP_INT_SIZE; |
|
116 | - $mask = ~0; |
|
104 | + /** |
|
105 | + * Still safely calculate wider ranges. |
|
106 | + * Provided by @CodesInChaos, @oittaa |
|
107 | + * |
|
108 | + * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435 |
|
109 | + * |
|
110 | + * We use ~0 as a mask in this case because it generates all 1s |
|
111 | + * |
|
112 | + * @ref https://eval.in/400356 (32-bit) |
|
113 | + * @ref http://3v4l.org/XX9r5 (64-bit) |
|
114 | + */ |
|
115 | + $bytes = PHP_INT_SIZE; |
|
116 | + $mask = ~0; |
|
117 | 117 | |
118 | - } else { |
|
118 | + } else { |
|
119 | 119 | |
120 | - /** |
|
121 | - * $bits is effectively ceil(log($range, 2)) without dealing with |
|
122 | - * type juggling |
|
123 | - */ |
|
124 | - while ($range > 0) { |
|
125 | - if ($bits % 8 === 0) { |
|
126 | - ++$bytes; |
|
127 | - } |
|
128 | - ++$bits; |
|
129 | - $range >>= 1; |
|
130 | - $mask = $mask << 1 | 1; |
|
131 | - } |
|
132 | - $valueShift = $min; |
|
133 | - } |
|
120 | + /** |
|
121 | + * $bits is effectively ceil(log($range, 2)) without dealing with |
|
122 | + * type juggling |
|
123 | + */ |
|
124 | + while ($range > 0) { |
|
125 | + if ($bits % 8 === 0) { |
|
126 | + ++$bytes; |
|
127 | + } |
|
128 | + ++$bits; |
|
129 | + $range >>= 1; |
|
130 | + $mask = $mask << 1 | 1; |
|
131 | + } |
|
132 | + $valueShift = $min; |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Now that we have our parameters set up, let's begin generating |
|
137 | - * random integers until one falls between $min and $max |
|
138 | - */ |
|
139 | - do { |
|
140 | - /** |
|
141 | - * The rejection probability is at most 0.5, so this corresponds |
|
142 | - * to a failure probability of 2^-128 for a working RNG |
|
143 | - */ |
|
144 | - if ($attempts > 128) { |
|
145 | - throw new Exception( |
|
146 | - 'random_int: RNG is broken - too many rejections' |
|
147 | - ); |
|
148 | - } |
|
135 | + /** |
|
136 | + * Now that we have our parameters set up, let's begin generating |
|
137 | + * random integers until one falls between $min and $max |
|
138 | + */ |
|
139 | + do { |
|
140 | + /** |
|
141 | + * The rejection probability is at most 0.5, so this corresponds |
|
142 | + * to a failure probability of 2^-128 for a working RNG |
|
143 | + */ |
|
144 | + if ($attempts > 128) { |
|
145 | + throw new Exception( |
|
146 | + 'random_int: RNG is broken - too many rejections' |
|
147 | + ); |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Let's grab the necessary number of random bytes |
|
152 | - */ |
|
153 | - $randomByteString = random_bytes($bytes); |
|
154 | - if ($randomByteString === false) { |
|
155 | - throw new Exception( |
|
156 | - 'Random number generator failure' |
|
157 | - ); |
|
158 | - } |
|
150 | + /** |
|
151 | + * Let's grab the necessary number of random bytes |
|
152 | + */ |
|
153 | + $randomByteString = random_bytes($bytes); |
|
154 | + if ($randomByteString === false) { |
|
155 | + throw new Exception( |
|
156 | + 'Random number generator failure' |
|
157 | + ); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * Let's turn $randomByteString into an integer |
|
162 | - * |
|
163 | - * This uses bitwise operators (<< and |) to build an integer |
|
164 | - * out of the values extracted from ord() |
|
165 | - * |
|
166 | - * Example: [9F] | [6D] | [32] | [0C] => |
|
167 | - * 159 + 27904 + 3276800 + 201326592 => |
|
168 | - * 204631455 |
|
169 | - */ |
|
170 | - $val = 0; |
|
171 | - for ($i = 0; $i < $bytes; ++$i) { |
|
172 | - $val |= ord($randomByteString[$i]) << ($i * 8); |
|
173 | - } |
|
160 | + /** |
|
161 | + * Let's turn $randomByteString into an integer |
|
162 | + * |
|
163 | + * This uses bitwise operators (<< and |) to build an integer |
|
164 | + * out of the values extracted from ord() |
|
165 | + * |
|
166 | + * Example: [9F] | [6D] | [32] | [0C] => |
|
167 | + * 159 + 27904 + 3276800 + 201326592 => |
|
168 | + * 204631455 |
|
169 | + */ |
|
170 | + $val = 0; |
|
171 | + for ($i = 0; $i < $bytes; ++$i) { |
|
172 | + $val |= ord($randomByteString[$i]) << ($i * 8); |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Apply mask |
|
177 | - */ |
|
178 | - $val &= $mask; |
|
179 | - $val += $valueShift; |
|
175 | + /** |
|
176 | + * Apply mask |
|
177 | + */ |
|
178 | + $val &= $mask; |
|
179 | + $val += $valueShift; |
|
180 | 180 | |
181 | - ++$attempts; |
|
182 | - /** |
|
183 | - * If $val overflows to a floating point number, |
|
184 | - * ... or is larger than $max, |
|
185 | - * ... or smaller than $min, |
|
186 | - * then try again. |
|
187 | - */ |
|
188 | - } while (!is_int($val) || $val > $max || $val < $min); |
|
181 | + ++$attempts; |
|
182 | + /** |
|
183 | + * If $val overflows to a floating point number, |
|
184 | + * ... or is larger than $max, |
|
185 | + * ... or smaller than $min, |
|
186 | + * then try again. |
|
187 | + */ |
|
188 | + } while (!is_int($val) || $val > $max || $val < $min); |
|
189 | 189 | |
190 | - return (int) $val; |
|
190 | + return (int) $val; |
|
191 | 191 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!function_exists('RandomCompat_intval')) { |
|
29 | +if ( ! function_exists('RandomCompat_intval')) { |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Cast to an integer if we can, safely. |
@@ -28,44 +28,44 @@ |
||
28 | 28 | |
29 | 29 | if (!function_exists('RandomCompat_intval')) { |
30 | 30 | |
31 | - /** |
|
32 | - * Cast to an integer if we can, safely. |
|
33 | - * |
|
34 | - * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
35 | - * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
36 | - * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
37 | - * lose precision, so the <= and => operators might accidentally let a float |
|
38 | - * through. |
|
39 | - * |
|
40 | - * @param int|float $number The number we want to convert to an int |
|
41 | - * @param boolean $fail_open Set to true to not throw an exception |
|
42 | - * |
|
43 | - * @return int (or float if $fail_open) |
|
44 | - * |
|
45 | - * @throws TypeError |
|
46 | - */ |
|
47 | - function RandomCompat_intval($number, $fail_open = false) |
|
48 | - { |
|
49 | - if (is_numeric($number)) { |
|
50 | - $number += 0; |
|
51 | - } |
|
31 | + /** |
|
32 | + * Cast to an integer if we can, safely. |
|
33 | + * |
|
34 | + * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX) |
|
35 | + * (non-inclusive), it will sanely cast it to an int. If you it's equal to |
|
36 | + * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats |
|
37 | + * lose precision, so the <= and => operators might accidentally let a float |
|
38 | + * through. |
|
39 | + * |
|
40 | + * @param int|float $number The number we want to convert to an int |
|
41 | + * @param boolean $fail_open Set to true to not throw an exception |
|
42 | + * |
|
43 | + * @return int (or float if $fail_open) |
|
44 | + * |
|
45 | + * @throws TypeError |
|
46 | + */ |
|
47 | + function RandomCompat_intval($number, $fail_open = false) |
|
48 | + { |
|
49 | + if (is_numeric($number)) { |
|
50 | + $number += 0; |
|
51 | + } |
|
52 | 52 | |
53 | - if ( |
|
54 | - is_float($number) |
|
55 | - && |
|
56 | - $number > ~PHP_INT_MAX |
|
57 | - && |
|
58 | - $number < PHP_INT_MAX |
|
59 | - ) { |
|
60 | - $number = (int) $number; |
|
61 | - } |
|
53 | + if ( |
|
54 | + is_float($number) |
|
55 | + && |
|
56 | + $number > ~PHP_INT_MAX |
|
57 | + && |
|
58 | + $number < PHP_INT_MAX |
|
59 | + ) { |
|
60 | + $number = (int) $number; |
|
61 | + } |
|
62 | 62 | |
63 | - if (is_int($number) || $fail_open) { |
|
64 | - return $number; |
|
65 | - } |
|
63 | + if (is_int($number) || $fail_open) { |
|
64 | + return $number; |
|
65 | + } |
|
66 | 66 | |
67 | - throw new TypeError( |
|
68 | - 'Expected an integer.' |
|
69 | - ); |
|
70 | - } |
|
67 | + throw new TypeError( |
|
68 | + 'Expected an integer.' |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!class_exists('Error', false)) { |
|
29 | +if ( ! class_exists('Error', false)) { |
|
30 | 30 | // We can't really avoid making this extend Exception in PHP 5. |
31 | 31 | class Error extends Exception |
32 | 32 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | -if (!class_exists('TypeError', false)) { |
|
37 | +if ( ! class_exists('TypeError', false)) { |
|
38 | 38 | class TypeError extends Error |
39 | 39 | { |
40 | 40 |
@@ -27,16 +27,16 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!class_exists('Error', false)) { |
30 | - // We can't really avoid making this extend Exception in PHP 5. |
|
31 | - class Error extends Exception |
|
32 | - { |
|
30 | + // We can't really avoid making this extend Exception in PHP 5. |
|
31 | + class Error extends Exception |
|
32 | + { |
|
33 | 33 | |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | if (!class_exists('TypeError', false)) { |
38 | - class TypeError extends Error |
|
39 | - { |
|
38 | + class TypeError extends Error |
|
39 | + { |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | } |
@@ -90,8 +90,9 @@ discard block |
||
90 | 90 | function get_category( $category, $output = OBJECT, $filter = 'raw' ) { |
91 | 91 | $category = get_term( $category, 'category', $output, $filter ); |
92 | 92 | |
93 | - if ( is_wp_error( $category ) ) |
|
94 | - return $category; |
|
93 | + if ( is_wp_error( $category ) ) { |
|
94 | + return $category; |
|
95 | + } |
|
95 | 96 | |
96 | 97 | _make_cat_compat( $category ); |
97 | 98 | |
@@ -170,8 +171,9 @@ discard block |
||
170 | 171 | */ |
171 | 172 | function get_category_by_slug( $slug ) { |
172 | 173 | $category = get_term_by( 'slug', $slug, 'category' ); |
173 | - if ( $category ) |
|
174 | - _make_cat_compat( $category ); |
|
174 | + if ( $category ) { |
|
175 | + _make_cat_compat( $category ); |
|
176 | + } |
|
175 | 177 | |
176 | 178 | return $category; |
177 | 179 | } |
@@ -186,8 +188,9 @@ discard block |
||
186 | 188 | */ |
187 | 189 | function get_cat_ID( $cat_name ) { |
188 | 190 | $cat = get_term_by( 'name', $cat_name, 'category' ); |
189 | - if ( $cat ) |
|
190 | - return $cat->term_id; |
|
191 | + if ( $cat ) { |
|
192 | + return $cat->term_id; |
|
193 | + } |
|
191 | 194 | return 0; |
192 | 195 | } |
193 | 196 | |
@@ -202,8 +205,9 @@ discard block |
||
202 | 205 | function get_cat_name( $cat_id ) { |
203 | 206 | $cat_id = (int) $cat_id; |
204 | 207 | $category = get_term( $cat_id, 'category' ); |
205 | - if ( ! $category || is_wp_error( $category ) ) |
|
206 | - return ''; |
|
208 | + if ( ! $category || is_wp_error( $category ) ) { |
|
209 | + return ''; |
|
210 | + } |
|
207 | 211 | return $category->name; |
208 | 212 | } |
209 | 213 |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | * } |
24 | 24 | * @return array List of categories. |
25 | 25 | */ |
26 | -function get_categories( $args = '' ) { |
|
27 | - $defaults = array( 'taxonomy' => 'category' ); |
|
28 | - $args = wp_parse_args( $args, $defaults ); |
|
26 | +function get_categories($args = '') { |
|
27 | + $defaults = array('taxonomy' => 'category'); |
|
28 | + $args = wp_parse_args($args, $defaults); |
|
29 | 29 | |
30 | 30 | $taxonomy = $args['taxonomy']; |
31 | 31 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | * @param string $taxonomy Taxonomy to retrieve terms from. |
38 | 38 | * @param array $args An array of arguments. See get_terms(). |
39 | 39 | */ |
40 | - $taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args ); |
|
40 | + $taxonomy = apply_filters('get_categories_taxonomy', $taxonomy, $args); |
|
41 | 41 | |
42 | 42 | // Back compat |
43 | - if ( isset($args['type']) && 'link' == $args['type'] ) { |
|
43 | + if (isset($args['type']) && 'link' == $args['type']) { |
|
44 | 44 | /* translators: 1: "type => link", 2: "taxonomy => link_category" alternative */ |
45 | - _deprecated_argument( __FUNCTION__, '3.0.0', |
|
46 | - sprintf( __( '%1$s is deprecated. Use %2$s instead.' ), |
|
45 | + _deprecated_argument(__FUNCTION__, '3.0.0', |
|
46 | + sprintf(__('%1$s is deprecated. Use %2$s instead.'), |
|
47 | 47 | '<code>type => link</code>', |
48 | 48 | '<code>taxonomy => link_category</code>' |
49 | 49 | ) |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $taxonomy = $args['taxonomy'] = 'link_category'; |
52 | 52 | } |
53 | 53 | |
54 | - $categories = get_terms( $taxonomy, $args ); |
|
54 | + $categories = get_terms($taxonomy, $args); |
|
55 | 55 | |
56 | - if ( is_wp_error( $categories ) ) { |
|
56 | + if (is_wp_error($categories)) { |
|
57 | 57 | $categories = array(); |
58 | 58 | } else { |
59 | 59 | $categories = (array) $categories; |
60 | - foreach ( array_keys( $categories ) as $k ) { |
|
61 | - _make_cat_compat( $categories[ $k ] ); |
|
60 | + foreach (array_keys($categories) as $k) { |
|
61 | + _make_cat_compat($categories[$k]); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | * @return object|array|WP_Error|null Category data in type defined by $output parameter. |
88 | 88 | * WP_Error if $category is empty, null if it does not exist. |
89 | 89 | */ |
90 | -function get_category( $category, $output = OBJECT, $filter = 'raw' ) { |
|
91 | - $category = get_term( $category, 'category', $output, $filter ); |
|
90 | +function get_category($category, $output = OBJECT, $filter = 'raw') { |
|
91 | + $category = get_term($category, 'category', $output, $filter); |
|
92 | 92 | |
93 | - if ( is_wp_error( $category ) ) |
|
93 | + if (is_wp_error($category)) |
|
94 | 94 | return $category; |
95 | 95 | |
96 | - _make_cat_compat( $category ); |
|
96 | + _make_cat_compat($category); |
|
97 | 97 | |
98 | 98 | return $category; |
99 | 99 | } |
@@ -117,45 +117,45 @@ discard block |
||
117 | 117 | * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N |
118 | 118 | * @return object|array|WP_Error|void Type is based on $output value. |
119 | 119 | */ |
120 | -function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) { |
|
121 | - $category_path = rawurlencode( urldecode( $category_path ) ); |
|
122 | - $category_path = str_replace( '%2F', '/', $category_path ); |
|
123 | - $category_path = str_replace( '%20', ' ', $category_path ); |
|
124 | - $category_paths = '/' . trim( $category_path, '/' ); |
|
125 | - $leaf_path = sanitize_title( basename( $category_paths ) ); |
|
126 | - $category_paths = explode( '/', $category_paths ); |
|
120 | +function get_category_by_path($category_path, $full_match = true, $output = OBJECT) { |
|
121 | + $category_path = rawurlencode(urldecode($category_path)); |
|
122 | + $category_path = str_replace('%2F', '/', $category_path); |
|
123 | + $category_path = str_replace('%20', ' ', $category_path); |
|
124 | + $category_paths = '/'.trim($category_path, '/'); |
|
125 | + $leaf_path = sanitize_title(basename($category_paths)); |
|
126 | + $category_paths = explode('/', $category_paths); |
|
127 | 127 | $full_path = ''; |
128 | - foreach ( (array) $category_paths as $pathdir ) { |
|
129 | - $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir ); |
|
128 | + foreach ((array) $category_paths as $pathdir) { |
|
129 | + $full_path .= ($pathdir != '' ? '/' : '').sanitize_title($pathdir); |
|
130 | 130 | } |
131 | - $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) ); |
|
131 | + $categories = get_terms('category', array('get' => 'all', 'slug' => $leaf_path)); |
|
132 | 132 | |
133 | - if ( empty( $categories ) ) { |
|
133 | + if (empty($categories)) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - foreach ( $categories as $category ) { |
|
138 | - $path = '/' . $leaf_path; |
|
137 | + foreach ($categories as $category) { |
|
138 | + $path = '/'.$leaf_path; |
|
139 | 139 | $curcategory = $category; |
140 | - while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) { |
|
141 | - $curcategory = get_term( $curcategory->parent, 'category' ); |
|
142 | - if ( is_wp_error( $curcategory ) ) { |
|
140 | + while (($curcategory->parent != 0) && ($curcategory->parent != $curcategory->term_id)) { |
|
141 | + $curcategory = get_term($curcategory->parent, 'category'); |
|
142 | + if (is_wp_error($curcategory)) { |
|
143 | 143 | return $curcategory; |
144 | 144 | } |
145 | - $path = '/' . $curcategory->slug . $path; |
|
145 | + $path = '/'.$curcategory->slug.$path; |
|
146 | 146 | } |
147 | 147 | |
148 | - if ( $path == $full_path ) { |
|
149 | - $category = get_term( $category->term_id, 'category', $output ); |
|
150 | - _make_cat_compat( $category ); |
|
148 | + if ($path == $full_path) { |
|
149 | + $category = get_term($category->term_id, 'category', $output); |
|
150 | + _make_cat_compat($category); |
|
151 | 151 | return $category; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | // If full matching is not required, return the first cat that matches the leaf. |
156 | - if ( ! $full_match ) { |
|
157 | - $category = get_term( reset( $categories )->term_id, 'category', $output ); |
|
158 | - _make_cat_compat( $category ); |
|
156 | + if ( ! $full_match) { |
|
157 | + $category = get_term(reset($categories)->term_id, 'category', $output); |
|
158 | + _make_cat_compat($category); |
|
159 | 159 | return $category; |
160 | 160 | } |
161 | 161 | } |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | * @param string $slug The category slug. |
169 | 169 | * @return object Category data object |
170 | 170 | */ |
171 | -function get_category_by_slug( $slug ) { |
|
172 | - $category = get_term_by( 'slug', $slug, 'category' ); |
|
173 | - if ( $category ) |
|
174 | - _make_cat_compat( $category ); |
|
171 | +function get_category_by_slug($slug) { |
|
172 | + $category = get_term_by('slug', $slug, 'category'); |
|
173 | + if ($category) |
|
174 | + _make_cat_compat($category); |
|
175 | 175 | |
176 | 176 | return $category; |
177 | 177 | } |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @param string $cat_name Category name. |
185 | 185 | * @return int 0, if failure and ID of category on success. |
186 | 186 | */ |
187 | -function get_cat_ID( $cat_name ) { |
|
188 | - $cat = get_term_by( 'name', $cat_name, 'category' ); |
|
189 | - if ( $cat ) |
|
187 | +function get_cat_ID($cat_name) { |
|
188 | + $cat = get_term_by('name', $cat_name, 'category'); |
|
189 | + if ($cat) |
|
190 | 190 | return $cat->term_id; |
191 | 191 | return 0; |
192 | 192 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $cat_id Category ID |
200 | 200 | * @return string Category name, or an empty string if category doesn't exist. |
201 | 201 | */ |
202 | -function get_cat_name( $cat_id ) { |
|
202 | +function get_cat_name($cat_id) { |
|
203 | 203 | $cat_id = (int) $cat_id; |
204 | - $category = get_term( $cat_id, 'category' ); |
|
205 | - if ( ! $category || is_wp_error( $category ) ) |
|
204 | + $category = get_term($cat_id, 'category'); |
|
205 | + if ( ! $category || is_wp_error($category)) |
|
206 | 206 | return ''; |
207 | 207 | return $category->name; |
208 | 208 | } |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * @param int|object $cat2 The child category. |
220 | 220 | * @return bool Whether $cat2 is child of $cat1 |
221 | 221 | */ |
222 | -function cat_is_ancestor_of( $cat1, $cat2 ) { |
|
223 | - return term_is_ancestor_of( $cat1, $cat2, 'category' ); |
|
222 | +function cat_is_ancestor_of($cat1, $cat2) { |
|
223 | + return term_is_ancestor_of($cat1, $cat2, 'category'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @param string $context Optional. Default is 'display'. |
233 | 233 | * @return object|array Same type as $category with sanitized data for safe use. |
234 | 234 | */ |
235 | -function sanitize_category( $category, $context = 'display' ) { |
|
236 | - return sanitize_term( $category, 'category', $context ); |
|
235 | +function sanitize_category($category, $context = 'display') { |
|
236 | + return sanitize_term($category, 'category', $context); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param string $context What filter to use, 'raw', 'display', etc. |
248 | 248 | * @return mixed Same type as $value after $value has been sanitized. |
249 | 249 | */ |
250 | -function sanitize_category_field( $field, $value, $cat_id, $context ) { |
|
251 | - return sanitize_term_field( $field, $value, $cat_id, 'category', $context ); |
|
250 | +function sanitize_category_field($field, $value, $cat_id, $context) { |
|
251 | + return sanitize_term_field($field, $value, $cat_id, 'category', $context); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /* Tags */ |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | * @param string|array $args Tag arguments to use when retrieving tags. |
263 | 263 | * @return array List of tags. |
264 | 264 | */ |
265 | -function get_tags( $args = '' ) { |
|
266 | - $tags = get_terms( 'post_tag', $args ); |
|
265 | +function get_tags($args = '') { |
|
266 | + $tags = get_terms('post_tag', $args); |
|
267 | 267 | |
268 | - if ( empty( $tags ) ) { |
|
268 | + if (empty($tags)) { |
|
269 | 269 | $return = array(); |
270 | 270 | return $return; |
271 | 271 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param array $tags Array of 'post_tag' term objects. |
279 | 279 | * @param array $args An array of arguments. @see get_terms() |
280 | 280 | */ |
281 | - $tags = apply_filters( 'get_tags', $tags, $args ); |
|
281 | + $tags = apply_filters('get_tags', $tags, $args); |
|
282 | 282 | return $tags; |
283 | 283 | } |
284 | 284 | |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. |
302 | 302 | * @return object|array|WP_Error|null Tag data in type defined by $output parameter. WP_Error if $tag is empty, null if it does not exist. |
303 | 303 | */ |
304 | -function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) { |
|
305 | - return get_term( $tag, 'post_tag', $output, $filter ); |
|
304 | +function get_tag($tag, $output = OBJECT, $filter = 'raw') { |
|
305 | + return get_term($tag, 'post_tag', $output, $filter); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /* Cache */ |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @param int $id Category ID |
316 | 316 | */ |
317 | -function clean_category_cache( $id ) { |
|
318 | - clean_term_cache( $id, 'category' ); |
|
317 | +function clean_category_cache($id) { |
|
318 | + clean_term_cache($id, 'category'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -338,15 +338,15 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param array|object|WP_Term $category Category Row object or array |
340 | 340 | */ |
341 | -function _make_cat_compat( &$category ) { |
|
342 | - if ( is_object( $category ) && ! is_wp_error( $category ) ) { |
|
341 | +function _make_cat_compat(&$category) { |
|
342 | + if (is_object($category) && ! is_wp_error($category)) { |
|
343 | 343 | $category->cat_ID = $category->term_id; |
344 | 344 | $category->category_count = $category->count; |
345 | 345 | $category->category_description = $category->description; |
346 | 346 | $category->cat_name = $category->name; |
347 | 347 | $category->category_nicename = $category->slug; |
348 | 348 | $category->category_parent = $category->parent; |
349 | - } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) { |
|
349 | + } elseif (is_array($category) && isset($category['term_id'])) { |
|
350 | 350 | $category['cat_ID'] = &$category['term_id']; |
351 | 351 | $category['category_count'] = &$category['count']; |
352 | 352 | $category['category_description'] = &$category['description']; |