author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 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 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 19 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
9 | 21 |
* Default current comment. |
0 | 22 |
* @return string The comment author |
23 |
*/ |
|
24 |
function get_comment_author( $comment_ID = 0 ) { |
|
25 |
$comment = get_comment( $comment_ID ); |
|
26 |
||
27 |
if ( empty( $comment->comment_author ) ) { |
|
9 | 28 |
if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { |
0 | 29 |
$author = $user->display_name; |
9 | 30 |
} else { |
31 |
$author = __( 'Anonymous' ); |
|
32 |
} |
|
0 | 33 |
} else { |
34 |
$author = $comment->comment_author; |
|
35 |
} |
|
36 |
||
37 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
* Filters the returned comment author name. |
0 | 39 |
* |
5 | 40 |
* @since 1.5.0 |
41 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
0 | 42 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
* @param string $author The comment author's username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
* @param int $comment_ID The comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
* @param WP_Comment $comment The comment object. |
0 | 46 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment ); |
0 | 48 |
} |
49 |
||
50 |
/** |
|
51 |
* Displays the author of the current comment. |
|
52 |
* |
|
53 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 55 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. |
9 | 57 |
* Default current comment. |
0 | 58 |
*/ |
59 |
function comment_author( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
$comment = get_comment( $comment_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
$author = get_comment_author( $comment ); |
5 | 62 |
|
0 | 63 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
* Filters the comment author's name for display. |
0 | 65 |
* |
5 | 66 |
* @since 1.2.0 |
67 |
* @since 4.1.0 The `$comment_ID` parameter was added. |
|
0 | 68 |
* |
5 | 69 |
* @param string $author The comment author's username. |
70 |
* @param int $comment_ID The comment ID. |
|
0 | 71 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
echo apply_filters( 'comment_author', $author, $comment->comment_ID ); |
0 | 73 |
} |
74 |
||
75 |
/** |
|
76 |
* Retrieve the email of the author of the current comment. |
|
77 |
* |
|
78 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 80 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. |
9 | 82 |
* Default current comment. |
0 | 83 |
* @return string The current comment author's email |
84 |
*/ |
|
85 |
function get_comment_author_email( $comment_ID = 0 ) { |
|
86 |
$comment = get_comment( $comment_ID ); |
|
5 | 87 |
|
0 | 88 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
* Filters the comment author's returned email address. |
0 | 90 |
* |
5 | 91 |
* @since 1.5.0 |
92 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
0 | 93 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @param string $comment_author_email The comment author's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
* @param int $comment_ID The comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
* @param WP_Comment $comment The comment object. |
0 | 97 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); |
0 | 99 |
} |
100 |
||
101 |
/** |
|
102 |
* Display the email of the author of the current global $comment. |
|
103 |
* |
|
104 |
* Care should be taken to protect the email address and assure that email |
|
9 | 105 |
* harvesters do not capture your commenter's email address. Most assume that |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
* their email address will not appear in raw form on the site. Doing so will |
0 | 107 |
* enable anyone, including those that people don't want to get the email |
108 |
* address and use it for their own means good and bad. |
|
109 |
* |
|
110 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 112 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. |
9 | 114 |
* Default current comment. |
0 | 115 |
*/ |
116 |
function comment_author_email( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
$comment = get_comment( $comment_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
$author_email = get_comment_author_email( $comment ); |
5 | 119 |
|
0 | 120 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
* Filters the comment author's email for display. |
0 | 122 |
* |
5 | 123 |
* @since 1.2.0 |
124 |
* @since 4.1.0 The `$comment_ID` parameter was added. |
|
0 | 125 |
* |
126 |
* @param string $author_email The comment author's email address. |
|
5 | 127 |
* @param int $comment_ID The comment ID. |
0 | 128 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
echo apply_filters( 'author_email', $author_email, $comment->comment_ID ); |
0 | 130 |
} |
131 |
||
132 |
/** |
|
133 |
* Display the html email link to the author of the current comment. |
|
134 |
* |
|
135 |
* Care should be taken to protect the email address and assure that email |
|
9 | 136 |
* harvesters do not capture your commenter's email address. Most assume that |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
* their email address will not appear in raw form on the site. Doing so will |
0 | 138 |
* enable anyone, including those that people don't want to get the email |
139 |
* address and use it for their own means good and bad. |
|
140 |
* |
|
141 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* @since 4.6.0 Added the `$comment` parameter. |
0 | 143 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
* @param string $linktext Optional. Text to display instead of the comment author's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* @param string $before Optional. Text or HTML to display before the email link. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* @param string $after Optional. Text or HTML to display after the email link. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. |
0 | 149 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) { |
0 | 152 |
echo $link; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
} |
0 | 154 |
} |
155 |
||
156 |
/** |
|
157 |
* Return the html email link to the author of the current comment. |
|
158 |
* |
|
159 |
* Care should be taken to protect the email address and assure that email |
|
9 | 160 |
* harvesters do not capture your commenter's email address. Most assume that |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
* their email address will not appear in raw form on the site. Doing so will |
0 | 162 |
* enable anyone, including those that people don't want to get the email |
163 |
* address and use it for their own means good and bad. |
|
164 |
* |
|
5 | 165 |
* @since 2.7.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
* @since 4.6.0 Added the `$comment` parameter. |
0 | 167 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
* @param string $linktext Optional. Text to display instead of the comment author's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
* @param string $before Optional. Text or HTML to display before the email link. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
* @param string $after Optional. Text or HTML to display after the email link. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
* @return string HTML markup for the comment author email link. By default, the email address is obfuscated |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
* via the {@see 'comment_email'} filter with antispambot(). |
0 | 175 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
$comment = get_comment( $comment ); |
5 | 178 |
|
0 | 179 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
* Filters the comment author's email for display. |
0 | 181 |
* |
182 |
* Care should be taken to protect the email address and assure that email |
|
5 | 183 |
* harvesters do not capture your commenter's email address. |
0 | 184 |
* |
5 | 185 |
* @since 1.2.0 |
186 |
* @since 4.1.0 The `$comment` parameter was added. |
|
0 | 187 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
* @param string $comment_author_email The comment author's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
* @param WP_Comment $comment The comment object. |
0 | 190 |
*/ |
5 | 191 |
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
|
9 | 193 |
if ( ( ! empty( $email ) ) && ( $email != '@' ) ) { |
194 |
$display = ( $linktext != '' ) ? $linktext : $email; |
|
0 | 195 |
$return = $before; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); |
9 | 197 |
$return .= $after; |
0 | 198 |
return $return; |
199 |
} else { |
|
200 |
return ''; |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
/** |
|
205 |
* Retrieve the HTML link to the URL of the author of the current comment. |
|
206 |
* |
|
207 |
* Both get_comment_author_url() and get_comment_author() rely on get_comment(), |
|
208 |
* which falls back to the global comment variable if the $comment_ID argument is empty. |
|
209 |
* |
|
210 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 212 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
9 | 214 |
* Default current comment. |
0 | 215 |
* @return string The comment author name or HTML link for author's URL. |
216 |
*/ |
|
217 |
function get_comment_author_link( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
$comment = get_comment( $comment_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
$url = get_comment_author_url( $comment ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
$author = get_comment_author( $comment ); |
0 | 221 |
|
9 | 222 |
if ( empty( $url ) || 'http://' == $url ) { |
0 | 223 |
$return = $author; |
9 | 224 |
} else { |
0 | 225 |
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
9 | 226 |
} |
0 | 227 |
|
228 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
229 |
* Filters the comment author's link for display. |
0 | 230 |
* |
5 | 231 |
* @since 1.5.0 |
232 |
* @since 4.1.0 The `$author` and `$comment_ID` parameters were added. |
|
0 | 233 |
* |
5 | 234 |
* @param string $return The HTML-formatted comment author link. |
235 |
* Empty for an invalid URL. |
|
236 |
* @param string $author The comment author's username. |
|
237 |
* @param int $comment_ID The comment ID. |
|
0 | 238 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); |
0 | 240 |
} |
241 |
||
242 |
/** |
|
243 |
* Display the html link to the url of the author of the current comment. |
|
244 |
* |
|
245 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 247 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. |
9 | 249 |
* Default current comment. |
0 | 250 |
*/ |
251 |
function comment_author_link( $comment_ID = 0 ) { |
|
252 |
echo get_comment_author_link( $comment_ID ); |
|
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* Retrieve the IP address of the author of the current comment. |
|
257 |
* |
|
258 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 260 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
9 | 262 |
* Default current comment. |
5 | 263 |
* @return string Comment author's IP address. |
0 | 264 |
*/ |
265 |
function get_comment_author_IP( $comment_ID = 0 ) { |
|
266 |
$comment = get_comment( $comment_ID ); |
|
267 |
||
268 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
* Filters the comment author's returned IP address. |
0 | 270 |
* |
5 | 271 |
* @since 1.5.0 |
272 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
0 | 273 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
* @param string $comment_author_IP The comment author's IP address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
* @param int $comment_ID The comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
* @param WP_Comment $comment The comment object. |
0 | 277 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); |
0 | 279 |
} |
280 |
||
281 |
/** |
|
282 |
* Display the IP address of the author of the current comment. |
|
283 |
* |
|
284 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 286 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. |
9 | 288 |
* Default current comment. |
0 | 289 |
*/ |
290 |
function comment_author_IP( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
echo esc_html( get_comment_author_IP( $comment_ID ) ); |
0 | 292 |
} |
293 |
||
294 |
/** |
|
295 |
* Retrieve the url of the author of the current comment. |
|
296 |
* |
|
297 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 299 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
9 | 301 |
* Default current comment. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
* @return string Comment author URL. |
0 | 303 |
*/ |
304 |
function get_comment_author_url( $comment_ID = 0 ) { |
|
305 |
$comment = get_comment( $comment_ID ); |
|
9 | 306 |
$url = ''; |
307 |
$id = 0; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
if ( ! empty( $comment ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; |
9 | 310 |
$url = esc_url( $author_url, array( 'http', 'https' ) ); |
311 |
$id = $comment->comment_ID; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
} |
5 | 313 |
|
314 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* Filters the comment author's URL. |
5 | 316 |
* |
317 |
* @since 1.5.0 |
|
318 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
319 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
* @param string $url The comment author's URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* @param int $comment_ID The comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* @param WP_Comment $comment The comment object. |
5 | 323 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
return apply_filters( 'get_comment_author_url', $url, $id, $comment ); |
0 | 325 |
} |
326 |
||
327 |
/** |
|
328 |
* Display the url of the author of the current comment. |
|
329 |
* |
|
330 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 332 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. |
9 | 334 |
* Default current comment. |
0 | 335 |
*/ |
336 |
function comment_author_url( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
$comment = get_comment( $comment_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
$author_url = get_comment_author_url( $comment ); |
5 | 339 |
|
0 | 340 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
* Filters the comment author's URL for display. |
0 | 342 |
* |
5 | 343 |
* @since 1.2.0 |
344 |
* @since 4.1.0 The `$comment_ID` parameter was added. |
|
0 | 345 |
* |
346 |
* @param string $author_url The comment author's URL. |
|
5 | 347 |
* @param int $comment_ID The comment ID. |
0 | 348 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
echo apply_filters( 'comment_url', $author_url, $comment->comment_ID ); |
0 | 350 |
} |
351 |
||
352 |
/** |
|
353 |
* Retrieves the HTML link of the url of the author of the current comment. |
|
354 |
* |
|
355 |
* $linktext parameter is only used if the URL does not exist for the comment |
|
356 |
* author. If the URL does exist then the URL will be used and the $linktext |
|
357 |
* will be ignored. |
|
358 |
* |
|
359 |
* Encapsulate the HTML link between the $before and $after. So it will appear |
|
360 |
* in the order of $before, link, and finally $after. |
|
361 |
* |
|
362 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
* @since 4.6.0 Added the `$comment` parameter. |
0 | 364 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
* @param string $linktext Optional. The text to display instead of the comment |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
* author's email address. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
* @param string $before Optional. The text or HTML to display before the email link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
* @param string $after Optional. The text or HTML to display after the email link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
* Default is the current comment. |
0 | 373 |
* @return string The HTML link between the $before and $after parameters. |
374 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
9 | 376 |
$url = get_comment_author_url( $comment ); |
377 |
$display = ( $linktext != '' ) ? $linktext : $url; |
|
0 | 378 |
$display = str_replace( 'http://www.', '', $display ); |
379 |
$display = str_replace( 'http://', '', $display ); |
|
5 | 380 |
|
9 | 381 |
if ( '/' == substr( $display, -1 ) ) { |
382 |
$display = substr( $display, 0, -1 ); |
|
5 | 383 |
} |
384 |
||
0 | 385 |
$return = "$before<a href='$url' rel='external'>$display</a>$after"; |
386 |
||
387 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* Filters the comment author's returned URL link. |
0 | 389 |
* |
5 | 390 |
* @since 1.5.0 |
0 | 391 |
* |
392 |
* @param string $return The HTML-formatted comment author URL link. |
|
393 |
*/ |
|
394 |
return apply_filters( 'get_comment_author_url_link', $return ); |
|
395 |
} |
|
396 |
||
397 |
/** |
|
398 |
* Displays the HTML link of the url of the author of the current comment. |
|
399 |
* |
|
400 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
* @since 4.6.0 Added the `$comment` parameter. |
0 | 402 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
* @param string $linktext Optional. Text to display instead of the comment author's |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
* email address. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
* @param string $before Optional. Text or HTML to display before the email link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* @param string $after Optional. Text or HTML to display after the email link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
* Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
* Default is the current comment. |
0 | 411 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
echo get_comment_author_url_link( $linktext, $before, $after, $comment ); |
0 | 414 |
} |
415 |
||
416 |
/** |
|
5 | 417 |
* Generates semantic classes for each comment element. |
0 | 418 |
* |
419 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. |
0 | 421 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
* @param string|array $class Optional. One or more classes to add to the class list. |
5 | 423 |
* Default empty. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* @param bool $echo Optional. Whether to cho or return the output. |
5 | 427 |
* Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* @return string If `$echo` is false, the class will be returned. Void otherwise. |
0 | 429 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
0 | 431 |
// Separates classes with a single space, collates classes for comment DIV |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
$class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
9 | 433 |
if ( $echo ) { |
0 | 434 |
echo $class; |
9 | 435 |
} else { |
0 | 436 |
return $class; |
9 | 437 |
} |
0 | 438 |
} |
439 |
||
440 |
/** |
|
5 | 441 |
* Returns the classes for the comment div as an array. |
0 | 442 |
* |
443 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object. |
0 | 445 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
* @global int $comment_alt |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
* @global int $comment_depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
* @global int $comment_thread_alt |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
* @param string|array $class Optional. One or more classes to add to the class list. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
0 | 453 |
* @return array An array of classes. |
454 |
*/ |
|
455 |
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
|
456 |
global $comment_alt, $comment_depth, $comment_thread_alt; |
|
457 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
$classes = array(); |
0 | 459 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
$comment = get_comment( $comment_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
if ( ! $comment ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
return $classes; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
} |
0 | 464 |
|
465 |
// Get the comment type (comment, trackback), |
|
466 |
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; |
|
467 |
||
5 | 468 |
// Add classes for comment authors that are registered users. |
469 |
if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
|
0 | 470 |
$classes[] = 'byuser'; |
5 | 471 |
$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
0 | 472 |
// For comment authors who are the author of the post |
9 | 473 |
if ( $post = get_post( $post_id ) ) { |
5 | 474 |
if ( $comment->user_id === $post->post_author ) { |
0 | 475 |
$classes[] = 'bypostauthor'; |
5 | 476 |
} |
0 | 477 |
} |
478 |
} |
|
479 |
||
9 | 480 |
if ( empty( $comment_alt ) ) { |
0 | 481 |
$comment_alt = 0; |
9 | 482 |
} |
483 |
if ( empty( $comment_depth ) ) { |
|
0 | 484 |
$comment_depth = 1; |
9 | 485 |
} |
486 |
if ( empty( $comment_thread_alt ) ) { |
|
0 | 487 |
$comment_thread_alt = 0; |
9 | 488 |
} |
0 | 489 |
|
490 |
if ( $comment_alt % 2 ) { |
|
491 |
$classes[] = 'odd'; |
|
492 |
$classes[] = 'alt'; |
|
493 |
} else { |
|
494 |
$classes[] = 'even'; |
|
495 |
} |
|
496 |
||
497 |
$comment_alt++; |
|
498 |
||
499 |
// Alt for top-level comments |
|
500 |
if ( 1 == $comment_depth ) { |
|
501 |
if ( $comment_thread_alt % 2 ) { |
|
502 |
$classes[] = 'thread-odd'; |
|
503 |
$classes[] = 'thread-alt'; |
|
504 |
} else { |
|
505 |
$classes[] = 'thread-even'; |
|
506 |
} |
|
507 |
$comment_thread_alt++; |
|
508 |
} |
|
509 |
||
510 |
$classes[] = "depth-$comment_depth"; |
|
511 |
||
9 | 512 |
if ( ! empty( $class ) ) { |
513 |
if ( ! is_array( $class ) ) { |
|
514 |
$class = preg_split( '#\s+#', $class ); |
|
515 |
} |
|
516 |
$classes = array_merge( $classes, $class ); |
|
0 | 517 |
} |
518 |
||
9 | 519 |
$classes = array_map( 'esc_attr', $classes ); |
0 | 520 |
|
521 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
* Filters the returned CSS classes for the current comment. |
0 | 523 |
* |
524 |
* @since 2.7.0 |
|
525 |
* |
|
9 | 526 |
* @param string[] $classes An array of comment classes. |
0 | 527 |
* @param string $class A comma-separated list of additional classes added to the list. |
528 |
* @param int $comment_id The comment id. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
* @param WP_Comment $comment The comment object. |
0 | 530 |
* @param int|WP_Post $post_id The post ID or WP_Post object. |
531 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id ); |
0 | 533 |
} |
534 |
||
535 |
/** |
|
536 |
* Retrieve the comment date of the current comment. |
|
537 |
* |
|
538 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 540 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
* @param string $d Optional. The format of the date. Default user's setting. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
543 |
* Default current comment. |
0 | 544 |
* @return string The comment's date. |
545 |
*/ |
|
546 |
function get_comment_date( $d = '', $comment_ID = 0 ) { |
|
547 |
$comment = get_comment( $comment_ID ); |
|
9 | 548 |
if ( '' == $d ) { |
549 |
$date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); |
|
550 |
} else { |
|
551 |
$date = mysql2date( $d, $comment->comment_date ); |
|
552 |
} |
|
0 | 553 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
* Filters the returned comment date. |
0 | 555 |
* |
5 | 556 |
* @since 1.5.0 |
0 | 557 |
* |
5 | 558 |
* @param string|int $date Formatted date string or Unix timestamp. |
559 |
* @param string $d The format of the date. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
* @param WP_Comment $comment The comment object. |
0 | 561 |
*/ |
5 | 562 |
return apply_filters( 'get_comment_date', $date, $d, $comment ); |
0 | 563 |
} |
564 |
||
565 |
/** |
|
566 |
* Display the comment date of the current comment. |
|
567 |
* |
|
568 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 570 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
* @param string $d Optional. The format of the date. Default user's settings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
* Default current comment. |
0 | 574 |
*/ |
575 |
function comment_date( $d = '', $comment_ID = 0 ) { |
|
576 |
echo get_comment_date( $d, $comment_ID ); |
|
577 |
} |
|
578 |
||
579 |
/** |
|
580 |
* Retrieve the excerpt of the current comment. |
|
581 |
* |
|
582 |
* Will cut each word and only output the first 20 words with '…' at the end. |
|
583 |
* If the word count is less than 20, then no truncating is done and no '…' |
|
584 |
* will appear. |
|
585 |
* |
|
586 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 588 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
* Default current comment. |
0 | 591 |
* @return string The maybe truncated comment with 20 words or less. |
592 |
*/ |
|
593 |
function get_comment_excerpt( $comment_ID = 0 ) { |
|
9 | 594 |
$comment = get_comment( $comment_ID ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); |
9 | 596 |
$words = explode( ' ', $comment_text ); |
5 | 597 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
* Filters the amount of words used in the comment excerpt. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
* @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
$comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
$use_ellipsis = count( $words ) > $comment_excerpt_length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
if ( $use_ellipsis ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
$words = array_slice( $words, 0, $comment_excerpt_length ); |
0 | 610 |
} |
5 | 611 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
$excerpt = trim( join( ' ', $words ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
if ( $use_ellipsis ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
$excerpt .= '…'; |
0 | 615 |
} |
5 | 616 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
* Filters the retrieved comment excerpt. |
5 | 618 |
* |
619 |
* @since 1.5.0 |
|
620 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
621 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
* @param string $excerpt The comment excerpt text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
* @param int $comment_ID The comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
* @param WP_Comment $comment The comment object. |
5 | 625 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); |
0 | 627 |
} |
628 |
||
629 |
/** |
|
630 |
* Display the excerpt of the current comment. |
|
631 |
* |
|
632 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 634 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
* Default current comment. |
0 | 637 |
*/ |
638 |
function comment_excerpt( $comment_ID = 0 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
$comment = get_comment( $comment_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
$comment_excerpt = get_comment_excerpt( $comment ); |
5 | 641 |
|
0 | 642 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
* Filters the comment excerpt for display. |
0 | 644 |
* |
5 | 645 |
* @since 1.2.0 |
646 |
* @since 4.1.0 The `$comment_ID` parameter was added. |
|
0 | 647 |
* |
648 |
* @param string $comment_excerpt The comment excerpt text. |
|
5 | 649 |
* @param int $comment_ID The comment ID. |
0 | 650 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); |
0 | 652 |
} |
653 |
||
654 |
/** |
|
655 |
* Retrieve the comment id of the current comment. |
|
656 |
* |
|
657 |
* @since 1.5.0 |
|
658 |
* |
|
659 |
* @return int The comment ID. |
|
660 |
*/ |
|
661 |
function get_comment_ID() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
$comment = get_comment(); |
5 | 663 |
|
0 | 664 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
* Filters the returned comment ID. |
0 | 666 |
* |
5 | 667 |
* @since 1.5.0 |
668 |
* @since 4.1.0 The `$comment_ID` parameter was added. |
|
0 | 669 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
* @param int $comment_ID The current comment ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
* @param WP_Comment $comment The comment object. |
0 | 672 |
*/ |
5 | 673 |
return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); |
0 | 674 |
} |
675 |
||
676 |
/** |
|
677 |
* Display the comment id of the current comment. |
|
678 |
* |
|
679 |
* @since 0.71 |
|
680 |
*/ |
|
681 |
function comment_ID() { |
|
682 |
echo get_comment_ID(); |
|
683 |
} |
|
684 |
||
685 |
/** |
|
686 |
* Retrieve the link to a given comment. |
|
687 |
* |
|
688 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument. |
0 | 690 |
* |
5 | 691 |
* @see get_page_of_comment() |
692 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
* @global WP_Rewrite $wp_rewrite |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
* @global bool $in_comment_loop |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
* @param WP_Comment|int|null $comment Comment to retrieve. Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
* @param array $args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
* An array of optional arguments to override the defaults. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* @type string $type Passed to get_page_of_comment(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
* @type int $page Current page of comments, for calculating comment pagination. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
* @type int $per_page Per-page value for comment pagination. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
* @type int $max_depth Passed to get_page_of_comment(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
* @type int|string $cpage Value to use for the comment's "comment-page" or "cpage" value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
* If provided, this value overrides any value calculated from `$page` |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
* and `$per_page`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
* } |
0 | 708 |
* @return string The permalink to the given comment. |
709 |
*/ |
|
710 |
function get_comment_link( $comment = null, $args = array() ) { |
|
711 |
global $wp_rewrite, $in_comment_loop; |
|
712 |
||
9 | 713 |
$comment = get_comment( $comment ); |
0 | 714 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
// Back-compat. |
5 | 716 |
if ( ! is_array( $args ) ) { |
717 |
$args = array( 'page' => $args ); |
|
0 | 718 |
} |
719 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
$defaults = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
'type' => 'all', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
'page' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
'per_page' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
'max_depth' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
'cpage' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
); |
9 | 727 |
$args = wp_parse_args( $args, $defaults ); |
0 | 728 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
$link = get_permalink( $comment->comment_post_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
// The 'cpage' param takes precedence. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
if ( ! is_null( $args['cpage'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
$cpage = $args['cpage']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
|
9 | 735 |
// No 'cpage' is provided, so we calculate one. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { |
9 | 738 |
$args['per_page'] = get_option( 'comments_per_page' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
if ( empty( $args['per_page'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
$args['per_page'] = 0; |
9 | 743 |
$args['page'] = 0; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
} |
0 | 745 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
$cpage = $args['page']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
if ( '' == $cpage ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
if ( ! empty( $in_comment_loop ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
$cpage = get_query_var( 'cpage' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
// Requires a database hit, so we only do it when we can't figure out from context. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
$cpage = get_page_of_comment( $comment->comment_ID, $args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
* If the default page displays the oldest comments, the permalinks for comments on the default page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
* do not need a 'cpage' query var. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
$cpage = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
} |
0 | 764 |
} |
765 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
if ( $cpage && get_option( 'page_comments' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
if ( $wp_rewrite->using_permalinks() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
768 |
if ( $cpage ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
769 |
$link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
} |
0 | 771 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
$link = user_trailingslashit( $link, 'comment' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
} elseif ( $cpage ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
$link = add_query_arg( 'cpage', $cpage, $link ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
if ( $wp_rewrite->using_permalinks() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
$link = user_trailingslashit( $link, 'comment' ); |
0 | 780 |
} |
781 |
||
782 |
$link = $link . '#comment-' . $comment->comment_ID; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
|
0 | 784 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
* Filters the returned single comment permalink. |
0 | 786 |
* |
787 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
* @since 4.4.0 Added the `$cpage` parameter. |
0 | 789 |
* |
5 | 790 |
* @see get_page_of_comment() |
791 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
* @param string $link The comment permalink with '#comment-$id' appended. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
* @param WP_Comment $comment The current comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
* @param array $args An array of arguments to override the defaults. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
* @param int $cpage The calculated 'cpage' value. |
0 | 796 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage ); |
0 | 798 |
} |
799 |
||
800 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
* Retrieves the link to the current post comments. |
0 | 802 |
* |
803 |
* @since 1.5.0 |
|
804 |
* |
|
5 | 805 |
* @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
0 | 806 |
* @return string The link to the comments. |
807 |
*/ |
|
808 |
function get_comments_link( $post_id = 0 ) { |
|
9 | 809 |
$hash = get_comments_number( $post_id ) ? '#comments' : '#respond'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
$comments_link = get_permalink( $post_id ) . $hash; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
811 |
|
0 | 812 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
* Filters the returned post comments permalink. |
0 | 814 |
* |
5 | 815 |
* @since 3.6.0 |
0 | 816 |
* |
5 | 817 |
* @param string $comments_link Post comments permalink with '#comments' appended. |
818 |
* @param int|WP_Post $post_id Post ID or WP_Post object. |
|
0 | 819 |
*/ |
820 |
return apply_filters( 'get_comments_link', $comments_link, $post_id ); |
|
821 |
} |
|
822 |
||
823 |
/** |
|
824 |
* Display the link to the current post comments. |
|
825 |
* |
|
826 |
* @since 0.71 |
|
827 |
* |
|
828 |
* @param string $deprecated Not Used. |
|
5 | 829 |
* @param string $deprecated_2 Not Used. |
0 | 830 |
*/ |
831 |
function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
|
9 | 832 |
if ( ! empty( $deprecated ) ) { |
0 | 833 |
_deprecated_argument( __FUNCTION__, '0.72' ); |
9 | 834 |
} |
835 |
if ( ! empty( $deprecated_2 ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
_deprecated_argument( __FUNCTION__, '1.3.0' ); |
9 | 837 |
} |
0 | 838 |
echo esc_url( get_comments_link() ); |
839 |
} |
|
840 |
||
841 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
* Retrieves the amount of comments a post has. |
0 | 843 |
* |
844 |
* @since 1.5.0 |
|
845 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
* @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
* @return string|int If the post exists, a numeric string representing the number of comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
* the post has, otherwise 0. |
0 | 849 |
*/ |
850 |
function get_comments_number( $post_id = 0 ) { |
|
5 | 851 |
$post = get_post( $post_id ); |
0 | 852 |
|
5 | 853 |
if ( ! $post ) { |
0 | 854 |
$count = 0; |
5 | 855 |
} else { |
9 | 856 |
$count = $post->comment_count; |
5 | 857 |
$post_id = $post->ID; |
858 |
} |
|
0 | 859 |
|
860 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
* Filters the returned comment count for a post. |
0 | 862 |
* |
5 | 863 |
* @since 1.5.0 |
0 | 864 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
* @param string|int $count A string representing the number of comments a post has, otherwise 0. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
866 |
* @param int $post_id Post ID. |
0 | 867 |
*/ |
868 |
return apply_filters( 'get_comments_number', $count, $post_id ); |
|
869 |
} |
|
870 |
||
871 |
/** |
|
872 |
* Display the language string for the number of comments the current post has. |
|
873 |
* |
|
874 |
* @since 0.71 |
|
875 |
* |
|
876 |
* @param string $zero Optional. Text for no comments. Default false. |
|
877 |
* @param string $one Optional. Text for one comment. Default false. |
|
878 |
* @param string $more Optional. Text for more than one comment. Default false. |
|
879 |
* @param string $deprecated Not used. |
|
880 |
*/ |
|
881 |
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { |
|
5 | 882 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
_deprecated_argument( __FUNCTION__, '1.3.0' ); |
5 | 884 |
} |
885 |
echo get_comments_number_text( $zero, $one, $more ); |
|
886 |
} |
|
0 | 887 |
|
5 | 888 |
/** |
889 |
* Display the language string for the number of comments the current post has. |
|
890 |
* |
|
891 |
* @since 4.0.0 |
|
892 |
* |
|
893 |
* @param string $zero Optional. Text for no comments. Default false. |
|
894 |
* @param string $one Optional. Text for one comment. Default false. |
|
895 |
* @param string $more Optional. Text for more than one comment. Default false. |
|
896 |
*/ |
|
897 |
function get_comments_number_text( $zero = false, $one = false, $more = false ) { |
|
0 | 898 |
$number = get_comments_number(); |
899 |
||
5 | 900 |
if ( $number > 1 ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
if ( false === $more ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
/* translators: %s: number of comments */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
$output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
// % Comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
/* translators: If comment number in your language requires declension, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
* translate this to 'on'. Do not translate into your own language. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
$text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
$text = preg_replace( '/&.+?;/', '', $text ); // Kill entities |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
$text = trim( strip_tags( $text ), '% ' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
// Replace '% Comments' with a proper plural form |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
/* translators: %s: number of comments */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
$new_text = _n( '%s Comment', '%s Comments', $number ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
918 |
$new_text = trim( sprintf( $new_text, '' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
$more = str_replace( $text, $new_text, $more ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
if ( false === strpos( $more, '%' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
$more = '% ' . $more; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
926 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
$output = str_replace( '%', number_format_i18n( $number ), $more ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
} |
5 | 929 |
} elseif ( $number == 0 ) { |
930 |
$output = ( false === $zero ) ? __( 'No Comments' ) : $zero; |
|
931 |
} else { // must be one |
|
932 |
$output = ( false === $one ) ? __( '1 Comment' ) : $one; |
|
933 |
} |
|
0 | 934 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
* Filters the comments count for display. |
0 | 936 |
* |
5 | 937 |
* @since 1.5.0 |
0 | 938 |
* |
5 | 939 |
* @see _n() |
940 |
* |
|
941 |
* @param string $output A translatable string formatted based on whether the count |
|
942 |
* is equal to 0, 1, or 1+. |
|
0 | 943 |
* @param int $number The number of post comments. |
944 |
*/ |
|
5 | 945 |
return apply_filters( 'comments_number', $output, $number ); |
0 | 946 |
} |
947 |
||
948 |
/** |
|
949 |
* Retrieve the text of the current comment. |
|
950 |
* |
|
951 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 953 |
* |
5 | 954 |
* @see Walker_Comment::comment() |
955 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
* Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
* @param array $args Optional. An array of arguments. Default empty. |
0 | 959 |
* @return string The comment content. |
960 |
*/ |
|
961 |
function get_comment_text( $comment_ID = 0, $args = array() ) { |
|
962 |
$comment = get_comment( $comment_ID ); |
|
963 |
||
964 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
* Filters the text of a comment. |
0 | 966 |
* |
5 | 967 |
* @since 1.5.0 |
968 |
* |
|
969 |
* @see Walker_Comment::comment() |
|
0 | 970 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
* @param string $comment_content Text of the comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
* @param WP_Comment $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
* @param array $args An array of arguments. |
0 | 974 |
*/ |
975 |
return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); |
|
976 |
} |
|
977 |
||
978 |
/** |
|
979 |
* Display the text of the current comment. |
|
980 |
* |
|
981 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 983 |
* |
5 | 984 |
* @see Walker_Comment::comment() |
985 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
* @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
* Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
* @param array $args Optional. An array of arguments. Default empty array. Default empty. |
0 | 989 |
*/ |
990 |
function comment_text( $comment_ID = 0, $args = array() ) { |
|
991 |
$comment = get_comment( $comment_ID ); |
|
992 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
$comment_text = get_comment_text( $comment, $args ); |
0 | 994 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
* Filters the text of a comment to be displayed. |
0 | 996 |
* |
5 | 997 |
* @since 1.2.0 |
998 |
* |
|
999 |
* @see Walker_Comment::comment() |
|
0 | 1000 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
* @param string $comment_text Text of the current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
* @param WP_Comment|null $comment The comment object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
* @param array $args An array of arguments. |
0 | 1004 |
*/ |
1005 |
echo apply_filters( 'comment_text', $comment_text, $comment, $args ); |
|
1006 |
} |
|
1007 |
||
1008 |
/** |
|
1009 |
* Retrieve the comment time of the current comment. |
|
1010 |
* |
|
1011 |
* @since 1.5.0 |
|
1012 |
* |
|
1013 |
* @param string $d Optional. The format of the time. Default user's settings. |
|
1014 |
* @param bool $gmt Optional. Whether to use the GMT date. Default false. |
|
5 | 1015 |
* @param bool $translate Optional. Whether to translate the time (for use in feeds). |
1016 |
* Default true. |
|
1017 |
* @return string The formatted time. |
|
0 | 1018 |
*/ |
1019 |
function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
$comment = get_comment(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
|
0 | 1022 |
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
9 | 1023 |
if ( '' == $d ) { |
1024 |
$date = mysql2date( get_option( 'time_format' ), $comment_date, $translate ); |
|
1025 |
} else { |
|
1026 |
$date = mysql2date( $d, $comment_date, $translate ); |
|
1027 |
} |
|
0 | 1028 |
|
1029 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
* Filters the returned comment time. |
0 | 1031 |
* |
5 | 1032 |
* @since 1.5.0 |
0 | 1033 |
* |
1034 |
* @param string|int $date The comment time, formatted as a date string or Unix timestamp. |
|
5 | 1035 |
* @param string $d Date format. |
0 | 1036 |
* @param bool $gmt Whether the GMT date is in use. |
1037 |
* @param bool $translate Whether the time is translated. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1038 |
* @param WP_Comment $comment The comment object. |
0 | 1039 |
*/ |
5 | 1040 |
return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment ); |
0 | 1041 |
} |
1042 |
||
1043 |
/** |
|
1044 |
* Display the comment time of the current comment. |
|
1045 |
* |
|
1046 |
* @since 0.71 |
|
1047 |
* |
|
1048 |
* @param string $d Optional. The format of the time. Default user's settings. |
|
1049 |
*/ |
|
1050 |
function comment_time( $d = '' ) { |
|
9 | 1051 |
echo get_comment_time( $d ); |
0 | 1052 |
} |
1053 |
||
1054 |
/** |
|
1055 |
* Retrieve the comment type of the current comment. |
|
1056 |
* |
|
1057 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
0 | 1059 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
* @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
* Default current comment. |
5 | 1062 |
* @return string The comment type. |
0 | 1063 |
*/ |
1064 |
function get_comment_type( $comment_ID = 0 ) { |
|
1065 |
$comment = get_comment( $comment_ID ); |
|
9 | 1066 |
if ( '' == $comment->comment_type ) { |
0 | 1067 |
$comment->comment_type = 'comment'; |
9 | 1068 |
} |
0 | 1069 |
|
1070 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
* Filters the returned comment type. |
0 | 1072 |
* |
5 | 1073 |
* @since 1.5.0 |
1074 |
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
|
0 | 1075 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1076 |
* @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. |
9 | 1077 |
* @param int $comment_ID The comment ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
* @param WP_Comment $comment The comment object. |
0 | 1079 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
0 | 1081 |
} |
1082 |
||
1083 |
/** |
|
1084 |
* Display the comment type of the current comment. |
|
1085 |
* |
|
1086 |
* @since 0.71 |
|
1087 |
* |
|
5 | 1088 |
* @param string $commenttxt Optional. String to display for comment type. Default false. |
1089 |
* @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
|
1090 |
* @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
|
0 | 1091 |
*/ |
1092 |
function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
|
9 | 1093 |
if ( false === $commenttxt ) { |
1094 |
$commenttxt = _x( 'Comment', 'noun' ); |
|
1095 |
} |
|
1096 |
if ( false === $trackbacktxt ) { |
|
1097 |
$trackbacktxt = __( 'Trackback' ); |
|
1098 |
} |
|
1099 |
if ( false === $pingbacktxt ) { |
|
1100 |
$pingbacktxt = __( 'Pingback' ); |
|
1101 |
} |
|
0 | 1102 |
$type = get_comment_type(); |
9 | 1103 |
switch ( $type ) { |
1104 |
case 'trackback': |
|
0 | 1105 |
echo $trackbacktxt; |
1106 |
break; |
|
9 | 1107 |
case 'pingback': |
0 | 1108 |
echo $pingbacktxt; |
1109 |
break; |
|
9 | 1110 |
default: |
0 | 1111 |
echo $commenttxt; |
1112 |
} |
|
1113 |
} |
|
1114 |
||
1115 |
/** |
|
1116 |
* Retrieve The current post's trackback URL. |
|
1117 |
* |
|
1118 |
* There is a check to see if permalink's have been enabled and if so, will |
|
1119 |
* retrieve the pretty path. If permalinks weren't enabled, the ID of the |
|
1120 |
* current post is used and appended to the correct page to go to. |
|
1121 |
* |
|
1122 |
* @since 1.5.0 |
|
1123 |
* |
|
1124 |
* @return string The trackback URL after being filtered. |
|
1125 |
*/ |
|
1126 |
function get_trackback_url() { |
|
9 | 1127 |
if ( '' != get_option( 'permalink_structure' ) ) { |
1128 |
$tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' ); |
|
1129 |
} else { |
|
1130 |
$tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID(); |
|
1131 |
} |
|
0 | 1132 |
|
1133 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
* Filters the returned trackback URL. |
0 | 1135 |
* |
1136 |
* @since 2.2.0 |
|
1137 |
* |
|
1138 |
* @param string $tb_url The trackback URL. |
|
1139 |
*/ |
|
1140 |
return apply_filters( 'trackback_url', $tb_url ); |
|
1141 |
} |
|
1142 |
||
1143 |
/** |
|
1144 |
* Display the current post's trackback URL. |
|
1145 |
* |
|
1146 |
* @since 0.71 |
|
1147 |
* |
|
1148 |
* @param bool $deprecated_echo Not used. |
|
5 | 1149 |
* @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
1150 |
* for the result instead. |
|
0 | 1151 |
*/ |
1152 |
function trackback_url( $deprecated_echo = true ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
if ( true !== $deprecated_echo ) { |
9 | 1154 |
_deprecated_argument( |
1155 |
__FUNCTION__, |
|
1156 |
'2.5.0', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
/* translators: %s: get_trackback_url() */ |
9 | 1158 |
sprintf( |
1159 |
__( 'Use %s instead if you do not want the value echoed.' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
'<code>get_trackback_url()</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
if ( $deprecated_echo ) { |
0 | 1166 |
echo get_trackback_url(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
} else { |
0 | 1168 |
return get_trackback_url(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
} |
0 | 1170 |
} |
1171 |
||
1172 |
/** |
|
1173 |
* Generate and display the RDF for the trackback information of current post. |
|
1174 |
* |
|
1175 |
* Deprecated in 3.0.0, and restored in 3.0.1. |
|
1176 |
* |
|
1177 |
* @since 0.71 |
|
1178 |
* |
|
1179 |
* @param int $deprecated Not used (Was $timezone = 0). |
|
1180 |
*/ |
|
1181 |
function trackback_rdf( $deprecated = '' ) { |
|
5 | 1182 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
_deprecated_argument( __FUNCTION__, '2.5.0' ); |
5 | 1184 |
} |
0 | 1185 |
|
5 | 1186 |
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) { |
0 | 1187 |
return; |
5 | 1188 |
} |
0 | 1189 |
|
1190 |
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|
1191 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
1192 |
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> |
|
1193 |
<rdf:Description rdf:about="'; |
|
1194 |
the_permalink(); |
|
9 | 1195 |
echo '"' . "\n"; |
0 | 1196 |
echo ' dc:identifier="'; |
1197 |
the_permalink(); |
|
9 | 1198 |
echo '"' . "\n"; |
1199 |
echo ' dc:title="' . str_replace( '--', '--', wptexturize( strip_tags( get_the_title() ) ) ) . '"' . "\n"; |
|
1200 |
echo ' trackback:ping="' . get_trackback_url() . '"' . " />\n"; |
|
0 | 1201 |
echo '</rdf:RDF>'; |
1202 |
} |
|
1203 |
||
1204 |
/** |
|
9 | 1205 |
* Determines whether the current post is open for comments. |
1206 |
* |
|
1207 |
* For more information on this and similar theme functions, check out |
|
1208 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1209 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
0 | 1210 |
* |
1211 |
* @since 1.5.0 |
|
1212 |
* |
|
5 | 1213 |
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
0 | 1214 |
* @return bool True if the comments are open. |
1215 |
*/ |
|
1216 |
function comments_open( $post_id = null ) { |
|
1217 |
||
9 | 1218 |
$_post = get_post( $post_id ); |
0 | 1219 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
$post_id = $_post ? $_post->ID : 0; |
9 | 1221 |
$open = ( 'open' == $_post->comment_status ); |
0 | 1222 |
|
1223 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* Filters whether the current post is open for comments. |
0 | 1225 |
* |
5 | 1226 |
* @since 2.5.0 |
0 | 1227 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* @param bool $open Whether the current post is open for comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
* @param int $post_id The post ID. |
0 | 1230 |
*/ |
1231 |
return apply_filters( 'comments_open', $open, $post_id ); |
|
1232 |
} |
|
1233 |
||
1234 |
/** |
|
9 | 1235 |
* Determines whether the current post is open for pings. |
1236 |
* |
|
1237 |
* For more information on this and similar theme functions, check out |
|
1238 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1239 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
0 | 1240 |
* |
1241 |
* @since 1.5.0 |
|
1242 |
* |
|
5 | 1243 |
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
0 | 1244 |
* @return bool True if pings are accepted |
1245 |
*/ |
|
1246 |
function pings_open( $post_id = null ) { |
|
1247 |
||
9 | 1248 |
$_post = get_post( $post_id ); |
0 | 1249 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
$post_id = $_post ? $_post->ID : 0; |
9 | 1251 |
$open = ( 'open' == $_post->ping_status ); |
5 | 1252 |
|
1253 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
* Filters whether the current post is open for pings. |
5 | 1255 |
* |
1256 |
* @since 2.5.0 |
|
1257 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
* @param bool $open Whether the current post is open for pings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
* @param int $post_id The post ID. |
5 | 1260 |
*/ |
0 | 1261 |
return apply_filters( 'pings_open', $open, $post_id ); |
1262 |
} |
|
1263 |
||
1264 |
/** |
|
1265 |
* Display form token for unfiltered comments. |
|
1266 |
* |
|
1267 |
* Will only display nonce token if the current user has permissions for |
|
1268 |
* unfiltered html. Won't display the token for other users. |
|
1269 |
* |
|
1270 |
* The function was backported to 2.0.10 and was added to versions 2.1.3 and |
|
1271 |
* above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in |
|
1272 |
* the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0. |
|
1273 |
* |
|
1274 |
* Backported to 2.0.10. |
|
1275 |
* |
|
1276 |
* @since 2.1.3 |
|
1277 |
*/ |
|
1278 |
function wp_comment_form_unfiltered_html_nonce() { |
|
9 | 1279 |
$post = get_post(); |
0 | 1280 |
$post_id = $post ? $post->ID : 0; |
1281 |
||
1282 |
if ( current_user_can( 'unfiltered_html' ) ) { |
|
1283 |
wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
|
1284 |
echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
|
1285 |
} |
|
1286 |
} |
|
1287 |
||
1288 |
/** |
|
1289 |
* Load the comment template specified in $file. |
|
1290 |
* |
|
1291 |
* Will not display the comments template if not on single post or page, or if |
|
1292 |
* the post does not have comments. |
|
1293 |
* |
|
1294 |
* Uses the WordPress database object to query for the comments. The comments |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
* are passed through the {@see 'comments_array'} filter hook with the list of comments |
0 | 1296 |
* and the post ID respectively. |
1297 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
* The `$file` path is passed through a filter hook called {@see 'comments_template'}, |
0 | 1299 |
* which includes the TEMPLATEPATH and $file combined. Tries the $filtered path |
1300 |
* first and if it fails it will require the default comment template from the |
|
1301 |
* default theme. If either does not exist, then the WordPress process will be |
|
1302 |
* halted. It is advised for that reason, that the default theme is not deleted. |
|
1303 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
* Will not try to get the comments if the post has none. |
0 | 1305 |
* |
1306 |
* @since 1.5.0 |
|
1307 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
* @global WP_Query $wp_query |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
* @global WP_Post $post |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
* @global wpdb $wpdb |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
* @global int $id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* @global WP_Comment $comment |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
* @global string $user_login |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
* @global int $user_ID |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
* @global string $user_identity |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
* @global bool $overridden_cpage |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
* @global bool $withcomments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
* |
0 | 1319 |
* @param string $file Optional. The file to load. Default '/comments.php'. |
5 | 1320 |
* @param bool $separate_comments Optional. Whether to separate the comments by comment type. |
1321 |
* Default false. |
|
0 | 1322 |
*/ |
1323 |
function comments_template( $file = '/comments.php', $separate_comments = false ) { |
|
1324 |
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
|
1325 |
||
9 | 1326 |
if ( ! ( is_single() || is_page() || $withcomments ) || empty( $post ) ) { |
0 | 1327 |
return; |
9 | 1328 |
} |
0 | 1329 |
|
9 | 1330 |
if ( empty( $file ) ) { |
0 | 1331 |
$file = '/comments.php'; |
9 | 1332 |
} |
0 | 1333 |
|
9 | 1334 |
$req = get_option( 'require_name_email' ); |
0 | 1335 |
|
5 | 1336 |
/* |
0 | 1337 |
* Comment author information fetched from the comment cookies. |
1338 |
*/ |
|
1339 |
$commenter = wp_get_current_commenter(); |
|
1340 |
||
5 | 1341 |
/* |
0 | 1342 |
* The name of the current comment author escaped for use in attributes. |
5 | 1343 |
* Escaped by sanitize_comment_cookies(). |
0 | 1344 |
*/ |
5 | 1345 |
$comment_author = $commenter['comment_author']; |
0 | 1346 |
|
5 | 1347 |
/* |
0 | 1348 |
* The email address of the current comment author escaped for use in attributes. |
5 | 1349 |
* Escaped by sanitize_comment_cookies(). |
0 | 1350 |
*/ |
5 | 1351 |
$comment_author_email = $commenter['comment_author_email']; |
0 | 1352 |
|
5 | 1353 |
/* |
0 | 1354 |
* The url of the current comment author escaped for use in attributes. |
1355 |
*/ |
|
9 | 1356 |
$comment_author_url = esc_url( $commenter['comment_author_url'] ); |
0 | 1357 |
|
5 | 1358 |
$comment_args = array( |
9 | 1359 |
'orderby' => 'comment_date_gmt', |
1360 |
'order' => 'ASC', |
|
1361 |
'status' => 'approve', |
|
1362 |
'post_id' => $post->ID, |
|
1363 |
'no_found_rows' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1364 |
'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. |
5 | 1365 |
); |
1366 |
||
9 | 1367 |
if ( get_option( 'thread_comments' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
$comment_args['hierarchical'] = 'threaded'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
$comment_args['hierarchical'] = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
|
5 | 1373 |
if ( $user_ID ) { |
1374 |
$comment_args['include_unapproved'] = array( $user_ID ); |
|
9 | 1375 |
} else { |
1376 |
$unapproved_email = wp_get_unapproved_comment_author_email(); |
|
1377 |
||
1378 |
if ( $unapproved_email ) { |
|
1379 |
$comment_args['include_unapproved'] = array( $unapproved_email ); |
|
1380 |
} |
|
0 | 1381 |
} |
1382 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
$per_page = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
if ( get_option( 'page_comments' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
$per_page = (int) get_query_var( 'comments_per_page' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
if ( 0 === $per_page ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
$per_page = (int) get_option( 'comments_per_page' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
$comment_args['number'] = $per_page; |
9 | 1391 |
$page = (int) get_query_var( 'cpage' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
if ( $page ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
$comment_args['offset'] = ( $page - 1 ) * $per_page; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
} elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
$comment_args['offset'] = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
// If fetching the first page of 'newest', we need a top-level comment count. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
$top_level_query = new WP_Comment_Query(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
$top_level_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
'count' => true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
'orderby' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
'post_id' => $post->ID, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
'status' => 'approve', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1407 |
if ( $comment_args['hierarchical'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1408 |
$top_level_args['parent'] = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1410 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
if ( isset( $comment_args['include_unapproved'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1412 |
$top_level_args['include_unapproved'] = $comment_args['include_unapproved']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
$top_level_count = $top_level_query->query( $top_level_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1417 |
$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1418 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
} |
5 | 1420 |
|
0 | 1421 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1422 |
* Filters the arguments used to query comments in comments_template(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1424 |
* @since 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
* @see WP_Comment_Query::__construct() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
* @param array $comment_args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1429 |
* Array of WP_Comment_Query arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
* @type string|array $orderby Field(s) to order by. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
* @type string $order Order of results. Accepts 'ASC' or 'DESC'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
* @type string $status Comment status. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1434 |
* @type array $include_unapproved Array of IDs or email addresses whose unapproved comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
* will be included in results. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
* @type int $post_id ID of the post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1437 |
* @type bool $no_found_rows Whether to refrain from querying for found rows. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
* @type bool $update_comment_meta_cache Whether to prime cache for comment meta. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
* @type bool|string $hierarchical Whether to query for comments hierarchically. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
* @type int $offset Comment offset. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
* @type int $number Number of comments to fetch. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
*/ |
9 | 1444 |
$comment_args = apply_filters( 'comments_template_query_args', $comment_args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
$comment_query = new WP_Comment_Query( $comment_args ); |
9 | 1446 |
$_comments = $comment_query->comments; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
// Trees must be flattened before they're passed to the walker. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
if ( $comment_args['hierarchical'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
$comments_flat = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
foreach ( $_comments as $_comment ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
$comments_flat[] = $_comment; |
9 | 1453 |
$comment_children = $_comment->get_children( |
1454 |
array( |
|
1455 |
'format' => 'flat', |
|
1456 |
'status' => $comment_args['status'], |
|
1457 |
'orderby' => $comment_args['orderby'], |
|
1458 |
) |
|
1459 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
foreach ( $comment_children as $comment_child ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
$comments_flat[] = $comment_child; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
$comments_flat = $_comments; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
* Filters the comments array. |
0 | 1471 |
* |
1472 |
* @since 2.1.0 |
|
1473 |
* |
|
5 | 1474 |
* @param array $comments Array of comments supplied to the comments template. |
1475 |
* @param int $post_ID Post ID. |
|
0 | 1476 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
$wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1478 |
|
9 | 1479 |
$comments = &$wp_query->comments; |
1480 |
$wp_query->comment_count = count( $wp_query->comments ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1481 |
$wp_query->max_num_comment_pages = $comment_query->max_num_pages; |
0 | 1482 |
|
1483 |
if ( $separate_comments ) { |
|
9 | 1484 |
$wp_query->comments_by_type = separate_comments( $comments ); |
1485 |
$comments_by_type = &$wp_query->comments_by_type; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1486 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1487 |
$wp_query->comments_by_type = array(); |
0 | 1488 |
} |
1489 |
||
1490 |
$overridden_cpage = false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { |
9 | 1492 |
set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); |
0 | 1493 |
$overridden_cpage = true; |
1494 |
} |
|
1495 |
||
9 | 1496 |
if ( ! defined( 'COMMENTS_TEMPLATE' ) ) { |
1497 |
define( 'COMMENTS_TEMPLATE', true ); |
|
1498 |
} |
|
0 | 1499 |
|
1500 |
$theme_template = STYLESHEETPATH . $file; |
|
1501 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
* Filters the path to the theme template file used for the comments template. |
0 | 1503 |
* |
5 | 1504 |
* @since 1.5.1 |
0 | 1505 |
* |
1506 |
* @param string $theme_template The path to the theme template file. |
|
1507 |
*/ |
|
1508 |
$include = apply_filters( 'comments_template', $theme_template ); |
|
9 | 1509 |
if ( file_exists( $include ) ) { |
0 | 1510 |
require( $include ); |
9 | 1511 |
} elseif ( file_exists( TEMPLATEPATH . $file ) ) { |
0 | 1512 |
require( TEMPLATEPATH . $file ); |
9 | 1513 |
} else { // Backward compat code will be removed in a future release |
1514 |
require( ABSPATH . WPINC . '/theme-compat/comments.php' ); |
|
1515 |
} |
|
0 | 1516 |
} |
1517 |
||
1518 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
* Displays the link to the comments for the current post ID. |
0 | 1520 |
* |
1521 |
* @since 0.71 |
|
1522 |
* |
|
9 | 1523 |
* @param false|string $zero Optional. String to display when no comments. Default false. |
1524 |
* @param false|string $one Optional. String to display when only one comment is available. Default false. |
|
1525 |
* @param false|string $more Optional. String to display when there are more than one comment. Default false. |
|
1526 |
* @param string $css_class Optional. CSS class to use for comments. Default empty. |
|
1527 |
* @param false|string $none Optional. String to display when comments have been turned off. Default false. |
|
0 | 1528 |
*/ |
1529 |
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
|
9 | 1530 |
$id = get_the_ID(); |
1531 |
$title = get_the_title(); |
|
5 | 1532 |
$number = get_comments_number( $id ); |
0 | 1533 |
|
5 | 1534 |
if ( false === $zero ) { |
1535 |
/* translators: %s: post title */ |
|
1536 |
$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1537 |
} |
|
1538 |
||
1539 |
if ( false === $one ) { |
|
1540 |
/* translators: %s: post title */ |
|
1541 |
$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1542 |
} |
|
0 | 1543 |
|
5 | 1544 |
if ( false === $more ) { |
9 | 1545 |
/* translators: 1: number of comments, 2: post title */ |
5 | 1546 |
$more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number ); |
1547 |
$more = sprintf( $more, number_format_i18n( $number ), $title ); |
|
1548 |
} |
|
1549 |
||
1550 |
if ( false === $none ) { |
|
1551 |
/* translators: %s: post title */ |
|
1552 |
$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
1553 |
} |
|
0 | 1554 |
|
9 | 1555 |
if ( 0 == $number && ! comments_open() && ! pings_open() ) { |
1556 |
echo '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>'; |
|
0 | 1557 |
return; |
1558 |
} |
|
1559 |
||
1560 |
if ( post_password_required() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1561 |
_e( 'Enter your password to view comments.' ); |
0 | 1562 |
return; |
1563 |
} |
|
1564 |
||
1565 |
echo '<a href="'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
if ( 0 == $number ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
$respond_link = get_permalink() . '#respond'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
* Filters the respond link when a post has no comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1572 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
* @param string $respond_link The default response link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* @param integer $id The post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1575 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
echo apply_filters( 'respond_link', $respond_link, $id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
comments_link(); |
0 | 1579 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
echo '"'; |
0 | 1581 |
|
9 | 1582 |
if ( ! empty( $css_class ) ) { |
1583 |
echo ' class="' . $css_class . '" '; |
|
0 | 1584 |
} |
1585 |
||
1586 |
$attributes = ''; |
|
1587 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1588 |
* Filters the comments link attributes for display. |
0 | 1589 |
* |
1590 |
* @since 2.5.0 |
|
1591 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1592 |
* @param string $attributes The comments link attributes. Default empty. |
0 | 1593 |
*/ |
1594 |
echo apply_filters( 'comments_popup_link_attributes', $attributes ); |
|
1595 |
||
5 | 1596 |
echo '>'; |
0 | 1597 |
comments_number( $zero, $one, $more ); |
1598 |
echo '</a>'; |
|
1599 |
} |
|
1600 |
||
1601 |
/** |
|
1602 |
* Retrieve HTML content for reply to comment link. |
|
1603 |
* |
|
1604 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1605 |
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. |
0 | 1606 |
* |
1607 |
* @param array $args { |
|
1608 |
* Optional. Override default arguments. |
|
1609 |
* |
|
5 | 1610 |
* @type string $add_below The first part of the selector used to identify the comment to respond below. |
1611 |
* The resulting value is passed as the first parameter to addComment.moveForm(), |
|
1612 |
* concatenated as $add_below-$comment->comment_ID. Default 'comment'. |
|
1613 |
* @type string $respond_id The selector identifying the responding comment. Passed as the third parameter |
|
1614 |
* to addComment.moveForm(), and appended to the link URL as a hash value. |
|
1615 |
* Default 'respond'. |
|
1616 |
* @type string $reply_text The text of the Reply link. Default 'Reply'. |
|
1617 |
* @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1618 |
* @type int $max_depth The max depth of the comment tree. Default 0. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1619 |
* @type int $depth The depth of the new comment. Must be greater than 0 and less than the value |
5 | 1620 |
* of the 'thread_comments_depth' option set in Settings > Discussion. Default 0. |
1621 |
* @type string $before The text or HTML to add before the reply link. Default empty. |
|
1622 |
* @type string $after The text or HTML to add after the reply link. Default empty. |
|
0 | 1623 |
* } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1624 |
* @param int|WP_Comment $comment Comment being replied to. Default current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1625 |
* @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1626 |
* Default current post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1627 |
* @return void|false|string Link to show comment form, if successful. False, if comments are closed. |
0 | 1628 |
*/ |
5 | 1629 |
function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
0 | 1630 |
$defaults = array( |
5 | 1631 |
'add_below' => 'comment', |
1632 |
'respond_id' => 'respond', |
|
1633 |
'reply_text' => __( 'Reply' ), |
|
9 | 1634 |
/* translators: Comment reply button text. %s: Comment author name */ |
5 | 1635 |
'reply_to_text' => __( 'Reply to %s' ), |
1636 |
'login_text' => __( 'Log in to Reply' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1637 |
'max_depth' => 0, |
5 | 1638 |
'depth' => 0, |
1639 |
'before' => '', |
|
9 | 1640 |
'after' => '', |
0 | 1641 |
); |
1642 |
||
5 | 1643 |
$args = wp_parse_args( $args, $defaults ); |
0 | 1644 |
|
5 | 1645 |
if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
1646 |
return; |
|
1647 |
} |
|
0 | 1648 |
|
5 | 1649 |
$comment = get_comment( $comment ); |
1650 |
||
1651 |
if ( empty( $post ) ) { |
|
0 | 1652 |
$post = $comment->comment_post_ID; |
5 | 1653 |
} |
1654 |
||
1655 |
$post = get_post( $post ); |
|
0 | 1656 |
|
5 | 1657 |
if ( ! comments_open( $post->ID ) ) { |
0 | 1658 |
return false; |
5 | 1659 |
} |
0 | 1660 |
|
5 | 1661 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1662 |
* Filters the comment reply link arguments. |
5 | 1663 |
* |
1664 |
* @since 4.1.0 |
|
1665 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1666 |
* @param array $args Comment reply link arguments. See get_comment_reply_link() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1667 |
* for more information on accepted arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1668 |
* @param WP_Comment $comment The object of the comment being replied to. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1669 |
* @param WP_Post $post The WP_Post object. |
5 | 1670 |
*/ |
1671 |
$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
|
0 | 1672 |
|
5 | 1673 |
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
9 | 1674 |
$link = sprintf( |
1675 |
'<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
5 | 1676 |
esc_url( wp_login_url( get_permalink() ) ), |
1677 |
$args['login_text'] |
|
1678 |
); |
|
1679 |
} else { |
|
9 | 1680 |
$data_attributes = array( |
1681 |
'commentid' => $comment->comment_ID, |
|
1682 |
'postid' => $post->ID, |
|
1683 |
'belowelement' => $args['add_below'] . '-' . $comment->comment_ID, |
|
1684 |
'respondelement' => $args['respond_id'], |
|
5 | 1685 |
); |
0 | 1686 |
|
9 | 1687 |
$data_attribute_string = ''; |
1688 |
||
1689 |
foreach ( $data_attributes as $name => $value ) { |
|
1690 |
$data_attribute_string .= " data-${name}=\"" . esc_attr( $value ) . '"'; |
|
1691 |
} |
|
1692 |
||
1693 |
$data_attribute_string = trim( $data_attribute_string ); |
|
1694 |
||
1695 |
$link = sprintf( |
|
1696 |
"<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>", |
|
1697 |
esc_url( |
|
1698 |
add_query_arg( |
|
1699 |
array( |
|
1700 |
'replytocom' => $comment->comment_ID, |
|
1701 |
'unapproved' => false, |
|
1702 |
'moderation-hash' => false, |
|
1703 |
) |
|
1704 |
) |
|
1705 |
) . '#' . $args['respond_id'], |
|
1706 |
$data_attribute_string, |
|
5 | 1707 |
esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
1708 |
$args['reply_text'] |
|
1709 |
); |
|
1710 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1711 |
|
0 | 1712 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1713 |
* Filters the comment reply link. |
0 | 1714 |
* |
1715 |
* @since 2.7.0 |
|
1716 |
* |
|
1717 |
* @param string $link The HTML markup for the comment reply link. |
|
1718 |
* @param array $args An array of arguments overriding the defaults. |
|
1719 |
* @param object $comment The object of the comment being replied. |
|
1720 |
* @param WP_Post $post The WP_Post object. |
|
1721 |
*/ |
|
5 | 1722 |
return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); |
0 | 1723 |
} |
1724 |
||
1725 |
/** |
|
1726 |
* Displays the HTML content for reply to comment link. |
|
1727 |
* |
|
1728 |
* @since 2.7.0 |
|
1729 |
* |
|
5 | 1730 |
* @see get_comment_reply_link() |
1731 |
* |
|
1732 |
* @param array $args Optional. Override default options. |
|
1733 |
* @param int $comment Comment being replied to. Default current comment. |
|
1734 |
* @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
|
1735 |
* Default current post. |
|
0 | 1736 |
* @return mixed Link to show comment form, if successful. False, if comments are closed. |
1737 |
*/ |
|
9 | 1738 |
function comment_reply_link( $args = array(), $comment = null, $post = null ) { |
1739 |
echo get_comment_reply_link( $args, $comment, $post ); |
|
0 | 1740 |
} |
1741 |
||
1742 |
/** |
|
1743 |
* Retrieve HTML content for reply to post link. |
|
1744 |
* |
|
1745 |
* @since 2.7.0 |
|
1746 |
* |
|
1747 |
* @param array $args { |
|
1748 |
* Optional. Override default arguments. |
|
1749 |
* |
|
5 | 1750 |
* @type string $add_below The first part of the selector used to identify the comment to respond below. |
1751 |
* The resulting value is passed as the first parameter to addComment.moveForm(), |
|
1752 |
* concatenated as $add_below-$comment->comment_ID. Default is 'post'. |
|
1753 |
* @type string $respond_id The selector identifying the responding comment. Passed as the third parameter |
|
1754 |
* to addComment.moveForm(), and appended to the link URL as a hash value. |
|
1755 |
* Default 'respond'. |
|
1756 |
* @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'. |
|
1757 |
* @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'. |
|
1758 |
* @type string $before Text or HTML to add before the reply link. Default empty. |
|
1759 |
* @type string $after Text or HTML to add after the reply link. Default empty. |
|
0 | 1760 |
* } |
5 | 1761 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. |
1762 |
* Default current post. |
|
1763 |
* @return false|null|string Link to show comment form, if successful. False, if comments are closed. |
|
0 | 1764 |
*/ |
9 | 1765 |
function get_post_reply_link( $args = array(), $post = null ) { |
0 | 1766 |
$defaults = array( |
1767 |
'add_below' => 'post', |
|
1768 |
'respond_id' => 'respond', |
|
9 | 1769 |
'reply_text' => __( 'Leave a Comment' ), |
1770 |
'login_text' => __( 'Log in to leave a Comment' ), |
|
0 | 1771 |
'before' => '', |
1772 |
'after' => '', |
|
1773 |
); |
|
1774 |
||
9 | 1775 |
$args = wp_parse_args( $args, $defaults ); |
5 | 1776 |
|
9 | 1777 |
$post = get_post( $post ); |
0 | 1778 |
|
5 | 1779 |
if ( ! comments_open( $post->ID ) ) { |
0 | 1780 |
return false; |
5 | 1781 |
} |
0 | 1782 |
|
9 | 1783 |
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
1784 |
$link = sprintf( |
|
1785 |
'<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
5 | 1786 |
wp_login_url( get_permalink() ), |
1787 |
$args['login_text'] |
|
1788 |
); |
|
1789 |
} else { |
|
9 | 1790 |
$onclick = sprintf( |
1791 |
'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
1792 |
$args['add_below'], |
|
1793 |
$post->ID, |
|
1794 |
$args['respond_id'] |
|
5 | 1795 |
); |
0 | 1796 |
|
9 | 1797 |
$link = sprintf( |
1798 |
"<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
5 | 1799 |
get_permalink( $post->ID ) . '#' . $args['respond_id'], |
1800 |
$onclick, |
|
1801 |
$args['reply_text'] |
|
1802 |
); |
|
1803 |
} |
|
1804 |
$formatted_link = $args['before'] . $link . $args['after']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1805 |
|
0 | 1806 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1807 |
* Filters the formatted post comments link HTML. |
0 | 1808 |
* |
1809 |
* @since 2.7.0 |
|
1810 |
* |
|
1811 |
* @param string $formatted The HTML-formatted post comments link. |
|
1812 |
* @param int|WP_Post $post The post ID or WP_Post object. |
|
1813 |
*/ |
|
1814 |
return apply_filters( 'post_comments_link', $formatted_link, $post ); |
|
1815 |
} |
|
1816 |
||
1817 |
/** |
|
1818 |
* Displays the HTML content for reply to post link. |
|
1819 |
* |
|
1820 |
* @since 2.7.0 |
|
1821 |
* |
|
5 | 1822 |
* @see get_post_reply_link() |
1823 |
* |
|
1824 |
* @param array $args Optional. Override default options, |
|
1825 |
* @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
|
1826 |
* Default current post. |
|
0 | 1827 |
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
1828 |
*/ |
|
9 | 1829 |
function post_reply_link( $args = array(), $post = null ) { |
1830 |
echo get_post_reply_link( $args, $post ); |
|
0 | 1831 |
} |
1832 |
||
1833 |
/** |
|
1834 |
* Retrieve HTML content for cancel comment reply link. |
|
1835 |
* |
|
1836 |
* @since 2.7.0 |
|
1837 |
* |
|
1838 |
* @param string $text Optional. Text to display for cancel reply link. Default empty. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1839 |
* @return string |
0 | 1840 |
*/ |
1841 |
function get_cancel_comment_reply_link( $text = '' ) { |
|
9 | 1842 |
if ( empty( $text ) ) { |
1843 |
$text = __( 'Click here to cancel reply.' ); |
|
1844 |
} |
|
0 | 1845 |
|
9 | 1846 |
$style = isset( $_GET['replytocom'] ) ? '' : ' style="display:none;"'; |
1847 |
$link = esc_html( remove_query_arg( array( 'replytocom', 'unapproved', 'moderation-hash' ) ) ) . '#respond'; |
|
0 | 1848 |
|
1849 |
$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1850 |
|
0 | 1851 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1852 |
* Filters the cancel comment reply link HTML. |
0 | 1853 |
* |
1854 |
* @since 2.7.0 |
|
1855 |
* |
|
1856 |
* @param string $formatted_link The HTML-formatted cancel comment reply link. |
|
5 | 1857 |
* @param string $link Cancel comment reply link URL. |
1858 |
* @param string $text Cancel comment reply link text. |
|
0 | 1859 |
*/ |
1860 |
return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); |
|
1861 |
} |
|
1862 |
||
1863 |
/** |
|
1864 |
* Display HTML content for cancel comment reply link. |
|
1865 |
* |
|
1866 |
* @since 2.7.0 |
|
1867 |
* |
|
1868 |
* @param string $text Optional. Text to display for cancel reply link. Default empty. |
|
1869 |
*/ |
|
1870 |
function cancel_comment_reply_link( $text = '' ) { |
|
9 | 1871 |
echo get_cancel_comment_reply_link( $text ); |
0 | 1872 |
} |
1873 |
||
1874 |
/** |
|
1875 |
* Retrieve hidden input HTML for replying to comments. |
|
1876 |
* |
|
1877 |
* @since 3.0.0 |
|
1878 |
* |
|
1879 |
* @param int $id Optional. Post ID. Default current post ID. |
|
1880 |
* @return string Hidden input HTML for replying to comments |
|
1881 |
*/ |
|
1882 |
function get_comment_id_fields( $id = 0 ) { |
|
9 | 1883 |
if ( empty( $id ) ) { |
0 | 1884 |
$id = get_the_ID(); |
9 | 1885 |
} |
0 | 1886 |
|
9 | 1887 |
$replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; |
1888 |
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; |
|
1889 |
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; |
|
0 | 1890 |
|
1891 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1892 |
* Filters the returned comment id fields. |
0 | 1893 |
* |
1894 |
* @since 3.0.0 |
|
1895 |
* |
|
1896 |
* @param string $result The HTML-formatted hidden id field comment elements. |
|
1897 |
* @param int $id The post ID. |
|
1898 |
* @param int $replytoid The id of the comment being replied to. |
|
1899 |
*/ |
|
1900 |
return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); |
|
1901 |
} |
|
1902 |
||
1903 |
/** |
|
1904 |
* Output hidden input HTML for replying to comments. |
|
1905 |
* |
|
1906 |
* @since 2.7.0 |
|
1907 |
* |
|
1908 |
* @param int $id Optional. Post ID. Default current post ID. |
|
1909 |
*/ |
|
1910 |
function comment_id_fields( $id = 0 ) { |
|
1911 |
echo get_comment_id_fields( $id ); |
|
1912 |
} |
|
1913 |
||
1914 |
/** |
|
1915 |
* Display text based on comment reply status. |
|
1916 |
* |
|
5 | 1917 |
* Only affects users with JavaScript disabled. |
0 | 1918 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1919 |
* @internal The $comment global must be present to allow template tags access to the current |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1920 |
* comment. See https://core.trac.wordpress.org/changeset/36512. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1921 |
* |
0 | 1922 |
* @since 2.7.0 |
1923 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1924 |
* @global WP_Comment $comment Current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1925 |
* |
5 | 1926 |
* @param string $noreplytext Optional. Text to display when not replying to a comment. |
1927 |
* Default false. |
|
0 | 1928 |
* @param string $replytext Optional. Text to display when replying to a comment. |
5 | 1929 |
* Default false. Accepts "%s" for the author of the comment |
1930 |
* being replied to. |
|
1931 |
* @param string $linktoparent Optional. Boolean to control making the author's name a link |
|
1932 |
* to their comment. Default true. |
|
0 | 1933 |
*/ |
1934 |
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
|
1935 |
global $comment; |
|
1936 |
||
9 | 1937 |
if ( false === $noreplytext ) { |
1938 |
$noreplytext = __( 'Leave a Reply' ); |
|
1939 |
} |
|
1940 |
if ( false === $replytext ) { |
|
1941 |
$replytext = __( 'Leave a Reply to %s' ); |
|
1942 |
} |
|
0 | 1943 |
|
9 | 1944 |
$replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; |
1945 |
||
1946 |
if ( 0 == $replytoid ) { |
|
0 | 1947 |
echo $noreplytext; |
9 | 1948 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1949 |
// Sets the global so that template tags can be used in the comment form. |
9 | 1950 |
$comment = get_comment( $replytoid ); |
1951 |
$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
|
0 | 1952 |
printf( $replytext, $author ); |
1953 |
} |
|
1954 |
} |
|
1955 |
||
1956 |
/** |
|
1957 |
* List comments. |
|
1958 |
* |
|
1959 |
* Used in the comments.php template to list comments for a particular post. |
|
1960 |
* |
|
1961 |
* @since 2.7.0 |
|
1962 |
* |
|
5 | 1963 |
* @see WP_Query->comments |
1964 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1965 |
* @global WP_Query $wp_query |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1966 |
* @global int $comment_alt |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1967 |
* @global int $comment_depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1968 |
* @global int $comment_thread_alt |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1969 |
* @global bool $overridden_cpage |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1970 |
* @global bool $in_comment_loop |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1971 |
* |
0 | 1972 |
* @param string|array $args { |
1973 |
* Optional. Formatting options. |
|
1974 |
* |
|
5 | 1975 |
* @type object $walker Instance of a Walker class to list comments. Default null. |
1976 |
* @type int $max_depth The maximum comments depth. Default empty. |
|
1977 |
* @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
1978 |
* @type string $callback Callback function to use. Default null. |
|
1979 |
* @type string $end-callback Callback function to use at the end. Default null. |
|
1980 |
* @type string $type Type of comments to list. |
|
1981 |
* Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
1982 |
* @type int $page Page ID to list comments for. Default empty. |
|
1983 |
* @type int $per_page Number of comments to list per page. Default empty. |
|
1984 |
* @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1985 |
* @type bool $reverse_top_level Ordering of the listed comments. If true, will display newest comments first. |
5 | 1986 |
* @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
1987 |
* @type string $format How to format the comments list. |
|
1988 |
* Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
1989 |
* @type bool $short_ping Whether to output short pings. Default false. |
|
1990 |
* @type bool $echo Whether to echo the output or return it. Default true. |
|
0 | 1991 |
* } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1992 |
* @param array $comments Optional. Array of WP_Comment objects. |
0 | 1993 |
*/ |
1994 |
function wp_list_comments( $args = array(), $comments = null ) { |
|
1995 |
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; |
|
1996 |
||
1997 |
$in_comment_loop = true; |
|
1998 |
||
9 | 1999 |
$comment_alt = $comment_thread_alt = 0; |
0 | 2000 |
$comment_depth = 1; |
2001 |
||
2002 |
$defaults = array( |
|
2003 |
'walker' => null, |
|
2004 |
'max_depth' => '', |
|
2005 |
'style' => 'ul', |
|
2006 |
'callback' => null, |
|
2007 |
'end-callback' => null, |
|
2008 |
'type' => 'all', |
|
2009 |
'page' => '', |
|
2010 |
'per_page' => '', |
|
2011 |
'avatar_size' => 32, |
|
2012 |
'reverse_top_level' => null, |
|
2013 |
'reverse_children' => '', |
|
2014 |
'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', |
|
2015 |
'short_ping' => false, |
|
5 | 2016 |
'echo' => true, |
0 | 2017 |
); |
2018 |
||
2019 |
$r = wp_parse_args( $args, $defaults ); |
|
2020 |
||
5 | 2021 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2022 |
* Filters the arguments used in retrieving the comment list. |
5 | 2023 |
* |
2024 |
* @since 4.0.0 |
|
2025 |
* |
|
2026 |
* @see wp_list_comments() |
|
2027 |
* |
|
2028 |
* @param array $r An array of arguments for displaying comments. |
|
2029 |
*/ |
|
2030 |
$r = apply_filters( 'wp_list_comments_args', $r ); |
|
2031 |
||
0 | 2032 |
// Figure out what comments we'll be looping through ($_comments) |
2033 |
if ( null !== $comments ) { |
|
2034 |
$comments = (array) $comments; |
|
9 | 2035 |
if ( empty( $comments ) ) { |
0 | 2036 |
return; |
9 | 2037 |
} |
0 | 2038 |
if ( 'all' != $r['type'] ) { |
9 | 2039 |
$comments_by_type = separate_comments( $comments ); |
2040 |
if ( empty( $comments_by_type[ $r['type'] ] ) ) { |
|
0 | 2041 |
return; |
9 | 2042 |
} |
2043 |
$_comments = $comments_by_type[ $r['type'] ]; |
|
0 | 2044 |
} else { |
2045 |
$_comments = $comments; |
|
2046 |
} |
|
2047 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2048 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2049 |
* If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2050 |
* perform a separate comment query and allow Walker_Comment to paginate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2051 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2052 |
if ( $r['page'] || $r['per_page'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2053 |
$current_cpage = get_query_var( 'cpage' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2054 |
if ( ! $current_cpage ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2055 |
$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2056 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2057 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2058 |
$current_per_page = get_query_var( 'comments_per_page' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2059 |
if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2060 |
$comment_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2061 |
'post_id' => get_the_ID(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2062 |
'orderby' => 'comment_date_gmt', |
9 | 2063 |
'order' => 'ASC', |
2064 |
'status' => 'approve', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2065 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2066 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2067 |
if ( is_user_logged_in() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2068 |
$comment_args['include_unapproved'] = get_current_user_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2069 |
} else { |
9 | 2070 |
$unapproved_email = wp_get_unapproved_comment_author_email(); |
2071 |
||
2072 |
if ( $unapproved_email ) { |
|
2073 |
$comment_args['include_unapproved'] = array( $unapproved_email ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2074 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2075 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2076 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2077 |
$comments = get_comments( $comment_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2078 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2079 |
if ( 'all' != $r['type'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2080 |
$comments_by_type = separate_comments( $comments ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2081 |
if ( empty( $comments_by_type[ $r['type'] ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2082 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2083 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2084 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2085 |
$_comments = $comments_by_type[ $r['type'] ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2086 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2087 |
$_comments = $comments; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2088 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2089 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2090 |
|
9 | 2091 |
// Otherwise, fall back on the comments from `$wp_query->comments`. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2092 |
} else { |
9 | 2093 |
if ( empty( $wp_query->comments ) ) { |
0 | 2094 |
return; |
9 | 2095 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2096 |
if ( 'all' != $r['type'] ) { |
9 | 2097 |
if ( empty( $wp_query->comments_by_type ) ) { |
2098 |
$wp_query->comments_by_type = separate_comments( $wp_query->comments ); |
|
2099 |
} |
|
2100 |
if ( empty( $wp_query->comments_by_type[ $r['type'] ] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2101 |
return; |
9 | 2102 |
} |
2103 |
$_comments = $wp_query->comments_by_type[ $r['type'] ]; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2104 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2105 |
$_comments = $wp_query->comments; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2106 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2107 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2108 |
if ( $wp_query->max_num_comment_pages ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2109 |
$default_comments_page = get_option( 'default_comments_page' ); |
9 | 2110 |
$cpage = get_query_var( 'cpage' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2111 |
if ( 'newest' === $default_comments_page ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2112 |
$r['cpage'] = $cpage; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2113 |
|
9 | 2114 |
/* |
2115 |
* When first page shows oldest comments, post permalink is the same as |
|
2116 |
* the comment permalink. |
|
2117 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2118 |
} elseif ( $cpage == 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2119 |
$r['cpage'] = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2120 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2121 |
$r['cpage'] = $cpage; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2122 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2123 |
|
9 | 2124 |
$r['page'] = 0; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2125 |
$r['per_page'] = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2126 |
} |
0 | 2127 |
} |
2128 |
} |
|
2129 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2130 |
if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { |
9 | 2131 |
$r['per_page'] = get_query_var( 'comments_per_page' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2132 |
} |
0 | 2133 |
|
9 | 2134 |
if ( empty( $r['per_page'] ) ) { |
0 | 2135 |
$r['per_page'] = 0; |
9 | 2136 |
$r['page'] = 0; |
0 | 2137 |
} |
2138 |
||
2139 |
if ( '' === $r['max_depth'] ) { |
|
9 | 2140 |
if ( get_option( 'thread_comments' ) ) { |
2141 |
$r['max_depth'] = get_option( 'thread_comments_depth' ); |
|
2142 |
} else { |
|
0 | 2143 |
$r['max_depth'] = -1; |
9 | 2144 |
} |
0 | 2145 |
} |
2146 |
||
2147 |
if ( '' === $r['page'] ) { |
|
9 | 2148 |
if ( empty( $overridden_cpage ) ) { |
2149 |
$r['page'] = get_query_var( 'cpage' ); |
|
0 | 2150 |
} else { |
9 | 2151 |
$threaded = ( -1 != $r['max_depth'] ); |
2152 |
$r['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $r['per_page'], $threaded ) : 1; |
|
0 | 2153 |
set_query_var( 'cpage', $r['page'] ); |
2154 |
} |
|
2155 |
} |
|
2156 |
// Validation check |
|
9 | 2157 |
$r['page'] = intval( $r['page'] ); |
2158 |
if ( 0 == $r['page'] && 0 != $r['per_page'] ) { |
|
0 | 2159 |
$r['page'] = 1; |
9 | 2160 |
} |
0 | 2161 |
|
9 | 2162 |
if ( null === $r['reverse_top_level'] ) { |
2163 |
$r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); |
|
2164 |
} |
|
0 | 2165 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2166 |
wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2167 |
|
5 | 2168 |
if ( empty( $r['walker'] ) ) { |
2169 |
$walker = new Walker_Comment; |
|
2170 |
} else { |
|
2171 |
$walker = $r['walker']; |
|
2172 |
} |
|
0 | 2173 |
|
5 | 2174 |
$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); |
0 | 2175 |
|
2176 |
$in_comment_loop = false; |
|
5 | 2177 |
|
2178 |
if ( $r['echo'] ) { |
|
2179 |
echo $output; |
|
2180 |
} else { |
|
2181 |
return $output; |
|
2182 |
} |
|
0 | 2183 |
} |
2184 |
||
2185 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2186 |
* Outputs a complete commenting form for use within a template. |
0 | 2187 |
* |
2188 |
* Most strings and form fields may be controlled through the $args array passed |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2189 |
* into the function, while you may also choose to use the {@see 'comment_form_default_fields'} |
0 | 2190 |
* filter to modify the array of default fields if you'd just like to add a new |
2191 |
* one or remove a single field. All fields are also individually passed through |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2192 |
* a filter of the {@see 'comment_form_field_$name'} where $name is the key used |
0 | 2193 |
* in the array of fields. |
2194 |
* |
|
2195 |
* @since 3.0.0 |
|
5 | 2196 |
* @since 4.1.0 Introduced the 'class_submit' argument. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2197 |
* @since 4.2.0 Introduced the 'submit_button' and 'submit_fields' arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2198 |
* @since 4.4.0 Introduced the 'class_form', 'title_reply_before', 'title_reply_after', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2199 |
* 'cancel_reply_before', and 'cancel_reply_after' arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2200 |
* @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2201 |
* and 200 characters, respectively. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2202 |
* @since 4.6.0 Introduced the 'action' argument. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2203 |
* @since 4.9.6 Introduced the 'cookies' default comment field. |
0 | 2204 |
* |
2205 |
* @param array $args { |
|
2206 |
* Optional. Default arguments and form fields to override. |
|
2207 |
* |
|
5 | 2208 |
* @type array $fields { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2209 |
* Default comment fields, filterable by default via the {@see 'comment_form_default_fields'} hook. |
0 | 2210 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2211 |
* @type string $author Comment author field HTML. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2212 |
* @type string $email Comment author email field HTML. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2213 |
* @type string $url Comment author URL field HTML. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2214 |
* @type string $cookies Comment cookie opt-in field HTML. |
0 | 2215 |
* } |
5 | 2216 |
* @type string $comment_field The comment textarea field HTML. |
2217 |
* @type string $must_log_in HTML element for a 'must be logged in to comment' message. |
|
2218 |
* @type string $logged_in_as HTML element for a 'logged in as [user]' message. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2219 |
* @type string $comment_notes_before HTML element for a message displayed before the comment fields |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2220 |
* if the user is not logged in. |
5 | 2221 |
* Default 'Your email address will not be published.'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2222 |
* @type string $comment_notes_after HTML element for a message displayed after the textarea field. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2223 |
* @type string $action The comment form element action attribute. Default '/wp-comments-post.php'. |
5 | 2224 |
* @type string $id_form The comment form element id attribute. Default 'commentform'. |
2225 |
* @type string $id_submit The comment submit element id attribute. Default 'submit'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2226 |
* @type string $class_form The comment form element class attribute. Default 'comment-form'. |
5 | 2227 |
* @type string $class_submit The comment submit element class attribute. Default 'submit'. |
2228 |
* @type string $name_submit The comment submit element name attribute. Default 'submit'. |
|
2229 |
* @type string $title_reply The translatable 'reply' button label. Default 'Leave a Reply'. |
|
2230 |
* @type string $title_reply_to The translatable 'reply-to' button label. Default 'Leave a Reply to %s', |
|
2231 |
* where %s is the author of the comment being replied to. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2232 |
* @type string $title_reply_before HTML displayed before the comment form title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2233 |
* Default: '<h3 id="reply-title" class="comment-reply-title">'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2234 |
* @type string $title_reply_after HTML displayed after the comment form title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2235 |
* Default: '</h3>'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2236 |
* @type string $cancel_reply_before HTML displayed before the cancel reply link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2237 |
* @type string $cancel_reply_after HTML displayed after the cancel reply link. |
5 | 2238 |
* @type string $cancel_reply_link The translatable 'cancel reply' button label. Default 'Cancel reply'. |
2239 |
* @type string $label_submit The translatable 'submit' button label. Default 'Post a comment'. |
|
2240 |
* @type string $submit_button HTML format for the Submit button. |
|
2241 |
* Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'. |
|
2242 |
* @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2243 |
* fields. Default: '<p class="form-submit">%1$s %2$s</p>', where %1$s is the |
5 | 2244 |
* submit button markup and %2$s is the comment hidden fields. |
2245 |
* @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. |
|
0 | 2246 |
* } |
5 | 2247 |
* @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
0 | 2248 |
*/ |
2249 |
function comment_form( $args = array(), $post_id = null ) { |
|
9 | 2250 |
if ( null === $post_id ) { |
0 | 2251 |
$post_id = get_the_ID(); |
9 | 2252 |
} |
0 | 2253 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2254 |
// Exit the function when comments for the post are closed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2255 |
if ( ! comments_open( $post_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2256 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2257 |
* Fires after the comment form if comments are closed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2258 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2259 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2260 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2261 |
do_action( 'comment_form_comments_closed' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2262 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2263 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2264 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2265 |
|
9 | 2266 |
$commenter = wp_get_current_commenter(); |
2267 |
$user = wp_get_current_user(); |
|
0 | 2268 |
$user_identity = $user->exists() ? $user->display_name : ''; |
2269 |
||
2270 |
$args = wp_parse_args( $args ); |
|
9 | 2271 |
if ( ! isset( $args['format'] ) ) { |
0 | 2272 |
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
9 | 2273 |
} |
0 | 2274 |
|
2275 |
$req = get_option( 'require_name_email' ); |
|
5 | 2276 |
$html_req = ( $req ? " required='required'" : '' ); |
0 | 2277 |
$html5 = 'html5' === $args['format']; |
9 | 2278 |
$fields = array( |
2279 |
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2280 |
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>', |
9 | 2281 |
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2282 |
'<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>', |
9 | 2283 |
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2284 |
'<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
0 | 2285 |
); |
2286 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2287 |
if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2288 |
$consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2289 |
$fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2290 |
'<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2291 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2292 |
// Ensure that the passed fields include cookies consent. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2293 |
if ( isset( $args['fields'] ) && ! isset( $args['fields']['cookies'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2294 |
$args['fields']['cookies'] = $fields['cookies']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2295 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2296 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2297 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2298 |
$required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' ); |
0 | 2299 |
|
2300 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2301 |
* Filters the default comment form fields. |
0 | 2302 |
* |
2303 |
* @since 3.0.0 |
|
2304 |
* |
|
9 | 2305 |
* @param string[] $fields Array of the default comment fields. |
0 | 2306 |
*/ |
9 | 2307 |
$fields = apply_filters( 'comment_form_default_fields', $fields ); |
0 | 2308 |
$defaults = array( |
2309 |
'fields' => $fields, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2310 |
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>', |
5 | 2311 |
/** This filter is documented in wp-includes/link-template.php */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2312 |
'must_log_in' => '<p class="must-log-in">' . sprintf( |
9 | 2313 |
/* translators: %s: login URL */ |
2314 |
__( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
|
2315 |
wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
|
2316 |
) . '</p>', |
|
5 | 2317 |
/** This filter is documented in wp-includes/link-template.php */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2318 |
'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
9 | 2319 |
/* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
2320 |
__( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
|
2321 |
get_edit_user_link(), |
|
2322 |
/* translators: %s: user name */ |
|
2323 |
esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
|
2324 |
$user_identity, |
|
2325 |
wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
|
2326 |
) . '</p>', |
|
2327 |
'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>' . ( $req ? $required_text : '' ) . '</p>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2328 |
'comment_notes_after' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2329 |
'action' => site_url( '/wp-comments-post.php' ), |
0 | 2330 |
'id_form' => 'commentform', |
2331 |
'id_submit' => 'submit', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2332 |
'class_form' => 'comment-form', |
5 | 2333 |
'class_submit' => 'submit', |
2334 |
'name_submit' => 'submit', |
|
0 | 2335 |
'title_reply' => __( 'Leave a Reply' ), |
2336 |
'title_reply_to' => __( 'Leave a Reply to %s' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2337 |
'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2338 |
'title_reply_after' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2339 |
'cancel_reply_before' => ' <small>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2340 |
'cancel_reply_after' => '</small>', |
0 | 2341 |
'cancel_reply_link' => __( 'Cancel reply' ), |
2342 |
'label_submit' => __( 'Post Comment' ), |
|
5 | 2343 |
'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />', |
2344 |
'submit_field' => '<p class="form-submit">%1$s %2$s</p>', |
|
0 | 2345 |
'format' => 'xhtml', |
2346 |
); |
|
2347 |
||
2348 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2349 |
* Filters the comment form default arguments. |
0 | 2350 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2351 |
* Use {@see 'comment_form_default_fields'} to filter the comment fields. |
0 | 2352 |
* |
2353 |
* @since 3.0.0 |
|
2354 |
* |
|
2355 |
* @param array $defaults The default comment form arguments. |
|
2356 |
*/ |
|
2357 |
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
|
2358 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2359 |
// Ensure that the filtered args contain all required default values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2360 |
$args = array_merge( $defaults, $args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2361 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2362 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2363 |
* Fires before the comment form. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2364 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2365 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2366 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2367 |
do_action( 'comment_form_before' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2368 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2369 |
<div id="respond" class="comment-respond"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2370 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2371 |
echo $args['title_reply_before']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2372 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2373 |
comment_form_title( $args['title_reply'], $args['title_reply_to'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2374 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2375 |
echo $args['cancel_reply_before']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2376 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2377 |
cancel_comment_reply_link( $args['cancel_reply_link'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2378 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2379 |
echo $args['cancel_reply_after']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2380 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2381 |
echo $args['title_reply_after']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2382 |
|
9 | 2383 |
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) : |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2384 |
echo $args['must_log_in']; |
0 | 2385 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2386 |
* Fires after the HTML-formatted 'must log in after' message in the comment form. |
0 | 2387 |
* |
2388 |
* @since 3.0.0 |
|
2389 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2390 |
do_action( 'comment_form_must_log_in_after' ); |
9 | 2391 |
else : |
2392 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2393 |
<form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2394 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2395 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2396 |
* Fires at the top of the comment form, inside the form tag. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2397 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2398 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2399 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2400 |
do_action( 'comment_form_top' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2401 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2402 |
if ( is_user_logged_in() ) : |
0 | 2403 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2404 |
* Filters the 'logged in' message for the comment form for display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2405 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2406 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2407 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2408 |
* @param string $args_logged_in The logged-in-as HTML-formatted message. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2409 |
* @param array $commenter An array containing the comment author's |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2410 |
* username, email, and URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2411 |
* @param string $user_identity If the commenter is a registered user, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2412 |
* the display name, blank otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2413 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2414 |
echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2415 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2416 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2417 |
* Fires after the is_user_logged_in() check in the comment form. |
0 | 2418 |
* |
2419 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2420 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2421 |
* @param array $commenter An array containing the comment author's |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2422 |
* username, email, and URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2423 |
* @param string $user_identity If the commenter is a registered user, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2424 |
* the display name, blank otherwise. |
0 | 2425 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2426 |
do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2427 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2428 |
else : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2429 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2430 |
echo $args['comment_notes_before']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2431 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2432 |
endif; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2433 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2434 |
// Prepare an array of all fields, including the textarea |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2435 |
$comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2436 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2437 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2438 |
* Filters the comment form fields, including the textarea. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2439 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2440 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2441 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2442 |
* @param array $comment_fields The comment fields. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2443 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2444 |
$comment_fields = apply_filters( 'comment_form_fields', $comment_fields ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2445 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2446 |
// Get an array of field names, excluding the textarea |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2447 |
$comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2448 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2449 |
// Get the first and the last field name, excluding the textarea |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2450 |
$first_field = reset( $comment_field_keys ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2451 |
$last_field = end( $comment_field_keys ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2452 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2453 |
foreach ( $comment_fields as $name => $field ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2454 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2455 |
if ( 'comment' === $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2456 |
|
0 | 2457 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2458 |
* Filters the content of the comment textarea field for display. |
0 | 2459 |
* |
2460 |
* @since 3.0.0 |
|
2461 |
* |
|
5 | 2462 |
* @param string $args_comment_field The content of the comment textarea field. |
0 | 2463 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2464 |
echo apply_filters( 'comment_form_field_comment', $field ); |
5 | 2465 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2466 |
echo $args['comment_notes_after']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2467 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2468 |
} elseif ( ! is_user_logged_in() ) { |
5 | 2469 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2470 |
if ( $first_field === $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2471 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2472 |
* Fires before the comment fields in the comment form, excluding the textarea. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2473 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2474 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2475 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2476 |
do_action( 'comment_form_before_fields' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2477 |
} |
5 | 2478 |
|
2479 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2480 |
* Filters a comment form field for display. |
5 | 2481 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2482 |
* The dynamic portion of the filter hook, `$name`, refers to the name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2483 |
* of the comment form field. Such as 'author', 'email', or 'url'. |
0 | 2484 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2485 |
* @since 3.0.0 |
0 | 2486 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2487 |
* @param string $field The HTML-formatted output of the comment form field. |
0 | 2488 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2489 |
echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2490 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2491 |
if ( $last_field === $name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2492 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2493 |
* Fires after the comment fields in the comment form, excluding the textarea. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2494 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2495 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2496 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2497 |
do_action( 'comment_form_after_fields' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2498 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2499 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2500 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2501 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2502 |
$submit_button = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2503 |
$args['submit_button'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2504 |
esc_attr( $args['name_submit'] ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2505 |
esc_attr( $args['id_submit'] ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2506 |
esc_attr( $args['class_submit'] ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2507 |
esc_attr( $args['label_submit'] ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2508 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2509 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2510 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2511 |
* Filters the submit button for the comment form to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2512 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2513 |
* @since 4.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2514 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2515 |
* @param string $submit_button HTML markup for the submit button. |
9 | 2516 |
* @param array $args Arguments passed to comment_form(). |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2517 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2518 |
$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2519 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2520 |
$submit_field = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2521 |
$args['submit_field'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2522 |
$submit_button, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2523 |
get_comment_id_fields( $post_id ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2524 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2525 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2526 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2527 |
* Filters the submit field for the comment form to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2528 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2529 |
* The submit field includes the submit button, hidden fields for the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2530 |
* comment form, and any wrapper markup. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2531 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2532 |
* @since 4.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2533 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2534 |
* @param string $submit_field HTML markup for the submit field. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2535 |
* @param array $args Arguments passed to comment_form(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2536 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2537 |
echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2538 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2539 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2540 |
* Fires at the bottom of the comment form, inside the closing </form> tag. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2541 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2542 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2543 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2544 |
* @param int $post_id The post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2545 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2546 |
do_action( 'comment_form', $post_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2547 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2548 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2549 |
<?php endif; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2550 |
</div><!-- #respond --> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2551 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2552 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2553 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2554 |
* Fires after the comment form. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2555 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2556 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2557 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2558 |
do_action( 'comment_form_after' ); |
0 | 2559 |
} |