author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Author Template functions for use in themes. |
|
4 |
* |
|
5 |
* These functions must be used within the WordPress Loop. |
|
6 |
* |
|
5 | 7 |
* @link https://codex.wordpress.org/Author_Templates |
0 | 8 |
* |
9 |
* @package WordPress |
|
10 |
* @subpackage Template |
|
11 |
*/ |
|
12 |
||
13 |
/** |
|
19 | 14 |
* Retrieves the author of the current post. |
0 | 15 |
* |
5 | 16 |
* @since 1.5.0 |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
* @since 6.3.0 Returns an empty string if the author's display name is unknown. |
5 | 18 |
* |
16 | 19 |
* @global WP_User $authordata The current author's data. |
0 | 20 |
* |
21 |
* @param string $deprecated Deprecated. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
* @return string The author's display name, empty string if unknown. |
0 | 23 |
*/ |
9 | 24 |
function get_the_author( $deprecated = '' ) { |
0 | 25 |
global $authordata; |
26 |
||
9 | 27 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
_deprecated_argument( __FUNCTION__, '2.1.0' ); |
9 | 29 |
} |
0 | 30 |
|
31 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* Filters the display name of the current post's author. |
0 | 33 |
* |
34 |
* @since 2.9.0 |
|
35 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
36 |
* @param string $display_name The author's display name. |
0 | 37 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
38 |
return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : '' ); |
0 | 39 |
} |
40 |
||
41 |
/** |
|
19 | 42 |
* Displays the name of the author of the current post. |
0 | 43 |
* |
44 |
* The behavior of this function is based off of old functionality predating |
|
45 |
* get_the_author(). This function is not deprecated, but is designed to echo |
|
46 |
* the value from get_the_author() and as an result of any old theme that might |
|
47 |
* still use the old behavior will also pass the value from get_the_author(). |
|
48 |
* |
|
49 |
* The normal, expected behavior of this function is to echo the author and not |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
* return it. However, backward compatibility has to be maintained. |
0 | 51 |
* |
52 |
* @since 0.71 |
|
16 | 53 |
* |
0 | 54 |
* @see get_the_author() |
16 | 55 |
* @link https://developer.wordpress.org/reference/functions/the_author/ |
0 | 56 |
* |
9 | 57 |
* @param string $deprecated Deprecated. |
58 |
* @param bool $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
* @return string The author's display name, from get_the_author(). |
0 | 60 |
*/ |
61 |
function the_author( $deprecated = '', $deprecated_echo = true ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
if ( ! empty( $deprecated ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
_deprecated_argument( __FUNCTION__, '2.1.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
if ( true !== $deprecated_echo ) { |
9 | 67 |
_deprecated_argument( |
68 |
__FUNCTION__, |
|
69 |
'1.5.0', |
|
70 |
sprintf( |
|
16 | 71 |
/* translators: %s: get_the_author() */ |
9 | 72 |
__( '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
|
73 |
'<code>get_the_author()</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
if ( $deprecated_echo ) { |
0 | 79 |
echo get_the_author(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
|
0 | 82 |
return get_the_author(); |
83 |
} |
|
84 |
||
85 |
/** |
|
19 | 86 |
* Retrieves the author who last edited the current post. |
0 | 87 |
* |
5 | 88 |
* @since 2.8.0 |
89 |
* |
|
19 | 90 |
* @return string|void The author's display name, empty string if unknown. |
0 | 91 |
*/ |
92 |
function get_the_modified_author() { |
|
9 | 93 |
$last_id = get_post_meta( get_post()->ID, '_edit_last', true ); |
94 |
||
95 |
if ( $last_id ) { |
|
96 |
$last_user = get_userdata( $last_id ); |
|
0 | 97 |
|
98 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
* Filters the display name of the author who last edited the current post. |
0 | 100 |
* |
101 |
* @since 2.8.0 |
|
102 |
* |
|
19 | 103 |
* @param string $display_name The author's display name, empty string if unknown. |
0 | 104 |
*/ |
19 | 105 |
return apply_filters( 'the_modified_author', $last_user ? $last_user->display_name : '' ); |
0 | 106 |
} |
107 |
} |
|
108 |
||
109 |
/** |
|
19 | 110 |
* Displays the name of the author who last edited the current post, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
* if the author's ID is available. |
0 | 112 |
* |
5 | 113 |
* @since 2.8.0 |
114 |
* |
|
0 | 115 |
* @see get_the_author() |
116 |
*/ |
|
117 |
function the_modified_author() { |
|
118 |
echo get_the_modified_author(); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
* Retrieves the requested data of the author of the current post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
* Valid values for the `$field` parameter include: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
* - admin_color |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
* - aim |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
* - comment_shortcuts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
* - description |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
* - display_name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
* - first_name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* - ID |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
* - jabber |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* - last_name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
* - nickname |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
* - plugins_last_view |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
* - plugins_per_page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
* - rich_editing |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
* - syntax_highlighting |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
* - user_activation_key |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
* - user_description |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* - user_email |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
* - user_firstname |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
* - user_lastname |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
* - user_level |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* - user_login |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* - user_nicename |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* - user_pass |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
* - user_registered |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* - user_status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* - user_url |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
* - yim |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
* |
0 | 154 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
* |
16 | 156 |
* @global WP_User $authordata The current author's data. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
* |
9 | 158 |
* @param string $field Optional. The user field to retrieve. Default empty. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
159 |
* @param int|false $user_id Optional. User ID. Defaults to the current post author. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
* @return string The author's field from the current author's DB object, otherwise an empty string. |
0 | 161 |
*/ |
162 |
function get_the_author_meta( $field = '', $user_id = false ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
$original_user_id = $user_id; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
|
0 | 165 |
if ( ! $user_id ) { |
166 |
global $authordata; |
|
167 |
$user_id = isset( $authordata->ID ) ? $authordata->ID : 0; |
|
168 |
} else { |
|
169 |
$authordata = get_userdata( $user_id ); |
|
170 |
} |
|
171 |
||
16 | 172 |
if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ), true ) ) { |
0 | 173 |
$field = 'user_' . $field; |
9 | 174 |
} |
0 | 175 |
|
176 |
$value = isset( $authordata->$field ) ? $authordata->$field : ''; |
|
177 |
||
178 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
* Filters the value of the requested user metadata. |
0 | 180 |
* |
181 |
* The filter name is dynamic and depends on the $field parameter of the function. |
|
182 |
* |
|
183 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
* @since 4.3.0 The `$original_user_id` parameter was added. |
0 | 185 |
* |
9 | 186 |
* @param string $value The value of the metadata. |
187 |
* @param int $user_id The user ID for the value. |
|
188 |
* @param int|false $original_user_id The original user ID, as passed to the function. |
|
0 | 189 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id ); |
0 | 191 |
} |
192 |
||
193 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
* Outputs the field from the user's DB object. Defaults to current post's author. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
* |
0 | 196 |
* @since 2.8.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* |
9 | 198 |
* @param string $field Selects the field of the users record. See get_the_author_meta() |
199 |
* for the list of possible fields. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
200 |
* @param int|false $user_id Optional. User ID. Defaults to the current post author. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
* @see get_the_author_meta() |
0 | 203 |
*/ |
204 |
function the_author_meta( $field = '', $user_id = false ) { |
|
205 |
$author_meta = get_the_author_meta( $field, $user_id ); |
|
206 |
||
207 |
/** |
|
19 | 208 |
* Filters the value of the requested user metadata. |
0 | 209 |
* |
210 |
* The filter name is dynamic and depends on the $field parameter of the function. |
|
211 |
* |
|
212 |
* @since 2.8.0 |
|
213 |
* |
|
9 | 214 |
* @param string $author_meta The value of the metadata. |
215 |
* @param int|false $user_id The user ID. |
|
0 | 216 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
echo apply_filters( "the_author_{$field}", $author_meta, $user_id ); |
0 | 218 |
} |
219 |
||
220 |
/** |
|
19 | 221 |
* Retrieves either author's link or author's name. |
0 | 222 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
223 |
* If the author has a home page set, return an HTML link, otherwise just return |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
224 |
* the author's name. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
* @since 3.0.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
227 |
* |
19 | 228 |
* @global WP_User $authordata The current author's data. |
229 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
230 |
* @return string An HTML link if the author's URL exists in user meta, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
231 |
* otherwise the result of get_the_author(). |
0 | 232 |
*/ |
233 |
function get_the_author_link() { |
|
9 | 234 |
if ( get_the_author_meta( 'url' ) ) { |
19 | 235 |
global $authordata; |
236 |
||
237 |
$author_url = get_the_author_meta( 'url' ); |
|
238 |
$author_display_name = get_the_author(); |
|
239 |
||
240 |
$link = sprintf( |
|
9 | 241 |
'<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', |
19 | 242 |
esc_url( $author_url ), |
16 | 243 |
/* translators: %s: Author's display name. */ |
19 | 244 |
esc_attr( sprintf( __( 'Visit %s’s website' ), $author_display_name ) ), |
245 |
$author_display_name |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
); |
19 | 247 |
|
248 |
/** |
|
249 |
* Filters the author URL link HTML. |
|
250 |
* |
|
251 |
* @since 6.0.0 |
|
252 |
* |
|
253 |
* @param string $link The default rendered author HTML link. |
|
254 |
* @param string $author_url Author's URL. |
|
255 |
* @param WP_User $authordata Author user data. |
|
256 |
*/ |
|
257 |
return apply_filters( 'the_author_link', $link, $author_url, $authordata ); |
|
0 | 258 |
} else { |
259 |
return get_the_author(); |
|
260 |
} |
|
261 |
} |
|
262 |
||
263 |
/** |
|
19 | 264 |
* Displays either author's link or author's name. |
0 | 265 |
* |
266 |
* If the author has a home page set, echo an HTML link, otherwise just echo the |
|
267 |
* author's name. |
|
268 |
* |
|
16 | 269 |
* @link https://developer.wordpress.org/reference/functions/the_author_link/ |
5 | 270 |
* |
271 |
* @since 2.1.0 |
|
0 | 272 |
*/ |
273 |
function the_author_link() { |
|
274 |
echo get_the_author_link(); |
|
275 |
} |
|
276 |
||
277 |
/** |
|
19 | 278 |
* Retrieves the number of posts by the author of the current post. |
0 | 279 |
* |
5 | 280 |
* @since 1.5.0 |
281 |
* |
|
0 | 282 |
* @return int The number of posts by the author. |
283 |
*/ |
|
284 |
function get_the_author_posts() { |
|
5 | 285 |
$post = get_post(); |
286 |
if ( ! $post ) { |
|
287 |
return 0; |
|
288 |
} |
|
289 |
return count_user_posts( $post->post_author, $post->post_type ); |
|
0 | 290 |
} |
291 |
||
292 |
/** |
|
19 | 293 |
* Displays the number of posts by the author of the current post. |
0 | 294 |
* |
16 | 295 |
* @link https://developer.wordpress.org/reference/functions/the_author_posts/ |
0 | 296 |
* @since 0.71 |
297 |
*/ |
|
298 |
function the_author_posts() { |
|
299 |
echo get_the_author_posts(); |
|
300 |
} |
|
301 |
||
302 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
* Retrieves an HTML link to the author page of the current post's author. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* Returns an HTML-formatted link using get_author_posts_url(). |
0 | 306 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* @since 4.4.0 |
0 | 308 |
* |
16 | 309 |
* @global WP_User $authordata The current author's data. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
311 |
* @return string An HTML link to the author page, or an empty string if $authordata is not set. |
0 | 312 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
function get_the_author_posts_link() { |
0 | 314 |
global $authordata; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
315 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
if ( ! is_object( $authordata ) ) { |
9 | 317 |
return ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
|
9 | 320 |
$link = sprintf( |
321 |
'<a href="%1$s" title="%2$s" rel="author">%3$s</a>', |
|
0 | 322 |
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), |
16 | 323 |
/* translators: %s: Author's display name. */ |
0 | 324 |
esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), |
325 |
get_the_author() |
|
326 |
); |
|
327 |
||
328 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
* Filters the link to the author page of the author of the current post. |
0 | 330 |
* |
331 |
* @since 2.9.0 |
|
332 |
* |
|
333 |
* @param string $link HTML link. |
|
334 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
return apply_filters( 'the_author_posts_link', $link ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
* Displays an HTML link to the author page of the current post's author. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
* @since 1.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
* @since 4.4.0 Converted into a wrapper for get_the_author_posts_link() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* @param string $deprecated Unused. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
function the_author_posts_link( $deprecated = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
if ( ! empty( $deprecated ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
_deprecated_argument( __FUNCTION__, '2.1.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
echo get_the_author_posts_link(); |
0 | 351 |
} |
352 |
||
353 |
/** |
|
19 | 354 |
* Retrieves the URL to the author page for the user with the ID provided. |
0 | 355 |
* |
356 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
* |
16 | 358 |
* @global WP_Rewrite $wp_rewrite WordPress rewrite component. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
* @param int $author_id Author ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
* @param string $author_nicename Optional. The author's nicename (slug). Default empty. |
0 | 362 |
* @return string The URL to the author's page. |
363 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
function get_author_posts_url( $author_id, $author_nicename = '' ) { |
0 | 365 |
global $wp_rewrite; |
19 | 366 |
|
367 |
$author_id = (int) $author_id; |
|
368 |
$link = $wp_rewrite->get_author_permastruct(); |
|
0 | 369 |
|
9 | 370 |
if ( empty( $link ) ) { |
0 | 371 |
$file = home_url( '/' ); |
19 | 372 |
$link = $file . '?author=' . $author_id; |
0 | 373 |
} else { |
16 | 374 |
if ( '' === $author_nicename ) { |
9 | 375 |
$user = get_userdata( $author_id ); |
376 |
if ( ! empty( $user->user_nicename ) ) { |
|
0 | 377 |
$author_nicename = $user->user_nicename; |
9 | 378 |
} |
0 | 379 |
} |
9 | 380 |
$link = str_replace( '%author%', $author_nicename, $link ); |
0 | 381 |
$link = home_url( user_trailingslashit( $link ) ); |
382 |
} |
|
383 |
||
384 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
* Filters the URL to the author's page. |
0 | 386 |
* |
387 |
* @since 2.1.0 |
|
388 |
* |
|
389 |
* @param string $link The URL to the author's page. |
|
16 | 390 |
* @param int $author_id The author's ID. |
0 | 391 |
* @param string $author_nicename The author's nice name. |
392 |
*/ |
|
393 |
$link = apply_filters( 'author_link', $link, $author_id, $author_nicename ); |
|
394 |
||
395 |
return $link; |
|
396 |
} |
|
397 |
||
398 |
/** |
|
19 | 399 |
* Lists all the authors of the site, with several options available. |
0 | 400 |
* |
16 | 401 |
* @link https://developer.wordpress.org/reference/functions/wp_list_authors/ |
5 | 402 |
* |
403 |
* @since 1.2.0 |
|
404 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
* |
5 | 407 |
* @param string|array $args { |
408 |
* Optional. Array or string of default arguments. |
|
0 | 409 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
* @type string $orderby How to sort the authors. Accepts 'nicename', 'email', 'url', 'registered', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
* 'user_nicename', 'user_email', 'user_url', 'user_registered', 'name', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
* 'display_name', 'post_count', 'ID', 'meta_value', 'user_login'. Default 'name'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
* @type string $order Sorting direction for $orderby. Accepts 'ASC', 'DESC'. Default 'ASC'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
* @type int $number Maximum authors to return or display. Default empty (all authors). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
* @type bool $optioncount Show the count in parenthesis next to the author's name. Default false. |
9 | 416 |
* @type bool $exclude_admin Whether to exclude the 'admin' account, if it exists. Default true. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* @type bool $show_fullname Whether to show the author's full name. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
* @type bool $hide_empty Whether to hide any authors with no posts. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* @type string $feed If not empty, show a link to the author's feed and use this text as the alt |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
* parameter of the link. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
* @type string $feed_image If not empty, show a link to the author's feed and use this image URL as |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
* clickable anchor. Default empty. |
16 | 423 |
* @type string $feed_type The feed type to link to. Possible values include 'rss2', 'atom'. |
424 |
* Default is the value of get_default_feed(). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
* @type bool $echo Whether to output the result or instead return it. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* @type string $style If 'list', each author is wrapped in an `<li>` element, otherwise the authors |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
* will be separated by commas. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* @type bool $html Whether to list the items in HTML form or plaintext. Default true. |
18 | 429 |
* @type int[]|string $exclude Array or comma/space-separated list of author IDs to exclude. Default empty. |
430 |
* @type int[]|string $include Array or comma/space-separated list of author IDs to include. Default empty. |
|
5 | 431 |
* } |
16 | 432 |
* @return void|string Void if 'echo' argument is true, list of authors if 'echo' is false. |
0 | 433 |
*/ |
5 | 434 |
function wp_list_authors( $args = '' ) { |
0 | 435 |
global $wpdb; |
436 |
||
437 |
$defaults = array( |
|
9 | 438 |
'orderby' => 'name', |
439 |
'order' => 'ASC', |
|
440 |
'number' => '', |
|
441 |
'optioncount' => false, |
|
442 |
'exclude_admin' => true, |
|
443 |
'show_fullname' => false, |
|
444 |
'hide_empty' => true, |
|
445 |
'feed' => '', |
|
446 |
'feed_image' => '', |
|
447 |
'feed_type' => '', |
|
448 |
'echo' => true, |
|
449 |
'style' => 'list', |
|
450 |
'html' => true, |
|
451 |
'exclude' => '', |
|
452 |
'include' => '', |
|
0 | 453 |
); |
454 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
455 |
$parsed_args = wp_parse_args( $args, $defaults ); |
0 | 456 |
|
457 |
$return = ''; |
|
458 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
459 |
$query_args = wp_array_slice_assoc( $parsed_args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); |
0 | 460 |
$query_args['fields'] = 'ids'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
461 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
462 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
463 |
* Filters the query arguments for the list of all authors of the site. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
464 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
465 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
466 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
467 |
* @param array $query_args The query arguments for get_users(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
468 |
* @param array $parsed_args The arguments passed to wp_list_authors() combined with the defaults. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
469 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
470 |
$query_args = apply_filters( 'wp_list_authors_args', $query_args, $parsed_args ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
471 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
$authors = get_users( $query_args ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
473 |
$post_counts = array(); |
0 | 474 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
475 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
476 |
* Filters whether to short-circuit performing the query for author post counts. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
477 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
478 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
479 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
480 |
* @param int[]|false $post_counts Array of post counts, keyed by author ID. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
481 |
* @param array $parsed_args The arguments passed to wp_list_authors() combined with the defaults. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
482 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
483 |
$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
484 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
485 |
if ( ! is_array( $post_counts ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
486 |
$post_counts = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
$post_counts_query = $wpdb->get_results( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
488 |
"SELECT DISTINCT post_author, COUNT(ID) AS count |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
FROM $wpdb->posts |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
490 |
WHERE " . get_private_posts_cap_sql( 'post' ) . ' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
491 |
GROUP BY post_author' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
492 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
493 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
494 |
foreach ( (array) $post_counts_query as $row ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
495 |
$post_counts[ $row->post_author ] = $row->count; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
496 |
} |
5 | 497 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
|
0 | 499 |
foreach ( $authors as $author_id ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
500 |
$posts = isset( $post_counts[ $author_id ] ) ? $post_counts[ $author_id ] : 0; |
0 | 501 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
502 |
if ( ! $posts && $parsed_args['hide_empty'] ) { |
0 | 503 |
continue; |
5 | 504 |
} |
0 | 505 |
|
9 | 506 |
$author = get_userdata( $author_id ); |
0 | 507 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
508 |
if ( $parsed_args['exclude_admin'] && 'admin' === $author->display_name ) { |
0 | 509 |
continue; |
5 | 510 |
} |
0 | 511 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
512 |
if ( $parsed_args['show_fullname'] && $author->first_name && $author->last_name ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
$name = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
514 |
/* translators: 1: User's first name, 2: Last name. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
515 |
_x( '%1$s %2$s', 'Display name based on first name and last name' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
516 |
$author->first_name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
517 |
$author->last_name |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
); |
5 | 519 |
} else { |
0 | 520 |
$name = $author->display_name; |
5 | 521 |
} |
0 | 522 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
523 |
if ( ! $parsed_args['html'] ) { |
0 | 524 |
$return .= $name . ', '; |
525 |
||
526 |
continue; // No need to go further to process HTML. |
|
527 |
} |
|
528 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
if ( 'list' === $parsed_args['style'] ) { |
0 | 530 |
$return .= '<li>'; |
531 |
} |
|
532 |
||
9 | 533 |
$link = sprintf( |
534 |
'<a href="%1$s" title="%2$s">%3$s</a>', |
|
18 | 535 |
esc_url( get_author_posts_url( $author->ID, $author->user_nicename ) ), |
16 | 536 |
/* translators: %s: Author's display name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
esc_attr( sprintf( __( 'Posts by %s' ), $author->display_name ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
$name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
); |
0 | 540 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
if ( ! empty( $parsed_args['feed_image'] ) || ! empty( $parsed_args['feed'] ) ) { |
0 | 542 |
$link .= ' '; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
543 |
if ( empty( $parsed_args['feed_image'] ) ) { |
0 | 544 |
$link .= '('; |
545 |
} |
|
546 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
547 |
$link .= '<a href="' . get_author_feed_link( $author->ID, $parsed_args['feed_type'] ) . '"'; |
0 | 548 |
|
5 | 549 |
$alt = ''; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
550 |
if ( ! empty( $parsed_args['feed'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
551 |
$alt = ' alt="' . esc_attr( $parsed_args['feed'] ) . '"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
552 |
$name = $parsed_args['feed']; |
0 | 553 |
} |
554 |
||
555 |
$link .= '>'; |
|
556 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
557 |
if ( ! empty( $parsed_args['feed_image'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
558 |
$link .= '<img src="' . esc_url( $parsed_args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; |
5 | 559 |
} else { |
0 | 560 |
$link .= $name; |
5 | 561 |
} |
0 | 562 |
|
563 |
$link .= '</a>'; |
|
564 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
565 |
if ( empty( $parsed_args['feed_image'] ) ) { |
0 | 566 |
$link .= ')'; |
5 | 567 |
} |
0 | 568 |
} |
569 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
570 |
if ( $parsed_args['optioncount'] ) { |
9 | 571 |
$link .= ' (' . $posts . ')'; |
5 | 572 |
} |
0 | 573 |
|
574 |
$return .= $link; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
575 |
$return .= ( 'list' === $parsed_args['style'] ) ? '</li>' : ', '; |
0 | 576 |
} |
577 |
||
5 | 578 |
$return = rtrim( $return, ', ' ); |
0 | 579 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
580 |
if ( $parsed_args['echo'] ) { |
16 | 581 |
echo $return; |
582 |
} else { |
|
0 | 583 |
return $return; |
5 | 584 |
} |
0 | 585 |
} |
586 |
||
587 |
/** |
|
9 | 588 |
* Determines whether this site has more than one author. |
0 | 589 |
* |
590 |
* Checks to see if more than one author has published posts. |
|
591 |
* |
|
9 | 592 |
* For more information on this and similar theme functions, check out |
593 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
594 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
595 |
* |
|
0 | 596 |
* @since 3.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
* |
0 | 600 |
* @return bool Whether or not we have more than one author |
601 |
*/ |
|
602 |
function is_multi_author() { |
|
603 |
global $wpdb; |
|
604 |
||
16 | 605 |
$is_multi_author = get_transient( 'is_multi_author' ); |
606 |
if ( false === $is_multi_author ) { |
|
9 | 607 |
$rows = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2" ); |
0 | 608 |
$is_multi_author = 1 < count( $rows ) ? 1 : 0; |
609 |
set_transient( 'is_multi_author', $is_multi_author ); |
|
610 |
} |
|
611 |
||
612 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
* Filters whether the site has more than one author with published posts. |
0 | 614 |
* |
615 |
* @since 3.2.0 |
|
616 |
* |
|
617 |
* @param bool $is_multi_author Whether $is_multi_author should evaluate as true. |
|
618 |
*/ |
|
619 |
return apply_filters( 'is_multi_author', (bool) $is_multi_author ); |
|
620 |
} |
|
621 |
||
622 |
/** |
|
623 |
* Helper function to clear the cache for number of authors. |
|
624 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
* @since 3.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
* @access private |
0 | 627 |
*/ |
16 | 628 |
function __clear_multi_author_cache() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore |
0 | 629 |
delete_transient( 'is_multi_author' ); |
630 |
} |