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