Code Modernization: Rename parameters that use reserved keywords in `wp-includes/comment-template.php`.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit:
* Renames the `$class` parameter to `$css_class` in `comment_class()` and `get_comment_class()`.
* Renames the `$echo` parameter to `$display` in `comment_class()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53285


git-svn-id: http://core.svn.wordpress.org/trunk@52874 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-26 15:08:16 +00:00
parent 9134afa220
commit 39b11dd1f7
2 changed files with 21 additions and 21 deletions

View File

@ -423,22 +423,22 @@ function comment_author_url_link( $linktext = '', $before = '', $after = '', $co
* @since 2.7.0
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
*
* @param string|string[] $class Optional. One or more classes to add to the class list.
* Default empty.
* @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment.
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
* @param bool $echo Optional. Whether to echo or return the output.
* Default true.
* @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false.
* @param string|string[] $css_class Optional. One or more classes to add to the class list.
* Default empty.
* @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment.
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
* @param bool $display Optional. Whether to print or return the output.
* Default true.
* @return void|string Void if `$display` argument is true, comment classes if `$display` is false.
*/
function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
function comment_class( $css_class = '', $comment = null, $post_id = null, $display = true ) {
// Separates classes with a single space, collates classes for comment DIV.
$class = 'class="' . implode( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
$css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post_id ) ) . '"';
if ( $echo ) {
echo $class;
if ( $display ) {
echo $css_class;
} else {
return $class;
return $css_class;
}
}
@ -452,12 +452,12 @@ function comment_class( $class = '', $comment = null, $post_id = null, $echo = t
* @global int $comment_depth
* @global int $comment_thread_alt
*
* @param string|string[] $class Optional. One or more classes to add to the class list. Default empty.
* @param string|string[] $css_class Optional. One or more classes to add to the class list. Default empty.
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment.
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
* @return string[] An array of classes.
*/
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
function get_comment_class( $css_class = '', $comment_id = null, $post_id = null ) {
global $comment_alt, $comment_depth, $comment_thread_alt;
$classes = array();
@ -516,11 +516,11 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
$classes[] = "depth-$comment_depth";
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
if ( ! empty( $css_class ) ) {
if ( ! is_array( $css_class ) ) {
$css_class = preg_split( '#\s+#', $css_class );
}
$classes = array_merge( $classes, $class );
$classes = array_merge( $classes, $css_class );
}
$classes = array_map( 'esc_attr', $classes );
@ -531,12 +531,12 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
* @since 2.7.0
*
* @param string[] $classes An array of comment classes.
* @param string[] $class An array of additional classes added to the list.
* @param string[] $css_class An array of additional classes added to the list.
* @param string $comment_id The comment ID as a numeric string.
* @param WP_Comment $comment The comment object.
* @param int|WP_Post $post_id The post ID or WP_Post object.
*/
return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );
return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post_id );
}
/**

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-beta2-53284';
$wp_version = '6.0-beta2-53285';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.