Changeset 53285
- Timestamp:
- 04/26/2022 03:06:32 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r53265 r53285 424 424 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. 425 425 * 426 * @param string|string[] $c lassOptional. One or more classes to add to the class list.427 * Default empty.428 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment.429 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.430 * @param bool $ echo Optional. Whether to echoor return the output.431 * Default true.432 * @return void|string Void if `$ echo` argument is true, comment classes if `$echo` is false.433 */ 434 function comment_class( $c lass = '', $comment = null, $post_id = null, $echo= true ) {426 * @param string|string[] $css_class Optional. One or more classes to add to the class list. 427 * Default empty. 428 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. 429 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. 430 * @param bool $display Optional. Whether to print or return the output. 431 * Default true. 432 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false. 433 */ 434 function comment_class( $css_class = '', $comment = null, $post_id = null, $display = true ) { 435 435 // Separates classes with a single space, collates classes for comment DIV. 436 $c lass = 'class="' . implode( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';437 438 if ( $ echo) {439 echo $c lass;436 $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post_id ) ) . '"'; 437 438 if ( $display ) { 439 echo $css_class; 440 440 } else { 441 return $c lass;441 return $css_class; 442 442 } 443 443 } … … 453 453 * @global int $comment_thread_alt 454 454 * 455 * @param string|string[] $c lassOptional. One or more classes to add to the class list. Default empty.455 * @param string|string[] $css_class Optional. One or more classes to add to the class list. Default empty. 456 456 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. 457 457 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. 458 458 * @return string[] An array of classes. 459 459 */ 460 function get_comment_class( $c lass = '', $comment_id = null, $post_id = null ) {460 function get_comment_class( $css_class = '', $comment_id = null, $post_id = null ) { 461 461 global $comment_alt, $comment_depth, $comment_thread_alt; 462 462 … … 517 517 $classes[] = "depth-$comment_depth"; 518 518 519 if ( ! empty( $c lass ) ) {520 if ( ! is_array( $c lass ) ) {521 $c lass = preg_split( '#\s+#', $class );519 if ( ! empty( $css_class ) ) { 520 if ( ! is_array( $css_class ) ) { 521 $css_class = preg_split( '#\s+#', $css_class ); 522 522 } 523 $classes = array_merge( $classes, $c lass );523 $classes = array_merge( $classes, $css_class ); 524 524 } 525 525 … … 532 532 * 533 533 * @param string[] $classes An array of comment classes. 534 * @param string[] $c lassAn array of additional classes added to the list.534 * @param string[] $css_class An array of additional classes added to the list. 535 535 * @param string $comment_id The comment ID as a numeric string. 536 536 * @param WP_Comment $comment The comment object. 537 537 * @param int|WP_Post $post_id The post ID or WP_Post object. 538 538 */ 539 return apply_filters( 'comment_class', $classes, $c lass, $comment->comment_ID, $comment, $post_id );539 return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post_id ); 540 540 } 541 541
Note: See TracChangeset
for help on using the changeset viewer.