Ticket #25229: author-template.patch
File author-template.patch, 14.2 KB (added by , 11 years ago) |
---|
-
wp-includes/author-template.php
11 11 */ 12 12 13 13 /** 14 * Retrieve the author of the current post.14 * Retrieve the display name of the author of the current post. 15 15 * 16 * @since 1.5 17 * @uses $authordata The current author's DB object. 18 * @uses apply_filters() Calls 'the_author' hook on the author display name. 16 * @global $authordata 19 17 * 18 * @since 1.5.0 19 * 20 20 * @param string $deprecated Deprecated. 21 21 * @return string The author's display name. 22 22 */ … … 26 26 if ( !empty( $deprecated ) ) 27 27 _deprecated_argument( __FUNCTION__, '2.1' ); 28 28 29 /** 30 * The display name of the current post's author. 31 * 32 * @since 2.9.0 33 * 34 * @param string $authordata->display_name The author's display name. 35 */ 29 36 return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null); 30 37 } 31 38 32 39 /** 33 * Display the name of the author of the current post.40 * Display the display name of the author of the current post. 34 41 * 35 42 * The behavior of this function is based off of old functionality predating 36 43 * get_the_author(). This function is not deprecated, but is designed to echo … … 40 47 * The normal, expected behavior of this function is to echo the author and not 41 48 * return it. However, backwards compatibility has to be maintained. 42 49 * 43 * @since 0.7144 50 * @see get_the_author() 45 51 * @link http://codex.wordpress.org/Template_Tags/the_author 46 52 * 53 * @since 0.71 54 * 47 55 * @param string $deprecated Deprecated. 48 56 * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it. 49 * @return string The author's display name , from get_the_author().57 * @return string The author's display name. 50 58 */ 51 59 function the_author( $deprecated = '', $deprecated_echo = true ) { 52 60 if ( !empty( $deprecated ) ) … … 59 67 } 60 68 61 69 /** 62 * Retrieve the author who last edited the current post.70 * Retrieve the display name of the author who last edited the current post. 63 71 * 64 * @since 2.8 65 * @uses $post The current post's DB object. 66 * @uses get_post_meta() Retrieves the ID of the author who last edited the current post. 67 * @uses get_userdata() Retrieves the author's DB object. 68 * @uses apply_filters() Calls 'the_modified_author' hook on the author display name. 72 * @see get_post_meta() 73 * @see get_post() 74 * @see get_userdata() 75 * 76 * @since 2.8.0 77 * 69 78 * @return string The author's display name. 70 79 */ 71 80 function get_the_modified_author() { 72 81 if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) { 73 82 $last_user = get_userdata($last_id); 83 84 /** 85 * The display name of author who last edited the current post. 86 * 87 * @since 2.8.0 88 * 89 * @param string $last_user->display_name The author's display name. 90 */ 74 91 return apply_filters('the_modified_author', $last_user->display_name); 75 92 } 76 93 } 77 94 78 95 /** 79 * Display the name of the author who last edited the current post.96 * Display the display name of the author who last edited the current post. 80 97 * 81 * @since 2.8 82 * @see get_the_author() 83 * @return string The author's display name, from get_the_modified_author(). 98 * @see get_the_modified_author 99 * 100 * @since 2.8.0 101 * 102 * @return void 84 103 */ 85 104 function the_modified_author() { 86 105 echo get_the_modified_author(); 87 106 } 88 107 89 108 /** 90 * Retrieve the requested data of the author of the current post. 91 * @link http://codex.wordpress.org/Template_Tags/the_author_meta 109 * Retrieve the requested metadata for the author of the current post or the author with the specified ID. 110 * 111 * @see get_userdata() 112 * @link http://codex.wordpress.org/Function_Reference/get_the_author_meta 113 * 114 * @global $authordata 115 * 92 116 * @since 2.8.0 93 * @uses $authordata The current author's DB object (if $user_id not specified).94 * @param string $field selects the field of the users record.95 * @param int $user_id Optional. User ID.96 * @return string The author's field from the current author's DB object.117 * 118 * @param string $field The name of the metadata to retrieve. 119 * @param int $user_id Optional. The ID of a user. Defaults to the current user. 120 * @return string The value of the metadata or empty string. 97 121 */ 98 122 function get_the_author_meta( $field = '', $user_id = false ) { 99 123 if ( ! $user_id ) { … … 108 132 109 133 $value = isset( $authordata->$field ) ? $authordata->$field : ''; 110 134 135 /** 136 * The value of the requested user metadata. 137 * 138 * @since 2.8.0 139 * 140 * @param string The name of the metadata. 141 * @param string The value of the metadata. 142 * @param int The user ID. 143 */ 111 144 return apply_filters( 'get_the_author_' . $field, $value, $user_id ); 112 145 } 113 146 114 147 /** 115 * Retrieve the requested data of the author of the current post. 148 * Display the requested metadata for the author of the current post or the author with the specified ID. 149 * 150 * @see get_the_author_meta() 116 151 * @link http://codex.wordpress.org/Template_Tags/the_author_meta 152 * 117 153 * @since 2.8.0 118 * @param string $field selects the field of the users record. 119 * @param int $user_id Optional. User ID. 120 * @echo string The author's field from the current author's DB object. 154 * 155 * @param string $field The name of the metadata to display. 156 * @param int $user_id Optional. The ID of a user. Defaults to the current user. 157 * @return void 121 158 */ 122 159 function the_author_meta($field = '', $user_id = false) { 160 /** 161 * The value of the requested user metadata. 162 * 163 * @since 2.8.0 164 * 165 * @param string The name of the metadata. 166 * @param string The value of the metadata. 167 * @param int The user ID. 168 */ 123 169 echo apply_filters('the_author_' . $field, get_the_author_meta($field, $user_id), $user_id); 124 170 } 125 171 126 172 /** 127 * Retrieve either author's link or author'sname.173 * Retrieve the author's homepage link or the author's display name. 128 174 * 129 * If the author has a home page set, return an HTML link, otherwise just return the 130 * author's name. 175 * If the author has a home page set, return an HTML link, otherwise just return the author's display name. 131 176 * 132 * @uses get_the_author_meta() 133 * @uses get_the_author() 177 * @see get_the_author_meta() 178 * @see get_the_author() 179 * 180 * @since 2.1.0 181 * 182 * @return string HTML link to the author's homepage or the author's display name. 134 183 */ 135 184 function get_the_author_link() { 136 185 if ( get_the_author_meta('url') ) { … … 141 190 } 142 191 143 192 /** 144 * Display either author's link or author'sname.193 * Display the author's homepage link or the author's display name. 145 194 * 146 * If the author has a home page set, echo an HTML link, otherwise just echo the 147 * author's name. 195 * If the author has a home page set, display an HTML link, otherwise just display the author's display name. 148 196 * 197 * @see get_the_author_link() 149 198 * @link http://codex.wordpress.org/Template_Tags/the_author_link 150 * @since 2.1 151 * @uses get_the_author_link() 199 * 200 * @since 2.1.0 201 * 202 * @return void 152 203 */ 153 204 function the_author_link() { 154 205 echo get_the_author_link(); … … 157 208 /** 158 209 * Retrieve the number of posts by the author of the current post. 159 210 * 160 * @since 1.5 161 * @uses $post The current post in the Loop's DB object. 162 * @uses count_user_posts() 211 * @see count_user_posts() 212 * 213 * @since 1.5.0 214 * 163 215 * @return int The number of posts by the author. 164 216 */ 165 217 function get_the_author_posts() { … … 169 221 /** 170 222 * Display the number of posts by the author of the current post. 171 223 * 172 * @link http://codex.wordpress.org/Template_Tags/the_author_posts 224 * @see get_the_author_posts() 225 * 173 226 * @since 0.71 174 * @uses get_the_author_posts() Echoes returned value from function. 227 * 228 * @return void 175 229 */ 176 230 function the_author_posts() { 177 231 echo get_the_author_posts(); … … 180 234 /** 181 235 * Display an HTML link to the author page of the author of the current post. 182 236 * 183 * Does just echo get_author_posts_url() function, like the others do. The184 * reason for this, is that another function is used to help in printing the185 * link to the author's posts.237 * @see get_author_posts_url() 238 * @see get_the_author() 239 * @link http://codex.wordpress.org/Template_Tags/the_author_posts_link 186 240 * 187 * @link http://codex.wordpress.org/Template_Tags/the_author_posts_link 241 * @global $authordata 242 * 188 243 * @since 1.2.0 189 * @uses $authordata The current author's DB object. 190 * @uses get_author_posts_url() 191 * @uses get_the_author() 244 * 192 245 * @param string $deprecated Deprecated. 246 * @return void 193 247 */ 194 248 function the_author_posts_link($deprecated = '') { 195 249 if ( !empty( $deprecated ) ) … … 204 258 esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), 205 259 get_the_author() 206 260 ); 261 262 /** 263 * The link to the author page of the author of the current post. 264 * 265 * @since 2.9.0 266 * 267 * @param string HTML link 268 */ 207 269 echo apply_filters( 'the_author_posts_link', $link ); 208 270 } 209 271 210 272 /** 211 273 * Retrieve the URL to the author page for the user with the ID provided. 212 274 * 275 * @see get_author_permastruct() 276 * @see get_userdata() 277 * 278 * @global $wp_rewrite 279 * 213 280 * @since 2.1.0 214 * @uses $wp_rewrite WP_Rewrite 281 * 282 * @param int $author_id The ID of a user. 283 * @param string $author_nicename Optional. The author's nice name. 215 284 * @return string The URL to the author's page. 216 285 */ 217 286 function get_author_posts_url($author_id, $author_nicename = '') { … … 232 301 $link = home_url( user_trailingslashit( $link ) ); 233 302 } 234 303 304 /** 305 * The URL to the author's page. 306 * 307 * @since 2.1.0 308 * 309 * @param string $link The URL to the author's page. 310 * @param int $author_id The ID of a user. 311 * @param string $author_nicename Optional. The author's nice name. 312 */ 235 313 $link = apply_filters('author_link', $link, $author_id, $author_nicename); 236 314 237 315 return $link; 238 316 } 239 317 240 318 /** 241 * List all the authors of the blog, with several options available.319 * Display or return a list of all the authors of the blog. 242 320 * 243 * <ul> 244 * <li>optioncount (boolean) (false): Show the count in parenthesis next to the 245 * author's name.</li> 246 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is 247 * installed by default.</li> 248 * <li>show_fullname (boolean) (false): Show their full names.</li> 249 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li> 250 * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li> 251 * <li>feed_image (string) (''): If isn't empty, use this image to link to 252 * feeds.</li> 253 * <li>echo (boolean) (true): Set to false to return the output, instead of 254 * echoing.</li> 255 * <li>style (string) ('list'): Whether to display list of authors in list form 256 * or as a string.</li> 257 * <li>html (bool) (true): Whether to list the items in html form or plaintext. 258 * </li> 259 * </ul> 321 * The list can be displayed or returned as an unordered HTML list or as a comma-separated string. 260 322 * 323 * @see get_users() 324 * @see get_user_data() 261 325 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors 326 * 327 * @global $wpdb 328 * 262 329 * @since 1.2.0 263 * @param array $args The argument array. 264 * @return null|string The output, if echo is set to false. 330 * 331 * @param array $args { 332 * An array of arguments. Optional. 333 * @type string 'orderby' What columns to sort authors by, comma-separated. 334 * Default 'name'. @see WP_User_Query for accepted args. 335 * @type string 'order' How to sort retrieved authors. 336 * Default 'ASC'. @see WP_User_Query for accepted args. 337 * @type int 'number' The number of authors to return. 338 * Default blank. Accepts a number. 339 * @type bool 'optioncount' Whether to show the number of posts next to the name of each author in parenthesis. 340 * Default 'false'. Accepts 'true' or 'false'. 341 * @type bool 'exclude_admin' Whether to exclude the author with the 'admin' display name. 342 * Default 'true'. Accepts 'true' or 'false'. 343 * @type bool 'show_fullname' Whether to display the full names of the authors. 344 * Default 'false'. Accepts 'true' or 'false'. 345 * @type bool 'hide_empty' Whether to hide authors without any posts. 346 * Default 'true'. Accepts 'true' or 'false'. 347 * @type string 'feed' Whether to show a link to the author's feed. 348 * Default blank. Any other value will display the feed. 349 * @type string 'feed_image' URL to the feed image displayed as part of the feed link. 350 * Default blank. Accepts a URL. 351 * @type string 'feed_type' Unused argument. 352 * Default blank. 353 * @type bool 'echo' Whether to display the list or return it. 354 * Default 'true'. Accepts 'true' or 'false'. 355 * @type string 'style' Whether to list the items as an ordered list or as a comma separated list. 356 * Default 'list'. Any other value will produce a comma separated list. 357 * @type bool 'html' Whether to list the items in HTML or plain text format. 358 * Default 'true'. Accepts 'true' or 'false'. 359 * } 360 * 361 * @return void|string Returns nothing if 'echo' is set to true, else returns the list. 265 362 */ 266 363 function wp_list_authors($args = '') { 267 364 global $wpdb; … … 362 459 } 363 460 364 461 /** 365 * Does this site have more than one author 462 * Does this site have more than one author. 366 463 * 367 464 * Checks to see if more than one author has published posts. 368 465 * 466 * @global $wpdb 467 * 369 468 * @since 3.2.0 370 * @return bool Whether or not we have more than one author 469 * 470 * @return bool Whether or not we have more than one author. 371 471 */ 372 472 function is_multi_author() { 373 473 global $wpdb; … … 378 478 set_transient( 'is_multi_author', $is_multi_author ); 379 479 } 380 480 481 /** 482 * Whether the site has more than one author with published posts. 483 * 484 * @since 3.2.0 485 * 486 * @param bool $is_multi_author Is there more than one author. 487 */ 381 488 return apply_filters( 'is_multi_author', (bool) $is_multi_author ); 382 489 } 383 490 384 491 /** 385 492 * Helper function to clear the cache for number of authors. 386 493 * 387 * @private 494 * @access private 495 * 496 * @since 3.2.0 497 * 498 * @return void 388 499 */ 389 500 function __clear_multi_author_cache() { 390 501 delete_transient( 'is_multi_author' ); 391 502 } 392 add_action('transition_post_status', '__clear_multi_author_cache'); 503 add_action('transition_post_status', '__clear_multi_author_cache'); 504 No newline at end of file