author | Anthony Ly <anthonyly.com@gmail.com> |
Tue, 12 Mar 2013 18:21:39 +0100 | |
changeset 206 | 919b4ddb13fa |
parent 204 | 09a1c134465b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
/** |
|
3 |
* Comment template functions |
|
4 |
* |
|
5 |
* These functions are meant to live inside of the WordPress loop. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Template |
|
9 |
*/ |
|
10 |
||
11 |
/** |
|
12 |
* Retrieve the author of the current comment. |
|
13 |
* |
|
14 |
* If the comment has an empty comment_author field, then 'Anonymous' person is |
|
15 |
* assumed. |
|
16 |
* |
|
17 |
* @since 1.5.0 |
|
18 |
* @uses apply_filters() Calls 'get_comment_author' hook on the comment author |
|
19 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
20 |
* @param int $comment_ID The ID of the comment for which to retrieve the author. Optional. |
136 | 21 |
* @return string The comment author |
22 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
23 |
function get_comment_author( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
24 |
$comment = get_comment( $comment_ID ); |
136 | 25 |
if ( empty($comment->comment_author) ) { |
26 |
if (!empty($comment->user_id)){ |
|
27 |
$user=get_userdata($comment->user_id); |
|
28 |
$author=$user->user_login; |
|
29 |
} else { |
|
30 |
$author = __('Anonymous'); |
|
31 |
} |
|
32 |
} else { |
|
33 |
$author = $comment->comment_author; |
|
34 |
} |
|
35 |
return apply_filters('get_comment_author', $author); |
|
36 |
} |
|
37 |
||
38 |
/** |
|
39 |
* Displays the author of the current comment. |
|
40 |
* |
|
41 |
* @since 0.71 |
|
42 |
* @uses apply_filters() Calls 'comment_author' on comment author before displaying |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
43 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
44 |
* @param int $comment_ID The ID of the comment for which to print the author. Optional. |
136 | 45 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
46 |
function comment_author( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
47 |
$author = apply_filters('comment_author', get_comment_author( $comment_ID ) ); |
136 | 48 |
echo $author; |
49 |
} |
|
50 |
||
51 |
/** |
|
52 |
* Retrieve the email of the author of the current comment. |
|
53 |
* |
|
54 |
* @since 1.5.0 |
|
55 |
* @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email |
|
56 |
* @uses $comment |
|
57 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
58 |
* @param int $comment_ID The ID of the comment for which to get the author's email. Optional. |
136 | 59 |
* @return string The current comment author's email |
60 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
61 |
function get_comment_author_email( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
62 |
$comment = get_comment( $comment_ID ); |
136 | 63 |
return apply_filters('get_comment_author_email', $comment->comment_author_email); |
64 |
} |
|
65 |
||
66 |
/** |
|
67 |
* Display the email of the author of the current global $comment. |
|
68 |
* |
|
69 |
* Care should be taken to protect the email address and assure that email |
|
70 |
* harvesters do not capture your commentors' email address. Most assume that |
|
71 |
* their email address will not appear in raw form on the blog. Doing so will |
|
72 |
* enable anyone, including those that people don't want to get the email |
|
73 |
* address and use it for their own means good and bad. |
|
74 |
* |
|
75 |
* @since 0.71 |
|
76 |
* @uses apply_filters() Calls 'author_email' hook on the author email |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
77 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
78 |
* @param int $comment_ID The ID of the comment for which to print the author's email. Optional. |
136 | 79 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
80 |
function comment_author_email( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
81 |
echo apply_filters('author_email', get_comment_author_email( $comment_ID ) ); |
136 | 82 |
} |
83 |
||
84 |
/** |
|
85 |
* Display the html email link to the author of the current comment. |
|
86 |
* |
|
87 |
* Care should be taken to protect the email address and assure that email |
|
88 |
* harvesters do not capture your commentors' email address. Most assume that |
|
89 |
* their email address will not appear in raw form on the blog. Doing so will |
|
90 |
* enable anyone, including those that people don't want to get the email |
|
91 |
* address and use it for their own means good and bad. |
|
92 |
* |
|
93 |
* @since 0.71 |
|
94 |
* @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email |
|
95 |
* @uses get_comment_author_email_link() For generating the link |
|
96 |
* @global object $comment The current Comment row object |
|
97 |
* |
|
98 |
* @param string $linktext The text to display instead of the comment author's email address |
|
99 |
* @param string $before The text or HTML to display before the email link. |
|
100 |
* @param string $after The text or HTML to display after the email link. |
|
101 |
*/ |
|
102 |
function comment_author_email_link($linktext='', $before='', $after='') { |
|
103 |
if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) |
|
104 |
echo $link; |
|
105 |
} |
|
106 |
||
107 |
/** |
|
108 |
* Return the html email link to the author of the current comment. |
|
109 |
* |
|
110 |
* Care should be taken to protect the email address and assure that email |
|
111 |
* harvesters do not capture your commentors' email address. Most assume that |
|
112 |
* their email address will not appear in raw form on the blog. Doing so will |
|
113 |
* enable anyone, including those that people don't want to get the email |
|
114 |
* address and use it for their own means good and bad. |
|
115 |
* |
|
116 |
* @since 2.7 |
|
117 |
* @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email |
|
118 |
* @global object $comment The current Comment row object |
|
119 |
* |
|
120 |
* @param string $linktext The text to display instead of the comment author's email address |
|
121 |
* @param string $before The text or HTML to display before the email link. |
|
122 |
* @param string $after The text or HTML to display after the email link. |
|
123 |
*/ |
|
124 |
function get_comment_author_email_link($linktext='', $before='', $after='') { |
|
125 |
global $comment; |
|
126 |
$email = apply_filters('comment_email', $comment->comment_author_email); |
|
127 |
if ((!empty($email)) && ($email != '@')) { |
|
128 |
$display = ($linktext != '') ? $linktext : $email; |
|
129 |
$return = $before; |
|
130 |
$return .= "<a href='mailto:$email'>$display</a>"; |
|
131 |
$return .= $after; |
|
132 |
return $return; |
|
133 |
} else { |
|
134 |
return ''; |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Retrieve the html link to the url of the author of the current comment. |
|
140 |
* |
|
141 |
* @since 1.5.0 |
|
142 |
* @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author |
|
143 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
144 |
* @param int $comment_ID The ID of the comment for which to get the author's link. Optional. |
136 | 145 |
* @return string Comment Author name or HTML link for author's URL |
146 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
147 |
function get_comment_author_link( $comment_ID = 0 ) { |
136 | 148 |
/** @todo Only call these functions when they are needed. Include in if... else blocks */ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
149 |
$url = get_comment_author_url( $comment_ID ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
150 |
$author = get_comment_author( $comment_ID ); |
136 | 151 |
|
152 |
if ( empty( $url ) || 'http://' == $url ) |
|
153 |
$return = $author; |
|
154 |
else |
|
155 |
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
156 |
return apply_filters('get_comment_author_link', $return); |
|
157 |
} |
|
158 |
||
159 |
/** |
|
160 |
* Display the html link to the url of the author of the current comment. |
|
161 |
* |
|
162 |
* @since 0.71 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
163 |
* @see get_comment_author_link() Echoes result |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
164 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
165 |
* @param int $comment_ID The ID of the comment for which to print the author's link. Optional. |
136 | 166 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
167 |
function comment_author_link( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
168 |
echo get_comment_author_link( $comment_ID ); |
136 | 169 |
} |
170 |
||
171 |
/** |
|
172 |
* Retrieve the IP address of the author of the current comment. |
|
173 |
* |
|
174 |
* @since 1.5.0 |
|
175 |
* @uses $comment |
|
176 |
* @uses apply_filters() |
|
177 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
178 |
* @param int $comment_ID The ID of the comment for which to get the author's IP address. Optional. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
179 |
* @return string The comment author's IP address. |
136 | 180 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
181 |
function get_comment_author_IP( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
182 |
$comment = get_comment( $comment_ID ); |
136 | 183 |
return apply_filters('get_comment_author_IP', $comment->comment_author_IP); |
184 |
} |
|
185 |
||
186 |
/** |
|
187 |
* Display the IP address of the author of the current comment. |
|
188 |
* |
|
189 |
* @since 0.71 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
190 |
* @see get_comment_author_IP() Echoes Result |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
191 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
192 |
* @param int $comment_ID The ID of the comment for which to print the author's IP address. Optional. |
136 | 193 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
194 |
function comment_author_IP( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
195 |
echo get_comment_author_IP( $comment_ID ); |
136 | 196 |
} |
197 |
||
198 |
/** |
|
199 |
* Retrieve the url of the author of the current comment. |
|
200 |
* |
|
201 |
* @since 1.5.0 |
|
202 |
* @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL |
|
203 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
204 |
* @param int $comment_ID The ID of the comment for which to get the author's URL. Optional. |
136 | 205 |
* @return string |
206 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
207 |
function get_comment_author_url( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
208 |
$comment = get_comment( $comment_ID ); |
136 | 209 |
$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; |
210 |
$url = esc_url( $url, array('http', 'https') ); |
|
211 |
return apply_filters('get_comment_author_url', $url); |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Display the url of the author of the current comment. |
|
216 |
* |
|
217 |
* @since 0.71 |
|
218 |
* @uses apply_filters() |
|
219 |
* @uses get_comment_author_url() Retrieves the comment author's URL |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
220 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
221 |
* @param int $comment_ID The ID of the comment for which to print the author's URL. Optional. |
136 | 222 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
223 |
function comment_author_url( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
224 |
echo apply_filters('comment_url', get_comment_author_url( $comment_ID )); |
136 | 225 |
} |
226 |
||
227 |
/** |
|
228 |
* Retrieves the HTML link of the url of the author of the current comment. |
|
229 |
* |
|
230 |
* $linktext parameter is only used if the URL does not exist for the comment |
|
231 |
* author. If the URL does exist then the URL will be used and the $linktext |
|
232 |
* will be ignored. |
|
233 |
* |
|
234 |
* Encapsulate the HTML link between the $before and $after. So it will appear |
|
235 |
* in the order of $before, link, and finally $after. |
|
236 |
* |
|
237 |
* @since 1.5.0 |
|
238 |
* @uses apply_filters() Calls the 'get_comment_author_url_link' on the complete HTML before returning. |
|
239 |
* |
|
240 |
* @param string $linktext The text to display instead of the comment author's email address |
|
241 |
* @param string $before The text or HTML to display before the email link. |
|
242 |
* @param string $after The text or HTML to display after the email link. |
|
243 |
* @return string The HTML link between the $before and $after parameters |
|
244 |
*/ |
|
245 |
function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
246 |
$url = get_comment_author_url(); |
|
247 |
$display = ($linktext != '') ? $linktext : $url; |
|
248 |
$display = str_replace( 'http://www.', '', $display ); |
|
249 |
$display = str_replace( 'http://', '', $display ); |
|
250 |
if ( '/' == substr($display, -1) ) |
|
251 |
$display = substr($display, 0, -1); |
|
252 |
$return = "$before<a href='$url' rel='external'>$display</a>$after"; |
|
253 |
return apply_filters('get_comment_author_url_link', $return); |
|
254 |
} |
|
255 |
||
256 |
/** |
|
257 |
* Displays the HTML link of the url of the author of the current comment. |
|
258 |
* |
|
259 |
* @since 0.71 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
260 |
* @see get_comment_author_url_link() Echoes result |
136 | 261 |
* |
262 |
* @param string $linktext The text to display instead of the comment author's email address |
|
263 |
* @param string $before The text or HTML to display before the email link. |
|
264 |
* @param string $after The text or HTML to display after the email link. |
|
265 |
*/ |
|
266 |
function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
267 |
echo get_comment_author_url_link( $linktext, $before, $after ); |
|
268 |
} |
|
269 |
||
270 |
/** |
|
271 |
* Generates semantic classes for each comment element |
|
272 |
* |
|
273 |
* @since 2.7.0 |
|
274 |
* |
|
275 |
* @param string|array $class One or more classes to add to the class list |
|
276 |
* @param int $comment_id An optional comment ID |
|
277 |
* @param int $post_id An optional post ID |
|
278 |
* @param bool $echo Whether comment_class should echo or return |
|
279 |
*/ |
|
280 |
function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { |
|
281 |
// Separates classes with a single space, collates classes for comment DIV |
|
282 |
$class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; |
|
283 |
if ( $echo) |
|
284 |
echo $class; |
|
285 |
else |
|
286 |
return $class; |
|
287 |
} |
|
288 |
||
289 |
/** |
|
290 |
* Returns the classes for the comment div as an array |
|
291 |
* |
|
292 |
* @since 2.7.0 |
|
293 |
* |
|
294 |
* @param string|array $class One or more classes to add to the class list |
|
295 |
* @param int $comment_id An optional comment ID |
|
296 |
* @param int $post_id An optional post ID |
|
297 |
* @return array Array of classes |
|
298 |
*/ |
|
299 |
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
|
300 |
global $comment_alt, $comment_depth, $comment_thread_alt; |
|
301 |
||
302 |
$comment = get_comment($comment_id); |
|
303 |
||
304 |
$classes = array(); |
|
305 |
||
306 |
// Get the comment type (comment, trackback), |
|
307 |
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; |
|
308 |
||
309 |
// If the comment author has an id (registered), then print the log in name |
|
310 |
if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) { |
|
311 |
// For all registered users, 'byuser' |
|
312 |
$classes[] = 'byuser'; |
|
313 |
$classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id); |
|
314 |
// For comment authors who are the author of the post |
|
315 |
if ( $post = get_post($post_id) ) { |
|
316 |
if ( $comment->user_id === $post->post_author ) |
|
317 |
$classes[] = 'bypostauthor'; |
|
318 |
} |
|
319 |
} |
|
320 |
||
321 |
if ( empty($comment_alt) ) |
|
322 |
$comment_alt = 0; |
|
323 |
if ( empty($comment_depth) ) |
|
324 |
$comment_depth = 1; |
|
325 |
if ( empty($comment_thread_alt) ) |
|
326 |
$comment_thread_alt = 0; |
|
327 |
||
328 |
if ( $comment_alt % 2 ) { |
|
329 |
$classes[] = 'odd'; |
|
330 |
$classes[] = 'alt'; |
|
331 |
} else { |
|
332 |
$classes[] = 'even'; |
|
333 |
} |
|
334 |
||
335 |
$comment_alt++; |
|
336 |
||
337 |
// Alt for top-level comments |
|
338 |
if ( 1 == $comment_depth ) { |
|
339 |
if ( $comment_thread_alt % 2 ) { |
|
340 |
$classes[] = 'thread-odd'; |
|
341 |
$classes[] = 'thread-alt'; |
|
342 |
} else { |
|
343 |
$classes[] = 'thread-even'; |
|
344 |
} |
|
345 |
$comment_thread_alt++; |
|
346 |
} |
|
347 |
||
348 |
$classes[] = "depth-$comment_depth"; |
|
349 |
||
350 |
if ( !empty($class) ) { |
|
351 |
if ( !is_array( $class ) ) |
|
352 |
$class = preg_split('#\s+#', $class); |
|
353 |
$classes = array_merge($classes, $class); |
|
354 |
} |
|
355 |
||
356 |
$classes = array_map('esc_attr', $classes); |
|
357 |
||
358 |
return apply_filters('comment_class', $classes, $class, $comment_id, $post_id); |
|
359 |
} |
|
360 |
||
361 |
/** |
|
362 |
* Retrieve the comment date of the current comment. |
|
363 |
* |
|
364 |
* @since 1.5.0 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
365 |
* @uses apply_filters() Calls 'get_comment_date' hook with the formatted date and the $d parameter respectively |
136 | 366 |
* @uses $comment |
367 |
* |
|
368 |
* @param string $d The format of the date (defaults to user's config) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
369 |
* @param int $comment_ID The ID of the comment for which to get the date. Optional. |
136 | 370 |
* @return string The comment's date |
371 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
372 |
function get_comment_date( $d = '', $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
373 |
$comment = get_comment( $comment_ID ); |
136 | 374 |
if ( '' == $d ) |
375 |
$date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
376 |
else |
|
377 |
$date = mysql2date($d, $comment->comment_date); |
|
378 |
return apply_filters('get_comment_date', $date, $d); |
|
379 |
} |
|
380 |
||
381 |
/** |
|
382 |
* Display the comment date of the current comment. |
|
383 |
* |
|
384 |
* @since 0.71 |
|
385 |
* |
|
386 |
* @param string $d The format of the date (defaults to user's config) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
387 |
* @param int $comment_ID The ID of the comment for which to print the date. Optional. |
136 | 388 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
389 |
function comment_date( $d = '', $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
390 |
echo get_comment_date( $d, $comment_ID ); |
136 | 391 |
} |
392 |
||
393 |
/** |
|
394 |
* Retrieve the excerpt of the current comment. |
|
395 |
* |
|
396 |
* Will cut each word and only output the first 20 words with '...' at the end. |
|
397 |
* If the word count is less than 20, then no truncating is done and no '...' |
|
398 |
* will appear. |
|
399 |
* |
|
400 |
* @since 1.5.0 |
|
401 |
* @uses $comment |
|
402 |
* @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment |
|
403 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
404 |
* @param int $comment_ID The ID of the comment for which to get the excerpt. Optional. |
136 | 405 |
* @return string The maybe truncated comment with 20 words or less |
406 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
407 |
function get_comment_excerpt( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
408 |
$comment = get_comment( $comment_ID ); |
136 | 409 |
$comment_text = strip_tags($comment->comment_content); |
410 |
$blah = explode(' ', $comment_text); |
|
411 |
if (count($blah) > 20) { |
|
412 |
$k = 20; |
|
413 |
$use_dotdotdot = 1; |
|
414 |
} else { |
|
415 |
$k = count($blah); |
|
416 |
$use_dotdotdot = 0; |
|
417 |
} |
|
418 |
$excerpt = ''; |
|
419 |
for ($i=0; $i<$k; $i++) { |
|
420 |
$excerpt .= $blah[$i] . ' '; |
|
421 |
} |
|
422 |
$excerpt .= ($use_dotdotdot) ? '...' : ''; |
|
423 |
return apply_filters('get_comment_excerpt', $excerpt); |
|
424 |
} |
|
425 |
||
426 |
/** |
|
427 |
* Display the excerpt of the current comment. |
|
428 |
* |
|
429 |
* @since 1.2.0 |
|
430 |
* @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
431 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
432 |
* @param int $comment_ID The ID of the comment for which to print the excerpt. Optional. |
136 | 433 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
434 |
function comment_excerpt( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
435 |
echo apply_filters('comment_excerpt', get_comment_excerpt($comment_ID) ); |
136 | 436 |
} |
437 |
||
438 |
/** |
|
439 |
* Retrieve the comment id of the current comment. |
|
440 |
* |
|
441 |
* @since 1.5.0 |
|
442 |
* @uses $comment |
|
443 |
* @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID |
|
444 |
* |
|
445 |
* @return int The comment ID |
|
446 |
*/ |
|
447 |
function get_comment_ID() { |
|
448 |
global $comment; |
|
449 |
return apply_filters('get_comment_ID', $comment->comment_ID); |
|
450 |
} |
|
451 |
||
452 |
/** |
|
453 |
* Displays the comment id of the current comment. |
|
454 |
* |
|
455 |
* @since 0.71 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
456 |
* @see get_comment_ID() Echoes Result |
136 | 457 |
*/ |
458 |
function comment_ID() { |
|
459 |
echo get_comment_ID(); |
|
460 |
} |
|
461 |
||
462 |
/** |
|
463 |
* Retrieve the link to a given comment. |
|
464 |
* |
|
465 |
* @since 1.5.0 |
|
466 |
* @uses $comment |
|
467 |
* |
|
468 |
* @param object|string|int $comment Comment to retrieve. |
|
469 |
* @param array $args Optional args. |
|
470 |
* @return string The permalink to the given comment. |
|
471 |
*/ |
|
472 |
function get_comment_link( $comment = null, $args = array() ) { |
|
473 |
global $wp_rewrite, $in_comment_loop; |
|
474 |
||
475 |
$comment = get_comment($comment); |
|
476 |
||
477 |
// Backwards compat |
|
478 |
if ( !is_array($args) ) { |
|
479 |
$page = $args; |
|
480 |
$args = array(); |
|
481 |
$args['page'] = $page; |
|
482 |
} |
|
483 |
||
484 |
$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
|
485 |
$args = wp_parse_args( $args, $defaults ); |
|
486 |
||
487 |
if ( '' === $args['per_page'] && get_option('page_comments') ) |
|
488 |
$args['per_page'] = get_option('comments_per_page'); |
|
489 |
||
490 |
if ( empty($args['per_page']) ) { |
|
491 |
$args['per_page'] = 0; |
|
492 |
$args['page'] = 0; |
|
493 |
} |
|
494 |
||
495 |
if ( $args['per_page'] ) { |
|
496 |
if ( '' == $args['page'] ) |
|
497 |
$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); |
|
498 |
||
499 |
if ( $wp_rewrite->using_permalinks() ) |
|
500 |
$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ); |
|
501 |
else |
|
502 |
$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); |
|
503 |
} else { |
|
504 |
$link = get_permalink( $comment->comment_post_ID ); |
|
505 |
} |
|
506 |
||
507 |
return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args ); |
|
508 |
} |
|
509 |
||
510 |
/** |
|
511 |
* Retrieves the link to the current post comments. |
|
512 |
* |
|
513 |
* @since 1.5.0 |
|
514 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
515 |
* @param int $post_id Optional post id |
136 | 516 |
* @return string The link to the comments |
517 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
518 |
function get_comments_link($post_id = 0) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
519 |
return get_permalink($post_id) . '#comments'; |
136 | 520 |
} |
521 |
||
522 |
/** |
|
523 |
* Displays the link to the current post comments. |
|
524 |
* |
|
525 |
* @since 0.71 |
|
526 |
* |
|
527 |
* @param string $deprecated Not Used |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
528 |
* @param bool $deprecated_2 Not Used |
136 | 529 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
530 |
function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
531 |
if ( !empty( $deprecated ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
532 |
_deprecated_argument( __FUNCTION__, '0.72' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
533 |
if ( !empty( $deprecated_2 ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
534 |
_deprecated_argument( __FUNCTION__, '1.3' ); |
136 | 535 |
echo get_comments_link(); |
536 |
} |
|
537 |
||
538 |
/** |
|
539 |
* Retrieve the amount of comments a post has. |
|
540 |
* |
|
541 |
* @since 1.5.0 |
|
542 |
* @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments |
|
543 |
* |
|
544 |
* @param int $post_id The Post ID |
|
545 |
* @return int The number of comments a post has |
|
546 |
*/ |
|
547 |
function get_comments_number( $post_id = 0 ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
548 |
$post_id = absint( $post_id ); |
136 | 549 |
|
550 |
if ( !$post_id ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
551 |
$post_id = get_the_ID(); |
136 | 552 |
|
553 |
$post = get_post($post_id); |
|
554 |
if ( ! isset($post->comment_count) ) |
|
555 |
$count = 0; |
|
556 |
else |
|
557 |
$count = $post->comment_count; |
|
558 |
||
559 |
return apply_filters('get_comments_number', $count, $post_id); |
|
560 |
} |
|
561 |
||
562 |
/** |
|
563 |
* Display the language string for the number of comments the current post has. |
|
564 |
* |
|
565 |
* @since 0.71 |
|
566 |
* @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively. |
|
567 |
* |
|
568 |
* @param string $zero Text for no comments |
|
569 |
* @param string $one Text for one comment |
|
570 |
* @param string $more Text for more than one comment |
|
571 |
* @param string $deprecated Not used. |
|
572 |
*/ |
|
573 |
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
574 |
if ( !empty( $deprecated ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
575 |
_deprecated_argument( __FUNCTION__, '1.3' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
576 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
577 |
$number = get_comments_number(); |
136 | 578 |
|
579 |
if ( $number > 1 ) |
|
580 |
$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more); |
|
581 |
elseif ( $number == 0 ) |
|
582 |
$output = ( false === $zero ) ? __('No Comments') : $zero; |
|
583 |
else // must be one |
|
584 |
$output = ( false === $one ) ? __('1 Comment') : $one; |
|
585 |
||
586 |
echo apply_filters('comments_number', $output, $number); |
|
587 |
} |
|
588 |
||
589 |
/** |
|
590 |
* Retrieve the text of the current comment. |
|
591 |
* |
|
592 |
* @since 1.5.0 |
|
593 |
* @uses $comment |
|
594 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
595 |
* @param int $comment_ID The ID of the comment for which to get the text. Optional. |
136 | 596 |
* @return string The comment content |
597 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
598 |
function get_comment_text( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
599 |
$comment = get_comment( $comment_ID ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
600 |
return apply_filters( 'get_comment_text', $comment->comment_content, $comment ); |
136 | 601 |
} |
602 |
||
603 |
/** |
|
604 |
* Displays the text of the current comment. |
|
605 |
* |
|
606 |
* @since 0.71 |
|
607 |
* @uses apply_filters() Passes the comment content through the 'comment_text' hook before display |
|
608 |
* @uses get_comment_text() Gets the comment content |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
609 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
610 |
* @param int $comment_ID The ID of the comment for which to print the text. Optional. |
136 | 611 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
612 |
function comment_text( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
613 |
$comment = get_comment( $comment_ID ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
614 |
echo apply_filters( 'comment_text', get_comment_text( $comment_ID ), $comment ); |
136 | 615 |
} |
616 |
||
617 |
/** |
|
618 |
* Retrieve the comment time of the current comment. |
|
619 |
* |
|
620 |
* @since 1.5.0 |
|
621 |
* @uses $comment |
|
622 |
* @uses apply_filter() Calls 'get_comment_time' hook with the formatted time, the $d parameter, and $gmt parameter passed. |
|
623 |
* |
|
624 |
* @param string $d Optional. The format of the time (defaults to user's config) |
|
625 |
* @param bool $gmt Whether to use the GMT date |
|
626 |
* @param bool $translate Whether to translate the time (for use in feeds) |
|
627 |
* @return string The formatted time |
|
628 |
*/ |
|
629 |
function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
|
630 |
global $comment; |
|
631 |
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
|
632 |
if ( '' == $d ) |
|
633 |
$date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
634 |
else |
|
635 |
$date = mysql2date($d, $comment_date, $translate); |
|
636 |
return apply_filters('get_comment_time', $date, $d, $gmt, $translate); |
|
637 |
} |
|
638 |
||
639 |
/** |
|
640 |
* Display the comment time of the current comment. |
|
641 |
* |
|
642 |
* @since 0.71 |
|
643 |
* |
|
644 |
* @param string $d Optional. The format of the time (defaults to user's config) |
|
645 |
*/ |
|
646 |
function comment_time( $d = '' ) { |
|
647 |
echo get_comment_time($d); |
|
648 |
} |
|
649 |
||
650 |
/** |
|
651 |
* Retrieve the comment type of the current comment. |
|
652 |
* |
|
653 |
* @since 1.5.0 |
|
654 |
* @uses $comment |
|
655 |
* @uses apply_filters() Calls the 'get_comment_type' hook on the comment type |
|
656 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
657 |
* @param int $comment_ID The ID of the comment for which to get the type. Optional. |
136 | 658 |
* @return string The comment type |
659 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
660 |
function get_comment_type( $comment_ID = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
661 |
$comment = get_comment( $comment_ID ); |
136 | 662 |
if ( '' == $comment->comment_type ) |
663 |
$comment->comment_type = 'comment'; |
|
664 |
||
665 |
return apply_filters('get_comment_type', $comment->comment_type); |
|
666 |
} |
|
667 |
||
668 |
/** |
|
669 |
* Display the comment type of the current comment. |
|
670 |
* |
|
671 |
* @since 0.71 |
|
672 |
* |
|
673 |
* @param string $commenttxt The string to display for comment type |
|
674 |
* @param string $trackbacktxt The string to display for trackback type |
|
675 |
* @param string $pingbacktxt The string to display for pingback type |
|
676 |
*/ |
|
677 |
function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
678 |
if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
679 |
if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
680 |
if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
136 | 681 |
$type = get_comment_type(); |
682 |
switch( $type ) { |
|
683 |
case 'trackback' : |
|
684 |
echo $trackbacktxt; |
|
685 |
break; |
|
686 |
case 'pingback' : |
|
687 |
echo $pingbacktxt; |
|
688 |
break; |
|
689 |
default : |
|
690 |
echo $commenttxt; |
|
691 |
} |
|
692 |
} |
|
693 |
||
694 |
/** |
|
695 |
* Retrieve The current post's trackback URL. |
|
696 |
* |
|
697 |
* There is a check to see if permalink's have been enabled and if so, will |
|
698 |
* retrieve the pretty path. If permalinks weren't enabled, the ID of the |
|
699 |
* current post is used and appended to the correct page to go to. |
|
700 |
* |
|
701 |
* @since 1.5.0 |
|
702 |
* @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL |
|
703 |
* |
|
704 |
* @return string The trackback URL after being filtered |
|
705 |
*/ |
|
706 |
function get_trackback_url() { |
|
707 |
if ( '' != get_option('permalink_structure') ) { |
|
708 |
$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
709 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
710 |
$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
136 | 711 |
} |
712 |
return apply_filters('trackback_url', $tb_url); |
|
713 |
} |
|
714 |
||
715 |
/** |
|
716 |
* Displays the current post's trackback URL. |
|
717 |
* |
|
718 |
* @since 0.71 |
|
719 |
* @uses get_trackback_url() Gets the trackback url for the current post |
|
720 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
721 |
* @param bool $deprecated_echo Remove backwards compat in 2.5 |
136 | 722 |
* @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead. |
723 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
724 |
function trackback_url( $deprecated_echo = true ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
725 |
if ( $deprecated_echo !== true ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
726 |
_deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
727 |
if ( $deprecated_echo ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
728 |
echo get_trackback_url(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
729 |
else |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
730 |
return get_trackback_url(); |
136 | 731 |
} |
732 |
||
733 |
/** |
|
734 |
* Generates and displays the RDF for the trackback information of current post. |
|
735 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
736 |
* Deprecated in 3.0.0, and restored in 3.0.1. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
737 |
* |
136 | 738 |
* @since 0.71 |
739 |
* |
|
740 |
* @param int $deprecated Not used (Was $timezone = 0) |
|
741 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
742 |
function trackback_rdf( $deprecated = '' ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
743 |
if ( !empty( $deprecated ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
744 |
_deprecated_argument( __FUNCTION__, '2.5' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
745 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
746 |
if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
747 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
748 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
749 |
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
750 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
751 |
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
752 |
<rdf:Description rdf:about="'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
753 |
the_permalink(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
754 |
echo '"'."\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
755 |
echo ' dc:identifier="'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
756 |
the_permalink(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
757 |
echo '"'."\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
758 |
echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
759 |
echo ' trackback:ping="'.get_trackback_url().'"'." />\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
760 |
echo '</rdf:RDF>'; |
136 | 761 |
} |
762 |
||
763 |
/** |
|
764 |
* Whether the current post is open for comments. |
|
765 |
* |
|
766 |
* @since 1.5.0 |
|
767 |
* @uses $post |
|
768 |
* |
|
769 |
* @param int $post_id An optional post ID to check instead of the current post. |
|
770 |
* @return bool True if the comments are open |
|
771 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
772 |
function comments_open( $post_id = null ) { |
136 | 773 |
|
774 |
$_post = get_post($post_id); |
|
775 |
||
776 |
$open = ( 'open' == $_post->comment_status ); |
|
777 |
return apply_filters( 'comments_open', $open, $post_id ); |
|
778 |
} |
|
779 |
||
780 |
/** |
|
781 |
* Whether the current post is open for pings. |
|
782 |
* |
|
783 |
* @since 1.5.0 |
|
784 |
* @uses $post |
|
785 |
* |
|
786 |
* @param int $post_id An optional post ID to check instead of the current post. |
|
787 |
* @return bool True if pings are accepted |
|
788 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
789 |
function pings_open( $post_id = null ) { |
136 | 790 |
|
791 |
$_post = get_post($post_id); |
|
792 |
||
793 |
$open = ( 'open' == $_post->ping_status ); |
|
794 |
return apply_filters( 'pings_open', $open, $post_id ); |
|
795 |
} |
|
796 |
||
797 |
/** |
|
798 |
* Displays form token for unfiltered comments. |
|
799 |
* |
|
800 |
* Will only display nonce token if the current user has permissions for |
|
801 |
* unfiltered html. Won't display the token for other users. |
|
802 |
* |
|
803 |
* The function was backported to 2.0.10 and was added to versions 2.1.3 and |
|
804 |
* above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in |
|
805 |
* the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0. |
|
806 |
* |
|
807 |
* Backported to 2.0.10. |
|
808 |
* |
|
809 |
* @since 2.1.3 |
|
810 |
* @uses $post Gets the ID of the current post for the token |
|
811 |
*/ |
|
812 |
function wp_comment_form_unfiltered_html_nonce() { |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
813 |
$post = get_post(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
814 |
$post_id = $post ? $post->ID : 0; |
136 | 815 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
816 |
if ( current_user_can( 'unfiltered_html' ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
817 |
wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
818 |
echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
819 |
} |
136 | 820 |
} |
821 |
||
822 |
/** |
|
823 |
* Loads the comment template specified in $file. |
|
824 |
* |
|
825 |
* Will not display the comments template if not on single post or page, or if |
|
826 |
* the post does not have comments. |
|
827 |
* |
|
828 |
* Uses the WordPress database object to query for the comments. The comments |
|
829 |
* are passed through the 'comments_array' filter hook with the list of comments |
|
830 |
* and the post ID respectively. |
|
831 |
* |
|
832 |
* The $file path is passed through a filter hook called, 'comments_template' |
|
833 |
* which includes the TEMPLATEPATH and $file combined. Tries the $filtered path |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
834 |
* first and if it fails it will require the default comment template from the |
136 | 835 |
* default theme. If either does not exist, then the WordPress process will be |
836 |
* halted. It is advised for that reason, that the default theme is not deleted. |
|
837 |
* |
|
838 |
* @since 1.5.0 |
|
839 |
* @global array $comment List of comment objects for the current post |
|
840 |
* @uses $wpdb |
|
841 |
* @uses $post |
|
842 |
* @uses $withcomments Will not try to get the comments if the post has none. |
|
843 |
* |
|
844 |
* @param string $file Optional, default '/comments.php'. The file to load |
|
845 |
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false. |
|
846 |
* @return null Returns null if no comments appear |
|
847 |
*/ |
|
848 |
function comments_template( $file = '/comments.php', $separate_comments = false ) { |
|
849 |
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
|
850 |
||
851 |
if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
852 |
return; |
|
853 |
||
854 |
if ( empty($file) ) |
|
855 |
$file = '/comments.php'; |
|
856 |
||
857 |
$req = get_option('require_name_email'); |
|
858 |
||
859 |
/** |
|
860 |
* Comment author information fetched from the comment cookies. |
|
861 |
* |
|
862 |
* @uses wp_get_current_commenter() |
|
863 |
*/ |
|
864 |
$commenter = wp_get_current_commenter(); |
|
865 |
||
866 |
/** |
|
867 |
* The name of the current comment author escaped for use in attributes. |
|
868 |
*/ |
|
869 |
$comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies() |
|
870 |
||
871 |
/** |
|
872 |
* The email address of the current comment author escaped for use in attributes. |
|
873 |
*/ |
|
874 |
$comment_author_email = $commenter['comment_author_email']; // Escaped by sanitize_comment_cookies() |
|
875 |
||
876 |
/** |
|
877 |
* The url of the current comment author escaped for use in attributes. |
|
878 |
*/ |
|
879 |
$comment_author_url = esc_url($commenter['comment_author_url']); |
|
880 |
||
881 |
/** @todo Use API instead of SELECTs. */ |
|
882 |
if ( $user_ID) { |
|
883 |
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID)); |
|
884 |
} else if ( empty($comment_author) ) { |
|
885 |
$comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); |
|
886 |
} else { |
|
887 |
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email)); |
|
888 |
} |
|
889 |
||
890 |
// keep $comments for legacy's sake |
|
891 |
$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); |
|
892 |
$comments = &$wp_query->comments; |
|
893 |
$wp_query->comment_count = count($wp_query->comments); |
|
894 |
update_comment_cache($wp_query->comments); |
|
895 |
||
896 |
if ( $separate_comments ) { |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
897 |
$wp_query->comments_by_type = separate_comments($comments); |
136 | 898 |
$comments_by_type = &$wp_query->comments_by_type; |
899 |
} |
|
900 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
901 |
$overridden_cpage = false; |
136 | 902 |
if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
903 |
set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
904 |
$overridden_cpage = true; |
136 | 905 |
} |
906 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
907 |
if ( !defined('COMMENTS_TEMPLATE') ) |
136 | 908 |
define('COMMENTS_TEMPLATE', true); |
909 |
||
910 |
$include = apply_filters('comments_template', STYLESHEETPATH . $file ); |
|
911 |
if ( file_exists( $include ) ) |
|
912 |
require( $include ); |
|
913 |
elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
914 |
require( TEMPLATEPATH . $file ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
915 |
else // Backward compat code will be removed in a future release |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
916 |
require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
136 | 917 |
} |
918 |
||
919 |
/** |
|
920 |
* Displays the JS popup script to show a comment. |
|
921 |
* |
|
922 |
* If the $file parameter is empty, then the home page is assumed. The defaults |
|
923 |
* for the window are 400px by 400px. |
|
924 |
* |
|
925 |
* For the comment link popup to work, this function has to be called or the |
|
926 |
* normal comment link will be assumed. |
|
927 |
* |
|
928 |
* @since 0.71 |
|
929 |
* @global string $wpcommentspopupfile The URL to use for the popup window |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
930 |
* @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called |
136 | 931 |
* |
932 |
* @param int $width Optional. The width of the popup window |
|
933 |
* @param int $height Optional. The height of the popup window |
|
934 |
* @param string $file Optional. Sets the location of the popup window |
|
935 |
*/ |
|
936 |
function comments_popup_script($width=400, $height=400, $file='') { |
|
937 |
global $wpcommentspopupfile, $wpcommentsjavascript; |
|
938 |
||
939 |
if (empty ($file)) { |
|
940 |
$wpcommentspopupfile = ''; // Use the index. |
|
941 |
} else { |
|
942 |
$wpcommentspopupfile = $file; |
|
943 |
} |
|
944 |
||
945 |
$wpcommentsjavascript = 1; |
|
946 |
$javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n"; |
|
947 |
echo $javascript; |
|
948 |
} |
|
949 |
||
950 |
/** |
|
951 |
* Displays the link to the comments popup window for the current post ID. |
|
952 |
* |
|
953 |
* Is not meant to be displayed on single posts and pages. Should be used on the |
|
954 |
* lists of posts |
|
955 |
* |
|
956 |
* @since 0.71 |
|
957 |
* @uses $wpcommentspopupfile |
|
958 |
* @uses $wpcommentsjavascript |
|
959 |
* @uses $post |
|
960 |
* |
|
961 |
* @param string $zero The string to display when no comments |
|
962 |
* @param string $one The string to display when only one comment is available |
|
963 |
* @param string $more The string to display when there are more than one comment |
|
964 |
* @param string $css_class The CSS class to use for comments |
|
965 |
* @param string $none The string to display when comments have been turned off |
|
966 |
* @return null Returns null on single posts and pages. |
|
967 |
*/ |
|
968 |
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
969 |
global $wpcommentspopupfile, $wpcommentsjavascript; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
970 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
971 |
$id = get_the_ID(); |
136 | 972 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
973 |
if ( false === $zero ) $zero = __( 'No Comments' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
974 |
if ( false === $one ) $one = __( '1 Comment' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
975 |
if ( false === $more ) $more = __( '% Comments' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
976 |
if ( false === $none ) $none = __( 'Comments Off' ); |
136 | 977 |
|
978 |
$number = get_comments_number( $id ); |
|
979 |
||
980 |
if ( 0 == $number && !comments_open() && !pings_open() ) { |
|
981 |
echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; |
|
982 |
return; |
|
983 |
} |
|
984 |
||
985 |
if ( post_password_required() ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
986 |
echo __('Enter your password to view comments.'); |
136 | 987 |
return; |
988 |
} |
|
989 |
||
990 |
echo '<a href="'; |
|
991 |
if ( $wpcommentsjavascript ) { |
|
992 |
if ( empty( $wpcommentspopupfile ) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
993 |
$home = home_url(); |
136 | 994 |
else |
995 |
$home = get_option('siteurl'); |
|
996 |
echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; |
|
997 |
echo '" onclick="wpopen(this.href); return false"'; |
|
998 |
} else { // if comments_popup_script() is not in the template, display simple comment link |
|
999 |
if ( 0 == $number ) |
|
1000 |
echo get_permalink() . '#respond'; |
|
1001 |
else |
|
1002 |
comments_link(); |
|
1003 |
echo '"'; |
|
1004 |
} |
|
1005 |
||
1006 |
if ( !empty( $css_class ) ) { |
|
1007 |
echo ' class="'.$css_class.'" '; |
|
1008 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1009 |
$title = the_title_attribute( array('echo' => 0 ) ); |
136 | 1010 |
|
1011 |
echo apply_filters( 'comments_popup_link_attributes', '' ); |
|
1012 |
||
1013 |
echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1014 |
comments_number( $zero, $one, $more ); |
136 | 1015 |
echo '</a>'; |
1016 |
} |
|
1017 |
||
1018 |
/** |
|
1019 |
* Retrieve HTML content for reply to comment link. |
|
1020 |
* |
|
1021 |
* The default arguments that can be override are 'add_below', 'respond_id', |
|
1022 |
* 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be |
|
1023 |
* used, if the user must log in or register first before posting a comment. The |
|
1024 |
* 'reply_text' will be used, if they can post a reply. The 'add_below' and |
|
1025 |
* 'respond_id' arguments are for the JavaScript moveAddCommentForm() function |
|
1026 |
* parameters. |
|
1027 |
* |
|
1028 |
* @since 2.7.0 |
|
1029 |
* |
|
1030 |
* @param array $args Optional. Override default options. |
|
1031 |
* @param int $comment Optional. Comment being replied to. |
|
1032 |
* @param int $post Optional. Post that the comment is going to be displayed on. |
|
1033 |
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
|
1034 |
*/ |
|
1035 |
function get_comment_reply_link($args = array(), $comment = null, $post = null) { |
|
1036 |
global $user_ID; |
|
1037 |
||
1038 |
$defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'), |
|
1039 |
'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => ''); |
|
1040 |
||
1041 |
$args = wp_parse_args($args, $defaults); |
|
1042 |
||
1043 |
if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) |
|
1044 |
return; |
|
1045 |
||
1046 |
extract($args, EXTR_SKIP); |
|
1047 |
||
1048 |
$comment = get_comment($comment); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1049 |
if ( empty($post) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1050 |
$post = $comment->comment_post_ID; |
136 | 1051 |
$post = get_post($post); |
1052 |
||
1053 |
if ( !comments_open($post->ID) ) |
|
1054 |
return false; |
|
1055 |
||
1056 |
$link = ''; |
|
1057 |
||
1058 |
if ( get_option('comment_registration') && !$user_ID ) |
|
1059 |
$link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>'; |
|
1060 |
else |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1061 |
$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; |
136 | 1062 |
return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post); |
1063 |
} |
|
1064 |
||
1065 |
/** |
|
1066 |
* Displays the HTML content for reply to comment link. |
|
1067 |
* |
|
1068 |
* @since 2.7.0 |
|
1069 |
* @see get_comment_reply_link() Echoes result |
|
1070 |
* |
|
1071 |
* @param array $args Optional. Override default options. |
|
1072 |
* @param int $comment Optional. Comment being replied to. |
|
1073 |
* @param int $post Optional. Post that the comment is going to be displayed on. |
|
1074 |
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
|
1075 |
*/ |
|
1076 |
function comment_reply_link($args = array(), $comment = null, $post = null) { |
|
1077 |
echo get_comment_reply_link($args, $comment, $post); |
|
1078 |
} |
|
1079 |
||
1080 |
/** |
|
1081 |
* Retrieve HTML content for reply to post link. |
|
1082 |
* |
|
1083 |
* The default arguments that can be override are 'add_below', 'respond_id', |
|
1084 |
* 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be |
|
1085 |
* used, if the user must log in or register first before posting a comment. The |
|
1086 |
* 'reply_text' will be used, if they can post a reply. The 'add_below' and |
|
1087 |
* 'respond_id' arguments are for the JavaScript moveAddCommentForm() function |
|
1088 |
* parameters. |
|
1089 |
* |
|
1090 |
* @since 2.7.0 |
|
1091 |
* |
|
1092 |
* @param array $args Optional. Override default options. |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1093 |
* @param int|object $post Optional. Post that the comment is going to be displayed on. Defaults to current post. |
136 | 1094 |
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
1095 |
*/ |
|
1096 |
function get_post_reply_link($args = array(), $post = null) { |
|
1097 |
global $user_ID; |
|
1098 |
||
1099 |
$defaults = array('add_below' => 'post', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'), |
|
1100 |
'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => ''); |
|
1101 |
||
1102 |
$args = wp_parse_args($args, $defaults); |
|
1103 |
extract($args, EXTR_SKIP); |
|
1104 |
$post = get_post($post); |
|
1105 |
||
1106 |
if ( !comments_open($post->ID) ) |
|
1107 |
return false; |
|
1108 |
||
1109 |
if ( get_option('comment_registration') && !$user_ID ) { |
|
1110 |
$link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>'; |
|
1111 |
} else { |
|
1112 |
$link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; |
|
1113 |
} |
|
1114 |
return apply_filters('post_comments_link', $before . $link . $after, $post); |
|
1115 |
} |
|
1116 |
||
1117 |
/** |
|
1118 |
* Displays the HTML content for reply to post link. |
|
1119 |
* @since 2.7.0 |
|
1120 |
* @see get_post_reply_link() |
|
1121 |
* |
|
1122 |
* @param array $args Optional. Override default options. |
|
1123 |
* @param int|object $post Optional. Post that the comment is going to be displayed on. |
|
1124 |
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
|
1125 |
*/ |
|
1126 |
function post_reply_link($args = array(), $post = null) { |
|
1127 |
echo get_post_reply_link($args, $post); |
|
1128 |
} |
|
1129 |
||
1130 |
/** |
|
1131 |
* Retrieve HTML content for cancel comment reply link. |
|
1132 |
* |
|
1133 |
* @since 2.7.0 |
|
1134 |
* |
|
1135 |
* @param string $text Optional. Text to display for cancel reply link. |
|
1136 |
*/ |
|
1137 |
function get_cancel_comment_reply_link($text = '') { |
|
1138 |
if ( empty($text) ) |
|
1139 |
$text = __('Click here to cancel reply.'); |
|
1140 |
||
1141 |
$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
|
1142 |
$link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
|
1143 |
return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text); |
|
1144 |
} |
|
1145 |
||
1146 |
/** |
|
1147 |
* Display HTML content for cancel comment reply link. |
|
1148 |
* |
|
1149 |
* @since 2.7.0 |
|
1150 |
* |
|
1151 |
* @param string $text Optional. Text to display for cancel reply link. |
|
1152 |
*/ |
|
1153 |
function cancel_comment_reply_link($text = '') { |
|
1154 |
echo get_cancel_comment_reply_link($text); |
|
1155 |
} |
|
1156 |
||
1157 |
/** |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1158 |
* Retrieve hidden input HTML for replying to comments. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1159 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1160 |
* @since 3.0.0 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1161 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1162 |
* @return string Hidden input HTML for replying to comments |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1163 |
*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1164 |
function get_comment_id_fields( $id = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1165 |
if ( empty( $id ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1166 |
$id = get_the_ID(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1167 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1168 |
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1169 |
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1170 |
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1171 |
return apply_filters('comment_id_fields', $result, $id, $replytoid); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1172 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1173 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1174 |
/** |
136 | 1175 |
* Output hidden input HTML for replying to comments. |
1176 |
* |
|
1177 |
* @since 2.7.0 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1178 |
* @see get_comment_id_fields() Echoes result |
136 | 1179 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1180 |
function comment_id_fields( $id = 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1181 |
echo get_comment_id_fields( $id ); |
136 | 1182 |
} |
1183 |
||
1184 |
/** |
|
1185 |
* Display text based on comment reply status. Only affects users with Javascript disabled. |
|
1186 |
* |
|
1187 |
* @since 2.7.0 |
|
1188 |
* |
|
1189 |
* @param string $noreplytext Optional. Text to display when not replying to a comment. |
|
1190 |
* @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to. |
|
1191 |
* @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment. |
|
1192 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1193 |
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
136 | 1194 |
global $comment; |
1195 |
||
1196 |
if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
1197 |
if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
1198 |
||
1199 |
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
|
1200 |
||
1201 |
if ( 0 == $replytoid ) |
|
1202 |
echo $noreplytext; |
|
1203 |
else { |
|
1204 |
$comment = get_comment($replytoid); |
|
1205 |
$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author(); |
|
1206 |
printf( $replytext, $author ); |
|
1207 |
} |
|
1208 |
} |
|
1209 |
||
1210 |
/** |
|
1211 |
* HTML comment list class. |
|
1212 |
* |
|
1213 |
* @package WordPress |
|
1214 |
* @uses Walker |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1215 |
* @since 2.7.0 |
136 | 1216 |
*/ |
1217 |
class Walker_Comment extends Walker { |
|
1218 |
/** |
|
1219 |
* @see Walker::$tree_type |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1220 |
* @since 2.7.0 |
136 | 1221 |
* @var string |
1222 |
*/ |
|
1223 |
var $tree_type = 'comment'; |
|
1224 |
||
1225 |
/** |
|
1226 |
* @see Walker::$db_fields |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1227 |
* @since 2.7.0 |
136 | 1228 |
* @var array |
1229 |
*/ |
|
1230 |
var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); |
|
1231 |
||
1232 |
/** |
|
1233 |
* @see Walker::start_lvl() |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1234 |
* @since 2.7.0 |
136 | 1235 |
* |
1236 |
* @param string $output Passed by reference. Used to append additional content. |
|
1237 |
* @param int $depth Depth of comment. |
|
1238 |
* @param array $args Uses 'style' argument for type of HTML list. |
|
1239 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1240 |
function start_lvl( &$output, $depth = 0, $args = array() ) { |
136 | 1241 |
$GLOBALS['comment_depth'] = $depth + 1; |
1242 |
||
1243 |
switch ( $args['style'] ) { |
|
1244 |
case 'div': |
|
1245 |
break; |
|
1246 |
case 'ol': |
|
1247 |
echo "<ol class='children'>\n"; |
|
1248 |
break; |
|
1249 |
default: |
|
1250 |
case 'ul': |
|
1251 |
echo "<ul class='children'>\n"; |
|
1252 |
break; |
|
1253 |
} |
|
1254 |
} |
|
1255 |
||
1256 |
/** |
|
1257 |
* @see Walker::end_lvl() |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1258 |
* @since 2.7.0 |
136 | 1259 |
* |
1260 |
* @param string $output Passed by reference. Used to append additional content. |
|
1261 |
* @param int $depth Depth of comment. |
|
1262 |
* @param array $args Will only append content if style argument value is 'ol' or 'ul'. |
|
1263 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1264 |
function end_lvl( &$output, $depth = 0, $args = array() ) { |
136 | 1265 |
$GLOBALS['comment_depth'] = $depth + 1; |
1266 |
||
1267 |
switch ( $args['style'] ) { |
|
1268 |
case 'div': |
|
1269 |
break; |
|
1270 |
case 'ol': |
|
1271 |
echo "</ol>\n"; |
|
1272 |
break; |
|
1273 |
default: |
|
1274 |
case 'ul': |
|
1275 |
echo "</ul>\n"; |
|
1276 |
break; |
|
1277 |
} |
|
1278 |
} |
|
1279 |
||
1280 |
/** |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1281 |
* This function is designed to enhance Walker::display_element() to |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1282 |
* display children of higher nesting levels than selected inline on |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1283 |
* the highest depth level displayed. This prevents them being orphaned |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1284 |
* at the end of the comment list. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1285 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1286 |
* Example: max_depth = 2, with 5 levels of nested content. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1287 |
* 1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1288 |
* 1.1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1289 |
* 1.1.1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1290 |
* 1.1.1.1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1291 |
* 1.1.1.1.1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1292 |
* 1.1.2 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1293 |
* 1.1.2.1 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1294 |
* 2 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1295 |
* 2.2 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1296 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1297 |
*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1298 |
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1299 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1300 |
if ( !$element ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1301 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1302 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1303 |
$id_field = $this->db_fields['id']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1304 |
$id = $element->$id_field; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1305 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1306 |
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1307 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1308 |
// If we're at the max depth, and the current element still has children, loop over those and display them at this level |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1309 |
// This is to prevent them being orphaned to the end of the list. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1310 |
if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1311 |
foreach ( $children_elements[ $id ] as $child ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1312 |
$this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1313 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1314 |
unset( $children_elements[ $id ] ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1315 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1316 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1317 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1318 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1319 |
/** |
136 | 1320 |
* @see Walker::start_el() |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1321 |
* @since 2.7.0 |
136 | 1322 |
* |
1323 |
* @param string $output Passed by reference. Used to append additional content. |
|
1324 |
* @param object $comment Comment data object. |
|
1325 |
* @param int $depth Depth of comment in reference to parents. |
|
1326 |
* @param array $args |
|
1327 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1328 |
function start_el( &$output, $comment, $depth, $args, $id = 0 ) { |
136 | 1329 |
$depth++; |
1330 |
$GLOBALS['comment_depth'] = $depth; |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1331 |
$GLOBALS['comment'] = $comment; |
136 | 1332 |
|
1333 |
if ( !empty($args['callback']) ) { |
|
1334 |
call_user_func($args['callback'], $comment, $args, $depth); |
|
1335 |
return; |
|
1336 |
} |
|
1337 |
||
1338 |
extract($args, EXTR_SKIP); |
|
1339 |
||
1340 |
if ( 'div' == $args['style'] ) { |
|
1341 |
$tag = 'div'; |
|
1342 |
$add_below = 'comment'; |
|
1343 |
} else { |
|
1344 |
$tag = 'li'; |
|
1345 |
$add_below = 'div-comment'; |
|
1346 |
} |
|
1347 |
?> |
|
1348 |
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>"> |
|
1349 |
<?php if ( 'div' != $args['style'] ) : ?> |
|
1350 |
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"> |
|
1351 |
<?php endif; ?> |
|
1352 |
<div class="comment-author vcard"> |
|
1353 |
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
|
1354 |
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> |
|
1355 |
</div> |
|
1356 |
<?php if ($comment->comment_approved == '0') : ?> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1357 |
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em> |
136 | 1358 |
<br /> |
1359 |
<?php endif; ?> |
|
1360 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1361 |
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1362 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1363 |
/* translators: 1: date, 2: time */ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1364 |
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1365 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1366 |
</div> |
136 | 1367 |
|
1368 |
<?php comment_text() ?> |
|
1369 |
||
1370 |
<div class="reply"> |
|
1371 |
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?> |
|
1372 |
</div> |
|
1373 |
<?php if ( 'div' != $args['style'] ) : ?> |
|
1374 |
</div> |
|
1375 |
<?php endif; ?> |
|
1376 |
<?php |
|
1377 |
} |
|
1378 |
||
1379 |
/** |
|
1380 |
* @see Walker::end_el() |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1381 |
* @since 2.7.0 |
136 | 1382 |
* |
1383 |
* @param string $output Passed by reference. Used to append additional content. |
|
1384 |
* @param object $comment |
|
1385 |
* @param int $depth Depth of comment. |
|
1386 |
* @param array $args |
|
1387 |
*/ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1388 |
function end_el(&$output, $comment, $depth = 0, $args = array() ) { |
136 | 1389 |
if ( !empty($args['end-callback']) ) { |
1390 |
call_user_func($args['end-callback'], $comment, $args, $depth); |
|
1391 |
return; |
|
1392 |
} |
|
1393 |
if ( 'div' == $args['style'] ) |
|
1394 |
echo "</div>\n"; |
|
1395 |
else |
|
1396 |
echo "</li>\n"; |
|
1397 |
} |
|
1398 |
||
1399 |
} |
|
1400 |
||
1401 |
/** |
|
1402 |
* List comments |
|
1403 |
* |
|
1404 |
* Used in the comments.php template to list comments for a particular post |
|
1405 |
* |
|
1406 |
* @since 2.7.0 |
|
1407 |
* @uses Walker_Comment |
|
1408 |
* |
|
1409 |
* @param string|array $args Formatting options |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1410 |
* @param array $comments Optional array of comment objects. Defaults to $wp_query->comments |
136 | 1411 |
*/ |
1412 |
function wp_list_comments($args = array(), $comments = null ) { |
|
1413 |
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; |
|
1414 |
||
1415 |
$in_comment_loop = true; |
|
1416 |
||
1417 |
$comment_alt = $comment_thread_alt = 0; |
|
1418 |
$comment_depth = 1; |
|
1419 |
||
1420 |
$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', |
|
1421 |
'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => ''); |
|
1422 |
||
1423 |
$r = wp_parse_args( $args, $defaults ); |
|
1424 |
||
1425 |
// Figure out what comments we'll be looping through ($_comments) |
|
1426 |
if ( null !== $comments ) { |
|
1427 |
$comments = (array) $comments; |
|
1428 |
if ( empty($comments) ) |
|
1429 |
return; |
|
1430 |
if ( 'all' != $r['type'] ) { |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1431 |
$comments_by_type = separate_comments($comments); |
136 | 1432 |
if ( empty($comments_by_type[$r['type']]) ) |
1433 |
return; |
|
1434 |
$_comments = $comments_by_type[$r['type']]; |
|
1435 |
} else { |
|
1436 |
$_comments = $comments; |
|
1437 |
} |
|
1438 |
} else { |
|
1439 |
if ( empty($wp_query->comments) ) |
|
1440 |
return; |
|
1441 |
if ( 'all' != $r['type'] ) { |
|
1442 |
if ( empty($wp_query->comments_by_type) ) |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1443 |
$wp_query->comments_by_type = separate_comments($wp_query->comments); |
136 | 1444 |
if ( empty($wp_query->comments_by_type[$r['type']]) ) |
1445 |
return; |
|
1446 |
$_comments = $wp_query->comments_by_type[$r['type']]; |
|
1447 |
} else { |
|
1448 |
$_comments = $wp_query->comments; |
|
1449 |
} |
|
1450 |
} |
|
1451 |
||
1452 |
if ( '' === $r['per_page'] && get_option('page_comments') ) |
|
1453 |
$r['per_page'] = get_query_var('comments_per_page'); |
|
1454 |
||
1455 |
if ( empty($r['per_page']) ) { |
|
1456 |
$r['per_page'] = 0; |
|
1457 |
$r['page'] = 0; |
|
1458 |
} |
|
1459 |
||
1460 |
if ( '' === $r['max_depth'] ) { |
|
1461 |
if ( get_option('thread_comments') ) |
|
1462 |
$r['max_depth'] = get_option('thread_comments_depth'); |
|
1463 |
else |
|
1464 |
$r['max_depth'] = -1; |
|
1465 |
} |
|
1466 |
||
1467 |
if ( '' === $r['page'] ) { |
|
1468 |
if ( empty($overridden_cpage) ) { |
|
1469 |
$r['page'] = get_query_var('cpage'); |
|
1470 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1471 |
$threaded = ( -1 != $r['max_depth'] ); |
136 | 1472 |
$r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
1473 |
set_query_var( 'cpage', $r['page'] ); |
|
1474 |
} |
|
1475 |
} |
|
1476 |
// Validation check |
|
1477 |
$r['page'] = intval($r['page']); |
|
1478 |
if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
1479 |
$r['page'] = 1; |
|
1480 |
||
1481 |
if ( null === $r['reverse_top_level'] ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1482 |
$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
136 | 1483 |
|
1484 |
extract( $r, EXTR_SKIP ); |
|
1485 |
||
1486 |
if ( empty($walker) ) |
|
1487 |
$walker = new Walker_Comment; |
|
1488 |
||
1489 |
$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r); |
|
1490 |
$wp_query->max_num_comment_pages = $walker->max_pages; |
|
1491 |
||
1492 |
$in_comment_loop = false; |
|
1493 |
} |
|
1494 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1495 |
/** |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1496 |
* Outputs a complete commenting form for use within a template. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1497 |
* Most strings and form fields may be controlled through the $args array passed |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1498 |
* into the function, while you may also choose to use the comment_form_default_fields |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1499 |
* filter to modify the array of default fields if you'd just like to add a new |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1500 |
* one or remove a single field. All fields are also individually passed through |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1501 |
* a filter of the form comment_form_field_$name where $name is the key used |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1502 |
* in the array of fields. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1503 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1504 |
* @since 3.0.0 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1505 |
* @param array $args Options for strings, fields etc in the form |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1506 |
* @param mixed $post_id Post ID to generate the form for, uses the current post if null |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1507 |
* @return void |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1508 |
*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1509 |
function comment_form( $args = array(), $post_id = null ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1510 |
global $id; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1511 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1512 |
if ( null === $post_id ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1513 |
$post_id = $id; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1514 |
else |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1515 |
$id = $post_id; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1516 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1517 |
$commenter = wp_get_current_commenter(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1518 |
$user = wp_get_current_user(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1519 |
$user_identity = $user->exists() ? $user->display_name : ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1520 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1521 |
$req = get_option( 'require_name_email' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1522 |
$aria_req = ( $req ? " aria-required='true'" : '' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1523 |
$fields = array( |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1524 |
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1525 |
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1526 |
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1527 |
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1528 |
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' . |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1529 |
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1530 |
); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1531 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1532 |
$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1533 |
$defaults = array( |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1534 |
'fields' => apply_filters( 'comment_form_default_fields', $fields ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1535 |
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1536 |
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1537 |
'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1538 |
'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1539 |
'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1540 |
'id_form' => 'commentform', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1541 |
'id_submit' => 'submit', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1542 |
'title_reply' => __( 'Leave a Reply' ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1543 |
'title_reply_to' => __( 'Leave a Reply to %s' ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1544 |
'cancel_reply_link' => __( 'Cancel reply' ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1545 |
'label_submit' => __( 'Post Comment' ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1546 |
); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1547 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1548 |
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1549 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1550 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1551 |
<?php if ( comments_open( $post_id ) ) : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1552 |
<?php do_action( 'comment_form_before' ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1553 |
<div id="respond"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1554 |
<h3 id="reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1555 |
<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1556 |
<?php echo $args['must_log_in']; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1557 |
<?php do_action( 'comment_form_must_log_in_after' ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1558 |
<?php else : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1559 |
<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1560 |
<?php do_action( 'comment_form_top' ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1561 |
<?php if ( is_user_logged_in() ) : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1562 |
<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1563 |
<?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1564 |
<?php else : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1565 |
<?php echo $args['comment_notes_before']; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1566 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1567 |
do_action( 'comment_form_before_fields' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1568 |
foreach ( (array) $args['fields'] as $name => $field ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1569 |
echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1570 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1571 |
do_action( 'comment_form_after_fields' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1572 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1573 |
<?php endif; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1574 |
<?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1575 |
<?php echo $args['comment_notes_after']; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1576 |
<p class="form-submit"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1577 |
<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" /> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1578 |
<?php comment_id_fields( $post_id ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1579 |
</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1580 |
<?php do_action( 'comment_form', $post_id ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1581 |
</form> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1582 |
<?php endif; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1583 |
</div><!-- #respond --> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1584 |
<?php do_action( 'comment_form_after' ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1585 |
<?php else : ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1586 |
<?php do_action( 'comment_form_comments_closed' ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1587 |
<?php endif; ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1588 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1589 |
} |