如何从 WooCommerce 评论部分删除 comment-author-[USER-ID] class?

How to remove the comment-author-[USER-ID] class from the WooCommerce review section?

有谁知道如何从 woocommerce 评论部分删除突出显示的 class?

可以使用 WordPress comment_class 过滤器挂钩删除 comment-author-[USER-ID][USER-NICKNAME] class。

所以你得到:

/**
 * Filters the returned CSS classes for the current comment.
 *
 * @since 2.7.0
 *
 * @param string[]    $classes    An array of comment classes.
 * @param string      $class      A comma-separated list of additional classes added to the list.
 * @param int         $comment_id The comment ID.
 * @param WP_Comment  $comment    The comment object.
 * @param int|WP_Post $post_id    The post ID or WP_Post object.
 */
function filter_comment_class( $classes, $class, $comment_id, $comment, $post_id ) {
    // Loop through classes
    foreach ( $classes as $key => $class ) {
        // Check if a string contains a specific word
        if ( strpos( $class, 'comment-author') !== false ) {
            // Unset a given variable
            unset( $classes[$key] );
        }   
    }
    
    return $classes;
}
add_filter( 'comment_class', 'filter_comment_class', 10, 5 );